From feed2bf61768ea31a800abb4f8f9e374c2774a11 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Mon, 16 Jun 2014 22:34:48 +0200 Subject: [PATCH] switch from blogofile to jekyll for building the site --- _config.py | 9 - _config.yml | 3 + _filters/markdown_template.py | 16 -- _filters/rst_template.py | 11 -- _filters/syntax_highlight.py | 176 ------------------ _filters/textile_template.py | 11 -- _includes/downloadlogo.html | 3 + _includes/menulink.html | 5 + _includes/screenshot.html | 6 + _templates/i3.mako => _layouts/default.html | 47 ++--- _templates/atom.mako | 34 ---- _templates/chronological.mako | 21 --- _templates/permapage.mako | 7 - _templates/post.mako | 12 -- _templates/rss.mako | 35 ---- contact/{index.html.mako => index.html} | 9 +- docs/3.e/{index.html.mako => index.html} | 9 +- docs/4.6/{index.html.mako => index.html} | 9 +- docs/4.7/{index.html.mako => index.html} | 9 +- docs/{index.html.mako => index.html} | 9 +- ...conky-i3bar.html.mako => conky-i3bar.html} | 13 +- ...lzap-config.html.mako => lzap-config.html} | 9 +- .../{py3status.html.mako => py3status.html} | 9 +- ...ces.html.mako => swapping-workspaces.html} | 9 +- downloads/{index.html.mako => index.html} | 119 +++--------- i3bar/{index.html.mako => index.html} | 8 +- i3lock/{index.html.mako => index.html} | 8 +- i3status/{index.html.mako => index.html} | 8 +- impress.html.mako => impress.html | 8 +- index.html.mako => index.html | 9 +- screenshots/{index.html.mako => index.html} | 102 +++------- 31 files changed, 144 insertions(+), 599 deletions(-) delete mode 100644 _config.py create mode 100644 _config.yml delete mode 100644 _filters/markdown_template.py delete mode 100644 _filters/rst_template.py delete mode 100644 _filters/syntax_highlight.py delete mode 100644 _filters/textile_template.py create mode 100644 _includes/downloadlogo.html create mode 100644 _includes/menulink.html create mode 100644 _includes/screenshot.html rename _templates/i3.mako => _layouts/default.html (77%) delete mode 100644 _templates/atom.mako delete mode 100644 _templates/chronological.mako delete mode 100644 _templates/permapage.mako delete mode 100644 _templates/post.mako delete mode 100644 _templates/rss.mako rename contact/{index.html.mako => index.html} (95%) rename docs/3.e/{index.html.mako => index.html} (96%) rename docs/4.6/{index.html.mako => index.html} (98%) rename docs/4.7/{index.html.mako => index.html} (98%) rename docs/{index.html.mako => index.html} (98%) rename docs/user-contributed/{conky-i3bar.html.mako => conky-i3bar.html} (97%) rename docs/user-contributed/{lzap-config.html.mako => lzap-config.html} (99%) rename docs/user-contributed/{py3status.html.mako => py3status.html} (97%) rename docs/user-contributed/{swapping-workspaces.html.mako => swapping-workspaces.html} (96%) rename downloads/{index.html.mako => index.html} (84%) rename i3bar/{index.html.mako => index.html} (86%) rename i3lock/{index.html.mako => index.html} (97%) rename i3status/{index.html.mako => index.html} (97%) rename impress.html.mako => impress.html (98%) rename index.html.mako => index.html (98%) rename screenshots/{index.html.mako => index.html} (64%) diff --git a/_config.py b/_config.py deleted file mode 100644 index ab60b4c..0000000 --- a/_config.py +++ /dev/null @@ -1,9 +0,0 @@ -blog = controllers.blog -blog.enabled = True -site.url = "http://i3wm.org/" -blog.path = "/blog" -blog.name = "i3 - improved tiling wm - blog" -blog.description = "News about the i3 window manager" -blog.timezone = "Europe/Berlin" -blog.posts_per_page = 5 -blog.disqus.enabled = False diff --git a/_config.yml b/_config.yml new file mode 100644 index 0000000..acba381 --- /dev/null +++ b/_config.yml @@ -0,0 +1,3 @@ +name: i3 +markdown: redcarpet +pygments: true diff --git a/_filters/markdown_template.py b/_filters/markdown_template.py deleted file mode 100644 index c572efa..0000000 --- a/_filters/markdown_template.py +++ /dev/null @@ -1,16 +0,0 @@ -import markdown -import logging - -config = { - 'name': "Markdown", - 'description': "Renders markdown formatted text to HTML", - 'aliases': ['markdown'] - } - - -#Markdown logging is noisy, pot it down: -logging.getLogger("MARKDOWN").setLevel(logging.ERROR) - - -def run(content): - return markdown.markdown(content) diff --git a/_filters/rst_template.py b/_filters/rst_template.py deleted file mode 100644 index 496c36c..0000000 --- a/_filters/rst_template.py +++ /dev/null @@ -1,11 +0,0 @@ -import docutils.core - -config = { - 'name': "reStructuredText", - 'description': "Renders reStructuredText formatted text to HTML", - 'aliases': ['rst'] - } - - -def run(content): - return docutils.core.publish_parts(content, writer_name='html')['html_body'] diff --git a/_filters/syntax_highlight.py b/_filters/syntax_highlight.py deleted file mode 100644 index 2471c43..0000000 --- a/_filters/syntax_highlight.py +++ /dev/null @@ -1,176 +0,0 @@ -import re -import os - -import pygments -from pygments import formatters, util, lexers -import blogofile_bf as bf - -config = {"name": "Syntax Highlighter", - "description": "Highlights blocks of code based on syntax", - "author": "Ryan McGuire", - "css_dir": "/css", - "preload_styles": []} - - -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 bf.config.filters.syntax_highlight.preload_styles: - css_class = "pygments_{0}".format(style) - formatter = pygments.formatters.HtmlFormatter( - linenos=False, cssclass=css_class, style=style) - write_pygments_css(style, formatter) - - -example = """ - -This is normal text. - -The following is a python code block: - -$$code(lang=python) -import this - -prices = {'apple' : 0.50, #Prices of fruit - 'orange' : 0.65, - 'pear' : 0.90} - -def print_prices(): - for fruit, price in prices.items(): - print "An %s costs %s" % (fruit, price) -$$/code - -This is a ruby code block: - -$$code(lang=ruby) -class Person - attr_reader :name, :age - def initialize(name, age) - @name, @age = name, age - end - def <=>(person) # Comparison operator for sorting - @age <=> person.age - end - def to_s - "#@name (#@age)" - end -end - -group = [ - Person.new("Bob", 33), - Person.new("Chris", 16), - Person.new("Ash", 23) -] - -puts group.sort.reverse -$$/code - -This is normal text -""" - -css_files_written = set() - -code_block_re = re.compile( - r"(?:^|\s)" # $$code Must start as a new word - r"\$\$code" # $$code is the start of the block - r"(?P\([^\r\n]*\))?" # optional arguments are passed in brackets - r"[^\r\n]*\r?\n" # ignore everything else on the 1st line - r"(?P.*?)\s\$\$/code" # code block continues until $$/code - , re.DOTALL) - -argument_re = re.compile( - r"[ ]*" # eat spaces at the beginning - "(?P" # start of argument - ".*?" # the name of the argument - "=" # the assignment - r"""(?:(?:[^"']*?)""" # a non-quoted value - r"""|(?:"[^"]*")""" # or, a double-quoted value - r"""|(?:'[^']*')))""" # or, a single-quoted value - "[ ]*" # eat spaces at the end - "[,\r\n]" # ends in a comma or newline - ) - - -def highlight_code(code, language, formatter): - try: - lexer = pygments.lexers.get_lexer_by_name(language) - except pygments.util.ClassNotFound: - lexer = pygments.lexers.get_lexer_by_name("text") - #Highlight with pygments and surround by blank lines - #(blank lines required for markdown syntax) - highlighted = "\n\n{0}\n\n".format( - pygments.highlight(code, lexer, formatter)) - return highlighted - - -def parse_args(args): - #Make sure the args are newline terminated (req'd by regex) - opts = {} - if args is None: - return opts - args = args.lstrip("(").rstrip(")") - if args[-1] != "\n": - args = args+"\n" - for m in argument_re.finditer(args): - arg = m.group('arg').split('=') - opts[arg[0]] = arg[1] - return opts - - -def write_pygments_css(style, formatter, - location=bf.config.filters.syntax_highlight.css_dir): - path = bf.util.path_join("_site", bf.util.fs_site_path_helper(location)) - bf.util.mkdir(path) - css_file = "pygments_{0}.css".format(style) - css_path = os.path.join(path, css_file) - css_site_path = css_path.replace("_site", "") - if css_site_path in css_files_written: - return #already written, no need to overwrite it. - f = open(css_path, "w") - css_class = ".pygments_{0}".format(style) - f.write(formatter.get_style_defs(css_class)) - f.close() - css_files_written.add(css_site_path) - - -def run(src): - substitutions = {} - for m in code_block_re.finditer(src): - args = parse_args(m.group('args')) - #Make default args - if args.has_key('lang'): - lang = args['lang'] - elif args.has_key('language'): - lang = args['language'] - else: - lang = 'text' - try: - if args.has_key('linenums'): - linenums = args['linenums'] - elif args.has_key("linenos"): - linenums = args['linenos'] - if linenums.lower().strip() == "true": - linenums = True - else: - linenums = False - except: - linenums = False - try: - style = args['style'] - except KeyError: - style = bf.config.filters.syntax_highlight.style - try: - css_class = args['cssclass'] - except KeyError: - css_class = "pygments_{0}".format(style) - formatter = pygments.formatters.HtmlFormatter( - linenos=linenums, cssclass=css_class, style=style) - write_pygments_css(style, formatter) - substitutions[m.group()] = highlight_code( - m.group('code'), lang, formatter) - if len(substitutions) > 0: - p = re.compile('|'.join(map(re.escape, substitutions))) - src = p.sub(lambda x: substitutions[x.group(0)], src) - return src - else: - return src diff --git a/_filters/textile_template.py b/_filters/textile_template.py deleted file mode 100644 index 7863fa2..0000000 --- a/_filters/textile_template.py +++ /dev/null @@ -1,11 +0,0 @@ -import textile - -config = { - 'name': "Textile", - 'description': "Renders textile formatted text to HTML", - 'aliases': ['textile'] - } - - -def run(content): - return textile.textile(content) diff --git a/_includes/downloadlogo.html b/_includes/downloadlogo.html new file mode 100644 index 0000000..fc7d48d --- /dev/null +++ b/_includes/downloadlogo.html @@ -0,0 +1,3 @@ +
+{{include.title}} +
diff --git a/_includes/menulink.html b/_includes/menulink.html new file mode 100644 index 0000000..c5a5ab7 --- /dev/null +++ b/_includes/menulink.html @@ -0,0 +1,5 @@ +{% if page.group == include.name %} +
  • {{include.name}}
  • +{% else %} +
  • {{include.name}}
  • +{% endif %} diff --git a/_includes/screenshot.html b/_includes/screenshot.html new file mode 100644 index 0000000..3fdcffb --- /dev/null +++ b/_includes/screenshot.html @@ -0,0 +1,6 @@ + +
    + (Screenshot) {{include.description}}
    + {{include.description}} +
    + diff --git a/_templates/i3.mako b/_layouts/default.html similarity index 77% rename from _templates/i3.mako rename to _layouts/default.html index a61c234..68db1dc 100644 --- a/_templates/i3.mako +++ b/_layouts/default.html @@ -1,8 +1,4 @@ -<%! - require_jquery = False - javascript = None - js_callback = '' -%> + @@ -13,14 +9,14 @@ -% if self.attr.javascript: +{% if page.javascript != null %} -%endif +{% endif %}

    i3 - improved tiling WM


    - ${next.body()} + {{ content }}