plate 0.7.0.pre5 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -2,13 +2,13 @@
2
2
 
3
3
  [![Build Status](https://secure.travis-ci.org/jdtornow/plate.png)](http://travis-ci.org/jdtornow/plate) [![Dependency Status](https://gemnasium.com/jdtornow/plate.png?travis)](https://gemnasium.com/jdtornow/plate)
4
4
 
5
- Plate is a super simple static site generator and blog engine. At its core, it takes a folder full of Markdown files and turns it into a static HTML site that you can host anywhere.
5
+ Plate is a simple static site generator and blogging engine. At its core, it takes a folder full of Markdown files and turns it into a static HTML site that you can host anywhere.
6
6
 
7
- In addition to basic formatting with Markdown, Plate also supports generating more dynamic files with ERB or HAML, and compiling asset files with CoffeeScript, Sass and others.
7
+ In addition to basic formatting with Markdown, Plate also supports generating more dynamic files with ERB or HAML, and compiling asset files with CoffeeScript, Sass and and Less.
8
8
 
9
- Plate is a command line utility installed as a Ruby Gem. Installation requires Ruby 1.8.7, 1.9.2 or 1.9.3. For additional processing, install CoffeeScript, Sass, Haml and other formatters.
9
+ Plate is a command line utility installed as a Ruby Gem. Installation requires Ruby 1.8.7, 1.9.2 or 1.9.3.
10
10
 
11
- Current version is **0.6.3**
11
+ Current version is **0.7.0**
12
12
 
13
13
  ## Installation
14
14
 
@@ -18,111 +18,85 @@ Or, create a `Gemfile` and add:
18
18
 
19
19
  gem 'plate'
20
20
 
21
- ## Command line
21
+ ## Creating a new site
22
22
 
23
- Plate is designed to be a command-line utility. Here is a rundown of some of the basic commands:
24
-
25
- ### Creating a new site
26
-
27
- To generate a new site with plate, run the following command:
23
+ To generate a new site with plate, run the following command in the directory you want a new site in:
28
24
 
29
25
  platify .
30
26
 
31
- Or, with the normal `plate` command:
32
-
33
- plate new .
34
-
35
- ### Building a site
36
-
37
- To build your site, run:
38
-
39
- plate build
27
+ ## Building a site
40
28
 
41
- Or, just run `plate` without any options to build the site.
29
+ To build your entire site, just run
42
30
 
43
31
  plate
44
32
 
45
- To show details about the site build, enable verbose mode:
33
+ Add a `--verbose` tag to show some additional output about what is happening behind the scenes.
46
34
 
47
- plate --verbose
48
-
49
- ### Creating a new post
35
+ ## Create a new blog post
50
36
 
51
37
  To create a new blog post with the default options, run:
52
38
 
53
- plate post "New Post Name"
39
+ plate post "Your Post Name Here"
54
40
 
55
41
  You can also put default post options (such as a category or layout) into the command line:
56
42
 
57
- plate post "New Post Name" --category Articles --layout post
58
-
59
- Or, if you always use the same default category and/or layout, you can put those options into your config file instead like so:
43
+ plate post "Your Post Name Here" --category Articles --layout post
60
44
 
61
- # In config/plate.yml
62
- ...
63
- post_defaults:
64
- category: Articles
65
- layout: post
66
- ...
45
+ If you always end up using the same basic options for every new post, you can add these options as defaults in your [config file](https://github.com/jdtornow/plate/blob/master/doc/config.md#new-post-options).
67
46
 
68
47
  ## Directory Structure
69
48
 
70
49
  Plate observes the following folder structure in your site:
71
50
 
72
- * config/ - Put your global configuration settings here.
73
- * content/ - All custom content for the site, besides blog posts. Everything in this folder will be copied over to the published site.
74
- * drafts/ - All drafted blog posts. Posts in this directory are rendered into the `/_drafts` destination.
75
- * helpers/ - Helpers are loaded into views automatically and can be used within dynamically rendered pages using a template language. (Such as Erb or Haml)
51
+ * config/ - Configuration options (see [config](https://github.com/jdtornow/plate/blob/master/doc/config.md))
52
+ * content/ - All site pages and assets
53
+ * drafts/ - Any drafted blog posts
54
+ * helpers/ - Helpers used within dynamic templates (see [Helpers](https://github.com/jdtornow/plate/blob/master/doc/helpers.md))
76
55
  * layouts/ - Global layouts available for use on all content pages and posts.
77
- * lib/ - Extend the basic functionality of Plate with plugins in this directory. All `.rb` files run against the Plate DSL.
78
- * posts/ - All blog post content for the site. Posts can be organized into sub-directories if you like.
56
+ * lib/ - Extend the basic functionality of Plate with plugins in this directory. (see [DSL](https://github.com/jdtornow/plate/blob/master/doc/dsl.md))
57
+ * posts/ - All blog post content for the site.
79
58
  * public/ - This will be generated if it does not exist, contains the produced site. Set this as the web server root to your site for development mode.
80
59
 
81
60
  ## Extending Plate
82
61
 
83
- Plate is meant to be extended easily. You might want to extend the basic functionality of Plate to add additional functionality for your site. To get started, create a directory named `lib` in the root of your site. Any Ruby files (ending in `.rb`) will be automatically loaded into the stack when Plate is run.
84
-
85
- ### Callbacks
86
-
87
- Callbacks are used to call certain blocks of code when an event happens in the lifecycle of building a site.
88
-
89
- The callbacks currently available are:
90
-
91
- * Site - `before_render`, `after_render`
92
- * Page/Post - `before_render`, `after_render`, `before_write`, `after_write`
93
- * Asset - `before_render`, `after_render`, `before_write`, `after_write`
62
+ Plate is designed to be easily extended. To get started, create a directory named `lib` in the root of your site. Any Ruby files (ending in `.rb`) will be automatically loaded with the [Plate DSL](https://github.com/jdtornow/plate/blob/master/doc/dsl.md).
94
63
 
95
- Example of a callback to be run when a site completes the build:
64
+ ## Helpers
96
65
 
97
- register_callback :site, :after_render do |site|
98
- puts "the site finished rendering!"
99
- end
66
+ When using dynamic page templates, such as `erb` or `haml`, you can access Ruby helper methods that are baked in to Plate, or add your own. For more information about helpers, see the [helpers doc](https://github.com/jdtornow/plate/blob/master/doc/helpers.md).
100
67
 
101
- Put the above snippet in any file in the lib folder, and it will be registered when your site is compiled.
68
+ ## Draft Posts
102
69
 
103
- ### Helpers
70
+ When creating a new post, you can choose to put it in the *drafts* folder, instead of the posts folder, to hide it from display until the post is complete. Once the post is ready for publishing, just add the following line to the meta data section at the top of the post:
104
71
 
105
- Helpers are modules that are automatically loaded into views. Any methods in the module will be available when you render a page.
72
+ ```
73
+ publish: true
74
+ ```
75
+
76
+ On the next site build, your post will automatically be moved to the appropriate spot in the *posts* folder.
106
77
 
107
- An example of a helper file located in `helpers/sample_helper.rb`
78
+ By default, the `plate post [Title]` command does not use the drafts folder. To enable draft usage by default when a new post is generated, just change the following line in the `config/plate.yml` file to true:
108
79
 
109
- module SampleHelper
110
- def sample_helper_method
111
- "yes"
112
- end
113
- end
80
+ ```yml
81
+ posts:
82
+ draft: true
83
+ ```
114
84
 
115
- Then, in your `.erb` view you can call `sample_helper_method`.
85
+ ## Partials
116
86
 
117
- All files in the `helpers/` directory are assumed to be helper modules and will be loaded automatically at runtime.
87
+ Plate supports basic partial usage within dynamic pages. If your page is using Erb or Haml, you'll have access to partials. Partial files begin with an underscore, but are referenced in the `render` command without the underscore.
118
88
 
119
- ### Draft Posts
89
+ To display the contents of a partial located in `content/partials/_header.html`, use the following syntax:
120
90
 
121
- **In development -docs coming soon.**
91
+ ```ruby
92
+ render 'partials/header'
93
+ ```
122
94
 
123
- ### Partials
95
+ Partials also support local variables. To pass custom variables through to the partial view, just include a hash in the `render` call. Note that only dynamic template partials (such as those ending in .erb or .haml) will be able to take advantage of local variables.
124
96
 
125
- **In development -docs coming soon.**
97
+ ```ruby
98
+ render 'partials/header', :my => 'local', :vars => 'here'
99
+ ```
126
100
 
127
101
  ## Full Documentation
128
102
 
@@ -208,12 +208,16 @@ module Plate
208
208
  date = Time.now
209
209
 
210
210
  # if there are any post defaults in the config file, use those as the default options
211
- if builder.config.has_key?(:post_defaults)
212
- options.reverse_merge!(builder.config[:post_defaults])
211
+ if builder.config.has_key?(:posts)
212
+ options.reverse_merge!(builder.config[:posts])
213
213
  end
214
214
 
215
215
  category = options[:category] ? "\ncategory: #{options[:category]}" : ""
216
+ body = options[:body] ? options[:body].to_s : "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur."
216
217
  layout = options[:layout] ? "\nlayout: #{options[:layout]}" : ""
218
+ tags = options[:tags] ? options[:tags] : ""
219
+ tags = tags.join(', ') if Array === tags
220
+
217
221
  publish = "\npublish: false"
218
222
  label = "draft"
219
223
 
@@ -227,7 +231,7 @@ module Plate
227
231
  label = "post"
228
232
  end
229
233
 
230
- content = %Q(---\ntitle: "#{title}"\ndate: #{date.strftime('%Y-%m-%d %H:%M:%S')}#{category}#{layout}\ntags: []#{publish}\n\n# #{title}\n\nLorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.)
234
+ content = %Q(---\ntitle: "#{title}"\ndate: #{date.strftime('%Y-%m-%d %H:%M:%S')}#{category}#{layout}\ntags: [#{tags}]#{publish}\n\n# #{title}\n\n#{body})
231
235
 
232
236
  FileUtils.mkdir_p(File.dirname(filename))
233
237
  File.open(filename, 'w') { |f| f.write(content) }
@@ -33,6 +33,7 @@ module Plate
33
33
  self.meta = meta
34
34
  self.content = ""
35
35
  self.locals = {}
36
+ self.partials = []
36
37
  end
37
38
 
38
39
  # Set the full hash to be provided to the view. Hash keys are symbolized before
@@ -11,8 +11,11 @@ module Plate
11
11
  end
12
12
 
13
13
  locals.symbolize_keys!
14
-
14
+
15
15
  render_partial(path.to_s, locals)
16
+ rescue
17
+ site.log("Oops. There was a problem rendering the partial: #{path}")
18
+ ""
16
19
  end
17
20
 
18
21
  protected
@@ -20,9 +23,9 @@ module Plate
20
23
  def render_partial(path, locals)
21
24
  partial_name = Partial.name(self.site, path, self.file)
22
25
  partial = Partial.find(self.site, partial_name)
23
-
26
+
24
27
  self.page.partials << partial_name unless self.page.partials.include?(partial_name)
25
-
28
+
26
29
  if partial
27
30
  partial.pages << self.page unless partial.pages.include?(self.page)
28
31
  partial.render(locals)
@@ -8,56 +8,56 @@ module Plate
8
8
  def category
9
9
  default = self.meta[:category] || self.site.default_category
10
10
  end
11
-
11
+
12
12
  # Category for this post, formatted to be URL-friendly
13
13
  def category_for_url
14
14
  self.category.to_s.dasherize.parameterize
15
15
  end
16
-
16
+
17
17
  # Returns the date for this post, either from the filename or meta hash.
18
18
  # If both are provided, the meta information takes precedence.
19
19
  def date
20
20
  result = nil
21
-
21
+
22
22
  if self.meta[:date]
23
23
  result = self.meta[:date].to_s
24
24
  elsif self.basename =~ /^(\d{4}-\d{2}-\d{2})-/
25
25
  result = $1.to_s
26
26
  end
27
-
27
+
28
28
  begin
29
29
  return Time.parse(result)
30
30
  rescue Exception => e
31
- self.site.log(" ** Problem reading date for file #{relative_file} (#{e.message}). Post skipped.")
31
+ self.site.log(" ** Problem reading date for file #{relative_file} (#{e.message}). Post skipped.")
32
32
  end
33
-
33
+
34
34
  raise NoPostDateProvided
35
35
  end
36
-
36
+
37
37
  def day
38
38
  date.strftime('%d')
39
39
  end
40
-
40
+
41
41
  # The full file path of where this file will be written to. (Relative to site root)
42
42
  def file_path
43
43
  "#{permalink}/index.html"
44
44
  end
45
-
45
+
46
46
  def inspect
47
47
  "#<#{self.class}:0x#{object_id.to_s(16)} name=#{name.to_s.inspect} date=#{date.to_s}>"
48
48
  end
49
-
49
+
50
50
  def month
51
- date.strftime('%m')
51
+ date.strftime('%m')
52
52
  end
53
-
53
+
54
54
  # Return the [relative] path for this post. Uses the +permalink_template+
55
55
  # variable as the method for converting post data into a URL.
56
56
  #
57
57
  # The permalink_template can be set in the global config named 'permalink'.
58
58
  #
59
59
  # Available options are:
60
- #
60
+ #
61
61
  # * `date` - The date of this post, formatted as YYYY-MM-DD
62
62
  # * `title` - The title of this post, formatted for URL
63
63
  # * `slug` - The filename slug
@@ -69,11 +69,11 @@ module Plate
69
69
  # All values are formatted to be URL-safe. (No spaces, underscores or weird characters.)
70
70
  def permalink(cache_buster = false)
71
71
  return @permalink if @permalink and !cache_buster
72
-
72
+
73
73
  date = self.date
74
-
74
+
75
75
  # All of these variables can be put into a URL
76
- permalink_attributes = {
76
+ permalink_attributes = {
77
77
  "date" => date.strftime('%Y-%m-%d'),
78
78
  "slug" => slug,
79
79
  "title" => title_for_url,
@@ -82,50 +82,50 @@ module Plate
82
82
  "day" => day,
83
83
  "category" => category_for_url
84
84
  }
85
-
85
+
86
86
  # Copy the permalink template as a starting point
87
87
  result = permalink_template.clone
88
-
88
+
89
89
  # Replace all variables from the attributes into the template
90
90
  permalink_attributes.each { |key, value| result.gsub!(/:#{Regexp.escape(key)}/, value) }
91
-
91
+
92
92
  # Remove any double slashes
93
93
  result.gsub!(/\/\//, '/')
94
-
94
+
95
95
  # Remove file extensions, and cleanup URL
96
96
  result = result.split('/').reject{ |segment| segment =~ /^\.+$/ }.join('/')
97
-
97
+
98
98
  @permalink = result
99
99
  end
100
-
100
+
101
101
  # The template to use when generating the permalink.
102
102
  def permalink_template
103
103
  self.site.options[:permalink] || '/:category/:year/:month/:slug'
104
104
  end
105
105
 
106
- # Returns the URL slug to use for this blog post.
106
+ # Returns the URL slug to use for this blog post.
107
107
  #
108
108
  # This will convert the file name from a format like:
109
109
  #
110
110
  # 2012-01-01-post-name.md
111
111
  #
112
112
  # To simply:
113
- #
113
+ #
114
114
  # post-name
115
115
  def slug
116
116
  name = self.basename.to_s.downcase.gsub(/^(\d{4}-\d{2}-\d{2})-/, '').split('.')[0]
117
117
  name.dasherize.parameterize
118
118
  end
119
-
119
+
120
120
  # Utility method to sanitize tags output. Tags are returned as an array.
121
121
  def tags
122
- @tags ||= (Array === self.meta[:tags] ? self.meta[:tags] : self.meta[:tags].to_s.strip.split(',')).collect(&:strip).sort
122
+ @tags ||= (Array === self.meta[:tags] ? self.meta[:tags] : self.meta[:tags].to_s.strip.split(',')).collect { |s| s.to_s.strip }.sort
123
123
  end
124
-
124
+
125
125
  def year
126
126
  date.strftime('%Y')
127
127
  end
128
-
128
+
129
129
  # Compare two posts, by date.
130
130
  def <=>(other)
131
131
  self.date <=> other.date
@@ -1,3 +1,3 @@
1
1
  module Plate
2
- VERSION = "0.7.0.pre5" unless defined?(::Plate::VERSION)
2
+ VERSION = "0.7.0" unless defined?(::Plate::VERSION)
3
3
  end
@@ -20,10 +20,24 @@ base_url: "http://example.com"
20
20
  # * `category` - The category for this post
21
21
  permalink: "/posts/:year/:month/:slug"
22
22
 
23
- # New posts generated with the `plate post 'Title'` command can be put into a draft
24
- # state by setting this to true. Once your post is ready, add `publish: true` to the
25
- # meta information for that post and it will be published on the next build.
26
- draft: false
23
+ # Options available for new posts generated with `plate post [Title]`
24
+ posts:
25
+ # New posts generated with the `plate post 'Title'` command can be put into a draft
26
+ # state by setting this to true. Once your post is ready, add `publish: true` to the
27
+ # meta information for that post and it will be published on the next build.
28
+ draft: false
29
+
30
+ # The default layout to use for new posts. This layout should exist in `layouts/`
31
+ #layout: "default"
32
+
33
+ # The default category to use for new posts
34
+ #category: "posts"
35
+
36
+ # The default tags to use for new posts
37
+ #tags: [ tag1, tag2, tag3 ]
38
+
39
+ # The default body content for new posts.
40
+ #body: "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
27
41
 
28
42
  # The default meta data for your site
29
43
  meta:
@@ -25,7 +25,7 @@ title: "Home"
25
25
  <h2>Publish</h2>
26
26
  <p>To publish your site, just drop the <em>public</em> directory into the root of any major web hosting server.</p>
27
27
  <p>If you are on a Mac you can easily run your site with the built-in web server by changing your destination directory to your user account&#8217;s <em>Sites</em> directory. You can do so by putting the following line in the plate.yml configuration file.</p>
28
- <pre>destination: ~/Sites/</pre>
28
+ <pre>destination: ~/Sites/my-site</pre>
29
29
  <p>Note: this will overwrite anything existing in that folder, so be careful.</p>
30
30
  </div>
31
31
  </div>
metadata CHANGED
@@ -1,19 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0.pre5
5
- prerelease: 6
4
+ version: 0.7.0
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - John Tornow
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-16 00:00:00.000000000Z
12
+ date: 2012-08-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
- requirement: &70224087615620 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '3.2'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70224087615620
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '3.2'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: directory_watcher
27
- requirement: &70224087615160 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: '0'
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *70224087615160
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: i18n
38
- requirement: &70224087614540 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ~>
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: '0.6'
44
54
  type: :runtime
45
55
  prerelease: false
46
- version_requirements: *70224087614540
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '0.6'
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: rake
49
- requirement: &70224087614060 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ! '>='
@@ -54,10 +69,15 @@ dependencies:
54
69
  version: '0'
55
70
  type: :runtime
56
71
  prerelease: false
57
- version_requirements: *70224087614060
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
58
78
  - !ruby/object:Gem::Dependency
59
79
  name: redcarpet
60
- requirement: &70224087613420 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
61
81
  none: false
62
82
  requirements:
63
83
  - - ~>
@@ -65,10 +85,15 @@ dependencies:
65
85
  version: '2'
66
86
  type: :runtime
67
87
  prerelease: false
68
- version_requirements: *70224087613420
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '2'
69
94
  - !ruby/object:Gem::Dependency
70
95
  name: tilt
71
- requirement: &70224087612880 !ruby/object:Gem::Requirement
96
+ requirement: !ruby/object:Gem::Requirement
72
97
  none: false
73
98
  requirements:
74
99
  - - ~>
@@ -76,7 +101,12 @@ dependencies:
76
101
  version: '1.3'
77
102
  type: :runtime
78
103
  prerelease: false
79
- version_requirements: *70224087612880
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: '1.3'
80
110
  description: Plate is a simple, static site generator and blog engine.
81
111
  email:
82
112
  - john@johntornow.com
@@ -147,8 +177,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
177
  version: 1.8.12
148
178
  requirements: []
149
179
  rubyforge_project:
150
- rubygems_version: 1.8.15
180
+ rubygems_version: 1.8.23
151
181
  signing_key:
152
182
  specification_version: 3
153
183
  summary: A static site generator and blog engine.
154
184
  test_files: []
185
+ has_rdoc: