changeset 16:2bd6b2b543dc

now have blog entry snippets
author k0s <k0scist@gmail.com>
date Sun, 25 Oct 2009 18:11:25 -0400
parents 36698624435b
children e5cbc53cacf8
files bitsyblog/bitsyblog.py bitsyblog/templates/blog.html
diffstat 2 files changed, 58 insertions(+), 52 deletions(-) [+]
line wrap: on
line diff
--- a/bitsyblog/bitsyblog.py	Sun Oct 25 17:25:58 2009 -0400
+++ b/bitsyblog/bitsyblog.py	Sun Oct 25 18:11:25 2009 -0400
@@ -230,10 +230,11 @@
         # GENSHI: data dictionary
         request.environ['data'] = { 'site_name': self.site_name,
                                     'request': request,
-                                    'link': self.liin}
+                                    'link': self.link,
+                                    'escape': cgi.escape }
 
         # front matter of the site
-        index = self.get_index()
+        index = get_index()
         if index is not None:
             return index
 
@@ -883,7 +884,8 @@
         # GENSHI: global data dictionary
         request.environ['data'] = { 'site_name': self.site_name,
                                     'request': request,
-                                    'link': self.link }
+                                    'link': self.link,
+                                    'escape': cgi.escape }
 
         ### user space
         user, path = self.userpath(request)
--- a/bitsyblog/templates/blog.html	Sun Oct 25 17:25:58 2009 -0400
+++ b/bitsyblog/templates/blog.html	Sun Oct 25 18:11:25 2009 -0400
@@ -21,61 +21,65 @@
     
     <xi:include href="navigation.html" />
       
-      <div class="navigation"
-           py:if="n_links == 0 or not len(blog)"
-           py:with="_n_links = (n_links != -1) and n_links or len(blog)">
-        <ul>
-          <li py:for="index in range(_n_links)">
-          </li>
-        </ul>
-        <a py:if="_n_links != len(blog)" href="TODO?n=all">more</a>
-      </div>
+    <!-- blog navigation -->
+    <div class="navigation"
+         py:if="n_links == 0 or len(blog) &gt; 1"
+         py:with="_n_links = (n_links != -1) and n_links or len(blog)">
+      <ul>
+        <li py:for="index in range(_n_links)"
+            py:with="synopsis = blog[index].title()">
+          <a href="#${blog[index].datestamp()}">${blog[index].date.strftime(date_format)}</a><py:if test="synopsis">: ${escape(synopsis)}</py:if>
+        </li>
+      </ul>
+      <a py:if="_n_links != len(blog)" href="${request.path}?n=all">more</a>
+    </div>
 
-      <!-- blog entries -->
-      <div py:for="entry in blog"
-           id="${entry.datestamp()}" class="blog-entry">
-        <a name="${entry.datestamp()}" />
+    <!-- blog entries -->
+    <div py:for="entry in blog"
+         id="${entry.datestamp()}" class="blog-entry">
+      <a name="${entry.datestamp()}" />
+      
+      <div class="subject">
+        <a href="${user_url(request, request.user.name, entry.datestamp())}">${subject % dict(date=entry.date.strftime(date_format))}</a>
+        <em py:if="entry.privacy == 'secret' and role == 'friend'">
+          secret
+        </em>
+      </div>
         
-        <div class="subject">
-          <a href="${user_url(request, request.user.name, entry.datestamp())}">${subject % dict(date=entry.date.strftime(date_format))}</a>
-          <em py:if="entry.privacy == 'secret' and role == 'friend'">
-            secret
-          </em>
-        </div>
-        
-        ${entry.cooked_body}
-        
-        <div py:if="role == 'author'">
+      ${entry.cooked_body}
+      
+      <div py:if="role == 'author'">
 
-          <!-- privacy settings -->
-          <form action="TODO" method="post">
-            <span title="viewable to everyone">
-              public
-              <input type="radio" name="privacy" value="public" 
-                     py:attrs="{'checked': entry.privacy=='public' and True or None}"/>
-            </span> 
-            <span title="viewable only to your friends">
-              secret
-              <input type="radio" name="privacy" value="secret" 
-                     py:attrs="{'checked': entry.privacy=='secret' and True or None}"/>
-            </span> 
-            <span title="viewable only to you">
-              private
-              <input type="radio" name="privacy" value="private"
-                     py:attrs="{'checked': entry.privacy=='private' and True or None}"/>
-            </span>
-            <input type="submit" name="submit" value="Change Privacy" />
-          </form>
+        <!-- privacy settings -->
+        <form action="TODO" method="post">
+          <span title="viewable to everyone">
+            public
+            <input type="radio" name="privacy" value="public" 
+                   py:attrs="{'checked': entry.privacy=='public' and True or None}"/>
+          </span> 
+          <span title="viewable only to your friends">
+            secret
+            <input type="radio" name="privacy" value="secret" 
+                   py:attrs="{'checked': entry.privacy=='secret' and True or None}"/>
+          </span> 
+          <span title="viewable only to you">
+            private
+            <input type="radio" name="privacy" value="private"
+                   py:attrs="{'checked': entry.privacy=='private' and True or None}"/>
+          </span>
+          <input type="submit" name="submit" value="Change Privacy" />
+        </form>
 
-          <!-- mangled URL -->
-          <div py:if="entry.privacy != 'public'"
-               py:with="mangled_url = mangledurl(request, entry)">
-            <span title="${'You can give this URL so people may see this %s post without logging in' % entry.privacy}">Mangled URL:</span>
-            <a href="${mangled_url}">${mangled_url}</a>
-          </div>
+        <!-- mangled URL -->
+        <div py:if="entry.privacy != 'public'"
+             py:with="mangled_url = mangledurl(request, entry)">
+          <span title="${'You can give this URL so people may see this %s post without logging in' % entry.privacy}">Mangled URL:</span>
+          <a href="${mangled_url}">${mangled_url}</a>
         </div>
+      </div>
+      
+    </div><!-- blog-entry -->
 
-      </div>
   </body>
 
 </html>