;ò
+¯Ï@c           @   s¹   d  k  Z  d  k Z  d  k Z d  k Z d Z d Z d Z d Z d a d „  Z	 d Z
 d Z e a d	 „  Z e a d
 „  Z e d „ Z d e f d „  ƒ  YZ h  Z d „  Z e d d „ Z d  S(   Ns   /home/tom/idealog/blogs   /home/tom/WWW.blogs   /home/tom/idealog/commentsi
   i    c         C   sœ  d „  } t i d t i ƒ i | |  ƒ }  d } d } d } t	 } t	 } d } x.| t |  ƒ j  ot i d t i ƒ i |  | ƒ } | oå| i ƒ  } | i d ƒ } | } | i d ƒ i ƒ  } t	 }	 t	 }
 t	 } | d j o | d 7} | d 7} t }
 n | d j o$ | d 8} | d 8} t }
 t }	 n | d	 j o | d 7} t }
 n | d
 j o | d 8} t }	 t }
 n | d d d d f j o t }	 t }
 n | d j o0 t }
 t }	 t } t d 7a d t t f } n | d j o t }
 t }	 d } n | o |	 o | o | d 7} t } n |
 p | o | o | d 7} t	 } n | | 7} | | O} qQ n t i d ƒ i |  | ƒ } | oA | i ƒ  } | o | d 7} t	 } qQ | | i d ƒ 7} qQ n |  | d j o | d 7} | d 7} n | o | o | d 7} t } n t i d t i ƒ i |  | ƒ } | o | o´ | i ƒ  } | i d ƒ } | d j o | d 7} qQ | d j o | d 7} qQ | d j o | d 7} qQ | d j o* | } | o | d  7} qþ| d! 7} qQ | | 7} qQ n. | o& | i ƒ  } | | i d ƒ 7} qQ n t i d" ƒ i |  | ƒ } | o& | i ƒ  } | | i d ƒ 7} qQ qQ qQ W| o | d# 7} n | Sd$ S(%   sÒ   
    Formats text into html. The text is in my private format. It tries
    hard to get tag nesting right.
    
    @param text: The text to be formatted.
    
    @return: HTML, corresponding to the text.
    c         C   s¿   |  i d ƒ p d } | i d d ƒ } |  i d ƒ } | i d d ƒ } | i d d	 ƒ } | i d
 d ƒ } | i d d ƒ } | } t | ƒ d j o | d  d } n d | | | f Sd  S(   Ni   s   &rarr; s    s   &nbsp;i   s   &s   &amp;s   <s   &lt;s   >s   &gt;s   "s   &quot;i<   s   ...s5   <span class="link">%s<a href="%s">%s</a></span><br />(   s   ms   groups   vias   replaces   urls   shorturls   len(   s   ms   urls   shorturls   via(    (    s!   /home/tom/WWW.blog/code/common.pys   link%   s    s   ^(\w+ )?(http://\S+)s    i    s   <(/?\w+).*?>i   s   pres   /pres   tables   /tables
   blockquotes   /blockquotes   divs   /divs   spoilers…   <div id="spoiler_%d" class="spoiler"><p><span class="show_spoiler">(<a href="javascript:show_spoiler('spoiler_%d');">show</a>)</span>s   /spoilers   </div>s   <p>
s   </p>
s   \n\s*\ns   
</p>
s   
s   \\(.?)s   &s   &amp;s   <s   &lt;s   >s   &gt;s   "s   "<span class="quote">s   </span>"s	   [^\n\\<]+s   
</p>N(   s   links   res   compiles	   MULTILINEs   subs   texts   bodys   noautops   nobackslashs   Falses   inps   sqstates   poss   lens   DOTALLs   matchs   ms   ends   groups   tags   outputs   lowers   tagnames   nostartps
   forcestopps   manualps   Trues   spoilers   Is   c(   s   texts   inps   poss   tags   sqstates   nobackslashs   bodys   manualps   noautops   nostartps
   forcestopps   links   cs   ms   tagnames   output(    (    s!   /home/tom/WWW.blog/code/common.pys   txt2html   sÎ       	! !























!
s  <html>
<head>
<title>IF -- %(title)s</title>

<link rel="stylesheet" href="/style.css" />
<link rel="alternate" title="RSS" type="application/rss+xml" href="/rss.xml" />
<link rel="shortcut icon" type="img/png" href="/favicon.ico" />

<script>
<!--
function show_spoiler(name) {
    document.getElementById(name).style.visibility = "visible";
}
// -->
</script>

</head>

<body>
<table rows=%(rowcount)d cols=2 class="front" cellspacing=0 width="100%%" height="100%%">
<tr><td height="1" width="75%%" class="blogtitle" valign=top><h1>Intermediate Form</h1></td>
<td class="frontright" width="25%%" valign=top rowspan=21>
%(rightnav)s
<div class="recentten">
<h4 align=center>Front Page Posts</h4>
<ul>
%(recent)s
</ul>
</div>

</td>
</tr>

%(page_content)s

</table>
</body>
</html>
s“   <tr>
<td height="1" class="arttitle">
<a name="%(anchor)s" /><h2>%(title)s</h2></td></tr>
<tr>
<td class="artbody" valign="top">
%(content)s
</td>
c          C   s=   t  o- t t d d ƒ }  |  i ƒ  a  |  i ƒ  n t  Sd S(   s*   
    Return the right navigation bar.
    s   /rightnav.htmls   rN(   s	   _rightnavs   files   webdirs   fs   reads   close(   s   f(    (    s!   /home/tom/WWW.blog/code/common.pys   rightnav  s      c          C   sK   t  o; d a  x2 t t ƒ D]  }  t  d |  i |  i f 7a  q Wn t  Sd S(   s@   
    Return links to the posts that are on the front pages.
    s    s*   <li><a href="/index.shtml#%s">%s</a></li>
N(   s   _recents
   blog_postss   front_page_postss   bps   anchors   title(   s   bp(    (    s!   /home/tom/WWW.blog/code/common.pys   recent,  s       "c         C   sª   | t j o |  g } n d } xG t | ƒ D]9 \ } } d | j o d | | d <n | t | 7} q- Wt | ƒ |  d <| |  d <t	 ƒ  |  d <t
 ƒ  |  d <t |  Sd S(	   s€  
    This formats a page using the given substitutions.
    
    @param subs: A dictionary of substitutions into the page
    template. The important field here is 'title', the title of the
    page.
    
    @param rows: A list of dictionaries, where each is interpreted as
    a row. The dictionaries are used as substitutions into the row
    template. Important fields in each row are 'title', the title of
    the row, and 'content', the contents of the row. If left as None,
    this is initialized to a list containing [ subs ]. This will be
    the case if there's a single entry on the page.

    @returns: The formatted page.
    s    s   anchors   a%ds   rowcounts   page_contents   recents   rightnavN(   s   rowss   Nones   subss   page_contents	   enumerates   is   rs   row_templates   lens   recents   rightnavs   page_template(   s   subss   rowss   is   page_contents   r(    (    s!   /home/tom/WWW.blog/code/common.pys   format_page:  s      
s   BlogPostc           B   s    t  Z d  Z d „  Z d „  Z RS(   s  
    This object represents a blog post, including all of the important
    information about the post. It doesn't store the formatted text of
    the post, but does allow it to be accessed.

    @ivar filename: The filename that the blog post is stored
    in. (Just the basename.)
    @ivar title: The title of the blog post.
    @ivar posted: The date on which the post was posted.
    @ivar lastmodified: The date on which the post was last modified.
    @ivar text: The text of the body of the blog post.
    c         C   s¹  | |  _  t d | |  _ t i d | ƒ } t | i d ƒ ƒ |  _	 t
 i i |  i ƒ |  _ |  i |  _ t |  i ƒ } | i ƒ  i ƒ  |  _ | i ƒ  |  _ t |  i ƒ |  _ | i ƒ  t |  i	 ƒ |  _ |  i  i d d ƒ |  _ g  |  _ d t |  i	 f } t
 i i  | ƒ o¥ t
 i! | ƒ } | i# ƒ  x‰ | D]} } t | ƒ } | |  i j o | |  _ n t | d | ƒ } | i ƒ  | i ƒ  |  i i& | | i ƒ  f ƒ | i ƒ  q0Wn d S(   s¨   
        This initializes a BlogPost object from a filename.
        
        @param filename: The basename of the filename the blog post is
        stored in.
        s   /s	   \d+-(\d+)i   s	   .blog.txts   .shtmls   %s/%dN('   s   filenames   selfs   blogdirs   fullpaths   res   matchs   ms   ints   groups   posteds   oss   paths   getmtimes   lastmodifieds   pagemodifieds   files   fs   readlines   strips   titles   reads   texts   txt2htmls   htmls   closes   strs   anchors   replaces	   permalinks   commentss
   commentdirs   cdirs   isdirs   listdirs   cfiless   sorts   fns   ts   append(   s   selfs   filenames   fs   cdirs   ms   cfiless   fns   t(    (    s!   /home/tom/WWW.blog/code/common.pys   __init__m  s<     	
	
 

c         C   s¹   h  d t  i d t  i |  i ƒ ƒ <d t  i d t  i |  i ƒ ƒ <d t  i d t  i |  i ƒ ƒ <d |  i <d |  i <d	 |  i <d
 |  i	 <d |  i
 <d |  i <} | Sd  S(   Ns   datelines   %A, %B %d, %Ys   rssdates   %Y-%02m-%02dT%02H:%02M:%02SZs   lastmodifieds   %Y-%m-%d %H:%Ms   titles   bodys   anchors	   permalinks   filenames   posted(   s   times   strftimes	   localtimes   selfs   posteds   lastmodifieds   titles   htmls   anchors	   permalinks   filenames   rv(   s   selfs   rv(    (    s!   /home/tom/WWW.blog/code/common.pys   subs  s
    !!_	(   s   __name__s
   __module__s   __doc__s   __init__s   subs(    (    (    s!   /home/tom/WWW.blog/code/common.pys   BlogPost_  s    	0c         C   s7   |  t j o t |  Sn t |  ƒ } | t |  <| Sd S(   s_   
    This is the same as the BlogPost constructor, except that it
    caches its argument.
    N(   s   fns   _blog_post_caches   BlogPosts   rv(   s   fns   rv(    (    s!   /home/tom/WWW.blog/code/common.pys	   blog_post±  s     
s	   .blog.txtc         C   s¥   t  i t ƒ } g  i } | D]$ } | i | ƒ o | | ƒ q q ~ } | i	 ƒ  | i
 ƒ  |  o | |   } n g  } x! | D] } | i t | ƒ ƒ q€ W| Sd S(   sÿ   
    This returns a list of BlogPost objects, posts from the blog
    directory. The posts are generated from newest to oldest.
    
    @param count: If given, only generate the count newest entries.
    @param suffix: The suffix of blog post files.
    N(   s   oss   listdirs   blogdirs   entriess   appends   _[1]s   is   endswiths   suffixs   sorts   reverses   counts   rvs	   blog_post(   s   counts   suffixs   rvs   is   _[1]s   entries(    (    s!   /home/tom/WWW.blog/code/common.pys
   blog_posts¾  s     ;

 (   s   oss   os.paths   res   times   blogdirs   webdirs
   commentdirs   front_page_postss   spoilers   txt2htmls   page_templates   row_templates   Nones	   _rightnavs   rightnavs   _recents   recents   format_pages   objects   BlogPosts   _blog_post_caches	   blog_posts
   blog_posts(   s	   blog_posts   rightnavs   front_page_postss
   blog_postss   format_pages   res   blogdirs   txt2htmls   _blog_post_caches
   commentdirs   recents   BlogPosts   row_templates   page_templates   times   webdirs   os(    (    s!   /home/tom/WWW.blog/code/common.pys   ?   s(   					Ð)
		%P	
