spinto 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- data/_plugins/include_tree.rb +84 -28
- data/_plugins/include_watcher.rb +2 -6
- data/lib/spinto.rb +1 -1
- data/spinto.gemspec +2 -2
- metadata +17 -17
data/_plugins/include_tree.rb
CHANGED
@@ -10,6 +10,18 @@ Jekyll::Post.class_eval do
|
|
10
10
|
|
11
11
|
end
|
12
12
|
|
13
|
+
Jekyll::Layout.class_eval do
|
14
|
+
|
15
|
+
def location_on_server
|
16
|
+
nil
|
17
|
+
end
|
18
|
+
|
19
|
+
def path_to_source
|
20
|
+
"/_layouts/#{File.join(@name)}"
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
13
25
|
Jekyll::Page.class_eval do
|
14
26
|
|
15
27
|
# It is important that this is the same
|
@@ -41,51 +53,95 @@ Jekyll::Site.class_eval do
|
|
41
53
|
|
42
54
|
alias :render_without_include_tree :render
|
43
55
|
def render
|
44
|
-
|
45
|
-
#
|
56
|
+
|
57
|
+
# Clean up this thread.
|
58
|
+
#
|
59
|
+
Thread.current[:jekyll_inclusions] = {}
|
60
|
+
|
61
|
+
# Render like Jekyll normally does
|
62
|
+
#
|
46
63
|
render_without_include_tree
|
47
64
|
|
48
|
-
|
49
|
-
# inclusions fired.
|
50
|
-
(pages + posts + unpublished_posts + static_files).each do |file|
|
51
|
-
Jekyll::IncludeWatcher.inclusions[file.location_on_server] ||= {}
|
52
|
-
Jekyll::IncludeWatcher.inclusions[file.location_on_server].merge!(source: file.path_to_source)
|
53
|
-
if file.respond_to?(:data) && file.data
|
54
|
-
data = {}
|
55
|
-
['editable', '_content', 'title', 'description'].each do |key|
|
56
|
-
data[key] = file.data[key] if file.data[key]
|
57
|
-
end
|
58
|
-
if file.respond_to?(:published)
|
59
|
-
data['published'] = file.published
|
60
|
-
end
|
61
|
-
Jekyll::IncludeWatcher.inclusions[file.location_on_server].merge!(data)
|
62
|
-
end
|
63
|
-
end
|
65
|
+
spinto_data = {}
|
64
66
|
|
65
|
-
|
66
|
-
|
67
|
-
|
67
|
+
url_cleaner = lambda {|dirty_url|
|
68
|
+
matches = dirty_url.match(/^(.*\/)index.html$/)
|
69
|
+
clean_url = dirty_url
|
68
70
|
if matches
|
69
|
-
|
71
|
+
clean_url = if matches[1] == '/'
|
70
72
|
matches[1]
|
71
73
|
else
|
72
74
|
matches[1].gsub(/\/$/, '')
|
73
75
|
end
|
74
|
-
Jekyll::IncludeWatcher.inclusions[clean_name] = \
|
75
|
-
Jekyll::IncludeWatcher.inclusions.delete(key)
|
76
76
|
end
|
77
|
+
clean_url
|
78
|
+
}
|
79
|
+
|
80
|
+
# Add pages to the Spinto data
|
81
|
+
#
|
82
|
+
spinto_data['pages'] = pages.collect do |page|
|
83
|
+
spinto_page_data = {
|
84
|
+
'includes' => (Jekyll::IncludeWatcher.inclusions[page.location_on_server] || []),
|
85
|
+
'source_path' => page.path_to_source,
|
86
|
+
'url' => url_cleaner.call( page.location_on_server )
|
87
|
+
}
|
88
|
+
|
89
|
+
if page.data
|
90
|
+
%w{ editable title description }.each do |key|
|
91
|
+
spinto_page_data[key] = page.data[key] if page.data[key]
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
spinto_page_data
|
96
|
+
end.sort {|a,b| a['url'] <=> b['url'] }
|
97
|
+
|
98
|
+
# Add layouts to the Spinto data
|
99
|
+
#
|
100
|
+
spinto_data['layouts'] = layouts.values.collect do |layout|
|
101
|
+
{
|
102
|
+
'source_path' => layout.path_to_source
|
103
|
+
}
|
104
|
+
end.sort {|a,b| a['source_path'] <=> b['source_path'] }
|
105
|
+
|
106
|
+
# Add posts to Spinto data
|
107
|
+
#
|
108
|
+
%w{ posts unpublished_posts }.each do |post_type|
|
109
|
+
spinto_data[post_type] = send(post_type.to_sym).collect do |post|
|
110
|
+
spinto_post_data = {
|
111
|
+
'source_path' => post.path_to_source,
|
112
|
+
'url' => url_cleaner.call( post.location_on_server ),
|
113
|
+
'published' => post.published
|
114
|
+
}
|
115
|
+
|
116
|
+
if post.data
|
117
|
+
%w{ title description }.each do |key|
|
118
|
+
spinto_post_data[key] = post.data[key] if post.data[key]
|
119
|
+
end
|
120
|
+
end
|
121
|
+
spinto_post_data
|
122
|
+
end.sort {|a,b| a['url'] <=> b['url'] }
|
77
123
|
end
|
78
124
|
|
125
|
+
# Add pages to the Spinto data
|
126
|
+
#
|
127
|
+
spinto_data['static_files'] = static_files.collect do |file|
|
128
|
+
{
|
129
|
+
'source_path' => file.path_to_source,
|
130
|
+
'url' => url_cleaner.call( file.location_on_server )
|
131
|
+
}
|
132
|
+
end.sort {|a,b| a['url'] <=> b['url'] }
|
133
|
+
|
79
134
|
# Write our inclusions to a dot-file
|
80
|
-
|
135
|
+
#
|
136
|
+
filename = '.spinto_data'
|
81
137
|
|
82
138
|
File.open(File.join(source, filename), "w") do |f|
|
83
|
-
f.write JSON.dump(
|
139
|
+
f.write JSON.dump( spinto_data )
|
84
140
|
end
|
85
141
|
|
86
|
-
# Ensure Jekyll doesn't clean
|
142
|
+
# Ensure Jekyll doesn't clean this up.
|
143
|
+
#
|
87
144
|
static_files << Jekyll::StaticFile.new(self, source, "/", filename)
|
88
145
|
end
|
89
146
|
|
90
147
|
end
|
91
|
-
|
data/_plugins/include_watcher.rb
CHANGED
@@ -7,12 +7,8 @@ module Jekyll
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def render(context)
|
10
|
-
Jekyll::IncludeWatcher.inclusions[context.registers[:page]['url']] ||=
|
11
|
-
Jekyll::IncludeWatcher.inclusions[context.registers[:page]['url']]
|
12
|
-
Jekyll::IncludeWatcher.inclusions[context.registers[:page]['url']][:includes] = \
|
13
|
-
(Jekyll::IncludeWatcher.inclusions[context.registers[:page]['url']][:includes] || {}).merge(
|
14
|
-
@file => { 'editable' => true }
|
15
|
-
)
|
10
|
+
Jekyll::IncludeWatcher.inclusions[context.registers[:page]['url']] ||= []
|
11
|
+
Jekyll::IncludeWatcher.inclusions[context.registers[:page]['url']] << @file
|
16
12
|
super
|
17
13
|
end
|
18
14
|
|
data/lib/spinto.rb
CHANGED
data/spinto.gemspec
CHANGED
@@ -4,8 +4,8 @@ Gem::Specification.new do |s|
|
|
4
4
|
s.rubygems_version = '1.3.5'
|
5
5
|
|
6
6
|
s.name = 'spinto'
|
7
|
-
s.version = '0.2.
|
8
|
-
s.date = '2012-02-
|
7
|
+
s.version = '0.2.8'
|
8
|
+
s.date = '2012-02-28'
|
9
9
|
|
10
10
|
s.summary = "The site generator used at spintoapp.com"
|
11
11
|
s.description = "Spinto uses Jekyll and plugins to build static sites, this gem provides the spinto-site builder."
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spinto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.8
|
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-02-
|
12
|
+
date: 2012-02-28 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: spinto-jekyll
|
16
|
-
requirement: &
|
16
|
+
requirement: &2153826460 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - =
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.11.2.2
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2153826460
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: coffee-script
|
27
|
-
requirement: &
|
27
|
+
requirement: &2153853880 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - =
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 2.2.0
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2153853880
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: sass
|
38
|
-
requirement: &
|
38
|
+
requirement: &2153853420 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - =
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 3.1.15
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2153853420
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: less
|
49
|
-
requirement: &
|
49
|
+
requirement: &2153852960 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - =
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 2.0.9
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2153852960
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: RedCloth
|
60
|
-
requirement: &
|
60
|
+
requirement: &2153852500 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - =
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 4.2.9
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2153852500
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
|
-
requirement: &
|
71
|
+
requirement: &2153852040 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0.9'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *2153852040
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: rdoc
|
82
|
-
requirement: &
|
82
|
+
requirement: &2153851580 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ~>
|
@@ -87,7 +87,7 @@ dependencies:
|
|
87
87
|
version: '3.11'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *2153851580
|
91
91
|
description: Spinto uses Jekyll and plugins to build static sites, this gem provides
|
92
92
|
the spinto-site builder.
|
93
93
|
email: matt.beale@madhatted.com
|
@@ -122,7 +122,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
122
122
|
version: '0'
|
123
123
|
segments:
|
124
124
|
- 0
|
125
|
-
hash: -
|
125
|
+
hash: -1742459230377426559
|
126
126
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
127
127
|
none: false
|
128
128
|
requirements:
|