Exemple #1
0
# -*- coding: utf-8 -*-
import textile

from blogofile.cache import HierarchicalCache as HC

meta = {
    'name': "Textile",
    'description': "Renders textile formatted text to HTML",
}

config = HC(aliases=['textile'])


def run(content):
    return textile.textile(content)
import docutils.core

from blogofile.cache import HierarchicalCache as HC

meta = {
    'name': "reStructuredText",
    'description': "Renders reStructuredText formatted text to HTML",
}

config = HC(aliases=['rst'])


def run(content):
    return docutils.core.publish_parts(content,
                                       writer_name='html')['html_body']
config = HC(
    # name -- Your Blog's name.
    # This is used repeatedly in default blog templates
    name="Your Blog's name",
    ## blog_description -- A short one line description of the blog
    # used in the RSS/Atom feeds.
    description="Your Blog's short description",
    ## blog_path -- Blog path.
    #  This is the path of the blog relative to the site_url.
    #  If your site_url is "http://www.yoursite.com/~ryan"
    #  and you set blog_path to "/blog" your full blog URL would be
    #  "http://www.yoursite.com/~ryan/blog"
    #  Leave blank "" to set to the root of site_url
    path="/blog",
    ## blog_timezone -- the timezone that you normally write your blog
    ## posts from
    timezone="US/Eastern",
    ## blog_posts_per_page -- Blog posts per page
    posts_per_page=5,
    # Automatic Permalink
    # (If permalink is not defined in post article, it's generated
    #  automatically based on the following format:)
    # Available string replacements:
    # :year, :month, :day -> post's date
    # :title              -> post's title
    # :uuid               -> sha hash based on title
    # :filename           -> article's filename without suffix
    # path is relative to site_url
    auto_permalink=HC(enabled=True,
                      path=":blog_path/:year/:month/:day/:title"),
    # Automatic Post filenames
    # Post can be created automatically with:
    #   blogofile blog post create "Post Title"
    # auto_post_filename defines the filename format for posts
    # created this way.
    auto_post_filename=":year-:month-:day - :title.markdown",
    #### Disqus.com comment integration ####
    disqus=HC(enabled=False,
              name="your_disqus_name"),
    #### Custom blog index ####
    # If you want to create your own index page at your blog root
    # turn this on. Otherwise blogofile assumes you want the
    # first X posts displayed instead
    custom_index=False,
    #### Post excerpts ####
    # If you want to generate excerpts of your posts in addition to the
    # full post content turn this feature on
    # Also, if you don't like the way the post excerpt is generated
    # You can define assign a new function to blog.post_excerpts.method
    # This method must accept the following arguments: (content, num_words)
    post_excerpts=HC(enabled=False,
                     word_length=25,
                     method=None),
    #### Blog pagination directory ####
    # blogofile places extra pages of your blog in a secondary directory
    # like:
    #   http://www.yourblog.com/blog_root/page/4
    # You can rename the "page" part here:
    pagination_dir="page",
    #### Blog category directory ####
    # blogofile places extra pages of your or categories in
    # a secondary directory like the following:
    # http://www.yourblog.com/blog_root/category/your-topic/4
    # You can rename the "category" part here:
    category_dir="category",
    priority=90.0,
    base_template="site.mako",
    #Alternative template engine content blocks:
    template_engines=HC(
        jinja2=HC(
            content_regex=re.compile(
                "{%\W*block content\W*%}.*?{%\W*endblock\W*%}",
                re.MULTILINE | re.DOTALL)
            )
        ),
    #Where to find the templates? Can be relocated to user-space.
    template_path=None,
    #Posts
    post=HC(
        source_dir="_posts",
        date_format="%Y/%m/%d %H:%M:%S",
        encoding="utf-8",
        #What files in _posts directory should we consider posts?
        file_regex=(
            ".*((\.textile$)|(\.markdown$)|(\.md$)|"
            "(\.org$)|(\.html$)|(\.txt$)|(\.rst$))"),
        #### Default post filters ####
        # If a post does not specify a filter chain, use the
        # following defaults based on the post file extension:
        default_filters={
           "markdown": "syntax_highlight, markdown",
           "md": "syntax_highlight, markdown",
           "textile": "syntax_highlight, textile",
           "org": "syntax_highlight, org",
           "rst": "syntax_highlight, rst",
           "html": "syntax_highlight"
           },
        #An optional callback to run after all the posts are parsed
        #but before anything else is done with them.
        post_process=None,
        #Default Slugification function uses post titles.  User may
        #redefine their own function here, single argument is the Post
        #object:
        slugify=None,
        categories=HC(
            case_sensitive=False
            )
        )
    )
  Person.new("Ash", 23) 
]
 
puts group.sort.reverse
$$/code

This is normal text
"""

meta = {
    "name": "Syntax Highlighter",
    "description": "Highlights blocks of code based on syntax",
    "author": "Ryan McGuire"
}

config = HC(css_dir="/css", preload_styles=[], style="murphy")


def init():
    #This filter normally only loads pygments styles when needed.
    #This will force a particular style to get loaded at startup.
    for style in config.preload_styles:
        css_class = "pygments_{0}".format(style)
        formatter = pygments.formatters.HtmlFormatter(linenos=False,
                                                      cssclass=css_class,
                                                      style=style)
        write_pygments_css(style, formatter)


css_files_written = set()
filters.markdown.extensions.fenced_code.enabled = True
filters.markdown.extensions.headerid.enabled    = True
filters.markdown.extensions.tables.enabled      = True
"""

meta = {
    "name": "Markdown",
    "author": "Ryan McGuire",
    "description": "Renders markdown formatted text to HTML"
    }

config = HC(
    aliases = ["markdown"],
    extensions = HC(def_list    = HC(enabled=False),
                    abbr        = HC(enabled=False),
                    footnotes   = HC(enabled=False),
                    fenced_code = HC(enabled=False),
                    headerid    = HC(enabled=False),
                    tables      = HC(enabled=False)),
    extension_parameters = HC(headerid = HC(level=1,forceid=True))
    )

#Markdown logging is noisy, pot it down:
logging.getLogger("MARKDOWN").setLevel(logging.ERROR)

extensions = []

def init():
    #Create the list of enabled extensions with their arguments
    for name, ext in list(config["extensions"].items()):
        if ext.enabled:
            params = []
Exemple #6
0
 #  Leave blank "" to set to the root of site_url
 "path": "/blog",
 ## blog_timezone -- the timezone that you normally write your blog posts from
 "timezone": "US/Eastern",
 ## blog_posts_per_page -- Blog posts per page
 "posts_per_page": 5,
 # Automatic Permalink
 # (If permalink is not defined in post article, it's generated
 #  automatically based on the following format:)
 # Available string replacements:
 # :year, :month, :day -> post's date
 # :title              -> post's title
 # :uuid               -> sha hash based on title
 # :filename           -> article's filename without suffix
 # path is relative to site_url
 "auto_permalink": HC(enabled=True,
                      path=":blog_path/:year/:month/:day/:title"),
 #### Disqus.com comment integration ####
 "disqus": HC(enabled=False, name="your_disqus_name"),
 #### Custom blog index ####
 # If you want to create your own index page at your blog root
 # turn this on. Otherwise blogofile assumes you want the
 # first X posts displayed instead
 "custom_index": False,
 #### Post excerpts ####
 # If you want to generate excerpts of your posts in addition to the
 # full post content turn this feature on
 #Also, if you don't like the way the post excerpt is generated
 #You can define assign a new function to blog.post_excerpts.method
 #This method must accept the following arguments: (content, num_words)
 "post_excerpts": HC(enabled=True, word_length=25),
 #### Blog pagination directory ####
Exemple #7
0
filters.markdown.extensions.footnotes.enabled   = True
filters.markdown.extensions.fenced_code.enabled = True
filters.markdown.extensions.headerid.enabled    = True
filters.markdown.extensions.tables.enabled      = True
"""

config = {
    "name":
    "Markdown",
    "description":
    "Renders markdown formatted text to HTML",
    "aliases": ["markdown"],
    "extensions":
    HC(def_list=HC(enabled=False),
       abbr=HC(enabled=False),
       footnotes=HC(enabled=False),
       fenced_code=HC(enabled=False),
       headerid=HC(enabled=False),
       tables=HC(enabled=False)),
    "extension_parameters":
    HC(headerid=HC(level=1, forceid=True))
}

#Markdown logging is noisy, pot it down:
logging.getLogger("MARKDOWN").setLevel(logging.ERROR)

extensions = []


def init():
    #Create the list of enabled extensions with their arguments
    for name, ext in config["extensions"].items():