Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r78674 - in website/public_html/beta/site-tools: boost_site templates
From: dnljms_at_[hidden]
Date: 2012-05-27 08:47:54


Author: danieljames
Date: 2012-05-27 08:47:53 EDT (Sun, 27 May 2012)
New Revision: 78674
URL: http://svn.boost.org/trac/boost/changeset/78674

Log:
Website: Replace templite news/release pages with plain python templates.
Text files modified:
   website/public_html/beta/site-tools/boost_site/pages.py | 37 +++++++++++++++++++++++++++--
   website/public_html/beta/site-tools/boost_site/settings.py | 3 --
   website/public_html/beta/site-tools/boost_site/util.py | 10 +++++++
   website/public_html/beta/site-tools/templates/entry-template.html | 49 ++++++++++-----------------------------
   4 files changed, 56 insertions(+), 43 deletions(-)

Modified: website/public_html/beta/site-tools/boost_site/pages.py
==============================================================================
--- website/public_html/beta/site-tools/boost_site/pages.py (original)
+++ website/public_html/beta/site-tools/boost_site/pages.py 2012-05-27 08:47:53 EDT (Sun, 27 May 2012)
@@ -112,10 +112,41 @@
                     page_data.load(bb_parser.parse(xml_filename), refresh)
                 finally:
                     os.unlink(xml_filename)
-
- boost_site.templite.write_template(page_data.location,
+
+ template_vars = {
+ 'history_style' : '',
+ 'full_title_xml' : page_data.full_title_xml,
+ 'title_xml' : page_data.title_xml,
+ 'note_xml' : '',
+ 'web_date' : page_data.web_date(),
+ 'documentation_para' : '',
+ 'download_table' : page_data.download_table(),
+ 'description_xml' : page_data.description_xml
+ }
+
+ if page_data.type == 'release' and 'released' not in page_data.flags:
+ template_vars['note_xml'] = '<div class="section-note"><p>Note: This version is at an early stage in its release cycle. The information listed below is incomplete and some of the documentation links may not work yet.</p></div>'
+
+ if page_data.documentation:
+ template_vars['documentation_para'] = '<p>Documentation'
+
+ if(page_data.location.startswith('users/history/')):
+ template_vars['history_style'] = """
+ <style type="text/css">
+/*<![CDATA[*/
+ #content .news-description ul {
+ list-style: none;
+ }
+ #content .news-description ul ul {
+ list-style: circle;
+ }
+ /*]]>*/
+ </style>
+"""
+
+ boost_site.util.write_template(page_data.location,
                     'site-tools/templates/entry-template.html',
- { 'page': page_data })
+ template_vars)
 
     def match_pages(self, patterns, count = None, sort = True):
         """

Modified: website/public_html/beta/site-tools/boost_site/settings.py
==============================================================================
--- website/public_html/beta/site-tools/boost_site/settings.py (original)
+++ website/public_html/beta/site-tools/boost_site/settings.py 2012-05-27 08:47:53 EDT (Sun, 27 May 2012)
@@ -21,16 +21,13 @@
     'pages': {
         'users/history/': {
             'src_files' : ['feed/history/*.qbk'],
- 'template' : 'site-tools/templates/entry-template.html',
             'type' : 'release'
         },
         'users/news/': {
             'src_files' : ['feed/news/*.qbk'],
- 'template' : 'site-tools/templates/entry-template.html'
         },
         'users/download/': {
             'src_files' : ['feed/downloads/*.qbk'],
- 'template' : 'site-tools/templates/entry-template.html',
             'type' : 'release'
         }
     },

Modified: website/public_html/beta/site-tools/boost_site/util.py
==============================================================================
--- website/public_html/beta/site-tools/boost_site/util.py (original)
+++ website/public_html/beta/site-tools/boost_site/util.py 2012-05-27 08:47:53 EDT (Sun, 27 May 2012)
@@ -3,7 +3,7 @@
 # Distributed under the Boost Software License, Version 1.0.
 # (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
 
-import urlparse, re
+import urlparse, re, string
 
 def htmlencode(text):
     return text.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&rt;')
@@ -34,3 +34,11 @@
     elif node.nodeType == node.DOCUMENT_FRAGMENT_NODE:
         for x in node.childNodes:
             transform_links_impl(x, tag_name, attribute, func)
+
+def write_template(dst_path, template_path, data):
+ file = open(template_path)
+ s = string.Template(file.read().decode('utf-8'))
+ output = s.substitute(data)
+ output = re.sub(r' +$', '', output, flags = re.M)
+ out = open(dst_path, "w")
+ out.write(output.encode('utf-8'))

Modified: website/public_html/beta/site-tools/templates/entry-template.html
==============================================================================
--- website/public_html/beta/site-tools/templates/entry-template.html (original)
+++ website/public_html/beta/site-tools/templates/entry-template.html 2012-05-27 08:47:53 EDT (Sun, 27 May 2012)
@@ -1,34 +1,16 @@
-${
-from boost_site.util import htmlencode
-}$<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 
 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
 <head>
- <title>${ emit(page.full_title_xml) }$</title>
+ <title>${full_title_xml}</title>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
   <link rel="icon" href="/favicon.ico" type="image/ico" />
   <link rel="stylesheet" type="text/css" href="/style-v2/section-boost.css" />
-${
-if(page.location.startswith('users/history/')):
- emit(""" <style type="text/css">
-/*<![CDATA[*/
- #content .news-description ul {
- list-style: none;
- }
- #content .news-description ul ul {
- list-style: circle;
- }
- /*]]>*/
- </style>
-""")
-}$ <!--[if IE 7]> <style type="text/css"> body { behavior: url(/style-v2/csshover3.htc); } </style> <![endif]-->
+${history_style}
+ <!--[if IE 7]> <style type="text/css"> body { behavior: url(/style-v2/csshover3.htc); } </style> <![endif]-->
 </head>
-
-${
- # Obviously doesn't apply here.
- emit("<!-- Don't edit this page! It's generated by site-tools/site-tools.py -->\n");
-}$
+<!-- Don't edit this page! It's generated by site-tools/site-tools.py -->
 <body>
   <div id="heading">
     <!--#include virtual="/common/heading.html" --> </div>
@@ -39,24 +21,19 @@
         <div class="section" id="intro">
           <div class="section-0">
             <div class="section-title">
- <h1>${ emit(page.title_xml) }$</h1>
+ <h1>${title_xml}</h1>
             </div>
-${
-if page.type == 'release' and 'released' not in page.flags:
- emit('<div class="section-note"><p>Note: This version is at an early stage in its release cycle. The information listed below is incomplete and some of the documentation links may not work yet.</p></div>\n');
-}$
+ ${note_xml}
             <div class="section-body">
               <h2><span class=
- "news-title">${ emit(page.full_title_xml) }$</span></h2>
+ "news-title">${full_title_xml}</span></h2>
 
- <p><span class=
- "news-date">${ emit(page.web_date()) }$</span></p>
-${
-if (page.documentation): emit('<p>Documentation')
-}$
- ${ emit(page.download_table()) }$
+ <p><span class=news-date">${web_date}</span></p>
+ ${documentation_para}
+ ${download_table}
               <div class="news-description">
- <div class="description">${ emit(page.description_xml) }$</div> </div>
+ <div class="description">${description_xml}</div>
+ </div>
             </div>
           </div>
         </div>


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk