Commits

Fredrik Håård committed 5ab452b

Genshi appears to work as intended

Comments (0)

Files changed (2)

         article.comment_thread_link = get_absolute_url(parts)
         article.article_url = get_absolute_url(parts)
         article.article_title = parts['title']
+        article.path = os.path.join(html_path, identifier(parts))
         articles.append(article)
-
+        
     template = loader.load("page_template.xhtml")
-    stream = template.generate(articles = articles, **defaults)
+    stream = template.generate(articles = articles, all_articles=articles,
+                               short_comments=True,
+                               **defaults)
     content = stream.render('html', doctype='html')
 
     #Write main page
     with open(os.path.join(html_path, "index.html"), "w") as target:
         target.write(content)
 
-    
-    for parts in data: 
-        parts.update(defaults)
-        htmltitle = identifier(parts)
-        target_path = os.path.join(html_path, htmltitle)
-        if not os.path.exists(target_path):
-            os.mkdir(target_path)
+    for article in articles:
+        if not os.path.exists(article.path):
+            os.mkdir(article.path)
 
-
-
-        with open(os.path.join(html_path, htmltitle, "index.html"), "w") as target:
-
-            article = Article(full=True)
-            article.article_id = identifier(parts)
-            article.body = Markup(parts['html_body'])
-            article.timestamp = parts['created_str']
-            article.modified = parts['modified_str']
-            article.comment_thread_link = get_absolute_url(parts)
-            article.article_url = get_absolute_url(parts)
-            article.article_title = parts['title']
-            
+        with open(os.path.join(article.path, "index.html"), "w") as target:            
             stream = template.generate(articles=[article], all_articles=articles, 
+                                       short_comments=False,
                                        **defaults)
             target.write(stream.render("html", doctype="html"))
 

templates/page_template.xhtml

           </div>
           
           
-          <div py:if="article.short_comment" class='shortcomments'>
-            <a href="$article.comment_thread_link##disqus_thread" 
+          <div py:if="short_comments" class='shortcomments'>
+            <a href="$article.comment_thread_link#disqus_thread" 
                data-disqus-identifier="$article.article_id">Comments</a>
           </div> 
 
-          <div py:if="article.long_comment" class='fullcomments'>
+          <div py:if="not short_comments" class='fullcomments'>
             <div id="disqus_thread"></div>
             <script type="text/javascript">
               /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
         <a href='/rss.xml' class='menu_link'>RSS Feed</a>
         <h4>My recent posts</h4>
         
-        <a py:for="article in articles" href='$article.article_url' class='menu_link'>$article.article_title</a>
+        <a py:for="article in all_articles" href='$article.article_url' class='menu_link'>$article.article_title</a>
 
       </nav>
       
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.