• Get the Flash Player to see the slideshow.
  • Categories

  • Authors

  • Great Quotes

    Everything should be as simple as possible, but not simpler. — Albert Einstein

Get in touch...

To have a chat about
your CMS needs...

Call us 0207 193 2014
or
Email us on

Author Archive

Command Line SWF Tools for Windows

Wednesday, September 10th, 2008

An excellent set of command line tools for manipulating and generating Flash content, SwfTools, is available at http://www.swftools.org/ 

Tools include :

  • swfc
  • font2swf
  • swfcombine
  • swfextract
  • pdf2swf
  • gif2swf
  • jpeg2swf
  • png2swf
  • avi2swf
  • wav2swf
  • swfdump (will dump out compressed SWF)
  • swfstrings
  • swfbbox

 

Process XML Documents on the CLI

Thursday, August 21st, 2008

You can query or manipulate XML documents on the command-line using either XSH, the PERL XML Shell, or even easier, use xmlstarlet, a windows/unix binary, available from http://xmlstar.sourceforge.net

Building <A href=”…” /> in LiveSite – Revisited

Thursday, August 14th, 2008

Instead of :-

<a>
<xsl:attribute name=”href”>
<xsl:value-of select=”Properties/Datum[@ID='FFactPerformance']“/>
<xsl:text>?idtype=</xsl:text>
<xsl:value-of select=”//Datum[@ID='idtype']“/>
<xsl:text>&fundid=</xsl:text>
<xsl:value-of select=”//Datum[@ID='fundid']“/>
</xsl:attribute>
<xsl:attribute name=”id”>tab2</xsl:attribute>
<xsl:attribute name=”name”>tab2</xsl:attribute>
Performance & Risk
</a>

 

Use this notation :-

<a href=”{Properties/Datum[@ID='FFactPerformance']}?

idtype={//Datum[@ID='idtype']}&

fundid={//Datum[@ID='fundid']}” id=”tab2″ name=”tab2″>

Performance & Risk</a>

Much shorter to type, and easier to remember.

Work with LiveSite Components “Offline”

Friday, August 8th, 2008

If you are developing LiveSite components in a shared environment, the chances are high that your editing will be interrupted by other users performing builds. To get around this you can bypass the online environment, and access the component files direct.

1) Use Samba or a tool such as FileZilla to access the component files. If you are using FileZilla, set the editor to VIM.

2) Select “view/edit” in FileZilla to access each LiveSite component.

3) The component file is very difficult to read as the XSL code has amongst other things,  < and > replaced with < and >

4) To remedy the above, add the following functions and menu options to your VIM environment :-

” Make a LiveSite component more readable
func MakeComponentReadable()
%s/</<|/g
%s/>/|>/g
%s/</</g
%s/>/>/g
%s/ /<cr\/>/g
set syntax=xml
1
endf

” Restore a LiveSite component back to it’s original state prior to uploading
func RestoreComponent()
%s/<cr\/>/\ /g
%s/\([^\|]\)>/\1\>/g
%s/<\([^\|]\)/\<\1/g
%s/<|/</g
%s/|>/>/g
set syntax=
1
endf

amenu one.Make\ LS\ Component\ Readable :call MakeComponentReadable()<CR><ESC>
amenu one.Restore\ LS\ Component :call RestoreComponent()<CR><ESC>

5) The first function adds readability to the component file, whilst the second is used to restore the standard component formatting once your editing is done, and you are ready to upload the component back to the LS environment.

Remove Single Line HTML Comments using VIM

Friday, August 8th, 2008

If you want to remove all HTML style comments (ones that span a single line), use the following VIM commands :

Check for all single line HTML comments in VIM :-

:g/<!– .\{-}–>/p

Typing the above displays all lines that contain HTML style comments

To remove all the comments use the following VIM command :-

:%s/<!– .\{-}–>//g

 

VIM Functions and Menu Items for Writing XSL

Thursday, July 31st, 2008

Add the following lines to a myxsl.vim file and place it in your VIM plugins directory.

The next time you start VIM, you will have a menu called “lf” appear with the following items

listed that allow you to create more xsl code with less typing.

Note that you must also add the VIM utility functions listed in a previous blog article, found here:

http://www.littleforest.co.uk/vim-unix/vim-toolkit-functions/ 

amenu lf.xsl:template\ w\ name :call XslTemplateWithName()<CR><ESC>
amenu lf.xsl:call-template :call XslCallTemplate()<CR><ESC>
amenu lf.xsl:param :call XslParam()<CR><ESC>
amenu lf.xsl:with-param :call XslWithParam()<CR><ESC>
amenu lf.xsl:if :call XslIf()<CR><ESC>
amenu lf.xsl:choose :call XslChoose()<CR><ESC>
amenu lf.xsl:when :call XslWhen()<CR><ESC>
amenu lf.xsl:otherwise :call XslOtherwise()<CR><ESC>
amenu lf.xsl:variable :call XslVariable()<CR><ESC>
amenu lf.xsl:value-of :call XslValueOf()<CR><ESC>
amenu lf.xsl:text :call XslText()<CR><ESC>
amenu lf.xsl:for-each :call XslForEach()<CR><ESC>
amenu lf.xsl:sort :call XslSort()<CR><ESC>

func! XslTemplateWithName()
        let n=inputdialog(”Template Name”)
        call P(”<xsl:template name=\”" . n . “\”>”)
        call P(”</xsl:template>”)
        call Up()
endf

func! XslForEach()
        let n=inputdialog(”Select Expression”)
        call P(”<xsl:for-each select=\”" . n . “\”>”)
        call P(”</xsl:for-each>”)
        call Up()
endf

func! XslCallTemplate()
        let n=inputdialog(”Template Name”)
        call P(”<xsl:call-template name=\”" . n . “\”>”)
        call P(”</xsl:call-template>”)
        call Up()
endf

func! XslSort()
        let n=inputdialog(”Sort Select Expression”)
        call P(”<xsl:sort select=\”" . n . “\”/>”)
endf

func! XslParam()
        let n=inputdialog(”Param Name”)
        call P(”<xsl:param name=\”" . n . “\”/>”)
endf

func! XslWithParam()
        let n=inputdialog(”Param Name”)
        let v=inputdialog(”Param Value”)
        call P(”<xsl:with-param name=\”" . n . “\”>” . v . “</xsl:with-param>”)
endf

func! XslIf()
        let n=inputdialog(”Test Expression”)
        call P(”<xsl:if test=\”" . n . “\”>”)
        call P(”</xsl:if>”)
        call Up()
endf

func! XslChoose()
        call P(”<xsl:choose>”)
        call P(”</xsl:choose>”)
        call Up()
endf

func! XslAttribute()
        let n=inputdialog(”Attribute Name”)
        call P(”<xsl:attribute name=\”" . n . “\”>”)
        call P(”</xsl:attribute>”)
        call Up()
endf

func! XslText()
        call P(”<xsl:text></xsl:text>”)
endf

func! XslWhen()
        let n=inputdialog(”Test Expression”)
        call P(”<xsl:when test=\”" . n . “\”>”)
        call P(”</xsl:when>”)
        call Up()
endf

func! XslOtherwise()
        call P(”<xsl:otherwise>”)
        call P(”</xsl:otherwise>”)
        call Up()
endf

func! XslVariable()
        let n=inputdialog(”Variable Name”)
        let v=inputdialog(”Variable Value”)
        call P(”<xsl:variable name=\”" . n . “\”>” . v . “</xsl:variable>”)
        call Up()
endf

func! XslValueOf()
        let n=inputdialog(”Variable Name”)
        call P(”<xsl:value-of select=\”" . n . “\”/>”)
endf

 

Formatting XML & HTML with HTML Tidy

Thursday, July 31st, 2008
  1. Get the tidy program from http://www.w3.org/People/Raggett/tidy/
  2. Unzip and run it from the command line, or, place it in your VIM runtime directory, add the following lines to your .vimrc, and when you visually select some text and type ,x on the command line, the selected text will be indented.

“—–
” select xml text to format and hit ,x
vmap ,x :!tidy -q -i –newline LF -xml<CR>
“—

 

VIM Toolkit Functions

Thursday, July 24th, 2008

General-purpose functions for building up more useful VIM scripts.

” Move the cursor up a line

func Up()
exe “normal k”
endf

” Move the cursor down a line
func Down()
exe “normal j”
endf

” Cut the selected buffer text to the windows clipboard
func! Cut()
exe “normal \”+x”
endf

” Copy the selected buffer text to the windows clipboard

func! Copy()
exe “normal \”+y”
endf

” Paste windows clipboard data to the current buffer

func! Paste()
exe “normal \”+gP”
endf

” Select all text in the editor’s current buffer
func! SelectAll()
exe “normal ggVG”
endf

” Wrapper function to write a string to the buffer

func! Print(str)
exe “normal o” . a:str . “”
endf

” Wrapper function to write a string to the buffer

func! P(str)
call Print(a:str)
endf

” Write a newline character to the buffer

func! NL()
call P(”")
endf
” Write a newline character to the buffer

func! CR()
call NL()
endf

Split Up XML or HTML Elements in VIM

Thursday, July 24th, 2008

If there are multiple HTML or XML tags on one line, use the following command to split that data over several lines instead & make it more readable :-

:%s/></>\r</g

Remove DOS EOL Chars in VIM

Thursday, July 24th, 2008

Use the following command :-

:%s/\r//g