26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/sinatra/kinbote_helpers.rb', line 26
def publish
FileUtils.rm_rf("#{$site.kinbote_path}/www")
FileUtils.mkdir_p("#{$site.kinbote_path}/www/css/pages")
FileUtils.copy_entry("#{$site.kinbote_path}/public", "#{$site.kinbote_path}/www")
files = Dir.glob("#{$site.kinbote_path}/views/**/*.{haml,sass}")
files.each do |file|
next if file.include?("/.kinbote/") || file.include?("/snippets/") || file.include?("/layout.haml")
slug = (file.include?("/views/pages/") ? slug_from_file(file) : nil)
@page = (slug ? $site.find_page(slug) : nil)
type = type_from_file(file)
if @page && type == "haml"
File.open("#{$site.kinbote_path}/www/#{@page.slug}.html", 'w') {|f| f.write(haml(:"#{@page.path}")) }
elsif @page && type == "sass"
File.open("#{$site.kinbote_path}/www/css/pages/#{@page.slug}.css", 'w') {|f| f.write(sass(:"#{@page.path.gsub(".haml", ".sass")}")) }
elsif type == "haml"
FileUtils.mkdir_p("#{dir_from_file(output_path(file))}")
File.open(output_path(file), "w") {|f| f.write(render(type.to_sym, :"#{file_without_extension(view_path(file))}"))}
elsif type == "sass"
FileUtils.mkdir_p("#{dir_from_file(output_path(file))}")
File.open(output_path(file), "w") {|f| f.write(render(type.to_sym, :"#{file_without_extension(view_path(file))}"))}
end
end
return if !$site.config.has_key?("remote_host") || !$site.config.has_key?("remote_user") || !$site.config.has_key?("remote_pw")
Net::SCP.start($site.config["remote_host"], $site.config["remote_user"], :password => $site.config["remote_pw"] ) do |scp|
scp.upload!("#{$site.kinbote_path}/www", $site.config["remote_path"], :recursive => true)
end
end
|