plateau 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +9 -0
- data/bin/plateau +6 -0
- data/lib/Plateau.rb +512 -0
- data/resources/Plateau.tar.gz +0 -0
- metadata +72 -0
data/README.md
ADDED
data/bin/plateau
ADDED
data/lib/Plateau.rb
ADDED
@@ -0,0 +1,512 @@
|
|
1
|
+
require 'mustache'
|
2
|
+
require 'maruku'
|
3
|
+
require 'yaml'
|
4
|
+
require 'rss/maker'
|
5
|
+
|
6
|
+
|
7
|
+
class Plateau
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
def init_dir(name="plateau")
|
14
|
+
version = "0.0.1"
|
15
|
+
@gem_path = Gem.path[0]+"/gems/plateau-"+version
|
16
|
+
@resources_path = Gem.path[0]+"/gems/plateau-"+version+"/resources"
|
17
|
+
system("tar -xzvf #{@resources_path}/Plateau.tar.gz")
|
18
|
+
system("mv Plateau #{name}")
|
19
|
+
end
|
20
|
+
|
21
|
+
def build
|
22
|
+
inhale
|
23
|
+
#...
|
24
|
+
exhale
|
25
|
+
end
|
26
|
+
|
27
|
+
def load_templates
|
28
|
+
#read templates
|
29
|
+
Mustache.template_path = "./themes/#{@site_config['theme']}"
|
30
|
+
@templates = {}
|
31
|
+
Dir.glob("./themes/#{@site_config['theme']}/*.mustache").each { |file_path|
|
32
|
+
filename = file_path.split('/').last.split('.mustache').first
|
33
|
+
file = File.read(file_path)
|
34
|
+
@templates[filename] = file
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
def load_config
|
39
|
+
@site_config =YAML::load( File.open("plateau.yml" ) )
|
40
|
+
end
|
41
|
+
|
42
|
+
def inhale
|
43
|
+
load_config
|
44
|
+
load_templates
|
45
|
+
|
46
|
+
@time_start = Time.now
|
47
|
+
|
48
|
+
|
49
|
+
#Read Pages
|
50
|
+
puts "Reading Pages"
|
51
|
+
@pages = []
|
52
|
+
@page_dirs = Dir.glob("./content/pages/*")
|
53
|
+
@page_dirs.each_index {|index|
|
54
|
+
file_path = @page_dirs[index]
|
55
|
+
post_name = file_path.split('/').last
|
56
|
+
if post_name.include?(" ") then
|
57
|
+
new_file_path = file_path.gsub(' ','_')
|
58
|
+
puts file_path + " renamed to " + new_file_path
|
59
|
+
system("mv '#{file_path}' #{new_file_path}")
|
60
|
+
file_path = new_file_path
|
61
|
+
post_name = post_name.gsub(" ","_")
|
62
|
+
end
|
63
|
+
extras = []
|
64
|
+
Dir.glob("#{file_path}/*.js").each { |script|
|
65
|
+
script_string = %Q{<script type="text/javascript" src="#{script.split("/").last}" ></script>\n}
|
66
|
+
extras << script_string
|
67
|
+
}
|
68
|
+
Dir.glob("#{file_path}/*.css").each { |stylesheet|
|
69
|
+
style_string = %Q{<link rel="stylesheet" href="#{stylesheet.split("/").last}" >\n}
|
70
|
+
extras << style_string
|
71
|
+
}
|
72
|
+
|
73
|
+
page_meta = {
|
74
|
+
'title' => @site_config['title']
|
75
|
+
}
|
76
|
+
begin
|
77
|
+
page_meta = YAML::load( File.open( "#{file_path}/meta.yml" ) )
|
78
|
+
if page_meta['title'] then page_meta['title'] = "#{@site_config['title']} - #{page_meta['title']}" end
|
79
|
+
rescue Exception => e
|
80
|
+
end
|
81
|
+
|
82
|
+
if File.exists? "#{file_path}/index.html" then
|
83
|
+
post_markup = File.read("#{file_path}/index.html")
|
84
|
+
mod_date = File.ctime("#{file_path}/index.html")
|
85
|
+
else
|
86
|
+
begin
|
87
|
+
markdown_file_path = Dir.glob("#{file_path}/*.md")[0]
|
88
|
+
post_markdown = File.read(markdown_file_path)
|
89
|
+
mod_date = File.ctime(markdown_file_path)
|
90
|
+
mku = Maruku.new(post_markdown)
|
91
|
+
post_markup = mku.to_html
|
92
|
+
rescue Exception => e
|
93
|
+
puts "No markdown or index.html file for #{post_name}"
|
94
|
+
break
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
post = {
|
99
|
+
'markdown' => post_markdown,
|
100
|
+
'markup' => post_markup,
|
101
|
+
'path' => "/#{post_name}/",
|
102
|
+
'mod_date' => mod_date,
|
103
|
+
'extras' => extras.join,
|
104
|
+
'slug' => post_name,
|
105
|
+
'meta' => page_meta
|
106
|
+
}
|
107
|
+
@pages << post
|
108
|
+
}
|
109
|
+
|
110
|
+
|
111
|
+
#Read Posts
|
112
|
+
puts "Reading Posts"
|
113
|
+
@posts = []
|
114
|
+
@posts_by_tag = {}
|
115
|
+
|
116
|
+
@post_dirs = Dir.glob("./content/posts/*")
|
117
|
+
@post_dirs.each_index { |index|
|
118
|
+
file_path = @post_dirs[index]
|
119
|
+
post_name = file_path.split('/').last
|
120
|
+
if post_name.include?(" ") then
|
121
|
+
new_file_path = file_path.gsub(' ','_')
|
122
|
+
puts file_path + " renamed to " + new_file_path
|
123
|
+
system("mv '#{file_path}' #{new_file_path}")
|
124
|
+
file_path = new_file_path
|
125
|
+
post_name = post_name.gsub(" ","_")
|
126
|
+
end
|
127
|
+
post_meta = {}
|
128
|
+
|
129
|
+
begin
|
130
|
+
post_meta = YAML::load( File.open( "#{file_path}/meta.yml" ) )
|
131
|
+
rescue Exception => e
|
132
|
+
puts "No post meta.yml (or malformed yaml) for #{post_name}"
|
133
|
+
break
|
134
|
+
end
|
135
|
+
if post_meta['status'] != "published" then
|
136
|
+
puts "Set #{post_name}'s status to 'published' in its meta.yml to publish it"
|
137
|
+
break
|
138
|
+
end
|
139
|
+
if post_meta['date'].class != Time then
|
140
|
+
puts "#{post_name} needs a correctly formatted date (yyyy-mm-dd hh:mm:ss +0)"
|
141
|
+
break
|
142
|
+
end
|
143
|
+
if post_meta['title'] == nil then
|
144
|
+
puts "#{post_name} needs a title"
|
145
|
+
break
|
146
|
+
end
|
147
|
+
|
148
|
+
if post_meta['tags'].class == Array then
|
149
|
+
tag_hashes = []
|
150
|
+
post_meta['tags'].each {|tag|
|
151
|
+
tag_hashes << {'tag' => tag, 'slug'=>tag.gsub(" ","_")}
|
152
|
+
}
|
153
|
+
post_meta['tags'] = tag_hashes
|
154
|
+
else
|
155
|
+
post_meta['tags'] = []
|
156
|
+
end
|
157
|
+
|
158
|
+
if File.exists? "#{file_path}/index.html" then
|
159
|
+
post_markup = File.read("#{file_path}/index.html")
|
160
|
+
mod_date = File.ctime("#{file_path}/index.html")
|
161
|
+
else
|
162
|
+
begin
|
163
|
+
markdown_file_path = Dir.glob("#{file_path}/*.md").delete_if{|x| x.match("lede")}[0]
|
164
|
+
post_markdown = File.read(markdown_file_path)
|
165
|
+
mod_date = File.ctime(markdown_file_path)
|
166
|
+
mku = Maruku.new(post_markdown)
|
167
|
+
post_markup = mku.to_html
|
168
|
+
rescue Exception => e
|
169
|
+
puts "No markdown or index.html file for #{post_name}"
|
170
|
+
break
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
if File.exists?("#{file_path}/lede.md") then
|
175
|
+
post_lede_markdown = File.read("#{file_path}/lede.md")
|
176
|
+
end
|
177
|
+
|
178
|
+
extras = [];
|
179
|
+
Dir.glob("#{file_path}/*.js").each { |script|
|
180
|
+
script_string = %Q{<script type="text/javascript" src="#{script.split("/").last}" ></script>\n}
|
181
|
+
extras << script_string
|
182
|
+
}
|
183
|
+
Dir.glob("#{file_path}/*.css").each { |stylesheet|
|
184
|
+
style_string = %Q{<link rel="stylesheet" href="#{stylesheet.split("/").last}" >\n}
|
185
|
+
extras << style_string
|
186
|
+
}
|
187
|
+
post = post_meta.merge({
|
188
|
+
'markdown' => post_markdown,
|
189
|
+
'markup' => post_markup,
|
190
|
+
'lede_markdown' => post_lede_markdown,
|
191
|
+
'mod_date' => mod_date,
|
192
|
+
'slug' => post_name,
|
193
|
+
'path' => "/posts/#{post_name}/",
|
194
|
+
'extras' => extras.join,
|
195
|
+
'date_string' => post_meta['date'].strftime("%Y/%m/%d"),
|
196
|
+
'date' => post_meta['date'],
|
197
|
+
'date_object' => {
|
198
|
+
'Y' => post_meta['date'].strftime("%Y"),
|
199
|
+
'F' => post_meta['date'].strftime("%F"),
|
200
|
+
'H' => post_meta['date'].strftime("%H"),
|
201
|
+
'T' => post_meta['date'].strftime("%T"),
|
202
|
+
'm' => post_meta['date'].strftime("%m"),
|
203
|
+
'B' => post_meta['date'].strftime("%B"),
|
204
|
+
'b' => post_meta['date'].strftime("%b"),
|
205
|
+
'd' => post_meta['date'].strftime("%d"),
|
206
|
+
'e' => post_meta['date'].strftime("%e"),
|
207
|
+
'j' => post_meta['date'].strftime("%j"),
|
208
|
+
'k' => post_meta['date'].strftime("%k"),
|
209
|
+
'M' => post_meta['date'].strftime("%M"),
|
210
|
+
'S' => post_meta['date'].strftime("%S"),
|
211
|
+
'z' => post_meta['date'].strftime("%z"),
|
212
|
+
'Z' => post_meta['date'].strftime("%Z"),
|
213
|
+
'A' => post_meta['date'].strftime("%A"),
|
214
|
+
'a' => post_meta['date'].strftime("%a"),
|
215
|
+
'w' => post_meta['date'].strftime("%w"),
|
216
|
+
'u' => post_meta['date'].strftime("%u")
|
217
|
+
}
|
218
|
+
})
|
219
|
+
post_meta['tags'].each { |tag|
|
220
|
+
t = tag['tag']
|
221
|
+
@posts_by_tag[t] = [] unless @posts_by_tag.has_key?(t)
|
222
|
+
@posts_by_tag[t] << post
|
223
|
+
}
|
224
|
+
@posts << post
|
225
|
+
}
|
226
|
+
@posts.sort_by!{ |post| post['date'] }.reverse!
|
227
|
+
|
228
|
+
end
|
229
|
+
|
230
|
+
def exhale
|
231
|
+
|
232
|
+
#Setup directories
|
233
|
+
system("rm -Rf ./site_build")
|
234
|
+
Dir.mkdir("./site_build/")
|
235
|
+
Dir.mkdir("./site_build/posts")
|
236
|
+
Dir.mkdir("./site_build/frontend")
|
237
|
+
|
238
|
+
|
239
|
+
#Copy Frontend Resources
|
240
|
+
Dir.glob("./themes/#{@site_config['theme']}/*.{jpg,gif,png,mov,m4v,swf,svg,css,js,mpg,flv,mpeg,jpeg,wmv,wma,zip,tar,gz}") {|file|
|
241
|
+
file_name = file.split("/").last
|
242
|
+
system("cp #{file} ./site_build/frontend/#{file_name}")
|
243
|
+
}
|
244
|
+
|
245
|
+
|
246
|
+
#Write Pages
|
247
|
+
@pages.each_index { |index|
|
248
|
+
puts "Rendering page #{index+1} of #{@pages.length}"
|
249
|
+
page = @pages[index]
|
250
|
+
Dir.mkdir("./site_build/#{page['slug']}")
|
251
|
+
page_html = Mustache.render(@templates['main'],{:page_content=>page['markup'],:section=>page['slug'],:extras=>page['extras']}.merge(@site_config).merge(page['meta']))
|
252
|
+
page_html = make_resources_absolute(page_html,"../")
|
253
|
+
File.open("./site_build/#{page['slug']}/index.html", 'w') {|f| f.write(page_html) }
|
254
|
+
copy_support_files("./content/pages/#{page['slug']}/","./site_build/#{page['slug']}")
|
255
|
+
}
|
256
|
+
|
257
|
+
|
258
|
+
#Write Posts
|
259
|
+
@posts.each_index { |index|
|
260
|
+
puts "Rendering post #{index+1} of #{@posts.length}"
|
261
|
+
post = @posts[index]
|
262
|
+
Dir.mkdir("./site_build/posts/#{post['slug']}")
|
263
|
+
if post['lede_markdown'] then post['lede'] = Maruku.new(post['lede_markdown']).to_html end
|
264
|
+
post_inner_html = Mustache.render(@templates['post'],post)
|
265
|
+
page_html = Mustache.render(@templates['main'],@site_config.merge({
|
266
|
+
:page_content => post_inner_html,
|
267
|
+
:section =>'posts',
|
268
|
+
:title => (@site_config['title'] + " - " + post['title'])
|
269
|
+
}))
|
270
|
+
page_html = make_resources_absolute(page_html,"../../")
|
271
|
+
File.open("./site_build/posts/#{post['slug']}/index.html", 'w') {|f| f.write(page_html) }
|
272
|
+
copy_support_files("./content/posts/#{post['slug']}","./site_build/posts/#{post['slug']}")
|
273
|
+
}
|
274
|
+
|
275
|
+
|
276
|
+
#Write Post Pages
|
277
|
+
post_pages = [[]]
|
278
|
+
current_post_count = 0
|
279
|
+
current_page = 0
|
280
|
+
@posts.each {|post|
|
281
|
+
current_post_count = current_post_count + 1
|
282
|
+
post_pages[current_page] << post.clone
|
283
|
+
if current_post_count == @site_config['posts_per_page']
|
284
|
+
current_post_count = 0
|
285
|
+
post_pages << []
|
286
|
+
current_page=current_page+1
|
287
|
+
end
|
288
|
+
}
|
289
|
+
post_pages.delete_if{|x|x==[]}
|
290
|
+
post_pages.each_index{|index|
|
291
|
+
puts "Rendering blog page #{index+1} of #{post_pages.length}"
|
292
|
+
posts = post_pages[index]
|
293
|
+
posts.each{ |post|
|
294
|
+
post['extras'] = make_links_absolute(post['extras'],"../posts/#{post['slug']}/")
|
295
|
+
post['markup'] = make_links_absolute(post['markup'],"../posts/#{post['slug']}/")
|
296
|
+
}
|
297
|
+
unless index == post_pages.length-1 then nxt = index+1 end
|
298
|
+
unless index == 0 then prv = index-1 end
|
299
|
+
if index == 1 then
|
300
|
+
prev_page_url = "/posts"
|
301
|
+
else
|
302
|
+
prev_page_url = "/posts/#{prv}"
|
303
|
+
end
|
304
|
+
posts_html = Mustache.render(@templates['posts'],{
|
305
|
+
:posts=>posts,
|
306
|
+
:current_page=>index,
|
307
|
+
:next=>nxt,
|
308
|
+
:next_page_url=>"/posts/#{nxt}",
|
309
|
+
:prev=>prv,
|
310
|
+
:prev_page_url=>prev_page_url
|
311
|
+
})
|
312
|
+
post_page_html = Mustache.render(@templates['main'],{:page_content=>posts_html,:section=>'posts'}.merge(@site_config))
|
313
|
+
|
314
|
+
if index == 0 then
|
315
|
+
filename = "./site_build/posts/index.html"
|
316
|
+
path_to_root = "../"
|
317
|
+
else
|
318
|
+
Dir.mkdir("./site_build/posts/#{index}")
|
319
|
+
filename = "./site_build/posts/#{index}/index.html"
|
320
|
+
path_to_root = "../../"
|
321
|
+
end
|
322
|
+
post_page_html = make_resources_absolute(post_page_html,path_to_root)
|
323
|
+
File.open(filename, 'w') {|f| f.write(post_page_html) }
|
324
|
+
}
|
325
|
+
|
326
|
+
|
327
|
+
#Write Post Index
|
328
|
+
puts "Rendering post index"
|
329
|
+
Dir.mkdir("./site_build/posts/archive")
|
330
|
+
posts_index_html = Mustache.render(@templates['posts_index'],{
|
331
|
+
:posts => @posts
|
332
|
+
})
|
333
|
+
html = Mustache.render(@templates['main'],{:page_content=>posts_index_html,:section=>'posts'}.merge(@site_config))
|
334
|
+
html = make_resources_absolute(html,"../../")
|
335
|
+
File.open("./site_build/posts/archive/index.html", 'w') {|f| f.write(html) }
|
336
|
+
|
337
|
+
|
338
|
+
#Copy root files
|
339
|
+
Dir.glob("./content/*.{jpg,gif,png,mov,m4v,swf,svg,css,js,mpg,flv,mpeg,jpeg,wmv,wma,zip,tar,gz}").each{|f|
|
340
|
+
system("cp '#{f}' './site_build/#{f.split('/').last}'")
|
341
|
+
}
|
342
|
+
|
343
|
+
|
344
|
+
#Write Tag Pages
|
345
|
+
puts "Rendering tag indexes"
|
346
|
+
Dir.mkdir("./site_build/posts/tagged")
|
347
|
+
@posts_by_tag.each_key { |tag|
|
348
|
+
post_array = @posts_by_tag[tag]
|
349
|
+
tag_slug = tag.gsub(" ","_")
|
350
|
+
Dir.mkdir("./site_build/posts/tagged/#{tag_slug}")
|
351
|
+
tags_page_html = Mustache.render(@templates['posts_tagged'],{
|
352
|
+
:posts => post_array,
|
353
|
+
:tag => tag
|
354
|
+
})
|
355
|
+
html = Mustache.render(@templates['main'],{:page_content=>tags_page_html,:section=>'posts'}.merge(@site_config))
|
356
|
+
html = make_resources_absolute(html,"../../../")
|
357
|
+
File.open("./site_build/posts/tagged/#{tag_slug}/index.html", 'w') {|f| f.write(html) }
|
358
|
+
}
|
359
|
+
|
360
|
+
|
361
|
+
#Write Home Page
|
362
|
+
begin
|
363
|
+
home_page_html = File.read("./site_build/#{@site_config['home_page']}/index.html")
|
364
|
+
home_page_html = make_links_absolute(home_page_html,"#{@site_config['home_page']}/")
|
365
|
+
home_page_html.gsub!("../","")
|
366
|
+
File.open("./site_build/index.html", 'w') { |f| f.write(home_page_html) }
|
367
|
+
rescue Exception => e
|
368
|
+
puts "Could not write home page, sure /@site_config['home_page']/ exists?"
|
369
|
+
end
|
370
|
+
|
371
|
+
|
372
|
+
#Write sitemap.xml
|
373
|
+
puts "Rendering Sitemap.xml"
|
374
|
+
sitemap = ""
|
375
|
+
sitemap << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
376
|
+
sitemap << "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n"
|
377
|
+
@pages.each {|p|
|
378
|
+
sitemap << "<url>\n<loc>#{@site_config['url']}#{p['path']}</loc>\n<lastmod>#{p['mod_date'].strftime("%Y-%m-%d")}</lastmod>\n</url>\n"
|
379
|
+
}
|
380
|
+
@posts.each {|p|
|
381
|
+
sitemap << "<url>\n<loc>#{@site_config['url']}#{p['path']}</loc>\n<lastmod>#{p['mod_date'].strftime("%Y-%m-%d")}</lastmod>\n</url>\n"
|
382
|
+
}
|
383
|
+
sitemap << "</urlset>"
|
384
|
+
File.open("./site_build/sitemap.xml","w") do |f|
|
385
|
+
f.write(sitemap)
|
386
|
+
end
|
387
|
+
|
388
|
+
#Write RSS
|
389
|
+
puts "Writing RSS"
|
390
|
+
rss = ""
|
391
|
+
rss << %Q{<?xml version="1.0" encoding="UTF-8"?>\n}
|
392
|
+
rss << %Q{<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">\n}
|
393
|
+
rss << "<channel>\n"
|
394
|
+
rss << "<title>#{@site_config['title']}</title>\n"
|
395
|
+
rss << "<link>#{@site_config['url']}</link>\n"
|
396
|
+
rss << %Q{<atom:link href="#{@site_config['url']}/rss.xml" rel="self" type="application/rss+xml" />\n}
|
397
|
+
rss << "<description>#{@site_config['description']}</description>\n"
|
398
|
+
@posts.each {|p|
|
399
|
+
rss << "<item>\n"
|
400
|
+
rss << "<title>#{p['title']}</title>\n"
|
401
|
+
rss << "<link>#{@site_config['url']}#{p['path']}</link>\n"
|
402
|
+
rss << "<guid>#{@site_config['url']}#{p['path']}</guid>\n"
|
403
|
+
rss << "<pubDate>#{p['date'].strftime("%a, %d %b %Y %H:%M:%S %Z")}</pubDate>\n"
|
404
|
+
if p['lede'] then
|
405
|
+
puts "rss item has lede"
|
406
|
+
description = p['lede']
|
407
|
+
else
|
408
|
+
description = p['markup']
|
409
|
+
end
|
410
|
+
rss << "<description><![CDATA[\n#{make_links_absolute(description,@site_config['url']+p['path'])}]]></description>\n"
|
411
|
+
rss << "</item>\n"
|
412
|
+
}
|
413
|
+
rss << "</channel>\n"
|
414
|
+
rss << "</rss>"
|
415
|
+
File.open("./site_build/rss.xml","w") do |f|
|
416
|
+
f.write(rss)
|
417
|
+
end
|
418
|
+
|
419
|
+
system("rm -Rf ./site")
|
420
|
+
system("mv site_build site")
|
421
|
+
|
422
|
+
build_time = Time.now - @time_start
|
423
|
+
puts "Built in #{build_time} seconds"
|
424
|
+
|
425
|
+
end
|
426
|
+
|
427
|
+
def make_preview
|
428
|
+
post_dir = Dir.getwd
|
429
|
+
Dir.chdir("../")
|
430
|
+
post_type = Dir.getwd.split("/").last
|
431
|
+
Dir.chdir("../../")
|
432
|
+
load_config
|
433
|
+
load_templates
|
434
|
+
Dir.chdir(post_dir)
|
435
|
+
markdown_file_path = Dir.glob("./*.md").delete_if{|x| x.match("lede")}[0]
|
436
|
+
post_markdown = File.read(markdown_file_path)
|
437
|
+
mku = Maruku.new(post_markdown)
|
438
|
+
post_markup = mku.to_html
|
439
|
+
extras = [];
|
440
|
+
Dir.glob("./*.js").each { |script|
|
441
|
+
script_string = %Q{<script type="text/javascript" src="#{script.split("/").last}" ></script>\n}
|
442
|
+
extras << script_string
|
443
|
+
}
|
444
|
+
Dir.glob("./*.css").each { |stylesheet|
|
445
|
+
style_string = %Q{<link rel="stylesheet" href="#{stylesheet.split("/").last}" >\n}
|
446
|
+
extras << style_string
|
447
|
+
}
|
448
|
+
if post_type == "pages" then
|
449
|
+
page_html = Mustache.render(@templates['main'],{
|
450
|
+
:page_content => post_markup,
|
451
|
+
:extras => extras.join("")
|
452
|
+
}.merge(@site_config))
|
453
|
+
end
|
454
|
+
if post_type == "posts" then
|
455
|
+
post_meta = {}
|
456
|
+
begin
|
457
|
+
post_meta = YAML::load( File.open( "meta.yml" ) )
|
458
|
+
rescue Exception => e
|
459
|
+
puts "No post meta.yml (or malformed yaml)"
|
460
|
+
return false
|
461
|
+
end
|
462
|
+
if post_meta['date'].class != Time then
|
463
|
+
puts "Post needs a correctly formatted date (yyyy-mm-dd hh:mm:ss +0)"
|
464
|
+
return false
|
465
|
+
end
|
466
|
+
if post_meta['title'] == nil then
|
467
|
+
puts "Post needs a title"
|
468
|
+
return false
|
469
|
+
end
|
470
|
+
page_inner_html = Mustache.render(@templates['post'],{
|
471
|
+
:markup => post_markup,
|
472
|
+
:extras => extras.join("")
|
473
|
+
}.merge(post_meta))
|
474
|
+
page_html = Mustache.render(@templates['main'],{:page_content=>page_inner_html}.merge(@site_config))
|
475
|
+
end
|
476
|
+
page_html = page_html.gsub(/frontend\//){|src|
|
477
|
+
src = "../../../themes/#{@site_config['theme']}/"
|
478
|
+
src
|
479
|
+
}
|
480
|
+
File.open("./preview.html", 'w') {|f| f.write(page_html) }
|
481
|
+
puts "Rendered preview.html"
|
482
|
+
end
|
483
|
+
|
484
|
+
def copy_support_files(path_from,path_to)
|
485
|
+
Dir.glob("#{path_from}/*.{jpg,gif,png,mov,m4v,swf,svg,css,js,mpg,flv,mpeg,jpeg,wmv,wma,zip,tar,gz}").each { |file|
|
486
|
+
file_name = file.split("/").last
|
487
|
+
system("cp #{file} #{path_to}/#{file_name}")
|
488
|
+
}
|
489
|
+
end
|
490
|
+
|
491
|
+
def make_links_absolute(html,path)
|
492
|
+
abs_html = html.gsub(/src=.+ /){|src|
|
493
|
+
unless src.index('http') == 5 || src.index('/') == 5 then src.insert(5,path) end
|
494
|
+
src
|
495
|
+
}
|
496
|
+
abs_html = abs_html.gsub(/href=.+ /){|src|
|
497
|
+
unless src.index('http') == 6 || src.index('/') == 6 || src.index('#') == 6 then src.insert(6,path) end
|
498
|
+
src
|
499
|
+
}
|
500
|
+
return abs_html
|
501
|
+
end
|
502
|
+
|
503
|
+
def make_resources_absolute(html,path_to_root="/")
|
504
|
+
absolute_html = html.gsub(/frontend\//){|src|
|
505
|
+
src = path_to_root+src
|
506
|
+
src
|
507
|
+
}
|
508
|
+
return absolute_html
|
509
|
+
end
|
510
|
+
|
511
|
+
|
512
|
+
end
|
Binary file
|
metadata
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: plateau
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Daniel Sim
|
9
|
+
- Exploding Box Productions
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2012-02-13 00:00:00.000000000Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: mustache
|
17
|
+
requirement: &70112699833120 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.99.4
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *70112699833120
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: maruku
|
28
|
+
requirement: &70112699832400 !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.6.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: *70112699832400
|
37
|
+
description: Flat file publishing engine
|
38
|
+
email: dan@explodingbox.com
|
39
|
+
executables:
|
40
|
+
- plateau
|
41
|
+
extensions: []
|
42
|
+
extra_rdoc_files: []
|
43
|
+
files:
|
44
|
+
- README.md
|
45
|
+
- lib/Plateau.rb
|
46
|
+
- resources/Plateau.tar.gz
|
47
|
+
- bin/plateau
|
48
|
+
homepage: https://github.com/explodingbox/Plateau
|
49
|
+
licenses: []
|
50
|
+
post_install_message:
|
51
|
+
rdoc_options: []
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ! '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
requirements: []
|
67
|
+
rubyforge_project:
|
68
|
+
rubygems_version: 1.8.10
|
69
|
+
signing_key:
|
70
|
+
specification_version: 3
|
71
|
+
summary: A publishing & blogging engine powered by markdown and mustache
|
72
|
+
test_files: []
|