bgotink-hyde 0.1.0 → 0.2.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/History.md +12 -1
- data/bgotink-hyde.gemspec +3 -2
- data/lib/hyde.rb +5 -4
- data/lib/hyde/commands/build.rb +5 -7
- data/lib/hyde/commands/serve.rb +2 -1
- data/lib/hyde/configuration.rb +15 -3
- data/lib/hyde/{jekyllfile.rb → page.rb} +24 -12
- data/lib/hyde/post.rb +13 -0
- data/lib/hyde/site.rb +112 -58
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b081f21b5c869455b93b00f9ebe7eff282203e4b
|
4
|
+
data.tar.gz: a9cb5777018d9612c8e3ae2128f05c5a833760ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb102e9467d222bb06d68f95132fa58df9ae963497e540fddf7ce179c2c03b84007962a087d707022fe783c7cd408c8fed1b853d018f6b079a628507a1a7f81a
|
7
|
+
data.tar.gz: 807d0a1b29aa0f87988260d036239c8ff541eaaf6ef7f87244805f5085c063dc1a2db109debcbd856270c27fce8dd2e6be05a729b0e91efd6eab783a1af35c45
|
data/History.md
CHANGED
@@ -1,4 +1,15 @@
|
|
1
|
-
##
|
1
|
+
## 0.2.0 / 2014-01-08
|
2
|
+
|
3
|
+
### Major Enhancements
|
4
|
+
* moved from `map` to `pages` and `posts` in `_config.yml`
|
5
|
+
* allow files to be included in `pages` and `posts` directly instead of requiring directories
|
6
|
+
* automatically checkout jekyll template from different branch while building
|
7
|
+
* also allow destination to be a git branch
|
8
|
+
|
9
|
+
### Bugfixes
|
10
|
+
* fixed rake release
|
11
|
+
|
12
|
+
## 0.1.0 / 2014-01-08
|
2
13
|
|
3
14
|
### Major Enhancements
|
4
15
|
* copied and modified gemspec, rakefile etc. from [jekyll](//github.com/jekyll/jekyll)
|
data/bgotink-hyde.gemspec
CHANGED
@@ -4,7 +4,7 @@ Gem::Specification.new do |s|
|
|
4
4
|
s.rubygems_version = '1.3.5'
|
5
5
|
|
6
6
|
s.name = 'bgotink-hyde'
|
7
|
-
s.version = '0.
|
7
|
+
s.version = '0.2.0'
|
8
8
|
s.license = 'MIT'
|
9
9
|
s.date = '2014-01-08'
|
10
10
|
s.rubyforge_project = 'bgotink-hyde'
|
@@ -59,7 +59,8 @@ Gem::Specification.new do |s|
|
|
59
59
|
lib/hyde/commands/build.rb
|
60
60
|
lib/hyde/commands/serve.rb
|
61
61
|
lib/hyde/configuration.rb
|
62
|
-
lib/hyde/
|
62
|
+
lib/hyde/page.rb
|
63
|
+
lib/hyde/post.rb
|
63
64
|
lib/hyde/site.rb
|
64
65
|
lib/hyde/stevenson.rb
|
65
66
|
]
|
data/lib/hyde.rb
CHANGED
@@ -10,7 +10,8 @@ def require_all(directory)
|
|
10
10
|
end
|
11
11
|
|
12
12
|
require 'hyde/configuration'
|
13
|
-
require 'hyde/
|
13
|
+
require 'hyde/page'
|
14
|
+
require 'hyde/post'
|
14
15
|
require 'hyde/site'
|
15
16
|
require 'hyde/command'
|
16
17
|
require 'hyde/stevenson'
|
@@ -18,7 +19,7 @@ require 'hyde/stevenson'
|
|
18
19
|
require_all 'hyde/commands'
|
19
20
|
|
20
21
|
module Hyde
|
21
|
-
VERSION = '0.
|
22
|
+
VERSION = '0.2.0'
|
22
23
|
|
23
24
|
# Public: Generate a Hyde configuration Hash by merging the default
|
24
25
|
# options with anything in _config.yml, and adding the given options on top.
|
@@ -43,8 +44,8 @@ module Hyde
|
|
43
44
|
def self.jekyll_configuration(configuration)
|
44
45
|
config = Jekyll::Configuration[Jekyll::Configuration::DEFAULTS]
|
45
46
|
override = Jekyll::Configuration[{
|
46
|
-
'source' => configuration['
|
47
|
-
'destination' => configuration['destination']
|
47
|
+
'source' => configuration['intermediary']['directory'],
|
48
|
+
'destination' => configuration['destination']['directory']
|
48
49
|
}].stringify_keys
|
49
50
|
config = config.read_config_files(config.config_files(override))
|
50
51
|
|
data/lib/hyde/commands/build.rb
CHANGED
@@ -13,9 +13,9 @@ module Hyde
|
|
13
13
|
|
14
14
|
def self.build(site, options)
|
15
15
|
source = options['source']
|
16
|
-
jekyll = options['
|
17
|
-
jekyll_out = options['
|
18
|
-
destination = options['destination']
|
16
|
+
jekyll = options['template']['directory']
|
17
|
+
jekyll_out = options['intermediary']['directory']
|
18
|
+
destination = options['destination']['directory']
|
19
19
|
|
20
20
|
Hyde.logger.info "Source:", source
|
21
21
|
Hyde.logger.info "Jekyll input:", jekyll
|
@@ -35,13 +35,11 @@ module Hyde
|
|
35
35
|
# TODO check whether dest is in source?
|
36
36
|
|
37
37
|
source = options['source']
|
38
|
-
intermediary = options['jekyll-out']
|
39
|
-
destination = options['destination']
|
40
38
|
|
41
39
|
ignored = Array.new
|
42
|
-
%w[
|
40
|
+
%w[intermediary destination].each do |o|
|
43
41
|
begin
|
44
|
-
d = Pathname.new(options[o]).relative_path_from(Pathname.new(source)).to_s
|
42
|
+
d = Pathname.new(options[o]['directory']).relative_path_from(Pathname.new(source)).to_s
|
45
43
|
ignored << Regexp.escape(d)
|
46
44
|
rescue ArgumentError
|
47
45
|
# nop
|
data/lib/hyde/commands/serve.rb
CHANGED
data/lib/hyde/configuration.rb
CHANGED
@@ -3,9 +3,18 @@ module Hyde
|
|
3
3
|
|
4
4
|
DEFAULTS = {
|
5
5
|
'source' => Dir.pwd,
|
6
|
-
'
|
7
|
-
|
8
|
-
|
6
|
+
'template' => {
|
7
|
+
'directory' => File.join(Dir.pwd, '_template'),
|
8
|
+
'branch' => nil,
|
9
|
+
'update' => true
|
10
|
+
},
|
11
|
+
'intermediary' => {
|
12
|
+
'directory' => File.join(Dir.pwd, '_intermediary')
|
13
|
+
},
|
14
|
+
'destination' => {
|
15
|
+
'directory' => File.join(Dir.pwd, '_site'),
|
16
|
+
'branch' => nil
|
17
|
+
},
|
9
18
|
|
10
19
|
'keep' => false,
|
11
20
|
|
@@ -14,6 +23,9 @@ module Hyde
|
|
14
23
|
'safe' => false,
|
15
24
|
'detach' => false,
|
16
25
|
|
26
|
+
'pages' => Hash.new,
|
27
|
+
'posts' => Hash.new,
|
28
|
+
|
17
29
|
'port' => Jekyll::Configuration::DEFAULTS['port'],
|
18
30
|
'host' => Jekyll::Configuration::DEFAULTS['host']
|
19
31
|
}
|
@@ -1,26 +1,38 @@
|
|
1
1
|
module Hyde
|
2
2
|
|
3
|
-
class
|
4
|
-
attr_accessor :original, :
|
3
|
+
class Page
|
4
|
+
attr_accessor :original, :name, :time
|
5
5
|
|
6
6
|
def initialize(location, destination)
|
7
|
-
|
7
|
+
@original = File.absolute_path(location)
|
8
|
+
@dest_dir = destination
|
9
|
+
|
8
10
|
data = read_yaml(self.original)
|
9
11
|
|
10
|
-
name = File.basename(location)
|
11
|
-
time = if data['hyde_date']
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
@name = File.basename(location)
|
13
|
+
@time = if data['hyde_date']
|
14
|
+
Time.parse(data['hyde_date'])
|
15
|
+
elsif data['date']
|
16
|
+
Time.parse(data['date'])
|
17
|
+
else
|
18
|
+
File.mtime(location)
|
19
|
+
end
|
20
|
+
end
|
16
21
|
|
17
|
-
|
22
|
+
def dest_filename
|
23
|
+
name
|
24
|
+
end
|
25
|
+
|
26
|
+
def dest_dir
|
27
|
+
@dest_dir
|
28
|
+
end
|
18
29
|
|
19
|
-
|
30
|
+
def destination
|
31
|
+
File.join(dest_dir, dest_filename)
|
20
32
|
end
|
21
33
|
|
22
34
|
def write
|
23
|
-
File.symlink(
|
35
|
+
File.symlink(original, destination)
|
24
36
|
end
|
25
37
|
|
26
38
|
private
|
data/lib/hyde/post.rb
ADDED
data/lib/hyde/site.rb
CHANGED
@@ -1,15 +1,19 @@
|
|
1
1
|
module Hyde
|
2
2
|
|
3
3
|
class Site
|
4
|
-
attr_accessor :
|
4
|
+
attr_accessor :options, :pages, :posts
|
5
|
+
attr_accessor :source, :template, :dest
|
6
|
+
attr_accessor :time, :files
|
5
7
|
|
6
|
-
def initialize(
|
7
|
-
self.
|
8
|
+
def initialize(options)
|
9
|
+
self.options = options
|
8
10
|
|
9
|
-
self.
|
10
|
-
self.
|
11
|
-
|
12
|
-
self.
|
11
|
+
self.pages = options['pages']
|
12
|
+
self.posts = options['posts']
|
13
|
+
|
14
|
+
self.source = File.expand_path(options['source'])
|
15
|
+
self.template = File.expand_path(options['template']['directory'])
|
16
|
+
self.dest = File.expand_path(options['intermediary']['directory'])
|
13
17
|
|
14
18
|
self.reset
|
15
19
|
self.setup
|
@@ -26,8 +30,8 @@ module Hyde
|
|
26
30
|
|
27
31
|
# reset the time
|
28
32
|
def reset
|
29
|
-
self.time = if
|
30
|
-
Time.parse(
|
33
|
+
self.time = if options['time']
|
34
|
+
Time.parse(options['time'].to_s)
|
31
35
|
else
|
32
36
|
Time.now
|
33
37
|
end
|
@@ -35,95 +39,145 @@ module Hyde
|
|
35
39
|
|
36
40
|
# copy Jekyll source files
|
37
41
|
def setup
|
38
|
-
|
39
|
-
|
42
|
+
if options['destination']['branch']
|
43
|
+
clone_directory(options['destination'])
|
44
|
+
else
|
45
|
+
FileUtils.rm_rf(dest)
|
46
|
+
end
|
47
|
+
|
48
|
+
clone_directory(options['template']) if options['template']['branch']
|
49
|
+
|
50
|
+
FileUtils.rm_rf(dest)
|
51
|
+
FileUtils.cp_r(template, dest, :preserve => true)
|
40
52
|
end
|
53
|
+
|
54
|
+
private
|
41
55
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
56
|
+
def clone_directory(options)
|
57
|
+
directory = options['directory']
|
58
|
+
branch = options['branch']
|
59
|
+
update = (options['update'] == true || options['update'] == 'true')
|
60
|
+
|
61
|
+
unless File.directory?('.git')
|
62
|
+
Hyde.logger.abort_with "Not a git repo:", "The current directory is not a git repository."
|
63
|
+
end
|
64
|
+
|
65
|
+
if File.exists?(directory)
|
66
|
+
if File.directory?(directory)
|
67
|
+
# if git: cd && git pull
|
68
|
+
if File.directory?(File.join(directory, '.git')) and update
|
69
|
+
Hyde.logger.info 'Updating directory:', "Pulling branch #{branch} in #{directory}..."
|
70
|
+
`cd #{directory} && git pull`
|
71
|
+
Hyde.logger.info '', 'done'
|
72
|
+
elsif update
|
73
|
+
Hyde.logger.warn 'Expected git repo:', "Expected #{directory} to be a git repo"
|
74
|
+
Hyde.logger.warn '', 'as a branch was supplied to pull from.'
|
57
75
|
end
|
58
76
|
else
|
59
|
-
Hyde.logger.
|
77
|
+
Hyde.logger.abort_with 'Expected directory:', "#{directory} but found file"
|
60
78
|
end
|
79
|
+
else
|
80
|
+
Hyde.logger.info 'Cloning template:', "Cloning branch #{branch} into #{directory}..."
|
81
|
+
`git new-workdir . #{directory} #{branch}`
|
82
|
+
Hyde.logger.info '', 'done.'
|
61
83
|
end
|
62
84
|
end
|
63
85
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
self.files[source_d] = files
|
71
|
-
|
72
|
-
read_directory(source_d, files, File.join(self.dest, dest_d))
|
73
|
-
end
|
86
|
+
public
|
87
|
+
|
88
|
+
# create the Hyde-to-Jekyll output directories
|
89
|
+
def directories
|
90
|
+
directories_helper(pages)
|
91
|
+
directories_helper(posts, '_posts')
|
74
92
|
end
|
75
93
|
|
76
94
|
private
|
77
95
|
|
78
|
-
def
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
96
|
+
def directories_helper(data, dest_suffix = '')
|
97
|
+
data.each do |source, dest|
|
98
|
+
source = File.join(self.source, source)
|
99
|
+
dest = File.join(self.dest, dest, dest_suffix)
|
100
|
+
|
101
|
+
unless File.exists?(source)
|
102
|
+
Hyde.logger.warn 'File not found:', "File/directory #{source} does not exist, skipping"
|
103
|
+
return
|
104
|
+
end
|
105
|
+
|
106
|
+
if File.exists?(dest)
|
107
|
+
unless File.directory?(source) == File.directory?(dest)
|
108
|
+
Hyde.logger.abort_with 'Illegal file:', "Expected #{dest} to be a #{File.directory?(source) ? 'directory but found file.' : 'file but found directory.'}"
|
109
|
+
end
|
110
|
+
|
111
|
+
FileUtils.rm_rf(dest)
|
112
|
+
end
|
113
|
+
|
114
|
+
# if directory: create directory, otherwise nop
|
115
|
+
if File.directory?(source)
|
116
|
+
FileUtils.mkdir_p(dest)
|
86
117
|
end
|
87
118
|
end
|
88
119
|
end
|
89
120
|
|
90
121
|
public
|
91
122
|
|
92
|
-
#
|
93
|
-
def
|
94
|
-
self.files
|
95
|
-
|
123
|
+
# read files
|
124
|
+
def read
|
125
|
+
self.files ||= Array.new
|
126
|
+
|
127
|
+
read_files(pages) do | source, destination |
|
128
|
+
files << Page.new(source, File.join(self.dest, destination))
|
129
|
+
end
|
130
|
+
read_files(posts) do | source, destination |
|
131
|
+
files << Post.new(source, File.join(self.dest, destination))
|
96
132
|
end
|
97
133
|
end
|
98
134
|
|
99
135
|
private
|
100
136
|
|
101
|
-
def
|
102
|
-
files.each do |
|
103
|
-
if
|
104
|
-
|
137
|
+
def read_files(files)
|
138
|
+
files.each do | source, destination |
|
139
|
+
if File.directory?(source)
|
140
|
+
read_directory(source, destination) { |s,d| yield(s,d) }
|
105
141
|
else
|
106
|
-
|
142
|
+
yield(source, destination)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
def read_directory(directory, destination)
|
148
|
+
Dir[File.join(directory, '*')].sort.each do |source|
|
149
|
+
if File.directory?(source)
|
150
|
+
read_directory(source, destination) { |s,d| yield(s,d) }
|
151
|
+
else
|
152
|
+
yield(source, destination)
|
107
153
|
end
|
108
154
|
end
|
109
155
|
end
|
110
156
|
|
111
157
|
public
|
112
158
|
|
159
|
+
# write jekyll files
|
160
|
+
def write
|
161
|
+
files.each do |file|
|
162
|
+
file.write
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
113
166
|
# cleanup
|
114
167
|
def cleanup
|
115
|
-
self.files =
|
116
|
-
FileUtils.rm_rf(self.dest) unless
|
168
|
+
self.files = Array.new
|
169
|
+
FileUtils.rm_rf(self.dest) unless options['keep'] or options['watching'] or options['serving']
|
117
170
|
end
|
118
171
|
|
119
172
|
# runs Jekyll
|
120
173
|
def build
|
121
174
|
jekyll_options = Hash.new
|
122
175
|
|
123
|
-
%w[safe
|
124
|
-
jekyll_options[c] =
|
176
|
+
%w[safe verbose].each do |c|
|
177
|
+
jekyll_options[c] = options[c] if options[c]
|
125
178
|
end
|
126
179
|
|
180
|
+
jekyll_options['destination'] = options['destination']['directory']
|
127
181
|
jekyll_options['source'] = self.dest
|
128
182
|
|
129
183
|
jekyll_options = Jekyll::configuration(jekyll_options)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bgotink-hyde
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bram Gotink
|
@@ -102,7 +102,8 @@ files:
|
|
102
102
|
- lib/hyde/commands/build.rb
|
103
103
|
- lib/hyde/commands/serve.rb
|
104
104
|
- lib/hyde/configuration.rb
|
105
|
-
- lib/hyde/
|
105
|
+
- lib/hyde/page.rb
|
106
|
+
- lib/hyde/post.rb
|
106
107
|
- lib/hyde/site.rb
|
107
108
|
- lib/hyde/stevenson.rb
|
108
109
|
homepage: http://github.com/bgotink/hyde
|