octopress 3.0.0.rc.18 → 3.0.0.rc.19

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e06beb1aacea443d9b080887b53f8b9b7a705a47
4
- data.tar.gz: 236b3fbb3766813875bf93391bcfd62603a88430
3
+ metadata.gz: 289b5305d8acc880d13c4fa6a1d38a380c832f89
4
+ data.tar.gz: 8276219b3fce82545abaa5f55f31299c344794e5
5
5
  SHA512:
6
- metadata.gz: b6f281eb30ffe7a95d4226474f5dc34d0ac36f7d06210a31f2303f083f78921c9b5402ca567d2bbb785e1f3ef6cc7251053cacda7741850f0e34d2d4c4a833a6
7
- data.tar.gz: 73ca967e81a63cc7ae0eea83c8a916269be385f6d8d8f57750df4df18df46623164df3220b72dedbdfac65bb7c7e6fb45d4a942c4d033007702bd6a5be4ed444
6
+ metadata.gz: d12b6c564acff5052258b854f43e050bd7e21645f60591396adc9299ca2754cdcdb5e75c7d328bc68da92d27092ec443075d2a3164438d5e1c5a88bccab9009e
7
+ data.tar.gz: 4e4474c9b455b185140eec13076c2149c45130e27e5760f48c64c4d22795b7727a58238d69d7167c83ce065919816b3e2755830637b87c86efa5b8f3799e3cdf
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Octopress Changelog
2
2
 
3
+ ### 3.0.0 RC19 - 2014-12-09
4
+
5
+ - Improvements to configuration management.
6
+ - Now using _config.yml for configuration instead of _octopress.yml
7
+
3
8
  ### 3.0.0 RC18 - 2014-12-08
4
9
 
5
10
  - Loads site plugins before creating new pages, posts and drafts, allowing liquid tag processing in _template files.
data/assets/docs/index.md CHANGED
@@ -42,8 +42,8 @@ $ octopress init <PATH> [options]
42
42
  This will copy Octopress's scaffolding into the specified directory. Use the `--force` option to overwrite existing files. The scaffolding is pretty simple:
43
43
 
44
44
  ```
45
- _octopress.yml
46
45
  _templates/
46
+ draft
47
47
  post
48
48
  page
49
49
  ```
@@ -149,15 +149,32 @@ Octopress post and page templates look like this.
149
149
  layout: {{ layout }}
150
150
  title: {{ title }}
151
151
  ---
152
-
153
152
  ```
154
153
 
155
- The YAML variables will be replaced with the correct content when you create a page or post. To modify this template create a `_templates/post` file and change it as you wish. You can add additional YAML front-matter or content, and you can even create multiple templates. Choose a custom template when creating a new post or page like this.
154
+ Dates get automatically added to a template for posts, and for pages if a --date option is set.
155
+
156
+ You can add to the YAML front matter, add content below and even even use liquid tags and filters from your site's plugins. There are
157
+ a handful of local variables you can use when working with templates.
158
+
159
+ | Variable | Description |
160
+ |:-------------------|:------------------------------------------|
161
+ | `date` | The date (if set) or Time.now.iso8601 |
162
+ | `title` | The title of the page (if set) |
163
+ | `slug` | The title in slug form |
164
+ | `ymd` | The date string, YYYY/MM/DD format |
165
+ | `year` | The date's year |
166
+ | `month` | The date's month, MM |
167
+ | `day` | The date's day, DD |
168
+
169
+ By default Octopress has templates for pages, posts and drafts. You can change them or create new ones for different types of content.
170
+ To create linkposts template, add a file at `_templates/linkpost` and use it with a new post like this:
156
171
 
157
172
  ```sh
158
173
  $ octopress new post --template _templates/linkpost
159
174
  ```
160
175
 
176
+ File name extensions are unnecessary since they're just plain text anyway.
177
+
161
178
  ## Isolate
162
179
 
163
180
  If your site is taking a while to build, but you want to preview a post quickly, you can isolate that post temporarily with the isolate command. Here's the syntax:
@@ -176,7 +193,7 @@ To reintegrate all exiled posts, run `octopress integrate` which will restore al
176
193
 
177
194
  ## Configuration
178
195
 
179
- Octopress reads its configurations from `_octopress.yml`. Here's what the configuration looks like by default.
196
+ Octopress reads its configurations from `_config.yml`. Here's what the configuration looks like by default.
180
197
 
181
198
  ```yaml
182
199
  # Default extension for new posts and pages
@@ -8,15 +8,6 @@ module Octopress
8
8
 
9
9
  def self.add_common_options(c)
10
10
  c.option 'config', '--config <CONFIG_FILE>[,CONFIG_FILE2,...]', Array, 'Custom Jekyll configuration file'
11
- c.option 'octopress-config', '--octopress-config <CONFIG_FILE>', 'Custom Octopress configuration file'
12
- end
13
-
14
- def self.site(options)
15
- options = {'config' => options['config']}
16
- Jekyll.logger.log_level = :error
17
- site = Jekyll::Site.new(Jekyll.configuration(options))
18
- Jekyll.logger.log_level = :info
19
- site
20
11
  end
21
12
  end
22
13
  end
@@ -25,7 +25,7 @@ module Octopress
25
25
 
26
26
  c.action do |args, options|
27
27
  options['path'] = args.first
28
- Page.new(CommandHelpers.site(options), options).write
28
+ Page.new(Octopress.site(options), options).write
29
29
  end
30
30
  end
31
31
 
@@ -39,7 +39,7 @@ module Octopress
39
39
 
40
40
  c.action do |args, options|
41
41
  options['title'] = args.first
42
- Post.new(CommandHelpers.site(options), options).write
42
+ Post.new(Octopress.site(options), options).write
43
43
  end
44
44
  end
45
45
 
@@ -52,7 +52,7 @@ module Octopress
52
52
 
53
53
  c.action do |args, options|
54
54
  options['title'] = args.first
55
- Draft.new(CommandHelpers.site(options), options).write
55
+ Draft.new(Octopress.site(options), options).write
56
56
  end
57
57
  end
58
58
  end
@@ -13,7 +13,7 @@ module Octopress
13
13
  abort "You must specify a path." if args.empty?
14
14
  options['path'] = args.first
15
15
  options['type'] = 'post from draft'
16
- Draft.new(CommandHelpers.site(options), options).publish
16
+ Draft.new(Octopress.site(options), options).publish
17
17
  end
18
18
  end
19
19
  end
@@ -13,7 +13,7 @@ module Octopress
13
13
 
14
14
  def initialize(site, options)
15
15
  @site = site
16
- @site.plugin_manager.conscientious_require
16
+ site.plugin_manager.conscientious_require
17
17
  @config = DEFAULT_OPTIONS.merge(site.config)
18
18
  @options = options
19
19
  set_default_options
@@ -29,6 +29,10 @@ module Octopress
29
29
  @content = options['content'] || content
30
30
  end
31
31
 
32
+ def site
33
+ @site
34
+ end
35
+
32
36
  def write
33
37
  if File.exist?(path) && !@options['force']
34
38
  raise "File #{relative_path(path)} already exists. Use --force to overwrite."
@@ -70,10 +74,6 @@ module Octopress
70
74
  path.sub(local, '')
71
75
  end
72
76
 
73
- def site
74
- @site
75
- end
76
-
77
77
  def path
78
78
  return @path if @path
79
79
  file = @options['path']
@@ -107,15 +107,16 @@ module Octopress
107
107
  def convert_date(date)
108
108
  date ||= 'now'
109
109
  if date == 'now'
110
- @options['date'] = Time.now.iso8601
110
+ date = Time.now.iso8601
111
111
  else
112
112
  begin
113
- Time.parse(date.to_s, Time.now).iso8601
113
+ date = Time.parse(date.to_s, Time.now).iso8601
114
114
  rescue => error
115
115
  puts 'Could not parse date. Try formatting it like YYYY-MM-DD HH:MM'
116
116
  abort error.message
117
117
  end
118
118
  end
119
+ date
119
120
  end
120
121
 
121
122
  # Load the user provided or default template for a new post or page.
@@ -148,9 +149,19 @@ module Octopress
148
149
  # Render Liquid vars in YAML front-matter.
149
150
  def parse_template(input)
150
151
 
152
+ vars = @options.dup
153
+
151
154
  if @config['titlecase']
152
- @options['title'].titlecase!
155
+ vars['title'].titlecase!
153
156
  end
157
+
158
+ vars['slug'] = title_slug
159
+ date = Time.parse(vars['date'] || Time.now.iso8601)
160
+ vars['year'] = date.year
161
+ vars['month'] = date.strftime('%m')
162
+ vars['day'] = date.strftime('%d')
163
+ vars['ymd'] = date.strftime('%D')
164
+
154
165
  # If possible only parse the YAML front matter.
155
166
  # If YAML front-matter dashes aren't present parse the whole
156
167
  # template and add dashes.
@@ -159,20 +170,33 @@ module Octopress
159
170
  parsed = if input =~ /\A-{3}\s+(.+?)\s+-{3}(.+)?/m
160
171
  input = $1
161
172
  content = $2
162
- if @options['date'] && !(input =~ /date:/)
163
- input += "\ndate: #{@options['date']}"
173
+ if vars['date'] && !(input =~ /date:/)
174
+ input += "\ndate: #{vars['date']}"
164
175
  end
165
176
  else
166
177
  content = ''
167
178
  end
168
179
 
169
180
  template = Liquid::Template.parse(input)
170
- "---\n#{template.render(@options).strip}\n---\n#{content}"
181
+ "---\n#{template.render(vars).strip}\n---\n#{content}"
171
182
  end
172
183
 
173
184
  def date_slug
174
185
  @options['date'].split('T')[0]
175
186
  end
187
+
188
+ # Returns a string which is url compatible.
189
+ #
190
+ def title_slug
191
+ value = (@options['slug'] || @options['title']).downcase
192
+ value.gsub!(/[^\x00-\x7F]/u, '')
193
+ value.gsub!(/(&amp;|&)+/, 'and')
194
+ value.gsub!(/[']+/, '')
195
+ value.gsub!(/\W+/, ' ')
196
+ value.strip!
197
+ value.gsub!(' ', '-')
198
+ value
199
+ end
176
200
 
177
201
  def front_matter(vars)
178
202
  fm = []
@@ -27,18 +27,5 @@ module Octopress
27
27
  front_matter %w{layout title date}
28
28
  end
29
29
 
30
- # Returns a string which is url compatible.
31
- #
32
- def title_slug
33
- value = (@options['slug'] || @options['title']).downcase
34
- value.gsub!(/[^\x00-\x7F]/u, '')
35
- value.gsub!(/(&amp;|&)+/, 'and')
36
- value.gsub!(/[']+/, '')
37
- value.gsub!(/\W+/, ' ')
38
- value.strip!
39
- value.gsub!(' ', '-')
40
- value
41
- end
42
-
43
30
  end
44
31
  end
@@ -1,3 +1,3 @@
1
1
  module Octopress
2
- VERSION = "3.0.0.rc.18"
2
+ VERSION = "3.0.0.rc.19"
3
3
  end
data/lib/octopress.rb CHANGED
@@ -2,7 +2,6 @@ require 'mercenary'
2
2
  require 'titlecase'
3
3
 
4
4
  module Octopress
5
- require 'octopress/configuration'
6
5
  require 'octopress/command'
7
6
  require 'octopress/version'
8
7
  require 'octopress/commands/new'
@@ -28,8 +27,25 @@ module Octopress
28
27
  @logger
29
28
  end
30
29
 
31
- def self.config(options={})
32
- @config ||= Configuration.config(options)
30
+ # Cache Jekyll's site configuration
31
+ #
32
+ def self.configuration(options={})
33
+ if @site
34
+ @site.config
35
+ else
36
+ @config ||= Jekyll.configuration({'config' => options['config']})
37
+ end
38
+ end
39
+
40
+ # Cache Jekyll's site
41
+ #
42
+ def self.site(options={})
43
+ if !@site
44
+ Jekyll.logger.log_level = :error
45
+ @site = Jekyll::Site.new(configuration(options))
46
+ Jekyll.logger.log_level = :info
47
+ end
48
+ @site
33
49
  end
34
50
 
35
51
  def self.gem_dir(dir='')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octopress
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.rc.18
4
+ version: 3.0.0.rc.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Mathis
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-12-09 00:00:00.000000000 Z
12
+ date: 2014-12-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mercenary
@@ -178,7 +178,6 @@ files:
178
178
  - lib/octopress/commands/isolate.rb
179
179
  - lib/octopress/commands/new.rb
180
180
  - lib/octopress/commands/publish.rb
181
- - lib/octopress/configuration.rb
182
181
  - lib/octopress/draft.rb
183
182
  - lib/octopress/isolate.rb
184
183
  - lib/octopress/page.rb
@@ -187,14 +186,12 @@ files:
187
186
  - lib/octopress/utils.rb
188
187
  - lib/octopress/version.rb
189
188
  - octopress.gemspec
190
- - scaffold/_octopress.yml
191
189
  - scaffold/_templates/draft
192
190
  - scaffold/_templates/page
193
191
  - scaffold/_templates/post
194
192
  - test/Gemfile
195
193
  - test/_config.yml
196
194
  - test/_expected/blank/_config.yml
197
- - test/_expected/blank/_octopress.yml
198
195
  - test/_expected/blank/_templates/draft
199
196
  - test/_expected/blank/_templates/page
200
197
  - test/_expected/blank/_templates/post
@@ -226,10 +223,6 @@ files:
226
223
  - test/_expected/publish-draft/_posts/2014-03-10-some-cool-idea.markdown
227
224
  - test/_layouts/page.html
228
225
  - test/_layouts/post.html
229
- - test/_octopress.yml
230
- - test/_templates/draft
231
- - test/_templates/page
232
- - test/_templates/post
233
226
  homepage: http://octopress.org
234
227
  licenses:
235
228
  - MIT
@@ -259,7 +252,6 @@ test_files:
259
252
  - test/Gemfile
260
253
  - test/_config.yml
261
254
  - test/_expected/blank/_config.yml
262
- - test/_expected/blank/_octopress.yml
263
255
  - test/_expected/blank/_templates/draft
264
256
  - test/_expected/blank/_templates/page
265
257
  - test/_expected/blank/_templates/post
@@ -291,7 +283,3 @@ test_files:
291
283
  - test/_expected/publish-draft/_posts/2014-03-10-some-cool-idea.markdown
292
284
  - test/_layouts/page.html
293
285
  - test/_layouts/post.html
294
- - test/_octopress.yml
295
- - test/_templates/draft
296
- - test/_templates/page
297
- - test/_templates/post
@@ -1,54 +0,0 @@
1
- module Octopress
2
- module Configuration
3
-
4
- DEFAULTS = {
5
- 'post_ext' => 'markdown',
6
- 'page_ext' => 'html',
7
- 'post_layout' => 'post',
8
- 'page_layout' => 'page',
9
- 'titlecase' => true
10
- }
11
-
12
- # Read _octopress.yml and merge with defaults
13
- #
14
- def self.config(options={})
15
-
16
- # Cache loading the config file
17
- unless @user_config
18
- file = options['octopress-config'] || '_octopress.yml'
19
-
20
- if File.exist? file
21
- config = SafeYAML.load_file(file) || {}
22
- else
23
- config = {}
24
- end
25
-
26
- # Allow cli extensioins to override default user configuration
27
- if options['override']
28
- config = Jekyll::Utils.deep_merge_hashes(config, options['override'])
29
- end
30
-
31
- # Merge Octopress defaults
32
- @user_config = Jekyll::Utils.deep_merge_hashes(DEFAULTS, config)
33
- end
34
-
35
- @user_config
36
- end
37
-
38
- # Read Jekyll's _config.yml merged with Jekyll's defaults
39
- #
40
- def self.jekyll_config(options={})
41
- return @jekyll_config if @jekyll_config
42
-
43
- configs = Jekyll::Configuration::DEFAULTS
44
-
45
- (options['config'] || ['_config.yml']).each do |file|
46
- if File.exist? file
47
- configs = Jekyll::Utils.deep_merge_hashes(configs, SafeYAML.load_file(file) || {})
48
- end
49
- end
50
-
51
- @jekyll_config = configs
52
- end
53
- end
54
- end
@@ -1,11 +0,0 @@
1
- # Default extension for new posts and pages
2
- post_ext: markdown
3
- page_ext: html
4
-
5
- # Default templates for posts and pages
6
- # Found in _templates/
7
- post_layout: post
8
- page_layout: page
9
-
10
- # Format titles with titlecase?
11
- titlecase: true
@@ -1,11 +0,0 @@
1
- # Default extension for new posts and pages
2
- post_ext: markdown
3
- page_ext: html
4
-
5
- # Default templates for posts and pages
6
- # Found in _templates/
7
- post_layout: post
8
- page_layout: page
9
-
10
- # Format titles with titlecase?
11
- titlecase: true
data/test/_octopress.yml DELETED
@@ -1,11 +0,0 @@
1
- # Default extension for new posts and pages
2
- post_ext: markdown
3
- page_ext: html
4
-
5
- # Default templates for posts and pages
6
- # Found in _templates/
7
- post_layout: post
8
- page_layout: page
9
-
10
- # Format titles with titlecase?
11
- titlecase: true
@@ -1,4 +0,0 @@
1
- ---
2
- layout: {{ layout }}
3
- title: {{ title }}
4
- ---
data/test/_templates/page DELETED
@@ -1,4 +0,0 @@
1
- ---
2
- layout: {{ layout }}
3
- title: {{ title }}
4
- ---
data/test/_templates/post DELETED
@@ -1,5 +0,0 @@
1
- ---
2
- layout: {{ layout }}
3
- title: {{ title }}
4
- date: {{ date }}
5
- ---