Skip to content
Myr

[svn] jinja webpage update. (one dirty script more)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

--HG-- branch : trunk

authored by Armin Ronacher · committed by Armin Ronacher · parent 2b76513 · Browse files · 17 files+212 added−80 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

17 files+212 added−80 removed

  • other:+212 added−80 removed

17 files+212 added−80 removed

modified:docs/generate.py+18 added-7 removed
107 unmodified lines
108LIST_OF_FILTERS = generate_list_of_filters()109LIST_OF_TESTS = generate_list_of_tests()110LIST_OF_LOADERS = generate_list_of_loaders()111112TEMPLATE = e.from_string('''\112FULL_TEMPLATE = e.from_string('''\113<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"114 "http://www.w3.org/TR/html4/strict.dtd">115<html>116<head>
38 unmodified lines
155 file id: {{ file_id }} -->156</html>\157''')158159PREPROC_TEMPLATE = e.from_string('''\160<!-- TITLE -->{{ title }}<!-- ENDTITLE -->161<!-- TOC -->{% for key, value in toc %}<li><a href="{{162 key }}">{{ value }}</a></li>{% endfor %}<!-- ENDTOC -->163<!-- BODY -->{{ body }}<!-- ENDBODY -->\164''')165166def pygments_directive(name, arguments, options, content, lineno,167 content_offset, block_text, state, state_machine):168 try:169 lexer = get_lexer_by_name(arguments[0])
74 unmodified lines
244 'toc': parts['toc']245 }246247241def handle_file(filename, fp, dst):248def handle_file(filename, fp, dst, preproc):249 now = datetime.now()250 title = os.path.basename(filename)[:-4]251 content = fp.read()252 parts = generate_documentation(content, (lambda x: './%s.html' % x))
1 unmodified line
254 c = dict(parts)255 c['style'] = PYGMENTS_FORMATTER.get_style_defs('.syntax')256 c['generation_date'] = now257 c['file_id'] = title258 if preproc:259 tmpl = PREPROC_TEMPLATE260 else:261 tmpl = FULL_TEMPLATE251 result.write(TEMPLATE.render(c).encode('utf-8'))262 result.write(tmpl.render(c).encode('utf-8'))263 result.close()264265255def run(dst, sources=()):266def run(dst, preproc, sources=(), handle_file=handle_file):267 path = os.path.abspath(os.path.join(os.path.dirname(__file__), 'src'))268 if not sources:269 sources = [os.path.join(path, fn) for fn in os.listdir(path)]270 for fn in sources:
1 unmodified line
272 continue273 print 'Processing %s' % fn274 f = open(fn)275 try:265 handle_file(fn, f, dst)276 handle_file(fn, f, dst, preproc)277 finally:278 f.close()279280270def main(dst='build/', *sources):271 return run(os.path.realpath(dst), sources)281def main(dst='build/', preproc=False, *sources):282 run(os.path.realpath(dst), str(preproc).lower() == 'true', sources)283284285if __name__ == '__main__':286 main(*sys.argv[1:])
modified:jinja/translators/python.py+8 added-8 removed
230 unmodified lines
231 else:232 raise AssertionError('unhandled node %r' % node.__class__)233 return out234235 def reset(self):236 self.indention = 0237 self.last_cycle_id = 0238239 def translate(self):240 self.reset()241 return self.handle_node(self.node)242243 # -- jinja nodes244245 def handle_template(self, node):246 """
611 unmodified lines
858 args = []859 for n in node.nodes:860 args.append(self.handle_node(n))861 return '[%s]' % ':'.join(args)854855 def reset(self):856 self.indention = 0857 self.last_cycle_id = 0858859 def translate(self):860 self.reset()861 return self.handle_node(self.node)
modified:jinja/datastructure.py+4 added
31 unmodified lines
32 else:33 raise TypeError('cannot create %r instances' %34 self.__class__.__name__)3536 def __add__(self, other):37 return other38 __sub__ = __mul__ = __div__ = __add__3940 def __getitem__(self, arg):41 return self4243 def __iter__(self):
303 unmodified lines
modified:jinja/exceptions.py+9 added
45 unmodified lines
46 def __init__(self, message):47 KeyError.__init__(self, message)484950class TestArgumentError(TypeError, TemplateError):51 """52 An argument passed to a test function was invalid.53 """5455 def __init__(self, message):56 TypeError.__init__(self, message)575859class TemplateNotFound(IOError, TemplateError):60 """61 Raised if a template does not exist.62 """
20 unmodified lines
added:www/documentation/item.tmpl+11 added
1<% extends 'layout/base.tmpl' %>2<% set title = page_title + " | Documentation" %>3<% set active_page = 'documentation' %>4<% block content %>5 <h1><%= page_title %></h1>6 <% if page_toc %>7 <h2 class="toc">Table Of Contents</h2>8 <ul><%= page_toc %></ul>9 <% endif %>10 <%= page_body %>11<% endblock %>
modified:www/layout/base.html+5 added-8 removed
modified:www/layout/base.tmpl+4 added-10 removed
2 unmodified lines
3 ('faq', 'FAQ'),4 ('documentation', 'Documentation'),5 ('download', 'Download')6] %>7<% block code %><% endblock %>7<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Frameset//EN"8 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">9<html xmlns="http://www.w3.org/1999/xhtml">10 <head>12 <title><% block title %>Untitled<% endblock %> | Jinja Template Engine</title>11 <title><%= title or 'Untitled' %> | Jinja Template Engine</title>12 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />13 <link rel="stylesheet" href="<%= root %>static/style.css" type="text/css" />14 <link rel="stylesheet" href="<%= root %>static/print.css" type="text/css" media="print" />15 <link rel="stylesheet" href="<%= root %>static/pygments.css" type="text/css" />
3 unmodified lines
19 <h1>Jinja</h1>20 </div>21 <ul id="navigation">22 <% for id, caption in navigation %>24 <% if id == file_id or id.startswith(file_id + '/') %>25 <li class="active"><%= caption|escape %></li>26 <% else %>27 <li><a href="<%= root %><%= id|escape %>.html"><%= caption|escape %></a></li>28 <% endif %>23 <li<% if id == active_page %> class="active"<% endif24 %>><a href="<%= root %><%= id|escape %>.html"><%= caption|escape25 %></a></li>26 <% endfor %>27 </ul>28 <% if trace %>29 <div id="trace">
9 unmodified lines
39 <div id="content">40 <div id="contentwrapper">41 <% block content %><% endblock %>42 </div>46 <p id="meta">47 <a href="<%= root + file_id + '.tmpl' %>">show template source</a>48 </p>43 </div>44 <div id="footer">45 &copy; Copyright 2007 by the Pocoo Team.46 </div>
2 unmodified lines
modified:www/static/style.css+77 added-8 removed
46 unmodified lines
47 font-size: 13px;48 font-family: 'Bitstream Vera Sans Mono', 'Monaco', monospace;49}5051table.docutils {52 border-collapse: collapse;53 border: 2px solid #aaa;54 margin: 0.5em 1.5em 0.5em 1.5em;55}5657table.docutils td {58 padding: 2px;59 border: 1px solid #ddd;60}6162dl {63 margin-left: 10px;64}6566li, dt {67 margin-top: 5px;68}6970dt {71 font-weight: bold;72}7374th {75 text-align: left;76 padding: 3px;77 background-color: #f2f2f2;78}7980tt {81 font-size: 13px;82 font-family: 'Bitstream Vera Sans Mono', 'Monaco', monospace;83 color: black;84 padding: 1px 2px 1px 2px;85 background-color: #f0f0f0;86}8788cite {89 /* abusing <cite>, it's generated by ReST for `x` */90 font-size: 13px;91 font-family: 'Bitstream Vera Sans Mono', 'Monaco', monospace;92 font-weight: bold;93 font-style: normal;94}9596div.admonition {97 margin: 10px 0 10px 0;98 padding: 10px;99 border: 1px solid #ccc;100 background-color: #f8f8f8;101}102103div.admonition p.admonition-title {104 margin: -3px 0 5px 0;105 font-weight: bold;106 color: #b41717;107 font-size: 16px;108}109110div.admonition p {111 margin: 0 0 0 40px;112}113114#content {115 background-color: white;116 background-image: url(watermark.png);117 padding: 10px;
6 unmodified lines
124 margin: 0 25px 25px 25px;125 border: 4px solid #ddd;126 border-top: none;127 background-color: #fff;128 color: #999;129 text-align: right;66 padding: 0 10px 5px 0;130 padding: 0 20px 20px 0;131}132133#contentwrapper {134 max-width: 700px;
22 unmodified lines
157 list-style: none;158 font-weight: bold;159}160161#navigation li {162 margin: 0;163}164165#navigation li a {166 display: block;167 text-decoration: none;168 padding: 5px 10px 5px 10px;
5 unmodified lines
174 background-color: #444;175}176177#navigation li.active {110 padding: 5px 10px 5px 10px;178 background-color: #b41717;112 color: white;179}180181#navigation li.active a {182 color: #fff;183}184185#navigation li a:focus {186 outline: none;187 background-color: #222;188 color: #fff;
10 unmodified lines
199 font-size: 20px;200 margin: 20px 0 0 0;201}202133#meta {134 clear: both;135 text-align: right;136 color: #888;137 font-size: 13px;203#contentwrapper h2.toc {204 color: #222;205 font-size: 16px;206 margin: 20px 0 0 0;207}
modified:www/documentation.html+9 added-9 removed
11 unmodified lines
12 <div id="header">13 <h1>Jinja</h1>14 </div>15 <ul id="navigation">16 <li><a href="./index.html">Index</a></li>17 <li><a href="./faq.html">FAQ</a></li>18 <li class="active">Documentation</li>19 <li><a href="./download.html">Download</a></li>20 </ul>16 <li><a href="./index.html">Index</a></li>17 <li><a href="./faq.html">FAQ</a></li>18 <li class="active"><a href="./documentation.html">Documentation</a></li>19 <li><a href="./download.html">Download</a></li>20 </ul>21 <div id="content">22 <div id="contentwrapper">23 <h1>Documentation</h1>24 <p>25 You can browse the documentation either online or download it:25 Currently Jinja 1 in still under heavy development and we have neither26 released a final version nor do we provide a documentation you can download.27 However you can browse the documentation of the current SVN version online:28 </p>29 <p><a href="./documentation/index.html">browse online documentation</a></p>30 </div>28 <p id="meta">29 <a href="./documentation.tmpl">show template source</a>30 </p>31 </div>32 <div id="footer">33 &copy; Copyright 2007 by the Pocoo Team.34 </div>
2 unmodified lines
modified:www/documentation.tmpl+6 added-2 removed
1<% extends 'layout/base.tmpl' %>2<% block title %>Documentation<% endblock %>2<% set title = 'Documentation' %>3<% set active_page = 'documentation' %>4<% block content %>5 <h1>Documentation</h1>6 <p>6 You can browse the documentation either online or download it:7 Currently Jinja 1 in still under heavy development and we have neither8 released a final version nor do we provide a documentation you can download.9 However you can browse the documentation of the current SVN version online:10 </p>11 <p><a href="./documentation/index.html">browse online documentation</a></p>12<% endblock %>
modified:www/download.html+5 added-8 removed
11 unmodified lines
12 <div id="header">13 <h1>Jinja</h1>14 </div>15 <ul id="navigation">16 <li><a href="./index.html">Index</a></li>17 <li><a href="./faq.html">FAQ</a></li>18 <li><a href="./documentation.html">Documentation</a></li>19 <li class="active">Download</li>20 </ul>16 <li><a href="./index.html">Index</a></li>17 <li><a href="./faq.html">FAQ</a></li>18 <li><a href="./documentation.html">Documentation</a></li>19 <li class="active"><a href="./download.html">Download</a></li>20 </ul>21 <div id="content">22 <div id="contentwrapper">23 <h1>Download</h1>24 <p>
15 unmodified lines
40 you can browse the source online41 <a href="http://trac.pocoo.org/browser/jinja/trunk">here</a>.42 </p>43 </div>44 <p id="meta">45 <a href="./download.tmpl">show template source</a>46 </p>44 </div>45 <div id="footer">46 &copy; Copyright 2007 by the Pocoo Team.47 </div>
2 unmodified lines
modified:www/download.tmpl+2 added-1 removed
1<% extends 'layout/base.tmpl' %>2<% block title %>Download<% endblock %>2<% set title = 'Download' %>3<% set active_page = 'download' %>4<% block content %>5 <h1>Download</h1>6 <p>7 If you want to install the release with
18 unmodified lines
modified:www/faq.html+5 added-8 removed
11 unmodified lines
12 <div id="header">13 <h1>Jinja</h1>14 </div>15 <ul id="navigation">16 <li><a href="./index.html">Index</a></li>17 <li class="active">FAQ</li>18 <li><a href="./documentation.html">Documentation</a></li>19 <li><a href="./download.html">Download</a></li>20 </ul>16 <li><a href="./index.html">Index</a></li>17 <li class="active"><a href="./faq.html">FAQ</a></li>18 <li><a href="./documentation.html">Documentation</a></li>19 <li><a href="./download.html">Download</a></li>20 </ul>21 <div id="content">22 <div id="contentwrapper">23 <h1>Frequently Asked Questions</h1>24 <p>
35 unmodified lines
60 python constructs have a look at mako. If you want sandboxed templates61 you probably want to check out Jinja.62 </p>63 </div>64 <p id="meta">65 <a href="./faq.tmpl">show template source</a>66 </p>64 </div>65 <div id="footer">66 &copy; Copyright 2007 by the Pocoo Team.67 </div>
2 unmodified lines
modified:www/faq.tmpl+2 added-1 removed
1<% extends 'layout/base.tmpl' %>2<% block title %>FAQ<% endblock %>2<% set title = 'FAQ' %>3<% set active_page = 'faq' %>4<% block content %>5 <h1>Frequently Asked Questions</h1>6 <p>7 Here a list of frequently asked questions.
38 unmodified lines
modified:www/generate.py+40 added-1 removed
2 unmodified lines
3 jinja webpage generator4 ~~~~~~~~~~~~~~~~~~~~~~~5"""6import os7import sys8import re9from codecs import open10from jinja import Environment, FileSystemLoader11from jinja.filters import stringfilter12from pygments import highlight13from pygments.lexers import get_lexer_by_name14from pygments.formatters import HtmlFormatter1516_data_re = re.compile(17 r'<!-- TITLE -->(?P<page_title>.*?)<!-- ENDTITLE -->.*?'18 r'<!-- TOC -->(?P<page_toc>.*?)<!-- ENDTOC -->.*?'19 r'<!-- BODY -->(?P<page_body>.*?)<!-- ENDBODY -->(?sm)'20)2122formatter = HtmlFormatter(cssclass='syntax', encoding=None, style='pastie')2324env = Environment('<%', '%>', '<%=', '%>', loader=FileSystemLoader('.',
11 unmodified lines
36 elif fn.endswith('.tmpl'):37 yield fn383940# generate static stuff41for filename in get_files('.'):42 root = './' + ''.join(['../' for _ in os.path.dirname(filename).43 split(os.path.sep)[1:]])4445 t = env.get_template(filename)46 f = open(filename[:-5] + '.html', 'w', 'utf-8')47 f.write(t.render(40 file_id=filename[2:-5],48 root=root49 ))50 f.close()51 print filename5253# generate pygments stylesheet54f = file('static/pygments.css', 'w')55f.write(formatter.get_style_defs('.syntax'))56f.close()5758# generate documentation59os.system(sys.executable + ' ../docs/generate.py documentation true')6061# render documentation with documentation template62tmpl = env.get_template('documentation/item.tmpl')6364for filename in os.listdir('documentation'):65 if not filename.endswith('.html'):66 continue67 filename = 'documentation/' + filename68 f = open(filename, 'r', 'utf-8')69 try:70 data = f.read()71 finally:72 f.close()73 match = _data_re.search(data)74 if match is None:75 continue76 data = match.groupdict()77 data['page_toc'] = data['page_toc'].strip()78 if data['page_toc'].count('</li') < 2:79 data['page_toc'] = ''80 f = open(filename, 'w', 'utf-8')81 f.write(tmpl.render(82 root='./../',83 **data84 ))85 f.close()86 print 'postprocessed', filename
modified:www/index.html+5 added-8 removed
11 unmodified lines
12 <div id="header">13 <h1>Jinja</h1>14 </div>15 <ul id="navigation">16 <li class="active">Index</li>17 <li><a href="./faq.html">FAQ</a></li>18 <li><a href="./documentation.html">Documentation</a></li>19 <li><a href="./download.html">Download</a></li>20 </ul>16 <li class="active"><a href="./index.html">Index</a></li>17 <li><a href="./faq.html">FAQ</a></li>18 <li><a href="./documentation.html">Documentation</a></li>19 <li><a href="./download.html">Download</a></li>20 </ul>21 <div id="content">22 <div id="contentwrapper">23 <h1>Jinja Templates</h1>24 <p>
55 unmodified lines
80 You can override the syntax elements on environment initialisation. It's81 no problem to use ASP/PHP/Ruby syntax, html comments for blocks etc.</li>82 </ul>83 </div>84 <p id="meta">85 <a href="./index.tmpl">show template source</a>86 </p>84 </div>85 <div id="footer">86 &copy; Copyright 2007 by the Pocoo Team.87 </div>
2 unmodified lines
modified:www/index.tmpl+2 added-1 removed
1<% extends 'layout/base.tmpl' %>2<% block title %>Index<% endblock %>2<% set title = 'Index' %>3<% set active_page = 'index' %>4<% block content %>5 <h1>Jinja Templates</h1>6 <p>7 Jinja is a
59 unmodified lines