Searching for Signal

the n01se blog

how to use a custom theme in rx4rdf

I've started experimenting with rx4rdf, and although there are more useful things I could do first, I started trying to replace the default visual theme with a custom one just for n01se.net. After much stumbling around, I found what I needed to add to the site-config.py file in order for my own XSLT (really RxSLT) and CSS stylesheets to work.

First I used __addItem__ to make rx4rdf aware of the two new stylesheet files, and how to treat each of them:

  __addItem__('n01senet-theme.xsl', loc="path:n01senet-theme.xsl",
    format='http://www.w3.org/1999/XSL/Transform',
    disposition='template'),

  __addItem__('n01senet-theme.css', loc="path:n01senet-theme.css",
    format='text', disposition='complete'),

The server will now expect to find those files in my site's "content" directory.

Next I created a new "theme" made up of those two stylesheets:

  __addRxML__(replace = '@themes', contents = '''
  base:n01senet-theme:
    a: wiki:SiteTheme
    wiki:uses-css-stylesheet: base:n01senet-theme.css
    wiki:uses-site-template-stylesheet: base:n01senet-theme.xsl
    rdfs:comment: `custom theme for n01se.net
  ''')

Note by using "replace =" above, I disabled the three themes that ship with rx4rdf. That's ok with me, since I won't be needing them for this site.

Finally, I configured my sitevars to point to the new theme:

  __addRxML__(replace = '@sitevars', contents = '''
  base:site-template:
    wiki:header-image: `n01senet-logo2.png
    #wiki:header-text: `n01se.net rocks!
    wiki:footer-text: `© 2007 n01se.net
    wiki:uses-theme: base:n01senet-theme
    #wiki:uses-skin:  base:skin-lightblue.css
  ''')

I also commented out the uses-skin predicate because I don't need another CSS file included.

This may not be the best way to do this, but since I couldn't find any existing documentation on how it should be done, I thought it would be worth writing up what worked for me.

I started off with n01senet-theme.css and .xsl files copied from rx4rdf-0.6.0/rhizome/themes/default/theme.css and .xsl files, and started modifying them to look like I want. I'm not done yet, but it looks like I'll have all the flexibility I need (a.k.a. enough rope to hang myself)