From: Bernardo Innocenti Date: Tue, 6 Nov 2007 11:41:23 +0000 (-0500) Subject: Add support for multiple CSS. X-Git-Tag: v3.0~49 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=a2b12762880b05790a30c3996a0468ce69dd7f89;p=geekigeeki.git Add support for multiple CSS. --- diff --git a/geekigeeki.conf.py b/geekigeeki.conf.py index 2c7b9be..1e959b0 100644 --- a/geekigeeki.conf.py +++ b/geekigeeki.conf.py @@ -6,7 +6,7 @@ site_name = 'Codewiz' privileged_url = 'https://www.codewiz.org/~bernie/wiki' data_dir = '/home/bernie/public_html/wiki/data' -css_url = '../wikidata/geekigeeki.css' # optional stylesheet link +css_url = ['../wikidata/geekigeeki.css'] # optional stylesheet links history_url = '../wikigit/wiki.git' post_edit_hook = './post_edit_hook.sh' diff --git a/geekigeeki.py b/geekigeeki.py index adc7d2a..56d71f1 100755 --- a/geekigeeki.py +++ b/geekigeeki.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#!/usr/bin/python # -*- coding: utf-8 -*- # # Copyright 1999, 2000 Martin Pool @@ -113,8 +113,8 @@ def send_title(name, text="Limbo", msg=None, msg_type='error'): print ' ' if not name: print ' ' - if globals().has_key('css_url'): - print ' ' % css_url + for css in css_url: + print ' ' % css print '' # Body @@ -563,7 +563,6 @@ class Page: self.page_name = page_name self.msg = '' self.msg_type = 'error' - self.attrs = {} def split_title(self): # look for the end of words and the start of a new word, @@ -602,8 +601,9 @@ class Page: raise er def get_attrs(self): - if self.attrs: + if self.__dict__.has_key('attrs'): return self.attrs + self.attrs = {} try: file = open(self._text_filename(), 'rt') attr_re = re.compile(r"^#(\S*)(.*)$") @@ -618,11 +618,16 @@ class Page: raise er return self.attrs + def get_attr(self, name, default): + if self.get_attrs().has_key(name): + return self.get_attrs()[name] + else: + return default + def can(self, action, default=True): - attrs = self.get_attrs() try: - # SomeUser:read,write All:read - acl = attrs["acl"] + #acl SomeUser:read,write All:read + acl = self.get_attr("acl", None) for rule in acl.split(): (user,perms) = rule.split(':') if user == remote_user() or user == "All": @@ -645,6 +650,12 @@ class Page: page_name = None if self.can_write(): page_name = self.page_name + + #FIXME: are there security implications? + #css foo.css bar.css + global css_url + css_url = css_url + self.get_attr("css", "").split() + send_title(page_name, self.split_title(), msg=self.msg, msg_type=self.msg_type) if self.can_read(): PageFormatter(self.get_raw_body()).print_html()