BB.Net / ramblings / tags / meta - Justin's Ramblings

This feed contains pages about the blog itself.

dynamic ikiwiki pages

Posted Fri 15 Feb 2008 08:57:58 PM EST

The static pages that ikiwiki generates are great, but I want to have some dynamic content here as well.

If this works, this page should include the servers uptime.

20:38:13 up 15 days, 5:28, 0 users, load average: 0.00, 0.00, 0.00

yay :-)

So how does that work?

first configure nginx as follows

server {
    listen       80;
    server_name  bouncybouncy.net  *.bouncybouncy.net web;

    location / {
        root   /home/justin/bbdotnet/static/;
        index  index.html index.htm;
        ssi on;
    }
    location /dyn {
        # All POST requests go to pylons directly
        include /usr/local/nginx/conf/proxy.conf;
        proxy_redirect  default; 
        if ($request_method = POST) {
            proxy_pass  http://127.0.0.1:5000;
            break;
        }
        default_type text/html; 

        set $memcached_key "$uri";
        memcached_pass localhost:11211;

        proxy_intercept_errors  on;

        # If no info would be found in memcache or memecache would be dead, go to real dynamic location
        error_page 404 502 = @dynamic_request;
    }
    location @dynamic_request{
        # This means, that we can't get to this location from outside - only by internal redirect
        internal;

        include /usr/local/nginx/conf/proxy.conf;
        proxy_redirect  default; 
        proxy_pass  http://127.0.0.1:5000;
    }

}

Pylons is setup to run on port 5000 as usual, nothing fancy there.

Then anywhere we want some dynamic content we can simply do

<!--# include virtual="/dyn/demo/uptime" -->

For now, you have to disable the htmlscrubber plugin for this to work. There is probably a better solution. I think this would simply involve a plugin that could run after htmlscrubber to insert the include, then you would only need to have something like [[include virtual="/dyn/demo/uptime"]] in your pages.

If you did not mind requring javscript, you could use HInclude instead of SSI.

To keep things running fast, we enable to caching on the pylons controller. using a modified version of the beakercache decorator. The following lines are inserted at the end of the createfunc method, which causes the page result to be cached in memcache as well as in beaker.

url = pylons.request.path_info
if pylons.request.params:
    url += "?" + pylons.request.environ['QUERY_STRING']

mc = memcache.Client(['localhost'])
mc.set(url, result, cache_expire)

The only remaining problem I see is a small race condition. If the cache expires, and 20 concurrent requests all come in for the page, most of them will end up hitting python instead of waiting for the memcache key to appear. This might actually work better using varnish or apache2 with mod_disk_cache, but the last time I tried I could not get varnish to work at all, and apache2 (I think) still does not support PURGE.

Tags: meta

ikiwiki problem solved

Posted Thu 14 Feb 2008 09:36:03 PM EST

I figured out the problem I was having with linking. I had to move ramblings/index.mdwm to ramblings.mdwn and change the pagespecs around a bit, but now everything seems to work

Tags: meta

testing syntax

Posted Thu 14 Feb 2008 08:48:51 PM EST

I installed the syntax plugin

lets see if it works


def hello():
    for x in list(set(xrange(10))):
        yield "Hello, World!"

I added the following to my local.css for it to work.

.syntax {
        background-color: #dde;
        padding: 0.5em;
        border: 1px solid #ccd;
}
span.synStatement {
        color: green;
}
span.synIdentifier, span.synType {
        font-weight: bold;
}
span.synConstant {
        color: blue;
}

Tags: meta

yay ikiwiki

Posted Thu 14 Feb 2008 07:25:21 PM EST

I've setup ikiwiki again. I am liking it much better than the last time I looked at it. There are much more plugins now.

However, I still have a few issues to work out.

Page titles

You can change the title of a page using [[meta title="New title here"]] but, any subpages of that link show the plain filename in the header

Usedir setting

I turned on the userdir setting. This is what seemed to give me the most trouble the last time around. Some things seem to still be broken though, like some of the back links in the header

Tags: meta

testing joeyh's blog script

Posted Thu 14 Feb 2008 07:17:24 PM EST

If this works, it means the script i found at http://git.kitenet.net/?p=joey/home;a=blob_plain;f=bin/blog works :)

Tags: meta