John Guidry avatar John Guidry committed db8a792

Add support for publish flag.
Remove ugly monkeypatch of nanoc Item.
Add better page title support.

Comments (0)

Files changed (6)

 ---
 kind: article
 created_at: #{Time.now.strftime('%e %b %Y %H:%m')}
-title: "#{title}"
+publish: false
+title: "#{title.titleize}"
 ---
 
 TEMPLATE
 require 'compass'
 Compass.add_project_configuration 'compass/config.rb' # when using Compass 0.10
 
+preprocess do
+  # authors may unpublish items by setting meta attribute publish: false
+  items.delete_if { |item| item[:publish] == false }
+end
+
 compile '/assets/css/*/' do
    filter :sass, Compass.sass_engine_options
 end

content/assets/css/stylesheet.scss

 $base-font-size: 14px;
 $base-line-height: 20px;
 
-$bg-color: #343838;
+$primary-bg-color: #fcfcf3;
+$secondary-bg-color: #343838;
 
 body {
   @include establish-baseline;
   font-family: 'Crimson Text', arial, serif;
   
-  background-color: #fcfcf3;
+  background-color: $primary-bg-color;
 }
 li {
   list-style-type: disc;
 }
 
 #header {
-  background-color: $bg-color;
+  background-color: $secondary-bg-color;
 }
 #logo { 
   padding: 1em 2em;
 .syntax {
   @include rhythm(0.5,0,0,0.5);
   @include rhythm-borders(1px, 0.5, 13px, dotted);
-  background: $bg-color;
-  color: #f8f8f2;
-  border-color: #f8f8f2;
+  background: $secondary-bg-color;
+  color: $primary-bg-color;
+  border-color: $primary-bg-color;
 }
 .syntax code {
   @include adjust-font-size-to(13px);
 
 
 #base {
-  background-color: $bg-color;
+  background-color: $secondary-bg-color;
 }

content/index.haml

 ---
 
 - @site.sorted_articles[0, 5].each do |post|
-  = post.content :rep => :summary
+  = post.compiled_content :rep => :summary, :snapshot => :last
 

layouts/default.haml

 %html{html_attrs()}
   %head
     %meta{:charset =>'utf-8'} 
-    %meta{:name => 'generator', :content => 'nanoc 3.1.7'}
-    %title a novel spin 
+    %title= "#{@item[:title]}"
     %link{:rel =>'stylesheet', 
           :type =>'text/css', 
           :href => '/assets/css/monokai.css',
 include Nanoc3::Helpers::Text
 
 #
-# Nabbed at http://starrhorne.com/posts/howto_build_a_blog_with_nanoc/
-#
-class Nanoc3::Item
-  def content(opts = {})                                                       
-    opts[:rep] ||= :default                                                    
-    opts[:snapshot] ||= :last                                                  
-    reps.find { |r| r.name == opts[:rep] }.content_at_snapshot(opts[:snapshot])
-  end
-
-  def name
-    identifier.split("/").last 
-  end
-end
-
-#
 # Next two nicked from https://github.com/unthinkingly/unthinkingly-blog
 #
 def filter_markup_by_ext(item)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.