author | Tero Marttila <terom@fixme.fi> |
Thu, 02 Jul 2009 23:59:58 +0300 | |
changeset 146 | c226063eeb65 |
parent 143 | a6e53a20fccb |
permissions | -rw-r--r-- |
62
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
1 |
""" |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
2 |
Templates for HTML output |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
3 |
""" |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
4 |
|
124
cac613118e75
add version module, currently just harcoded info
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
5 |
import html, version |
62
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
6 |
from html import tags |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
7 |
|
135
6534c77de93f
urlencode native filesystem node paths for template's http URLs
Tero Marttila <terom@fixme.fi>
parents:
127
diff
changeset
|
8 |
import urllib |
6534c77de93f
urlencode native filesystem node paths for template's http URLs
Tero Marttila <terom@fixme.fi>
parents:
127
diff
changeset
|
9 |
|
6534c77de93f
urlencode native filesystem node paths for template's http URLs
Tero Marttila <terom@fixme.fi>
parents:
127
diff
changeset
|
10 |
def quote_path (path) : |
6534c77de93f
urlencode native filesystem node paths for template's http URLs
Tero Marttila <terom@fixme.fi>
parents:
127
diff
changeset
|
11 |
""" |
6534c77de93f
urlencode native filesystem node paths for template's http URLs
Tero Marttila <terom@fixme.fi>
parents:
127
diff
changeset
|
12 |
Return an unicode-safe string with the escaped contents of the given str-able object, suitable for use |
6534c77de93f
urlencode native filesystem node paths for template's http URLs
Tero Marttila <terom@fixme.fi>
parents:
127
diff
changeset
|
13 |
in HTTP URLs. |
6534c77de93f
urlencode native filesystem node paths for template's http URLs
Tero Marttila <terom@fixme.fi>
parents:
127
diff
changeset
|
14 |
|
6534c77de93f
urlencode native filesystem node paths for template's http URLs
Tero Marttila <terom@fixme.fi>
parents:
127
diff
changeset
|
15 |
This should provide correct behaviour for use with filesystem Nodes. |
6534c77de93f
urlencode native filesystem node paths for template's http URLs
Tero Marttila <terom@fixme.fi>
parents:
127
diff
changeset
|
16 |
|
6534c77de93f
urlencode native filesystem node paths for template's http URLs
Tero Marttila <terom@fixme.fi>
parents:
127
diff
changeset
|
17 |
XXX: even this could be abstracted to some kind of "URL" thing |
6534c77de93f
urlencode native filesystem node paths for template's http URLs
Tero Marttila <terom@fixme.fi>
parents:
127
diff
changeset
|
18 |
""" |
6534c77de93f
urlencode native filesystem node paths for template's http URLs
Tero Marttila <terom@fixme.fi>
parents:
127
diff
changeset
|
19 |
|
6534c77de93f
urlencode native filesystem node paths for template's http URLs
Tero Marttila <terom@fixme.fi>
parents:
127
diff
changeset
|
20 |
return urllib.quote(str(path)) |
6534c77de93f
urlencode native filesystem node paths for template's http URLs
Tero Marttila <terom@fixme.fi>
parents:
127
diff
changeset
|
21 |
|
78
d580323b4bfa
fix html/templates to use a Container type (inherited by Tag) for flat lists of tags
Tero Marttila <terom@fixme.fi>
parents:
77
diff
changeset
|
22 |
def link_from (source, target) : |
62
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
23 |
""" |
135
6534c77de93f
urlencode native filesystem node paths for template's http URLs
Tero Marttila <terom@fixme.fi>
parents:
127
diff
changeset
|
24 |
Returns a partial a tag linking from the given source page to the target page, escaping binary paths. |
62
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
25 |
""" |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
26 |
|
135
6534c77de93f
urlencode native filesystem node paths for template's http URLs
Tero Marttila <terom@fixme.fi>
parents:
127
diff
changeset
|
27 |
return tags.a(href=quote_path(source.path_to(target))) |
62
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
28 |
|
78
d580323b4bfa
fix html/templates to use a Container type (inherited by Tag) for flat lists of tags
Tero Marttila <terom@fixme.fi>
parents:
77
diff
changeset
|
29 |
def image_link (from_page, image, target) : |
62
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
30 |
""" |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
31 |
Link to the given image |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
32 |
""" |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
33 |
|
78
d580323b4bfa
fix html/templates to use a Container type (inherited by Tag) for flat lists of tags
Tero Marttila <terom@fixme.fi>
parents:
77
diff
changeset
|
34 |
return link_from(from_page, target)( |
135
6534c77de93f
urlencode native filesystem node paths for template's http URLs
Tero Marttila <terom@fixme.fi>
parents:
127
diff
changeset
|
35 |
tags.img(src=quote_path(image.path_from(from_page))) |
62
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
36 |
) |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
37 |
|
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
38 |
def image_page (image) : |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
39 |
""" |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
40 |
The per-image view |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
41 |
""" |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
42 |
|
80
f4b637ae775c
fix html to have a separate Container type, but also special-case tuples, lists and genexps
Tero Marttila <terom@fixme.fi>
parents:
78
diff
changeset
|
43 |
return [ |
136
29e41a6415d7
no need to use 'id_' in html attributes instead of just 'id'
Tero Marttila <terom@fixme.fi>
parents:
135
diff
changeset
|
44 |
tags.div(id='image')( |
62
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
45 |
# title |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
46 |
tags.h1(image.title) if image.title else None, |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
47 |
|
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
48 |
# image-links |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
49 |
tags.p( |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
50 |
# prev thumb |
77
2a53c5ade434
misc. fixes, it runs now, but HTML output is corrupt (no flattening)
Tero Marttila <terom@fixme.fi>
parents:
62
diff
changeset
|
51 |
image_link(image.html, image.prev.thumb, image.prev.html) if image.prev else None, |
62
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
52 |
|
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
53 |
# preview |
77
2a53c5ade434
misc. fixes, it runs now, but HTML output is corrupt (no flattening)
Tero Marttila <terom@fixme.fi>
parents:
62
diff
changeset
|
54 |
image_link(image.html, image.preview, image), |
62
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
55 |
|
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
56 |
# next thumb |
77
2a53c5ade434
misc. fixes, it runs now, but HTML output is corrupt (no flattening)
Tero Marttila <terom@fixme.fi>
parents:
62
diff
changeset
|
57 |
image_link(image.html, image.next.thumb, image.next.html) if image.next else None |
62
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
58 |
), |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
59 |
|
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
60 |
# optional description |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
61 |
tags.p(image.description) if image.description else None, |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
62 |
), |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
63 |
|
143
a6e53a20fccb
comment styles.css, and rename info -> metadata, fix about -> footer in templates
Tero Marttila <terom@fixme.fi>
parents:
142
diff
changeset
|
64 |
# metadata |
a6e53a20fccb
comment styles.css, and rename info -> metadata, fix about -> footer in templates
Tero Marttila <terom@fixme.fi>
parents:
142
diff
changeset
|
65 |
tags.div(id='metadata')(*( |
120
55cb7fc9c8fb
add new exif.py to abstract between different exif libraries, and add partially working support for pyexiv2 and EXIFpy
Tero Marttila <terom@fixme.fi>
parents:
119
diff
changeset
|
66 |
tags.p(("%s: " % name), value) for name, value in image.metadata |
78
d580323b4bfa
fix html/templates to use a Container type (inherited by Tag) for flat lists of tags
Tero Marttila <terom@fixme.fi>
parents:
77
diff
changeset
|
67 |
)), |
80
f4b637ae775c
fix html to have a separate Container type, but also special-case tuples, lists and genexps
Tero Marttila <terom@fixme.fi>
parents:
78
diff
changeset
|
68 |
] |
62
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
69 |
|
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
70 |
def folder_link (from_page, folder, page=0) : |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
71 |
""" |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
72 |
Returns a link to the given folder from the given page |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
73 |
""" |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
74 |
|
119 | 75 |
return link_from(from_page, folder.html_page(page))(folder.title) |
62
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
76 |
|
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
77 |
def folder_page_link (folder, page) : |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
78 |
""" |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
79 |
Returns a partial a tag from the folder itself to the given page number |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
80 |
""" |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
81 |
|
119 | 82 |
return link_from(folder, folder.html_page(page)) |
62
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
83 |
|
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
84 |
def folder_paginate (folder, cur_page) : |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
85 |
""" |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
86 |
Render the pagination view for a folder, if needed |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
87 |
""" |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
88 |
|
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
89 |
if folder.page_count > 1 : |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
90 |
return tags.div(class_='paginate')( |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
91 |
tags.ul( |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
92 |
# prev link |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
93 |
tags.li(folder_page_link(folder, cur_page - 1)(html.raw("« Prev"))) |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
94 |
if cur_page > 0 else |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
95 |
tags.li(tags.span(html.raw("« Prev"))), |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
96 |
|
80
f4b637ae775c
fix html to have a separate Container type, but also special-case tuples, lists and genexps
Tero Marttila <terom@fixme.fi>
parents:
78
diff
changeset
|
97 |
(( |
62
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
98 |
# page link |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
99 |
tags.li(folder_page_link(folder, page)(page + 1)) |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
100 |
if page != cur_page else |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
101 |
tags.li(tags.strong(page + 1)) |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
102 |
) for page in xrange(folder.page_count)), |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
103 |
|
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
104 |
# next link |
127 | 105 |
tags.li(folder_page_link(folder, cur_page + 1)(html.raw("Next »"))) |
62
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
106 |
if cur_page < folder.page_count - 1 else |
127 | 107 |
tags.li(tags.span(html.raw("Next »"))), |
62
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
108 |
) |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
109 |
) |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
110 |
|
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
111 |
def folder_page (folder, cur_page) : |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
112 |
""" |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
113 |
Render the per-Folder view for the given page |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
114 |
""" |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
115 |
|
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
116 |
# render the paginate-view once |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
117 |
paginate = folder_paginate(folder, cur_page) |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
118 |
|
80
f4b637ae775c
fix html to have a separate Container type, but also special-case tuples, lists and genexps
Tero Marttila <terom@fixme.fi>
parents:
78
diff
changeset
|
119 |
return [ |
62
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
120 |
# title |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
121 |
tags.h1(folder.title) if folder.title else None, |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
122 |
|
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
123 |
# subdirs |
100 | 124 |
tags.div(id='dirs')( |
62
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
125 |
tags.ul( |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
126 |
tags.li( |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
127 |
folder_link(folder, subfolder) |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
128 |
) for subfolder in folder.subfolders |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
129 |
) if folder.subfolders else None |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
130 |
), |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
131 |
|
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
132 |
# upper paginate |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
133 |
paginate, |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
134 |
|
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
135 |
# image thumbnails |
100 | 136 |
tags.div(id='thumbnails')( |
137 |
image_link(folder, image.thumb, image.html) for image in folder.images_for_page(cur_page) |
|
138 |
), |
|
62
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
139 |
|
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
140 |
# lower paginate |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
141 |
paginate, |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
142 |
|
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
143 |
# description |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
144 |
tags.p(id='description')(folder.description) if folder.description else None, |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
145 |
|
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
146 |
# shorturl |
80
f4b637ae775c
fix html to have a separate Container type, but also special-case tuples, lists and genexps
Tero Marttila <terom@fixme.fi>
parents:
78
diff
changeset
|
147 |
] |
62
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
148 |
|
119 | 149 |
def breadcrumb_trail (gallery, cur_page) : |
62
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
150 |
""" |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
151 |
Yield the breadcrumb elements |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
152 |
""" |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
153 |
|
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
154 |
is_first = True |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
155 |
|
119 | 156 |
for page in gallery.path_to(cur_page) : |
62
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
157 |
# spacers |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
158 |
if is_first : |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
159 |
is_first = False |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
160 |
|
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
161 |
else : |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
162 |
yield html.raw("»") |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
163 |
|
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
164 |
# link from this page to sub-page |
119 | 165 |
yield link_from(cur_page, page.html)(page.title) |
62
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
166 |
|
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
167 |
def breadcrumb (gallery, page) : |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
168 |
""" |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
169 |
Build a breadcrumb trail from the gallery root to the given object |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
170 |
""" |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
171 |
|
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
172 |
return tags.div(id='breadcrumb')( |
80
f4b637ae775c
fix html to have a separate Container type, but also special-case tuples, lists and genexps
Tero Marttila <terom@fixme.fi>
parents:
78
diff
changeset
|
173 |
breadcrumb_trail(gallery, page) |
62
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
174 |
) |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
175 |
|
119 | 176 |
def master (gallery, page, body) : |
62
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
177 |
""" |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
178 |
Render the full-page HTML layout for the given page with title and body |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
179 |
""" |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
180 |
|
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
181 |
return html.XHTMLDocument( |
80
f4b637ae775c
fix html to have a separate Container type, but also special-case tuples, lists and genexps
Tero Marttila <terom@fixme.fi>
parents:
78
diff
changeset
|
182 |
head=[ |
119 | 183 |
tags.title(page.title), |
62
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
184 |
|
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
185 |
# stylesheet |
119 | 186 |
tags.link(rel='Stylesheet', type='text/css', href=gallery.stylesheet.path_from(page.html)) |
80
f4b637ae775c
fix html to have a separate Container type, but also special-case tuples, lists and genexps
Tero Marttila <terom@fixme.fi>
parents:
78
diff
changeset
|
187 |
], |
62
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
188 |
|
80
f4b637ae775c
fix html to have a separate Container type, but also special-case tuples, lists and genexps
Tero Marttila <terom@fixme.fi>
parents:
78
diff
changeset
|
189 |
body=[ |
62
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
190 |
# top-of-page breadcrumb nav |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
191 |
breadcrumb(gallery, page), |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
192 |
|
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
193 |
# other content |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
194 |
body, |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
195 |
|
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
196 |
# footer |
143
a6e53a20fccb
comment styles.css, and rename info -> metadata, fix about -> footer in templates
Tero Marttila <terom@fixme.fi>
parents:
142
diff
changeset
|
197 |
tags.p(id='footer')(page.config.footer), |
80
f4b637ae775c
fix html to have a separate Container type, but also special-case tuples, lists and genexps
Tero Marttila <terom@fixme.fi>
parents:
78
diff
changeset
|
198 |
], |
62
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
199 |
) |
53e798708413
write new templates using html, replacing old mako stuff
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
200 |
|
142
2b8dfacc6d2d
externalize footer contents from template into config
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
201 |
# default footer used |
2b8dfacc6d2d
externalize footer contents from template into config
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
202 |
footer = ( |
2b8dfacc6d2d
externalize footer contents from template into config
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
203 |
"Generated using", |
2b8dfacc6d2d
externalize footer contents from template into config
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
204 |
tags.a(href='http://projects.qmsk.net/degal')('Degal'), |
2b8dfacc6d2d
externalize footer contents from template into config
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
205 |
"version", |
2b8dfacc6d2d
externalize footer contents from template into config
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
206 |
tags.a(href=version.VERSION_URL)(version.VERSION_STRING), |
2b8dfacc6d2d
externalize footer contents from template into config
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
207 |
) |