title: "Ralf's Ramblings"
description: "Ralf rambling on things"
+readmes:
+ src_base: "/home/r/src"
+ out_base: "projects"
+ projects:
+ - name: "lilass"
+ - name: "dyn-nsupdate"
+ - name: "schsh"
+
defaults:
- scope:
- path: "" # all files in the project
+ path: "" # all files in the project
values:
- layout: "default"
+ layout: "default"
# Build settings
markdown: kramdown
<ul><!--{% for item in include.menu %}
- --><li class="{{ item.class }}"><a href="{{ item.url }}">{{ item.url }}: {{ item.title }}</a></li><!--
+ --><li class="{{ item.class }}"><a href="{{ item.url }}">{{ item.title }}</a></li><!--
{% if item.sub %}
-->{% include menu-level.html menu=item.sub %}<!--
{% endif %}
css_class = 'sibling'
end
# create menu node
- menu_node = { 'url' => page['url'], 'title' => page['title'], 'class' => css_class }
+ menu_node = { 'url' => page['url'], 'title' => page['slug'] ? page['slug'] : (page['title'] ? page['title'] : page['url']), 'class' => css_class, 'sort' => page['sort'] }
# potentially recurse
if (css_class == 'parent' or css_class == 'current')
sub_nodes = create_menu(pages, cururl + "/", displayurl)
result.push(menu_node)
end
end
- result
+ # sort the result before returning it
+ result.sort_by { |a| a['url'] }
end
create_menu(input, "", displayurl.sub('/index.html', ''))
--- /dev/null
+module Jekyll
+
+ class ReadmePage < Page
+ def initialize(site, base, dir, src)
+ @site = site
+ @base = base
+ @dir = dir
+ @name = 'index.md'
+
+ self.process(@name)
+ self.data ||= {}
+
+ content = File.read(src, self.merged_file_read_opts({})).each_line.to_a
+
+ self.data['layout'] = 'default'
+ self.data['title'] = content[0].match(/^# (.*)\n$/)[1]
+ self.data['slug'] = self.data['title'].match(/^(.*):.*$/)[1]
+ self.content = content[1..content.size].join
+ end
+ end
+
+ class CategoryPageGenerator < Generator
+ safe true
+
+ def generate(site)
+ readmes = site.config['readmes']
+ base = readmes['src_base']
+ dir = readmes['out_base']
+ for project in readmes['projects']
+ site.pages << ReadmePage.new(site, site.source, File.join(dir, project['name']), File.join(base, project['name'], 'README.md'))
+ end
+ end
+ end
+
+end
+++ /dev/null
-#!/bin/bash
-
-PROJECTS_BASE="$HOME/src"
-TMPFILE=$(mktemp)
-
-while getopts "ds" opt; do
- case $opt in
- d)
- DEVEL=1
- ;;
- s)
- SYNC=1
- ;;
- esac
-done
-
-# update READMEs
-for PROJECT in lilass schsh; do
- # get the file
- if [ -n "$DEVEL" ]; then
- INFILE="$PROJECTS_BASE/$PROJECT/README.md"
- else
- cd "$PROJECTS_BASE/$PROJECT"
- git show master:README.rst > "$TMPFILE"
- INFILE="$TMPFILE"
- cd - > /dev/null
- fi
- OUTFILE="projects/$PROJECT/index.md"
- # process it
- echo "---" > "$OUTFILE"
- head -n 1 "$INFILE" | sed 's/^# \(.*\)$/title: "\1"/' >> "$OUTFILE"
- echo "---" >> "$OUTFILE"
- echo >> "$OUTFILE"
- tail -n +3 "$INFILE" >> "$OUTFILE"
-done
-
-# call jekyll
-jekyll build
-
-if [ -n "$SYNC" ]; then
- echo "TODO: sync to server"
-fi