Archive for the 'PHP' Category

Moving to Movable Type

I have been having a great time with Movable Type recently, and so I plan to migrate the Docunext blog to MTOS very soon. I still have a lot to learn with ikiwiki, so for now I’m sticking with MediaWiki.

Wordpress Lightbox Plugin and jQuery 1.3+

I just found the solution to an annoying bug:

“[Exception… “‘Syntax error, unrecognized expression: [@rel*=lightbox]’ when calling method: [nsIDOMEventListener::handleEvent]” nsresult: “0×8057001e (NS_ERROR_XPC_JS_THREW_STRING)” location: “” data: no]”

This started after I upgraded jQuery to 1.3.2 from 1.2.x. The fix is:

Index: jquery-wp-lightbox/js/jquery.lightbox.js
===================================================================
--- jquery-wp-lightbox/js/jquery.lightbox.js	(revision 654)
+++ jquery-wp-lightbox/js/jquery.lightbox.js	(working copy)
@@ -501,7 +501,7 @@
 			var groups_n = 0;
 			var orig_rel = this.rel;
 			// Create the groups
-			$.each($('[@rel*='+orig_rel+']'), function(index, obj){
+			$.each($('[rel*='+orig_rel+']'), function(index, obj){
 				// Get the group
 				var rel = $(obj).attr('rel');
 				// Are we really a group

I also want to note that I had to do some serious snooping with K2 to figure out why jQuery’s dollar sign was causing a problem. Turns out that the k2 functions script disables it with:

jQuery.noConflict();

After commenting that out, it works! :-)

PHP, CSS and XML




I’m experimenting with PHP, CSS, and XML, trying to come up with some sort of css2xml script, while considering the idea of mangling classes and identifiers to prevent collisions when creating mashups.

<?php
require_once 'HTML/CSS.php';
require_once 'XML/Serializer.php';
$mycss = file_get_contents('test.css');
 
//$mycss = preg_replace('/#/','id___',$mycss);
//$mycss = preg_replace('/\n\./','class___',$mycss);
 
$css = new HTML_CSS();
$css->parseString($mycss);
 
//$arr = $css->toArray();
//var_export($arr);
ob_start();
$css->display();
$converted = ob_get_contents();
ob_end_clean();
//echo $converted;
 
//exit;
$mycss = preg_replace('/\n#/','id___',$converted);
$mycss = preg_replace('/\n\./','class___',$mycss);
$css->parseString($mycss);
$arr = $css->toArray();
 
//echo $converted;
//echo $mycss;
//exit;
 
$options = array(
  XML_SERIALIZER_OPTION_INDENT        => '    ',
  XML_SERIALIZER_OPTION_RETURN_RESULT => true
);
$serializer = &new XML_Serializer($options);
 
$result = $serializer->serialize($arr);
echo $result;
?>

Note, this code is just a sketch, and I don’t expect it to function well.

Also, of the post I made recently about css parsers, this one in ruby again caught my attention.

Lastly, I found csstoxml. Its written in java, so I’m a little hesitant to try it out due to my lack of experience with java.

Cgit.cgi, My New Choice for Git Source Code Revision Web Access

The latest upgrade of git seems to have broken git-web.php, so I guess its time to start using cgit. Cgit caught my attention a few weeks ago and I spent a little time trolling through the code, attempting to run it via fastcgi. I was able to get it running and I shared the code with the upstream developer, but I’m going to use the stock cgi setup for now. I’ve got a lot to learn about C so until I have more confident in the changes I made, I’ll hold off on using it live.

Only one mirrored repository is setup so far; more to come very soon!

Docunext GIT mirrors via CGIT