octopress 3.0.0.alpha3 → 3.0.0.alpha4
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/lib/octopress.rb +6 -17
- data/lib/octopress/commands/build.rb +21 -0
- data/lib/octopress/commands/docs.rb +42 -0
- data/lib/octopress/commands/doctor.rb +24 -0
- data/lib/octopress/commands/helpers.rb +20 -0
- data/lib/octopress/commands/serve.rb +31 -0
- data/lib/octopress/configuration.rb +35 -0
- data/lib/octopress/draft.rb +1 -1
- data/lib/octopress/page.rb +27 -10
- data/lib/octopress/post.rb +4 -3
- data/lib/octopress/version.rb +1 -1
- data/octopress.gemspec +1 -1
- metadata +10 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 143b9c71ad561fd9a939fea1b64efee7c076d453
|
4
|
+
data.tar.gz: 958d911bbe77152603ff177fec4a2c9f46de50cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 102c7015e4688e0f0dcce8457bcb4ebb5a9aa98092036123591d1da348bff257220a31fb55c533e229fd6ad6708b51b28ec581a9a6e1d8cd96b9f9d22718cdae
|
7
|
+
data.tar.gz: 9600f8aea81d1a57efccbefdd5402162e32faed45ec96518e981ce4cc7cac2fa91d14fb719b5cdaa3ac97f671493a27bab8a7f57bf781d71fa8c10690a3e24f5
|
data/lib/octopress.rb
CHANGED
@@ -1,9 +1,14 @@
|
|
1
1
|
module Octopress
|
2
2
|
require 'octopress/core_ext'
|
3
|
+
require 'octopress/configuration'
|
3
4
|
require 'octopress/command'
|
4
5
|
require 'octopress/version'
|
5
6
|
require 'octopress/commands/new'
|
6
7
|
require 'octopress/commands/publish'
|
8
|
+
require 'octopress/commands/build'
|
9
|
+
require 'octopress/commands/serve'
|
10
|
+
require 'octopress/commands/doctor'
|
11
|
+
require 'octopress/commands/docs'
|
7
12
|
|
8
13
|
autoload :Page, 'octopress/page'
|
9
14
|
autoload :Post, 'octopress/post'
|
@@ -14,30 +19,14 @@ module Octopress
|
|
14
19
|
octopress-ink
|
15
20
|
]
|
16
21
|
|
17
|
-
DEFAULTS = { 'octopress' => {
|
18
|
-
'new_post_extension' => 'markdown',
|
19
|
-
'new_page_extension' => 'html',
|
20
|
-
'new_post_layout' => 'post',
|
21
|
-
'new_page_layout' => 'page',
|
22
|
-
'titlecase' => true
|
23
|
-
}}
|
24
|
-
|
25
22
|
def self.logger
|
26
23
|
@logger ||= Logger.new(STDOUT)
|
27
24
|
@logger.level = Logger::DEBUG
|
28
25
|
@logger
|
29
26
|
end
|
30
27
|
|
31
|
-
def self.site(options={})
|
32
|
-
@site ||= Jekyll::Site.new(config(options))
|
33
|
-
end
|
34
|
-
|
35
28
|
def self.config(options={})
|
36
|
-
|
37
|
-
Jekyll.logger.log_level = Jekyll::Stevenson::WARN
|
38
|
-
@config ||= DEFAULTS.deep_merge Jekyll.configuration(options)
|
39
|
-
Jekyll.logger.log_level = log_level
|
40
|
-
@config
|
29
|
+
Configuration.config(options)
|
41
30
|
end
|
42
31
|
|
43
32
|
def self.require_blessed_gems
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'jekyll'
|
2
|
+
require File.expand_path('helpers', File.dirname(__FILE__))
|
3
|
+
|
4
|
+
module Octopress
|
5
|
+
class Build < Command
|
6
|
+
def self.init_with_program(p)
|
7
|
+
p.command(:build) do |c|
|
8
|
+
c.syntax 'octopress build [options]'
|
9
|
+
c.description 'Build your site'
|
10
|
+
CommandHelpers.add_build_options(c)
|
11
|
+
|
12
|
+
c.action do |args, options|
|
13
|
+
options = CommandHelpers.normalize_options(options)
|
14
|
+
options = ::Jekyll.configuration(options.to_symbol_keys)
|
15
|
+
::Jekyll::Commands::Build.process(options)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'jekyll'
|
2
|
+
require File.expand_path('helpers', File.dirname(__FILE__))
|
3
|
+
|
4
|
+
module Octopress
|
5
|
+
class Docs < Command
|
6
|
+
def self.init_with_program(p)
|
7
|
+
p.command(:docs) do |c|
|
8
|
+
c.syntax 'octopress docs'
|
9
|
+
c.description "Soon: Launch local server with docs for Octopress v#{Octopress::VERSION}"
|
10
|
+
|
11
|
+
c.option 'port', '-P', '--port [PORT]', 'Port to listen on'
|
12
|
+
c.option 'host', '-H', '--host [HOST]', 'Host to bind to'
|
13
|
+
c.option 'jekyll', '--jekyll', "Launch local server with docs for Jekyll v#{Jekyll::VERSION}"
|
14
|
+
|
15
|
+
c.action do |args, options|
|
16
|
+
|
17
|
+
# Only show jekyll docs if the jekyll flag was used
|
18
|
+
#
|
19
|
+
if options['jekyll']
|
20
|
+
options.delete('jekyll')
|
21
|
+
|
22
|
+
# Find local Jekyll gem path
|
23
|
+
#
|
24
|
+
spec = Gem::Specification.find_by_name("jekyll")
|
25
|
+
gem_path = spec.gem_dir
|
26
|
+
|
27
|
+
options = CommandHelpers.normalize_options(options)
|
28
|
+
options = ::Jekyll.configuration(options.to_symbol_keys.merge!({
|
29
|
+
'source' => "#{gem_path}/site",
|
30
|
+
'destination' => "#{gem_path}/site/_site"
|
31
|
+
}))
|
32
|
+
|
33
|
+
::Jekyll::Commands::Build.process(options)
|
34
|
+
::Jekyll::Commands::Serve.process(options)
|
35
|
+
else
|
36
|
+
puts "Sorry, not yet. View Octopress docs on http://octopress.org or view Jekyll docs locally by running `octopress docs --jekyll`"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'jekyll'
|
2
|
+
require File.expand_path('helpers', File.dirname(__FILE__))
|
3
|
+
|
4
|
+
module Octopress
|
5
|
+
class Doctor < Command
|
6
|
+
def self.init_with_program(p)
|
7
|
+
p.command(:doctor) do |c|
|
8
|
+
c.alias(:hyde)
|
9
|
+
|
10
|
+
c.syntax 'octopress doctor'
|
11
|
+
c.description 'Search site and print specific deprecation warnings'
|
12
|
+
|
13
|
+
c.option 'config', '--config CONFIG_FILE[,CONFIG_FILE2,...]', Array, 'Custom configuration file'
|
14
|
+
|
15
|
+
c.action do |args, options|
|
16
|
+
options = CommandHelpers.normalize_options(options)
|
17
|
+
options = Jekyll.configuration(options.to_symbol_keys)
|
18
|
+
::Jekyll::Commands::Doctor.process(options)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Octopress
|
2
|
+
module CommandHelpers
|
3
|
+
def self.add_build_options(c)
|
4
|
+
c.option 'config', '--config CONFIG_FILE[,CONFIG_FILE2,...]', Array, 'Custom configuration file'
|
5
|
+
c.option 'future', '--future', 'Publishes posts with a future date'
|
6
|
+
c.option 'limit_posts', '--limit_posts MAX_POSTS', Integer, 'Limits the number of posts to parse and publish'
|
7
|
+
c.option 'watch', '--watch', 'Watch for changes and rebuild'
|
8
|
+
c.option 'list', '--lsi', 'Use LSI for improved related posts'
|
9
|
+
c.option 'drafts','-D', '--drafts', 'Render posts in the _drafts folder'
|
10
|
+
c.option 'verbose', '--verbose', 'Print verbose output.'
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.normalize_options(options)
|
14
|
+
if drafts_state = options.delete('drafts')
|
15
|
+
options['show_drafts'] = drafts_state
|
16
|
+
end
|
17
|
+
options
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'jekyll'
|
2
|
+
require File.expand_path('helpers', File.dirname(__FILE__))
|
3
|
+
|
4
|
+
module Octopress
|
5
|
+
class Serve < Command
|
6
|
+
def self.init_with_program(p)
|
7
|
+
p.command(:serve) do |c|
|
8
|
+
c.alias(:server)
|
9
|
+
|
10
|
+
c.syntax 'jekyll serve [options]'
|
11
|
+
c.description 'Serve your site locally'
|
12
|
+
|
13
|
+
CommandHelpers.add_build_options(c)
|
14
|
+
|
15
|
+
c.option 'detach', '-B', '--detach', 'Run the server in the background (detach)'
|
16
|
+
c.option 'port', '-P', '--port PORT', 'Port to listen on'
|
17
|
+
c.option 'host', '-H', '--host HOST', 'Host to bind to'
|
18
|
+
c.option 'baseurl', '--baseurl URL', 'Base URL'
|
19
|
+
|
20
|
+
c.action do |args, options|
|
21
|
+
options.default :serving => true
|
22
|
+
options = CommandHelpers.normalize_options(options)
|
23
|
+
options = ::Jekyll.configuration(options.to_symbol_keys)
|
24
|
+
::Jekyll::Commands::Build.process(options)
|
25
|
+
::Jekyll::Commands::Serve.process(options)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Octopress
|
2
|
+
module Configuration
|
3
|
+
|
4
|
+
DEFAULTS = {
|
5
|
+
'new_post_extension' => 'markdown',
|
6
|
+
'new_page_extension' => 'html',
|
7
|
+
'new_post_layout' => 'post',
|
8
|
+
'new_page_layout' => 'page',
|
9
|
+
'titlecase' => true
|
10
|
+
}
|
11
|
+
|
12
|
+
def self.config(options={})
|
13
|
+
return @config if @config
|
14
|
+
|
15
|
+
file = '_octopress.yml'
|
16
|
+
config = {}
|
17
|
+
if File.exist? file
|
18
|
+
config = YAML.safe_load(File.open(file))
|
19
|
+
end
|
20
|
+
#config['jekyll'] = jekyll_config(options)
|
21
|
+
@config = DEFAULTS.deep_merge(config)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.jekyll_config(options={})
|
25
|
+
return @jekyll_config if @jekyll_config
|
26
|
+
|
27
|
+
log_level = Jekyll.logger.log_level
|
28
|
+
Jekyll.logger.log_level = Jekyll::Stevenson::WARN
|
29
|
+
jekyll_config = Jekyll.configuration(options)
|
30
|
+
Jekyll.logger.log_level = log_level
|
31
|
+
|
32
|
+
@jekyll_config = jekyll_config
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/octopress/draft.rb
CHANGED
data/lib/octopress/page.rb
CHANGED
@@ -10,7 +10,7 @@ module Octopress
|
|
10
10
|
|
11
11
|
def write
|
12
12
|
if File.exist?(path) && !@options['force']
|
13
|
-
abort "File #{relative_path} already exists"
|
13
|
+
abort "File #{relative_path} already exists"
|
14
14
|
end
|
15
15
|
|
16
16
|
FileUtils.mkdir_p(File.dirname(path))
|
@@ -27,16 +27,21 @@ module Octopress
|
|
27
27
|
path.sub(local, '')
|
28
28
|
end
|
29
29
|
|
30
|
+
def source
|
31
|
+
Configuration.jekyll_config(@options)['source']
|
32
|
+
end
|
33
|
+
|
30
34
|
def path
|
35
|
+
return @path if @path
|
31
36
|
file = @options['path']
|
32
37
|
|
33
38
|
# If path ends with a slash, make it an index
|
34
|
-
file
|
39
|
+
file += "index" if file =~ /\/$/
|
35
40
|
|
36
41
|
# if path has no extension, add the default extension
|
37
|
-
file
|
42
|
+
file += ".#{extension}" unless file =~ /\.\w+$/
|
38
43
|
|
39
|
-
File.join(
|
44
|
+
@path = File.join(source, file)
|
40
45
|
end
|
41
46
|
|
42
47
|
def extension
|
@@ -45,9 +50,10 @@ module Octopress
|
|
45
50
|
|
46
51
|
def set_default_options
|
47
52
|
@options['type'] ||= 'page'
|
48
|
-
@options['layout'] = @config['
|
53
|
+
@options['layout'] = @config['new_page_layout']
|
49
54
|
@options['date'] = convert_date @options['date']
|
50
|
-
@options['extension'] ||= @config['
|
55
|
+
@options['extension'] ||= @config['new_page_extension']
|
56
|
+
@options['template'] ||= @config['new_page_template']
|
51
57
|
end
|
52
58
|
|
53
59
|
def convert_date(date)
|
@@ -64,18 +70,29 @@ module Octopress
|
|
64
70
|
#
|
65
71
|
def content
|
66
72
|
file = @options['template']
|
67
|
-
file = File.join(
|
73
|
+
file = File.join(source, '_templates', file) if file
|
68
74
|
if file
|
69
|
-
|
75
|
+
abort "No template found at #{file}" unless File.exist? file
|
70
76
|
parse_template Pathname.new(file).read
|
71
77
|
else
|
72
78
|
parse_template default_content
|
73
79
|
end
|
74
80
|
end
|
75
81
|
|
82
|
+
# Render Liquid vars in YAML front-matter.
|
76
83
|
def parse_template(input)
|
77
|
-
|
78
|
-
|
84
|
+
|
85
|
+
# If possible only parse the YAML front matter.
|
86
|
+
# If YAML front-matter dashes aren't present parse the whole
|
87
|
+
# template and add dashes.
|
88
|
+
#
|
89
|
+
parsed = if input =~ /\A-{3}\s+(.+?)\s+-{3}\s+(.+)/m
|
90
|
+
template = Liquid::Template.parse($1)
|
91
|
+
"---\n#{template.render(@options)}\n---\n\n#{$2}"
|
92
|
+
else
|
93
|
+
template = Liquid::Template.parse(input)
|
94
|
+
"---\n#{template.render(@options)}\n---\n\n"
|
95
|
+
end
|
79
96
|
end
|
80
97
|
|
81
98
|
def date_slug
|
data/lib/octopress/post.rb
CHANGED
@@ -3,15 +3,16 @@ module Octopress
|
|
3
3
|
|
4
4
|
def set_default_options
|
5
5
|
@options['type'] ||= 'post'
|
6
|
-
@options['layout'] = @config['
|
6
|
+
@options['layout'] = @config['new_post_layout']
|
7
7
|
@options['title'] ||= 'New Post'
|
8
8
|
@options['date'] = convert_date @options['date'] || Time.now
|
9
|
-
@options['extension'] ||= @config['
|
9
|
+
@options['extension'] ||= @config['new_post_extension']
|
10
|
+
@options['template'] ||= @config['new_post_template']
|
10
11
|
end
|
11
12
|
|
12
13
|
def path
|
13
14
|
name = "#{date_slug}-#{title_slug}.#{extension}"
|
14
|
-
File.join(
|
15
|
+
File.join(source, '_posts', name)
|
15
16
|
end
|
16
17
|
|
17
18
|
# Post template defaults
|
data/lib/octopress/version.rb
CHANGED
data/octopress.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_runtime_dependency "mercenary", "~> 0.1.0"
|
22
|
-
spec.add_runtime_dependency "jekyll", "~> 1.
|
22
|
+
spec.add_runtime_dependency "jekyll", "~> 1.4.2"
|
23
23
|
|
24
24
|
spec.add_development_dependency "bundler", "~> 1.3"
|
25
25
|
spec.add_development_dependency "pry-debugger"
|
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.
|
4
|
+
version: 3.0.0.alpha4
|
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-02-
|
12
|
+
date: 2014-02-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mercenary
|
@@ -31,14 +31,14 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - ~>
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: 1.
|
34
|
+
version: 1.4.2
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - ~>
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: 1.
|
41
|
+
version: 1.4.2
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: bundler
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -99,8 +99,14 @@ files:
|
|
99
99
|
- bin/octopress
|
100
100
|
- lib/octopress.rb
|
101
101
|
- lib/octopress/command.rb
|
102
|
+
- lib/octopress/commands/build.rb
|
103
|
+
- lib/octopress/commands/docs.rb
|
104
|
+
- lib/octopress/commands/doctor.rb
|
105
|
+
- lib/octopress/commands/helpers.rb
|
102
106
|
- lib/octopress/commands/new.rb
|
103
107
|
- lib/octopress/commands/publish.rb
|
108
|
+
- lib/octopress/commands/serve.rb
|
109
|
+
- lib/octopress/configuration.rb
|
104
110
|
- lib/octopress/core_ext.rb
|
105
111
|
- lib/octopress/draft.rb
|
106
112
|
- lib/octopress/page.rb
|