diff options
author | Lars Henrik Mai <lars.mai@kontinui.de> | 2014-04-08 13:58:00 +0200 |
---|---|---|
committer | Lars Henrik Mai <lars.mai@kontinui.de> | 2014-04-08 13:58:00 +0200 |
commit | b0da6603c012280a33202836bb1e9a2456fbd054 (patch) | |
tree | 960d807a49c79f210b7307e87ce43ddf8524038d | |
parent | 3b2ecefb6b3f763762f191452e40c59fb7f58ec5 (diff) |
initialized blog extensions
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | Gemfile | 6 | ||||
-rw-r--r-- | Gemfile.lock | 6 | ||||
-rw-r--r-- | config.rb | 45 | ||||
-rw-r--r-- | source/2012-01-01-example-article.html.markdown | 7 | ||||
-rw-r--r-- | source/calendar.html.erb | 33 | ||||
-rw-r--r-- | source/feed.xml.builder | 24 | ||||
-rw-r--r-- | source/index.html.erb | 24 | ||||
-rw-r--r-- | source/layout.erb | 38 | ||||
-rw-r--r-- | source/tag.html.erb | 25 |
10 files changed, 200 insertions, 11 deletions
@@ -10,8 +10,9 @@ # Ignore the build directory /build -# Ignore Sass' cache +# Ignore cache /.sass-cache +/.cache # Ignore .DS_store file .DS_Store @@ -2,11 +2,13 @@ # the following line to use "https" source 'https://rubygems.org' -gem "middleman" -gem "middleman-blog" +gem "middleman", "~> 3.3.2" +gem "middleman-blog", "~> 3.5.2" # Live-reloading plugin gem "middleman-livereload" # For faster file watcher updates on Windows: gem "wdm", "~> 0.1.0", :platforms => [:mswin, :mingw] +# For feed.xml.builder +gem "builder", "~> 3.0" diff --git a/Gemfile.lock b/Gemfile.lock index 0d99d52..c268208 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,6 +8,7 @@ GEM thread_safe (~> 0.1) tzinfo (~> 0.3.37) addressable (2.3.6) + builder (3.2.2) chunky_png (1.3.0) coffee-script (2.2.0) coffee-script-source @@ -118,7 +119,8 @@ PLATFORMS ruby DEPENDENCIES - middleman - middleman-blog + builder (~> 3.0) + middleman (~> 3.3.2) + middleman-blog (~> 3.5.2) middleman-livereload wdm (~> 0.1.0) @@ -1,4 +1,37 @@ ### +# Blog settings +### + +# Time.zone = "UTC" + +activate :blog do |blog| + # This will add a prefix to all links, template references and source paths + # blog.prefix = "blog" + + # blog.permalink = "{year}/{month}/{day}/{title}.html" + # Matcher for blog source files + # blog.sources = "{year}-{month}-{day}-{title}.html" + # blog.taglink = "tags/{tag}.html" + # blog.layout = "layout" + # blog.summary_separator = /(READMORE)/ + # blog.summary_length = 250 + # blog.year_link = "{year}.html" + # blog.month_link = "{year}/{month}.html" + # blog.day_link = "{year}/{month}/{day}.html" + # blog.default_extension = ".markdown" + + blog.tag_template = "tag.html" + blog.calendar_template = "calendar.html" + + # Enable pagination + # blog.paginate = true + # blog.per_page = 10 + # blog.page_link = "page/{num}" +end + +page "/feed.xml", layout: false + +### # Compass ### @@ -14,19 +47,19 @@ # Per-page layout changes: # # With no layout -# page "/path/to/file.html", :layout => false +# page "/path/to/file.html", layout: false # # With alternative layout -# page "/path/to/file.html", :layout => :otherlayout +# page "/path/to/file.html", layout: :otherlayout # # A path which all have the same layout # with_layout :admin do # page "/admin/*" # end -# Proxy pages (http://middlemanapp.com/basics/dynamic-pages/) -# proxy "/this-page-has-no-template.html", "/template-file.html", :locals => { -# :which_fake_page => "Rendering a fake page with a local variable" } +# Proxy pages (http://middlemanapp.com/dynamic-pages/) +# proxy "/this-page-has-no-template.html", "/template-file.html", locals: { +# which_fake_page: "Rendering a fake page with a local variable" } ### # Helpers @@ -36,7 +69,7 @@ # activate :automatic_image_sizes # Reload the browser automatically whenever files change -activate :livereload +# activate :livereload # Methods defined in the helpers block are available in templates # helpers do diff --git a/source/2012-01-01-example-article.html.markdown b/source/2012-01-01-example-article.html.markdown new file mode 100644 index 0000000..618d7f3 --- /dev/null +++ b/source/2012-01-01-example-article.html.markdown @@ -0,0 +1,7 @@ +--- +title: Example Article +date: 2012-01-01 +tags: example +--- + +This is an example article. You probably want to delete it and write your own articles! diff --git a/source/calendar.html.erb b/source/calendar.html.erb new file mode 100644 index 0000000..4cdfdf9 --- /dev/null +++ b/source/calendar.html.erb @@ -0,0 +1,33 @@ +--- +pageable: true +--- +<h1>Archive for + <% case page_type + when 'day' %> + <%= Date.new(year, month, day).strftime('%b %e %Y') %> + <% when 'month' %> + <%= Date.new(year, month, 1).strftime('%b %Y') %> + <% when 'year' %> + <%= year %> + <% end %> +</h1> + +<% if paginate && num_pages > 1 %> + <p>Page <%= page_number %> of <%= num_pages %></p> + + <% if prev_page %> + <p><%= link_to 'Previous page', prev_page %></p> + <% end %> +<% end %> + +<ul> + <% page_articles.each_with_index do |article, i| %> + <li><%= link_to article.title, article %> <span><%= article.date.strftime('%b %e') %></span></li> + <% end %> +</ul> + +<% if paginate %> + <% if next_page %> + <p><%= link_to 'Next page', next_page %></p> + <% end %> +<% end %> diff --git a/source/feed.xml.builder b/source/feed.xml.builder new file mode 100644 index 0000000..6fa9c08 --- /dev/null +++ b/source/feed.xml.builder @@ -0,0 +1,24 @@ +xml.instruct! +xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do + site_url = "http://blog.url.com/" + xml.title "Blog Name" + xml.subtitle "Blog subtitle" + xml.id URI.join(site_url, blog.options.prefix.to_s) + xml.link "href" => URI.join(site_url, blog.options.prefix.to_s) + xml.link "href" => URI.join(site_url, current_page.path), "rel" => "self" + xml.updated(blog.articles.first.date.to_time.iso8601) unless blog.articles.empty? + xml.author { xml.name "Blog Author" } + + blog.articles[0..5].each do |article| + xml.entry do + xml.title article.title + xml.link "rel" => "alternate", "href" => URI.join(site_url, article.url) + xml.id URI.join(site_url, article.url) + xml.published article.date.to_time.iso8601 + xml.updated File.mtime(article.source_file).iso8601 + xml.author { xml.name "Article Author" } + # xml.summary article.summary, "type" => "html" + xml.content article.body, "type" => "html" + end + end +end diff --git a/source/index.html.erb b/source/index.html.erb new file mode 100644 index 0000000..0fae27e --- /dev/null +++ b/source/index.html.erb @@ -0,0 +1,24 @@ +--- +pageable: true +per_page: 10 +--- +<% if paginate && num_pages > 1 %> + <p>Page <%= page_number %> of <%= num_pages %></p> + + <% if prev_page %> + <p><%= link_to 'Previous page', prev_page %></p> + <% end %> +<% end %> + +<% page_articles.each_with_index do |article, i| %> + <h2><%= link_to article.title, article %> <span><%= article.date.strftime('%b %e') %></span></h2> + <!-- use article.summary(250) if you have Nokogiri available to show just + the first 250 characters --> + <%= article.body %> +<% end %> + +<% if paginate %> + <% if next_page %> + <p><%= link_to 'Next page', next_page %></p> + <% end %> +<% end %> diff --git a/source/layout.erb b/source/layout.erb new file mode 100644 index 0000000..36c3da9 --- /dev/null +++ b/source/layout.erb @@ -0,0 +1,38 @@ +<!doctype html> +<html> + <head> + <meta charset="utf-8" /> + <meta http-equiv='X-UA-Compatible' content='IE=edge;chrome=1' /> + <title>Blog Title<%= ' - ' + current_article.title unless current_article.nil? %></title> + <%= feed_tag :atom, "#{blog.options.prefix.to_s}/feed.xml", title: "Atom Feed" %> + </head> + <body> + + <div id="main" role="main"> + <%= yield %> + </div> + + <aside> + <h2>Recent Articles</h2> + <ol> + <% blog.articles[0...10].each do |article| %> + <li><%= link_to article.title, article %> <span><%= article.date.strftime('%b %e') %></span></li> + <% end %> + </ol> + + <h2>Tags</h2> + <ol> + <% blog.tags.each do |tag, articles| %> + <li><%= link_to "#{tag} (#{articles.size})", tag_path(tag) %></li> + <% end %> + </ol> + + <h2>By Year</h2> + <ol> + <% blog.articles.group_by {|a| a.date.year }.each do |year, articles| %> + <li><%= link_to "#{year} (#{articles.size})", blog_year_path(year) %></li> + <% end %> + </ol> + </aside> + </body> +</html> diff --git a/source/tag.html.erb b/source/tag.html.erb new file mode 100644 index 0000000..c28a20b --- /dev/null +++ b/source/tag.html.erb @@ -0,0 +1,25 @@ +--- +pageable: true +per_page: 12 +--- +<h1>Articles tagged '<%= tagname %>'</h1> + +<% if paginate && num_pages > 1 %> + <p>Page <%= page_number %> of <%= num_pages %></p> + + <% if prev_page %> + <p><%= link_to 'Previous page', prev_page %></p> + <% end %> +<% end %> + +<ul> + <% page_articles.each_with_index do |article, i| %> + <li><%= link_to article.title, article %> <span><%= article.date.strftime('%b %e') %></span></li> + <% end %> +</ul> + +<% if paginate %> + <% if next_page %> + <p><%= link_to 'Next page', next_page %></p> + <% end %> +<% end %> |