The Pope Is Dead ::

Main Navigation

The pope is dead. Long live the pope! Just another blog about web development. If you’re interested in web stuff you may find this blog useful.

blog latest entries

Continuous Integration Fun & Whats Coming Soon…

We have been busy setting up a continuous integration server at work this week, and I am impressed with the results.

We started by looking at using PHING and Xinc but found with the current setup of our tests and some other bits and pieces weren’t working together nicely. The major stumbling blocks being that PHING does not support running an AllTests.php PHPUnit setup and the lack of documentation for Xinc ( It is just past beta so very understandable ).

So after much tweaking with no success we decided to try Ant + PHPUnderControl + Cruise Control, I was a bit apprehensive about using a Java app as it would be harder to extend. However we found that it did exactly what we needed and works a treat. Now we have a nice new shiny CI Server in our office shouting at us when we break things :)

I was impressed with how nicely Ant was to configure (for win & linux!) and now we have it Updating the local build, Creating the build folders, Compressing the JS/Css, and Running the tests. Sweet :) PHPUnderControl is really cool, I now have nice set of data for all aspects of my project. This includes test results, Code Coverage reports, Coding Standards Compliance, and probably some other stuff I forgot…

Anyway so hopefully I will be posting some stuff on website accessibility soon, I was talking to someone about it today and thought it would be good to blog about.... 

Posted on 09/05/2008 at 05:15 PM

Setting up my weblog. part 1 tagging

So a major part of my weblog setup using the core version of Expression Engine was adding a way of tagging my posts. In the end I came up with an extension to add the admin functionality and a plugin to get various data into the frontend.

Creating the extension

Ok before we start you need to make sure that:

  • Your MySql server has InnoDb table support
  • You are running PHP5 ( seriously you shouldnt be using 4 anymore! )
  • You have download Zend Framework and added into your include path

Next lets setup a skeletion structure for the extension. Create a file called ext.kp_tagging.php in the extensions dir.

Posted on 06/05/2008 at 08:47 PM

Easy Javascript / CSS Compression with phing

Hi Just thought I would blog a new phing task I just created that minifies css or javascript using YUI Compressor

This would be placed in build/extended/tasks/kpMinTask.php, also place the yuicompressor in build/tools/yuicompressor.jar

© 2010 Keith Pope
  1. <?php
  2. /**
  3.  * Uses the Phing Task
  4.  */
  5. require_once 'phing/Task.php';
  6.  
  7. /**
  8.  * Task to compress files using YUI Compressor.
  9.  *
  10.  * @author      Keith Pope
  11.  */
  12. class kpMinTask extends Task
  13. {
  14.     /**
  15.      * path to YuiCompressor
  16.      *
  17.      * @var  string
  18.      */
  19.     protected $yuiPath;
  20.    
  21.     /**
  22.      * the source files
  23.      *
  24.      * @var  FileSet
  25.      */
  26.     protected $filesets    = array();
  27.    
  28.     /**
  29.      * Whether the build should fail, if
  30.      * errors occured
  31.      *
  32.      * @var boolean
  33.      */
  34.     protected $failonerror = false;
  35.    
  36.     /**
  37.      * directory to put minified javascript files into
  38.      *
  39.      * @var  string
  40.      */
  41.     protected $targetDir;
  42.  
  43.     /**
  44.      * sets the path where JSmin can be found
  45.      *
  46.      * @param  string  $yuiPath
  47.      */
  48.     public function setYuiPath( $yuiPath )
  49.     {
  50.         $this->yuiPath = $yuiPath;
  51.     }
  52.  
  53.     /**
  54.      *  Nested creator, adds a set of files (nested fileset attribute).
  55.      */
  56.     public function createFileSet()
  57.     {
  58.         $num = array_push( $this->filesets, new FileSet() );
  59.         return $this->filesets[$num - 1];
  60.     }
  61.  
  62.     /**
  63.      * Whether the build should fail, if an error occured.
  64.      *
  65.      * @param boolean $value
  66.      */
  67.     public function setFailonerror( $value )
  68.     {
  69.         $this->failonerror = $value;
  70.     }
  71.  
  72.     /**
  73.      * sets the directory compressor traget dir
  74.      *
  75.      * @param  string  $targetDir
  76.      */
  77.     public function setTargetDir( $targetDir )
  78.     {
  79.         $this->targetDir = $targetDir;
  80.     }
  81.  
  82.     /**
  83.      * The init method: Do init steps.
  84.      */
  85.     public function init()
  86.     {
  87.         return true;
  88.     }
  89.  
  90.     /**
  91.      * The main entry point method.
  92.      */
  93.     public function main()
  94.     {
  95.         $command = 'java -jar {yuipath} {src} -o {target}';
  96.        
  97.         foreach( $this->filesets as $fs )
  98.         {
  99.             try
  100.             {
  101.                 $files    = $fs->getDirectoryScanner( $this->project )->getIncludedFiles();
  102.                 $fullPath = realpath( $fs->getDir( $this->project ) );
  103.                
  104.                 foreach( $files as $file )
  105.                 {
  106.                     $this->log( 'Minifying file ' . $file );
  107.  
  108.                     $target = $this->targetDir . '/' . str_replace( $fullPath, '', $file );
  109.                    
  110.                     if( file_exists( dirname( $target ) ) == false )
  111.                     {
  112.                         mkdir( dirname( $target ), 0700, true );
  113.                     }
  114.                    
  115.                     $cmd = str_replace( '{src}', $fullPath . DIRECTORY_SEPARATOR . $file, $command );
  116.                     $cmd = str_replace( '{target}', realpath( $target ), $cmd );
  117.                     $cmd = str_replace( '{yuipath}', realpath( $this->yuiPath ), $cmd );
  118.                    
  119.                     $output = array();
  120.                     $return = null;
  121.                    
  122.                     exec( $cmd, $output, $return );
  123.            
  124.                     foreach( $output as $line )
  125.                     {
  126.                         $this->log( $line, Project::MSG_VERBOSE );
  127.                     }
  128.                    
  129.                     if( $return != 0 )
  130.                     {
  131.                       throw new BuildException( "Task exited with code $return" );
  132.                     }
  133.  
  134.                 }
  135.             }
  136.            
  137.             catch( BuildException $be )
  138.             {
  139.                 // directory doesn't exist or is not readable
  140.                 if ($this->failonerror)
  141.                 {
  142.                     throw $be;
  143.                 }
  144.                 else
  145.                 {
  146.                     $this->log($be->getMessage(), $this->quiet ? Project::MSG_VERBOSE : Project::MSG_WARN);
  147.                 }
  148.             }
  149.         }
  150.     }
  151. }
  152. ?>
Parsed in 0.150 seconds, using GeSHi 1.0.7.21

Then in your phing build.xml

© 2010 Keith Pope
  1. <taskdef name="minify" classname="extended.tasks.kpMinTask" />
  2.  
  3. <target name="minify-js">
  4.     <echo>--------------------------------</echo>
  5.     <echo>| Minify javascript to release |</echo>
  6.     <echo>--------------------------------</echo>
  7.     <minify targetDir="../www/resources/js/min"
  8.               yuiPath="tools/yuicompressor.jar">
  9.         <fileset dir="../www/resources/js/">
  10.           <include name="*.js"/>
  11.         </fileset>
  12.     </minify>
  13. </target>
  14.  
  15. <target name="minify-css">
  16.     <echo>--------------------------------</echo>
  17.     <echo>| Minify CSS to release |</echo>
  18.     <echo>--------------------------------</echo>
  19.     <minify targetDir="../www/resources/v2_css/min"
  20.               yuiPath="tools/yuicompressor.jar">
  21.         <fileset dir="../www/resources/v2_css/">
  22.           <include name="*.css"/>
  23.         </fileset>
  24.     </minify>
  25. </target>
Parsed in 0.026 seconds, using GeSHi 1.0.7.21

Now we can can compress easily by running phing minify-js, sweet...

Posted on 04/05/2008 at 12:08 PM

Previous Entries   Newer Entries

about me

I am a web developer/ project manager from Birmingham Uk, currently I am working for inflight productions as a technical project manager. Hopefully I will be posting here as regularly as possible on my experiences with various technologies that I am using and maybe the odd random thing..

the book