middleman-blog 3.6.0.beta.2 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +18 -2
- data/CHANGELOG.md +6 -1
- data/Gemfile +13 -10
- data/README.md +6 -6
- data/Rakefile +1 -15
- data/features/calendar.feature +23 -0
- data/features/calendar_multiblog.feature +0 -2
- data/features/language.feature +1 -13
- data/features/multiblog.feature +0 -2
- data/features/paginate_multiblog.feature +0 -2
- data/features/tags.feature +14 -0
- data/features/tags_multiblog.feature +0 -2
- data/fixtures/blog-sources-subdirs-app/config.rb +1 -1
- data/fixtures/blog-sources-subdirs-app/source/blog.html.erb +1 -1
- data/fixtures/blog-sources-subdirs-app/source/blog/{another-post.md.erb → another-post.html.md.erb} +0 -0
- data/fixtures/blog-sources-subdirs-app/source/blog/subdir/{yet-another-post.md.erb → yet-another-post.html.md.erb} +0 -0
- data/fixtures/calendar-app/config-only-year.rb +9 -0
- data/fixtures/custom-collections-sources-app/source/index.html.erb +3 -3
- data/fixtures/layouts-app/source/2011/01/02/{article-in-normal-layout.markdown → article-in-normal-layout.html.markdown} +0 -0
- data/fixtures/layouts-app/source/2011/01/03/{article-without-layout.markdown → article-without-layout.html.markdown} +0 -0
- data/fixtures/permalink-data-app/source/layout.erb +1 -1
- data/fixtures/tags-app/config-no-tags.rb +6 -0
- data/lib/middleman-blog.rb +0 -9
- data/lib/middleman-blog/blog_article.rb +11 -9
- data/lib/middleman-blog/blog_data.rb +17 -13
- data/lib/middleman-blog/calendar_pages.rb +9 -12
- data/lib/middleman-blog/custom_pages.rb +3 -4
- data/lib/middleman-blog/extension.rb +24 -8
- data/lib/middleman-blog/helpers.rb +10 -17
- data/lib/middleman-blog/paginator.rb +9 -7
- data/lib/middleman-blog/tag_pages.rb +5 -3
- data/lib/middleman-blog/version.rb +1 -1
- data/middleman-blog.gemspec +3 -3
- data/spec/uri_templates_spec.rb +17 -17
- metadata +22 -31
- data/features/article_cli.feature +0 -16
- data/lib/middleman-blog/commands/article.rb +0 -58
- data/lib/middleman-blog/commands/article.tt +0 -6
- data/lib/middleman-blog/template.rb +0 -37
- data/lib/middleman-blog/template/config.tt +0 -118
- data/lib/middleman-blog/template/shared/Gemfile.tt +0 -9
- data/lib/middleman-blog/template/source/2012-01-01-example-article.html.markdown +0 -7
- data/lib/middleman-blog/template/source/calendar.html.erb +0 -33
- data/lib/middleman-blog/template/source/feed.xml.builder +0 -24
- data/lib/middleman-blog/template/source/index.html.erb +0 -24
- data/lib/middleman-blog/template/source/layout.erb +0 -38
- data/lib/middleman-blog/template/source/tag.html.erb +0 -25
@@ -1,16 +0,0 @@
|
|
1
|
-
Feature: New article CLI command
|
2
|
-
Scenario: Create a new blog article with the CLI
|
3
|
-
Given a fixture app "blog-sources-app"
|
4
|
-
And I run `middleman article "My New Article" --date 2012-03-17`
|
5
|
-
Then the exit status should be 0
|
6
|
-
Then the following files should exist:
|
7
|
-
| source/blog/2012-03-17-my-new-article.html.markdown |
|
8
|
-
And the file "source/blog/2012-03-17-my-new-article.html.markdown" should contain "tags"
|
9
|
-
|
10
|
-
Scenario: Create a new blog article with the CLI using a custom template
|
11
|
-
Given a fixture app "custom-article-template-app"
|
12
|
-
And I run `middleman article "My New Article" --date 2012-03-17`
|
13
|
-
Then the exit status should be 0
|
14
|
-
Then the following files should exist:
|
15
|
-
| source/2012-03-17-my-new-article.html.markdown |
|
16
|
-
And the file "source/2012-03-17-my-new-article.html.markdown" should contain "From a template!"
|
@@ -1,58 +0,0 @@
|
|
1
|
-
require 'middleman-core/cli'
|
2
|
-
require 'date'
|
3
|
-
require 'middleman-blog/uri_templates'
|
4
|
-
|
5
|
-
module Middleman
|
6
|
-
module Cli
|
7
|
-
# This class provides an "article" command for the middleman CLI.
|
8
|
-
class Article < Thor
|
9
|
-
include Thor::Actions
|
10
|
-
include Blog::UriTemplates
|
11
|
-
|
12
|
-
check_unknown_options!
|
13
|
-
|
14
|
-
namespace :article
|
15
|
-
|
16
|
-
def self.source_root
|
17
|
-
ENV['MM_ROOT']
|
18
|
-
end
|
19
|
-
|
20
|
-
# Tell Thor to exit with a nonzero exit code on failure
|
21
|
-
def self.exit_on_failure?
|
22
|
-
true
|
23
|
-
end
|
24
|
-
|
25
|
-
desc "article TITLE", "Create a new blog article"
|
26
|
-
method_option "date",
|
27
|
-
aliases: "-d",
|
28
|
-
desc: "The date to create the post with (defaults to now)"
|
29
|
-
method_option "lang",
|
30
|
-
aliases: "-l",
|
31
|
-
desc: "The language to create the post with (defaults to I18n.default_locale if available)"
|
32
|
-
method_option "blog",
|
33
|
-
aliases: "-b",
|
34
|
-
desc: "The name of the blog to create the post inside (for multi-blog apps, defaults to the only blog in single-blog apps)"
|
35
|
-
def article(title)
|
36
|
-
shared_instance = ::Middleman::Application.server.inst
|
37
|
-
|
38
|
-
# This only exists when the config.rb sets it!
|
39
|
-
if shared_instance.respond_to? :blog
|
40
|
-
@title = title
|
41
|
-
@slug = safe_parameterize(title)
|
42
|
-
@date = options[:date] ? Time.zone.parse(options[:date]) : Time.zone.now
|
43
|
-
@lang = options[:lang] || ( I18n.default_locale if defined? I18n )
|
44
|
-
|
45
|
-
blog_inst = shared_instance.blog(options[:blog])
|
46
|
-
|
47
|
-
path_template = blog_inst.source_template
|
48
|
-
params = date_to_params(@date).merge(lang: @lang.to_s, title: @slug)
|
49
|
-
article_path = apply_uri_template path_template, params
|
50
|
-
|
51
|
-
template blog_inst.options.new_article_template, File.join(shared_instance.source_dir, article_path + blog_inst.options.default_extension)
|
52
|
-
else
|
53
|
-
raise Thor::Error.new "You need to activate the blog extension in config.rb before you can create an article"
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require "middleman-core/templates"
|
2
|
-
|
3
|
-
module Middleman
|
4
|
-
module Blog
|
5
|
-
|
6
|
-
# A template that generates a blog-specific config.rb
|
7
|
-
# and a set of example templates for index, layout, tags, and calendar.
|
8
|
-
class Template < Middleman::Templates::Base
|
9
|
-
class_option "css_dir",
|
10
|
-
default: "stylesheets",
|
11
|
-
desc: 'The path to the css files'
|
12
|
-
class_option "js_dir",
|
13
|
-
default: "javascripts",
|
14
|
-
desc: 'The path to the javascript files'
|
15
|
-
class_option "images_dir",
|
16
|
-
default: "images",
|
17
|
-
desc: 'The path to the image files'
|
18
|
-
|
19
|
-
def self.source_root
|
20
|
-
File.join(File.dirname(__FILE__), 'template')
|
21
|
-
end
|
22
|
-
|
23
|
-
def build_scaffold
|
24
|
-
template "config.tt", File.join(location, "config.rb")
|
25
|
-
|
26
|
-
source = File.join(location, "source")
|
27
|
-
directory "source", source
|
28
|
-
|
29
|
-
[:css_dir, :js_dir, :images_dir].each do |dir|
|
30
|
-
empty_directory File.join(source, options[dir])
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
Middleman::Templates.register(:blog, Middleman::Blog::Template)
|
@@ -1,118 +0,0 @@
|
|
1
|
-
###
|
2
|
-
# Blog settings
|
3
|
-
###
|
4
|
-
|
5
|
-
# Time.zone = "UTC"
|
6
|
-
|
7
|
-
activate :blog do |blog|
|
8
|
-
# This will add a prefix to all links, template references and source paths
|
9
|
-
# blog.prefix = "blog"
|
10
|
-
|
11
|
-
# blog.permalink = "{year}/{month}/{day}/{title}.html"
|
12
|
-
# Matcher for blog source files
|
13
|
-
# blog.sources = "{year}-{month}-{day}-{title}.html"
|
14
|
-
# blog.taglink = "tags/{tag}.html"
|
15
|
-
# blog.layout = "layout"
|
16
|
-
# blog.summary_separator = /(READMORE)/
|
17
|
-
# blog.summary_length = 250
|
18
|
-
# blog.year_link = "{year}.html"
|
19
|
-
# blog.month_link = "{year}/{month}.html"
|
20
|
-
# blog.day_link = "{year}/{month}/{day}.html"
|
21
|
-
# blog.default_extension = ".markdown"
|
22
|
-
|
23
|
-
blog.tag_template = "tag.html"
|
24
|
-
blog.calendar_template = "calendar.html"
|
25
|
-
|
26
|
-
# Enable pagination
|
27
|
-
# blog.paginate = true
|
28
|
-
# blog.per_page = 10
|
29
|
-
# blog.page_link = "page/{num}"
|
30
|
-
end
|
31
|
-
|
32
|
-
page "/feed.xml", layout: false
|
33
|
-
|
34
|
-
###
|
35
|
-
# Compass
|
36
|
-
###
|
37
|
-
|
38
|
-
# Change Compass configuration
|
39
|
-
# compass_config do |config|
|
40
|
-
# config.output_style = :compact
|
41
|
-
# end
|
42
|
-
|
43
|
-
###
|
44
|
-
# Page options, layouts, aliases and proxies
|
45
|
-
###
|
46
|
-
|
47
|
-
# Per-page layout changes:
|
48
|
-
#
|
49
|
-
# With no layout
|
50
|
-
# page "/path/to/file.html", layout: false
|
51
|
-
#
|
52
|
-
# With alternative layout
|
53
|
-
# page "/path/to/file.html", layout: :otherlayout
|
54
|
-
#
|
55
|
-
# A path which all have the same layout
|
56
|
-
# with_layout :admin do
|
57
|
-
# page "/admin/*"
|
58
|
-
# end
|
59
|
-
|
60
|
-
# Proxy pages (http://middlemanapp.com/basics/dynamic-pages/)
|
61
|
-
# proxy "/this-page-has-no-template.html", "/template-file.html", locals: {
|
62
|
-
# which_fake_page: "Rendering a fake page with a local variable" }
|
63
|
-
|
64
|
-
###
|
65
|
-
# Helpers
|
66
|
-
###
|
67
|
-
|
68
|
-
# Automatic image dimensions on image_tag helper
|
69
|
-
# activate :automatic_image_sizes
|
70
|
-
|
71
|
-
# Reload the browser automatically whenever files change
|
72
|
-
# activate :livereload
|
73
|
-
|
74
|
-
# Methods defined in the helpers block are available in templates
|
75
|
-
# helpers do
|
76
|
-
# def some_helper
|
77
|
-
# "Helping"
|
78
|
-
# end
|
79
|
-
# end
|
80
|
-
|
81
|
-
<% if options[:css_dir] -%>
|
82
|
-
set :css_dir, '<%= options[:css_dir] -%>'
|
83
|
-
<% else -%>
|
84
|
-
# Change the CSS directory
|
85
|
-
# set :css_dir, "alternative_css_directory"
|
86
|
-
<% end -%>
|
87
|
-
|
88
|
-
<% if options[:js_dir] -%>
|
89
|
-
set :js_dir, '<%= options[:js_dir] -%>'
|
90
|
-
<% else -%>
|
91
|
-
# Change the JS directory
|
92
|
-
# set :js_dir, "alternative_js_directory"
|
93
|
-
<% end -%>
|
94
|
-
|
95
|
-
<% if options[:images_dir] -%>
|
96
|
-
set :images_dir, '<%= options[:images_dir] -%>'
|
97
|
-
<% else -%>
|
98
|
-
# Change the images directory
|
99
|
-
# set :images_dir, "alternative_image_directory"
|
100
|
-
<% end -%>
|
101
|
-
|
102
|
-
# Build-specific configuration
|
103
|
-
configure :build do
|
104
|
-
# For example, change the Compass output style for deployment
|
105
|
-
# activate :minify_css
|
106
|
-
|
107
|
-
# Minify Javascript on build
|
108
|
-
# activate :minify_javascript
|
109
|
-
|
110
|
-
# Enable cache buster
|
111
|
-
# activate :asset_hash
|
112
|
-
|
113
|
-
# Use relative URLs
|
114
|
-
# activate :relative_assets
|
115
|
-
|
116
|
-
# Or use a different image path
|
117
|
-
# set :http_prefix, "/Content/images/"
|
118
|
-
end
|
@@ -1,9 +0,0 @@
|
|
1
|
-
# If you have OpenSSL installed, we recommend updating
|
2
|
-
# the following line to use "https"
|
3
|
-
source 'http://rubygems.org'
|
4
|
-
|
5
|
-
gem "middleman", "~> <%= Middleman::VERSION %>"
|
6
|
-
gem "middleman-blog", "~> <%= Middleman::Blog::VERSION %>"
|
7
|
-
|
8
|
-
# For feed.xml.builder
|
9
|
-
gem "builder", "~> 3.0"
|
@@ -1,33 +0,0 @@
|
|
1
|
-
---
|
2
|
-
pageable: true
|
3
|
-
---
|
4
|
-
<h1>Archive for
|
5
|
-
<% case page_type
|
6
|
-
when 'day' %>
|
7
|
-
<%= Date.new(year, month, day).strftime('%b %e %Y') %>
|
8
|
-
<% when 'month' %>
|
9
|
-
<%= Date.new(year, month, 1).strftime('%b %Y') %>
|
10
|
-
<% when 'year' %>
|
11
|
-
<%= year %>
|
12
|
-
<% end %>
|
13
|
-
</h1>
|
14
|
-
|
15
|
-
<% if paginate && num_pages > 1 %>
|
16
|
-
<p>Page <%= page_number %> of <%= num_pages %></p>
|
17
|
-
|
18
|
-
<% if prev_page %>
|
19
|
-
<p><%= link_to 'Previous page', prev_page %></p>
|
20
|
-
<% end %>
|
21
|
-
<% end %>
|
22
|
-
|
23
|
-
<ul>
|
24
|
-
<% page_articles.each_with_index do |article, i| %>
|
25
|
-
<li><%= link_to article.title, article %> <span><%= article.date.strftime('%b %e') %></span></li>
|
26
|
-
<% end %>
|
27
|
-
</ul>
|
28
|
-
|
29
|
-
<% if paginate %>
|
30
|
-
<% if next_page %>
|
31
|
-
<p><%= link_to 'Next page', next_page %></p>
|
32
|
-
<% end %>
|
33
|
-
<% end %>
|
@@ -1,24 +0,0 @@
|
|
1
|
-
xml.instruct!
|
2
|
-
xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do
|
3
|
-
site_url = "http://blog.url.com/"
|
4
|
-
xml.title "Blog Name"
|
5
|
-
xml.subtitle "Blog subtitle"
|
6
|
-
xml.id URI.join(site_url, blog.options.prefix.to_s)
|
7
|
-
xml.link "href" => URI.join(site_url, blog.options.prefix.to_s)
|
8
|
-
xml.link "href" => URI.join(site_url, current_page.path), "rel" => "self"
|
9
|
-
xml.updated(blog.articles.first.date.to_time.iso8601) unless blog.articles.empty?
|
10
|
-
xml.author { xml.name "Blog Author" }
|
11
|
-
|
12
|
-
blog.articles[0..5].each do |article|
|
13
|
-
xml.entry do
|
14
|
-
xml.title article.title
|
15
|
-
xml.link "rel" => "alternate", "href" => URI.join(site_url, article.url)
|
16
|
-
xml.id URI.join(site_url, article.url)
|
17
|
-
xml.published article.date.to_time.iso8601
|
18
|
-
xml.updated File.mtime(article.source_file).iso8601
|
19
|
-
xml.author { xml.name "Article Author" }
|
20
|
-
# xml.summary article.summary, "type" => "html"
|
21
|
-
xml.content article.body, "type" => "html"
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
---
|
2
|
-
pageable: true
|
3
|
-
per_page: 10
|
4
|
-
---
|
5
|
-
<% if paginate && num_pages > 1 %>
|
6
|
-
<p>Page <%= page_number %> of <%= num_pages %></p>
|
7
|
-
|
8
|
-
<% if prev_page %>
|
9
|
-
<p><%= link_to 'Previous page', prev_page %></p>
|
10
|
-
<% end %>
|
11
|
-
<% end %>
|
12
|
-
|
13
|
-
<% page_articles.each_with_index do |article, i| %>
|
14
|
-
<h2><%= link_to article.title, article %> <span><%= article.date.strftime('%b %e') %></span></h2>
|
15
|
-
<!-- use article.summary(250) if you have Nokogiri available to show just
|
16
|
-
the first 250 characters -->
|
17
|
-
<%= article.body %>
|
18
|
-
<% end %>
|
19
|
-
|
20
|
-
<% if paginate %>
|
21
|
-
<% if next_page %>
|
22
|
-
<p><%= link_to 'Next page', next_page %></p>
|
23
|
-
<% end %>
|
24
|
-
<% end %>
|
@@ -1,38 +0,0 @@
|
|
1
|
-
<!doctype html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<meta charset="utf-8" />
|
5
|
-
<meta http-equiv='X-UA-Compatible' content='IE=edge;chrome=1' />
|
6
|
-
<title>Blog Title<%= ' - ' + current_article.title unless current_article.nil? %></title>
|
7
|
-
<%= feed_tag :atom, "#{blog.options.prefix.to_s}/feed.xml", title: "Atom Feed" %>
|
8
|
-
</head>
|
9
|
-
<body>
|
10
|
-
|
11
|
-
<div id="main" role="main">
|
12
|
-
<%= yield %>
|
13
|
-
</div>
|
14
|
-
|
15
|
-
<aside>
|
16
|
-
<h2>Recent Articles</h2>
|
17
|
-
<ol>
|
18
|
-
<% blog.articles[0...10].each do |article| %>
|
19
|
-
<li><%= link_to article.title, article %> <span><%= article.date.strftime('%b %e') %></span></li>
|
20
|
-
<% end %>
|
21
|
-
</ol>
|
22
|
-
|
23
|
-
<h2>Tags</h2>
|
24
|
-
<ol>
|
25
|
-
<% blog.tags.each do |tag, articles| %>
|
26
|
-
<li><%= link_to "#{tag} (#{articles.size})", tag_path(tag) %></li>
|
27
|
-
<% end %>
|
28
|
-
</ol>
|
29
|
-
|
30
|
-
<h2>By Year</h2>
|
31
|
-
<ol>
|
32
|
-
<% blog.articles.group_by {|a| a.date.year }.each do |year, articles| %>
|
33
|
-
<li><%= link_to "#{year} (#{articles.size})", blog_year_path(year) %></li>
|
34
|
-
<% end %>
|
35
|
-
</ol>
|
36
|
-
</aside>
|
37
|
-
</body>
|
38
|
-
</html>
|
@@ -1,25 +0,0 @@
|
|
1
|
-
---
|
2
|
-
pageable: true
|
3
|
-
per_page: 12
|
4
|
-
---
|
5
|
-
<h1>Articles tagged '<%= tagname %>'</h1>
|
6
|
-
|
7
|
-
<% if paginate && num_pages > 1 %>
|
8
|
-
<p>Page <%= page_number %> of <%= num_pages %></p>
|
9
|
-
|
10
|
-
<% if prev_page %>
|
11
|
-
<p><%= link_to 'Previous page', prev_page %></p>
|
12
|
-
<% end %>
|
13
|
-
<% end %>
|
14
|
-
|
15
|
-
<ul>
|
16
|
-
<% page_articles.each_with_index do |article, i| %>
|
17
|
-
<li><%= link_to article.title, article %> <span><%= article.date.strftime('%b %e') %></span></li>
|
18
|
-
<% end %>
|
19
|
-
</ul>
|
20
|
-
|
21
|
-
<% if paginate %>
|
22
|
-
<% if next_page %>
|
23
|
-
<p><%= link_to 'Next page', next_page %></p>
|
24
|
-
<% end %>
|
25
|
-
<% end %>
|