plate 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,8 @@
1
+ ## Plate 0.5.4
2
+
3
+ * Added config option to command line utility to load a specific config file.
4
+ * Allowed new post command to have default options stored in config.yml file.
5
+
1
6
  ## Plate 0.5.3
2
7
 
3
8
  * Added support for Sass @import statements.
data/README.md CHANGED
@@ -2,9 +2,11 @@
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. It takes a folder full of Markdown files and turns it into a site that you can host anywhere. The output is a plain old static HTML site. In addition to basic formatting with Markdown, Plate also supports generating asset files with CoffeeScript, Sass and others.
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.
6
6
 
7
- Requires Ruby 1.9.2 or 1.9.3. For additional processing, install CoffeeScript, Sass, Haml and other formatters.
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.
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.
8
10
 
9
11
  ## Installation
10
12
 
@@ -16,10 +18,20 @@ Or, create a `Gemfile` and add:
16
18
 
17
19
  ## Command line
18
20
 
21
+ Plate is designed to be a command-line utility. Here is a rundown of some of the basic commands:
22
+
23
+ ### Creating a new site
24
+
19
25
  To generate a new site with plate, run the following command:
20
26
 
21
27
  platify .
22
28
 
29
+ Or, with the normal `plate` command:
30
+
31
+ plate new .
32
+
33
+ ### Building a site
34
+
23
35
  To build your site, run:
24
36
 
25
37
  plate build
@@ -31,6 +43,29 @@ Or, just run `plate` without any options to build the site.
31
43
  To show details about the site build, enable verbose mode:
32
44
 
33
45
  plate --verbose
46
+
47
+ When writing a post, it is sometimes helpful to watch the site for changes and just reload content after each file save. To enable this mode, run the build command with the `--watch` option. Every time a file is saved, the utility will rebuild that file so you can simply hit refresh in your browser to see the changes without rebuilding the entire site.
48
+
49
+ plate --watch
50
+
51
+ ### Creating a new post
52
+
53
+ To create a new blog post with the default options, run:
54
+
55
+ plate post "New Post Name"
56
+
57
+ You can also put default post options (such as a category or layout) into the command line:
58
+
59
+ plate post "New Post Name" --category Articles --layout post
60
+
61
+ Or, if you always use the same default category and/or layout, you can put those options into your config file instead like so:
62
+
63
+ # In config/plate.yml
64
+ ...
65
+ post_defaults:
66
+ category: Articles
67
+ layout: post
68
+ ...
34
69
 
35
70
  ## Directory Structure
36
71
 
@@ -76,6 +111,10 @@ An example of a helper file located in `lib/sample_helper.rb`
76
111
 
77
112
  Then, in your `.erb` view you can call `sample_helper_method`.
78
113
 
114
+ ## Full Documentation
115
+
116
+ View the [full documentation on rdoc.info](http://rdoc.info/gems/plate/frames)
117
+
79
118
  ## Issues
80
119
 
81
120
  If you have any issues or find bugs running Plate, please [report them on Github](https://github.com/jdtornow/plate/issues). While most functions should be stable, Plate is still in its infancy and certain issues may be present.
@@ -33,6 +33,12 @@ module Plate
33
33
  @loaded = false
34
34
  end
35
35
 
36
+ # Returns the options for this site.
37
+ def config
38
+ self.load!
39
+ @options
40
+ end
41
+
36
42
  # A unique id for this site, based off of the source directory
37
43
  def id
38
44
  check_source!
@@ -223,6 +229,12 @@ module Plate
223
229
  # option:
224
230
  #
225
231
  # Builder.new(source, destination, :config => 'config/other-file.yml')
232
+ #
233
+ # On the command line when building a site, or creating a new post, you can specify the
234
+ # custom config file as a command line option as well:
235
+ #
236
+ # plate build --config config/other-file.yml
237
+ #
226
238
  def load_config_file!
227
239
  config_file = 'config/plate.yml'
228
240
 
@@ -249,6 +261,7 @@ module Plate
249
261
 
250
262
  if yml
251
263
  yml.symbolize_keys!
264
+ yml.values.select { |value| Hash === value }.each { |hash| hash.symbolize_keys! }
252
265
  @options = @options.reverse_merge(yml)
253
266
  log("Options loaded from file", :indent)
254
267
  end
@@ -33,6 +33,10 @@ module Plate
33
33
  options[:category] = c
34
34
  end
35
35
 
36
+ opts.on('--config [PATH]', '-C', 'Set the config file location for the site.') do |c|
37
+ options[:config] = c
38
+ end
39
+
36
40
  opts.on('--destination [PATH]', '-d', 'Set the destination directory for this build.') do |d|
37
41
  @destination = File.expand_path(d)
38
42
  end
@@ -184,11 +188,17 @@ module Plate
184
188
  title = args.size == 0 ? "" : args[0]
185
189
  slug = title.parameterize
186
190
  date = Time.now
191
+
192
+ # if there are any post defaults in the config file, use those as the default options
193
+ if builder.config.has_key?(:post_defaults)
194
+ options.reverse_merge!(builder.config[:post_defaults])
195
+ end
196
+
187
197
  category = options[:category] ? "\ncategory: #{options[:category]}" : ""
188
198
  layout = options[:layout] ? "\nlayout: #{options[:layout]}" : ""
189
199
 
190
200
  filename = File.join(self.source, 'posts', date.strftime('%Y/%m'), "#{date.strftime('%Y-%m-%d')}-#{slug}.md")
191
- content = %Q(---\ntitle: "#{title}"\ndate: #{date.strftime('%Y-%m-%d %H:%M:%S')}#{category}#{layout}\ntags: []\n\n# #{title}\n\n)
201
+ content = %Q(---\ntitle: "#{title}"\ndate: #{date.strftime('%Y-%m-%d %H:%M:%S')}#{category}#{layout}\ntags: []\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.)
192
202
 
193
203
  FileUtils.mkdir_p(File.dirname(filename))
194
204
  File.open(filename, 'w') { |f| f.write(content) }
@@ -57,6 +57,11 @@ module Plate
57
57
  @post_index ||= self.posts.index(self.post)
58
58
  end
59
59
 
60
+ # Find all posts for the given category
61
+ def posts_for_category(category)
62
+ self.posts.select { |p| p.category == category }
63
+ end
64
+
60
65
  # Find all posts for the given year, month and optional category.
61
66
  def posts_for_month(year, month, category = nil)
62
67
  result = []
@@ -1,3 +1,3 @@
1
1
  module Plate
2
- VERSION = "0.5.3" unless defined?(::Plate::VERSION)
2
+ VERSION = "0.5.4" unless defined?(::Plate::VERSION)
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-12 00:00:00.000000000Z
12
+ date: 2012-03-24 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
- requirement: &70129250117980 !ruby/object:Gem::Requirement
16
+ requirement: &70215040139900 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '3.2'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70129250117980
24
+ version_requirements: *70215040139900
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: directory_watcher
27
- requirement: &70129250117600 !ruby/object:Gem::Requirement
27
+ requirement: &70215040141660 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70129250117600
35
+ version_requirements: *70215040141660
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: i18n
38
- requirement: &70129250117060 !ruby/object:Gem::Requirement
38
+ requirement: &70215040157640 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0.6'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70129250117060
46
+ version_requirements: *70215040157640
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rake
49
- requirement: &70129250116640 !ruby/object:Gem::Requirement
49
+ requirement: &70215040166620 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70129250116640
57
+ version_requirements: *70215040166620
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: redcarpet
60
- requirement: &70129250116100 !ruby/object:Gem::Requirement
60
+ requirement: &70215040168380 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '2'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70129250116100
68
+ version_requirements: *70215040168380
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: tilt
71
- requirement: &70129250115600 !ruby/object:Gem::Requirement
71
+ requirement: &70215040167820 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '1.3'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *70129250115600
79
+ version_requirements: *70215040167820
80
80
  description: Plate is a simple, static site generator and blog engine.
81
81
  email:
82
82
  - john@johntornow.com