prepare things for a blog
authorRalf Jung <post@ralfj.de>
Thu, 8 Oct 2015 15:23:32 +0000 (17:23 +0200)
committerRalf Jung <post@ralfj.de>
Thu, 8 Oct 2015 15:23:32 +0000 (17:23 +0200)
_config.yml
_layouts/default.html
_layouts/post.html
_plugins/menu.rb
blog/archive.html [new file with mode: 0644]
blog/feed.xml [moved from feed.xml with 98% similarity]
blog/index.html
style.scss

index 7d12ba3..37bb42d 100644 (file)
@@ -1,5 +1,7 @@
 # Site settings
 url: "https://www.ralfj.de"
+permalink: "/blog/:year/:month/:day/:title.html"
+timezone: "Europe/Berlin"
 
 blog:
     title: "Ralf's Ramblings"
@@ -22,6 +24,11 @@ defaults:
         path: "" # all files in the project
     values:
         layout: "default"
+  - scope:
+        path: ""
+        type: "posts"
+    values:
+        layout: "post"
 
 # Build settings
 markdown: kramdown
index cff4389..bd9f1f6 100644 (file)
@@ -5,13 +5,13 @@
     <meta charset="utf-8">
     <meta name="viewport" content="width=device-width">
 
-    <title>{{ page.title }}</title>
+    <title>{{ page.title }}{% if page.subtitle %} - {{ page.subtitle }}{% endif %}</title>
     {% if page.excerpt %}<meta name="description" content="{{ page.excerpt | strip_html | strip_newlines | truncate: 160 }}">{% endif %}
 
     <link rel="stylesheet" href="/style.css">
     {% capture canonicalurl %}{{ page.url | replace:'index.html','' }}{% endcapture %}
     <link rel="canonical" href="{{ canonicalurl | prepend: site.url }}">
-    {% if page.rss or page.layout == 'post' %}<link rel="alternate" type="application/rss+xml" title="{{ site.blog.title }}" href="/feed.xml" />{% endif %}
+    {% if page.rss %}<link rel="alternate" type="application/rss+xml" title="{{ site.blog.title }}" href="/blog/feed.xml" />{% endif %}
   </head>
 
 
@@ -22,7 +22,7 @@
     </header>
 
     <nav id="-navi">
-      {% assign menu = site.html_pages | menu: page.url %}
+      {% assign menu = site.pages | menu: page.url %}
       {% include menu-level.html menu=menu %}
     </nav>
 
index a2b4e52..5ed4c68 100644 (file)
@@ -1,15 +1,12 @@
 ---
 layout: default
+title: "Ralf's Ramblings"
+rss: true
 ---
-<div class="post">
+<header class="subtitle">
+  <div class="side"><a href="{{ page.url }}">Permalink</a> • {{ page.date | date: "%b %-d, %Y" }}{% if page.author %} • {{ page.author }}{% endif %}{% if page.meta %} • {{ page.meta }}{% endif %}</div>
+  <h1>{{ page.subtitle }}</h1>
+</header>
 
-  <header class="post-header">
-    <h1 class="post-title">{{ page.title }}</h1>
-    <p class="post-meta">{{ page.date | date: "%b %-d, %Y" }}{% if page.author %} • {{ page.author }}{% endif %}{% if page.meta %} • {{ page.meta }}{% endif %}</p>
-  </header>
+{{ content }}
 
-  <article class="post-content">
-    {{ content }}
-  </article>
-
-</div>
index befe357..37c0851 100644 (file)
@@ -1,41 +1,46 @@
 module Jekyll
-    module MenuFilter
-        def menu(input, displayurl)
-            def create_menu(pages, base, displayurl)
-                result = Array.new
-                for page in pages
-                    cururl = page['url'].sub('/index.html', '')
-                    if cururl.start_with?(base) and cururl.count('/') == base.count('/')
-                        # figure out CSS class
-                        if cururl == displayurl
-                            css_class = 'current'
-                        elsif cururl.start_with?(displayurl)
-                            css_class = 'child'
-                        elsif displayurl.start_with?(cururl)
-                            css_class = 'parent'
-                        else
-                            css_class = 'sibling'
-                        end
-                        # create menu node
-                        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)
-                            if sub_nodes.size > 0
-                                menu_node['sub'] = sub_nodes
-                            end
-                        end
-                        # store menu node
-                        result.push(menu_node)
-                    end
-                end
-                # sort the result before returning it
-                result.sort_by { |a| [a['sort'], a['url']] }
+  module MenuFilter
+    def menu(input, displayurl)
+      def create_menu(pages, base, displayurl)
+        result = Array.new
+        for page in pages
+          cururl = page['url'].sub('/index.html', '')
+          if cururl.start_with?(base) and cururl.count('/') == base.count('/') and (not page['hide'])
+            # figure out CSS class
+            if cururl == displayurl
+              css_class = 'current'
+            elsif cururl.start_with?(displayurl)
+              css_class = 'child'
+            elsif displayurl.start_with?(cururl)
+              css_class = 'parent'
+            else
+              css_class = 'sibling'
             end
-            
-            create_menu(input, "", displayurl.sub('/index.html', ''))
+            # create menu node
+            menu_node = { 'url' => page['url'], 'title' => page['slug'] ? page['slug'] : (page['title'] ? page['title'] : page['url']), 'class' => css_class, 'sort' => page['sort'] ? page['sort'] : 0 }
+            # potentially recurse
+            if (css_class == 'parent' or css_class == 'current')
+              sub_nodes = create_menu(pages, cururl + "/", displayurl)
+              if sub_nodes.size > 0
+                menu_node['sub'] = sub_nodes
+              end
+              if css_class == 'parent' and sub_nodes.all? { |page| page['class'] == 'sibling' }
+                # we won't get closer to this URL, it doesn't exist in our page list
+                menu_node['class'] = 'current'
+                sub_nodes.each { |page| page['class'] = 'child' }
+              end
+            end
+            # store menu node
+            result.push(menu_node)
+          end
         end
+        # sort the result before returning it
+        result.sort_by { |page| [page['sort'], page['url']] }
+      end
+      
+      create_menu(input, "", displayurl.sub('/index.html', ''))
     end
+  end
 end
 
 Liquid::Template.register_filter(Jekyll::MenuFilter)
diff --git a/blog/archive.html b/blog/archive.html
new file mode 100644 (file)
index 0000000..9f0119e
--- /dev/null
@@ -0,0 +1,19 @@
+---
+title: "Ralf's Ramblings: Archive"
+slug: Archive
+rss: true
+sort: 1
+hide: true
+---
+
+<p>Here you can find all my blog posts.</p>
+
+  <ul class="post-list">
+    {% for post in site.posts %}
+      <li>
+        <span class="post-meta">{{ post.date | date: "%b %-d, %Y" }}</span>
+        &raquo;
+        <a class="post-link" href="{{ post.url }}">{{ post.title }}</a>
+      </li>
+    {% endfor %}
+  </ul>
similarity index 98%
rename from feed.xml
rename to blog/feed.xml
index 05bc7f0..4e3b89a 100644 (file)
--- a/feed.xml
@@ -1,5 +1,6 @@
 ---
 layout: null
+slug: Subscribe
 ---
 <?xml version="1.0" encoding="UTF-8"?>
 <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
index e02b8d2..a0d8f1a 100644 (file)
@@ -5,17 +5,14 @@ slug: Blog
 rss: true
 ---
 
-
-  <ul class="post-list">
-    {% for post in site.posts %}
-      <li>
-        <span class="post-meta">{{ post.date | date: "%b %-d, %Y" }}</span>
-
-        <h2>
-          <a class="post-link" href="{{ post.url | prepend: site.baseurl }}">{{ post.title }}</a>
-        </h2>
-      </li>
-    {% endfor %}
-  </ul>
-
-  <p class="rss-subscribe">subscribe <a href="{{ "/feed.xml" | prepend: site.baseurl }}">via RSS</a></p>
+{% assign num_posts = 5 %}
+{% for post in site.posts %}
+    {% assign num_posts = num_posts | minus: 1 %}
+    {% if num_posts >= 0 %}
+        <header class="subtitle">
+            <div class="side"><a href="{{ post.url }}">Permalink</a> • {{ post.date | date: "%b %-d, %Y" }}{% if post.author %} • {{ post.author }}{% endif %}{% if post.meta %} • {{ post.meta }}{% endif %}</div>
+            <h1>{{ post.subtitle }}</h1>
+        </header>
+        {{ post.content }}
+    {% endif %}
+{% endfor %}
index 945f31a..0b50923 100644 (file)
@@ -1,5 +1,5 @@
 ---
-# YAML front matter
+hide: true
 ---
 @charset "utf-8";
 
@@ -42,6 +42,7 @@ $current-color: #ffa700;
 $outer-background-color:  #505050;
 $inner-background-color: #252525;
 $text-color:             #DDD;
+$light-text-color:       #888;
 $link-color: #9ed2ff;
 $link-color-visited: #bfe1ff;
 $link-color-hover: #5089ba;
@@ -145,6 +146,7 @@ body { /* This centers us in the page, and handles the "too wide" case */
         position: static;
         background-color: $inner-background-color;
         padding: 0;
+        height: auto;
     }
     #-navi ul, #-navi ul ul, #-navi li, #-navi li a {
         margin: 0;
@@ -200,6 +202,11 @@ body { /* This centers us in the page, and handles the "too wide" case */
 
 /* Content styling */
 #-content {
+    .subtitle .side {
+        float: right;
+        color: $light-text-color;
+    }
+
     code {
         padding: 0.1em 0.2em;
         background-color: $outer-background-color;