author | fabien@tzone.org |
Wed, 31 Dec 2008 16:26:22 -0500 | |
changeset 75 | 4f6b7b48322f |
parent 69 | d79722064d8d |
permissions | -rw-r--r-- |
47
2781ac85b807
[svn r1604] Implement default_view preferences, which move things around a lot.
fabien
parents:
diff
changeset
|
1 |
from htmltmpl import TemplateManager, TemplateProcessor |
51
7015d65beb3d
[svn r1608] Correct the keywords bugs and some other in folder view, plus mutual
fabien
parents:
47
diff
changeset
|
2 |
from urlparse import urljoin |
59 | 3 |
from os import environ, path |
69
d79722064d8d
Merge previous changeset and ensure everything seems to work.
fabien@tzone.org
parents:
63
diff
changeset
|
4 |
from config import CONFIG |
51
7015d65beb3d
[svn r1608] Correct the keywords bugs and some other in folder view, plus mutual
fabien
parents:
47
diff
changeset
|
5 |
|
7015d65beb3d
[svn r1608] Correct the keywords bugs and some other in folder view, plus mutual
fabien
parents:
47
diff
changeset
|
6 |
def get_curl(): |
58
004a32370ba5
Correct some bugs and make keywords edition with the new action
fabien@tzone.org
parents:
51
diff
changeset
|
7 |
url = "http" |
004a32370ba5
Correct some bugs and make keywords edition with the new action
fabien@tzone.org
parents:
51
diff
changeset
|
8 |
if environ["HTTPS"] == 'on': |
004a32370ba5
Correct some bugs and make keywords edition with the new action
fabien@tzone.org
parents:
51
diff
changeset
|
9 |
url += "s" |
004a32370ba5
Correct some bugs and make keywords edition with the new action
fabien@tzone.org
parents:
51
diff
changeset
|
10 |
url += "://" + environ["HTTP_HOST"] |
004a32370ba5
Correct some bugs and make keywords edition with the new action
fabien@tzone.org
parents:
51
diff
changeset
|
11 |
uri = environ["REQUEST_URI"] |
004a32370ba5
Correct some bugs and make keywords edition with the new action
fabien@tzone.org
parents:
51
diff
changeset
|
12 |
url += uri[:uri.find('?')] |
004a32370ba5
Correct some bugs and make keywords edition with the new action
fabien@tzone.org
parents:
51
diff
changeset
|
13 |
return url |
47
2781ac85b807
[svn r1604] Implement default_view preferences, which move things around a lot.
fabien
parents:
diff
changeset
|
14 |
|
2781ac85b807
[svn r1604] Implement default_view preferences, which move things around a lot.
fabien
parents:
diff
changeset
|
15 |
class Template: |
58
004a32370ba5
Correct some bugs and make keywords edition with the new action
fabien@tzone.org
parents:
51
diff
changeset
|
16 |
def __init__(self, template, prefs, status = "msg", status_msg = ""): |
47
2781ac85b807
[svn r1604] Implement default_view preferences, which move things around a lot.
fabien
parents:
diff
changeset
|
17 |
self.tproc = TemplateProcessor() |
69
d79722064d8d
Merge previous changeset and ensure everything seems to work.
fabien@tzone.org
parents:
63
diff
changeset
|
18 |
self.tmpl = TemplateManager().prepare(path.join(CONFIG.template_dir, template)) |
58
004a32370ba5
Correct some bugs and make keywords edition with the new action
fabien@tzone.org
parents:
51
diff
changeset
|
19 |
self.set("remote_user", prefs["fullname"]) |
004a32370ba5
Correct some bugs and make keywords edition with the new action
fabien@tzone.org
parents:
51
diff
changeset
|
20 |
self.set("kw_size", prefs['keywords_box']) |
004a32370ba5
Correct some bugs and make keywords edition with the new action
fabien@tzone.org
parents:
51
diff
changeset
|
21 |
self.set("kw_sort", prefs['keywords_sort']) |
004a32370ba5
Correct some bugs and make keywords edition with the new action
fabien@tzone.org
parents:
51
diff
changeset
|
22 |
self.set("kw_reverse", prefs['keywords_reverse']) |
004a32370ba5
Correct some bugs and make keywords edition with the new action
fabien@tzone.org
parents:
51
diff
changeset
|
23 |
self.set("curl", get_curl()) |
004a32370ba5
Correct some bugs and make keywords edition with the new action
fabien@tzone.org
parents:
51
diff
changeset
|
24 |
self.set("status", status) |
004a32370ba5
Correct some bugs and make keywords edition with the new action
fabien@tzone.org
parents:
51
diff
changeset
|
25 |
self.set("status_msg", status_msg) |
47
2781ac85b807
[svn r1604] Implement default_view preferences, which move things around a lot.
fabien
parents:
diff
changeset
|
26 |
def set(self, name, variable): |
2781ac85b807
[svn r1604] Implement default_view preferences, which move things around a lot.
fabien
parents:
diff
changeset
|
27 |
self.tproc.set(name, variable) |
2781ac85b807
[svn r1604] Implement default_view preferences, which move things around a lot.
fabien
parents:
diff
changeset
|
28 |
def process(self): |
2781ac85b807
[svn r1604] Implement default_view preferences, which move things around a lot.
fabien
parents:
diff
changeset
|
29 |
return self.tproc.process(self.tmpl) |
2781ac85b807
[svn r1604] Implement default_view preferences, which move things around a lot.
fabien
parents:
diff
changeset
|
30 |