projects
/
geekigeeki.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add support for multiple CSS.
[geekigeeki.git]
/
geekigeeki.py
diff --git
a/geekigeeki.py
b/geekigeeki.py
index adc7d2a88f3bab4e8d2bb28a5fdc263841d7d2db..56d71f156f6b62984397e1b91d66ce73427b658e 100755
(executable)
--- 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 <mbp@humbug.org.au>
# -*- coding: utf-8 -*-
#
# Copyright 1999, 2000 Martin Pool <mbp@humbug.org.au>
@@
-113,8
+113,8
@@
def send_title(name, text="Limbo", msg=None, msg_type='error'):
print ' <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />'
if not name:
print ' <meta name="robots" content="noindex,nofollow" />'
print ' <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />'
if not name:
print ' <meta name="robots" content="noindex,nofollow" />'
-
if globals().has_key('css_url')
:
- print ' <link rel="stylesheet" type="text/css" href="%s" />' % css
_url
+
for css in css_url
:
+ print ' <link rel="stylesheet" type="text/css" href="%s" />' % css
print '</head>'
# Body
print '</head>'
# Body
@@
-563,7
+563,6
@@
class Page:
self.page_name = page_name
self.msg = ''
self.msg_type = 'error'
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,
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):
raise er
def get_attrs(self):
- if self.
attrs
:
+ if self.
__dict__.has_key('attrs')
:
return self.attrs
return self.attrs
+ self.attrs = {}
try:
file = open(self._text_filename(), 'rt')
attr_re = re.compile(r"^#(\S*)(.*)$")
try:
file = open(self._text_filename(), 'rt')
attr_re = re.compile(r"^#(\S*)(.*)$")
@@
-618,11
+618,16
@@
class Page:
raise er
return self.attrs
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):
def can(self, action, default=True):
- attrs = self.get_attrs()
try:
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":
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
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()
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()