weaver 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/weaver +27 -2
- data/lib/weaver/version.rb +1 -1
- data/lib/weaver.rb +0 -24
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56ea5d732adead9467770719420810f53e615aeb
|
4
|
+
data.tar.gz: 1a0aeddf03834c5b8e3ff8075548a7216a7a339a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c396d94035893b179da71d5d5bc92989f492383a3b4af2becf146bd03206d95ad4af87db43ebe1e0760b75ba05237185a32724d777c5c27321e9a8056641e41a
|
7
|
+
data.tar.gz: ab19afbc85238a3b00c579c52050dcf44c6aaf22bf30ca24dfde482874d8242cbdac077177a9332667d587a3925505172a3906f166d93fa052f2e5a4bb9fa3e3
|
data/bin/weaver
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'weaver'
|
4
4
|
|
5
|
-
class
|
5
|
+
class Website < Sinatra::Base
|
6
6
|
|
7
7
|
set :static, true # set up static file routing
|
8
8
|
set :public_folder, Gem.datadir("weaver") # set up the static dir (with images/js/css inside)
|
@@ -32,6 +32,8 @@ class PreviewApp < Sinatra::Base
|
|
32
32
|
{ viewFile: viewFile, path: remainingPath }
|
33
33
|
end
|
34
34
|
|
35
|
+
|
36
|
+
|
35
37
|
get '/*' do
|
36
38
|
viewname = params[:splat].first
|
37
39
|
result = getWeavefile viewname
|
@@ -59,12 +61,35 @@ end
|
|
59
61
|
|
60
62
|
def build!
|
61
63
|
puts "Building site..."
|
64
|
+
|
65
|
+
buildDir = "#{Dir.pwd}/build"
|
66
|
+
FileUtils::rm_rf buildDir
|
67
|
+
FileUtils.cp_r(Gem.datadir("weaver"), buildDir)
|
68
|
+
|
69
|
+
files = Dir["source/**/*.weave"]
|
70
|
+
files.each do |file|
|
71
|
+
baseDir = file.chomp('.weave').chomp('index').sub(/^source\//, "")
|
72
|
+
|
73
|
+
site = Weaver::Weave.new(file)
|
74
|
+
|
75
|
+
site.pages.each do |localPath, page|
|
76
|
+
resultPath = File.join(baseDir, localPath)
|
77
|
+
|
78
|
+
level = resultPath.split(/\//, 0).length
|
79
|
+
puts "Writing: #{file} -> #{resultPath} (Level: #{level})"
|
80
|
+
|
81
|
+
fileName = File.join([buildDir, resultPath, "index.html"])
|
82
|
+
FileUtils::mkdir_p File.dirname(fileName)
|
83
|
+
File.write(fileName, page.generate(level))
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
62
87
|
end
|
63
88
|
|
64
89
|
def preview!
|
65
90
|
puts "Weaver Preview Mode in: #{Dir.pwd}"
|
66
91
|
|
67
|
-
|
92
|
+
Website.run!
|
68
93
|
end
|
69
94
|
|
70
95
|
if ARGV[0] == "build"
|
data/lib/weaver/version.rb
CHANGED
data/lib/weaver.rb
CHANGED
@@ -895,28 +895,4 @@ module Weaver
|
|
895
895
|
load filename
|
896
896
|
end
|
897
897
|
end
|
898
|
-
|
899
|
-
class SiteBuilder
|
900
|
-
|
901
|
-
def initialize(pages)
|
902
|
-
@pages = pages
|
903
|
-
end
|
904
|
-
|
905
|
-
|
906
|
-
def build_site(folder)
|
907
|
-
FileUtils::mkdir_p folder
|
908
|
-
FileUtils.cp_r(Gem.datadir("weaver") + '/css', folder + '/css')
|
909
|
-
FileUtils.cp_r(Gem.datadir("weaver") + '/fonts', folder + '/fonts')
|
910
|
-
FileUtils.cp_r(Gem.datadir("weaver") + '/js', folder + '/js')
|
911
|
-
FileUtils.cp_r(Gem.datadir("weaver") + '/font-awesome', folder + '/font-awesome')
|
912
|
-
|
913
|
-
@pages.each do |path, page|
|
914
|
-
FileUtils::mkdir_p folder + "/" + path
|
915
|
-
|
916
|
-
level = path.split(/\//, 0).length
|
917
|
-
|
918
|
-
File.write(folder + "/" + path + "/index.html", page.generate(level) )
|
919
|
-
end
|
920
|
-
end
|
921
|
-
end
|
922
898
|
end
|