WordPress + GoogleCode’s SVN = FlashTextEditor + FlashVars + PHPProxy
Been looking for a way to get the actionscript code in SVN, onto the blog, nicely formatted, colorized, with eventually smart help and highlighting. So the blog and upcoming wiki can 'decorate' it. Finally figured it out.
I use Google Code SVN as it's free, and solid. To get it work with Wordpress a with the plugins 1)pb-embedFlash and 2) FlashTextEditor. through PHP Proxy for Flash Cross-Domain Security problems
Strictly speaking, 1) isn't required but the syntax is cleaner than using 2) directly. A sample post in wordpress looks like
[
flash http://troyworks.com/blog/wp-content/plugins/FlashTextFormatter/ftf.swf f={file= http://troyworks.googlecode.com/svn-history/r7/trunk/AS3/dev/src/com/troyworks/ui/LayoutUtil.as}]
Where f={} is the passing of the flashvars with the proxy and actionscript file name. I had to make a patch to the pb-embedFlash.php to pass flashvars...though honestly I'd prefer to be using SWFObject instead. Here's a snippet of the patch :
-
-
} else { // not a flv file - what may it be?
-
-
$i = 0; global $pb_embedflash; if (preg_match('%f={(.+?)}%',$match[2],$hit) && $hit[1] != ' ') {
-
-
$flashvars = '?'.$hit[1];
-
-
}
-
-
-
{
-
-
if (preg_match(pb_buildpattern($pb_embedflash[$i][0]),$match[1],$hit) && (count($pb_embedflash[$i]) == 5))
-
-
{
-
-
$output = str_replace('###URL###', str_replace('###ID###', $hit[1], $pb_embedflash[$i][1]), $output);
-
-
-
-
$break = TRUE; break 1; // stop searching if we found sth.
-
-
}
-
-
$i++; // we don't want an infinite loop
-
-
}
-
-
-
{
-
-
-
}
-
-
}
and also had to add a whitespace trim() to the FlashTextEditor, as for whatever reason the flash vars are getting passed in with an extra space in the front (I don't know PHP so I'm probably doing something), which causes it to fail.
Since my framework will be up on google, and I check in via SVN it's a sound development practice to make sure the latest code that shows up on the blog is that from SVN, instead of being cut and pasted here or uploaded to the webserver. Unfortunately, Google doesn't have a cross domain file in place so loading the text isn't possible directly, thus the need for PHP Proxy.
Here's an example of getting LayoutUtil.as from Google Code.
What I'd like to do in the future as examples start coming out is highlighting selected lines + folding, and automatic linking to the adobe docs, making it more of a wiki. Probably will be a rewrite of FlashTextEditor.
If your contributing to this blog use the following tips:
All these require editing on the 'code' tab (not 'visual' tab) when writing a post. When embedding classes examples that are on google SVN use this
You can upload and then embed flash examples via:
and use this flash based editor for pulling code off of google
and pretty format it via:
<pre lang="actionscript">
YOUR CODE
</pre>
but you'll need an return before the first pre
2) You can make small blocks like
"In order to print, You will need to listen for <code> addListener</code>"
