Ejemplo n.º 1
0
 def _make_rss_item(self, post):
     desc = self._process_desc(post)
     link = fileutils.add_slash_if_missing(self.blog_url) + post["permalink"]
     return rssgen.RSSItem(
             title=post["title"],
             pubDate=post["date"],
             description=desc,
             guid=link,
             link=link)
Ejemplo n.º 2
0
 def process(self):
     """Given a directory of posts, return a dict representing those posts
        and a dict representing the blog's config.
        Return: (post_list, config_dict)
     """
     self.posts_dir = fileutils.add_slash_if_missing(self.posts_dir)
     post_list = []
     for post_filename in os.listdir(self.posts_dir):
         # Process config file
         if post_filename == "_config":
             config_dict = self._get_config_info(self.posts_dir+post_filename)
             continue
         # Process LaMark files
         if not post_filename.endswith(".lm"):
             continue
         post_info = self._get_post_info(self.posts_dir + post_filename)
         post_list.append(post_info)
     post_list.sort(key=lambda post_info: post_info['date'], reverse=True)
     post_list.append({
         'type': 'toc',
         'permalink': 'index.html',
         'regen': True,
         })
     return (post_list, config_dict)
Ejemplo n.º 3
0
 def _make_file_name(self, output_dir, post):
     output_dir = fileutils.add_slash_if_missing(output_dir)
     post_file_name = re.sub(r"[\s]", "-", post["permalink"])
     return output_dir + post_file_name
Ejemplo n.º 4
0
import datetime

import procfiles
import readtemplatestage
import lamarkstage
import markdownstage
import navbargen
import htmlpagegen
import tocgen
import rssgenstage
import writerstage

import fileutils

args_dict = {
    "posts_dir": fileutils.add_slash_if_missing(sys.argv[1]),
    "output_dir": fileutils.add_slash_if_missing(sys.argv[2]),
    }

stages = [
            readtemplatestage.ReadTemplateStage,
            lamarkstage.LamarkStage,
            markdownstage.MarkdownStage,
            navbargen.NavbarGen,
            tocgen.TOCGen,
            htmlpagegen.HTMLPageGen,
            rssgenstage.RSSGenStage,
            writerstage.WriterStage
        ]

proc_posts = procfiles.ProcFiles(args_dict)