gumdrop 0.5.2 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog.md +3 -0
- data/License +1 -1
- data/Notes.md +9 -1
- data/gumdrop.gemspec +4 -4
- data/lib/gumdrop/cli.rb +13 -3
- data/lib/gumdrop/content.rb +17 -15
- data/lib/gumdrop/context.rb +116 -111
- data/lib/gumdrop/data_manager.rb +93 -71
- data/lib/gumdrop/generator.rb +23 -18
- data/lib/gumdrop/server.rb +62 -110
- data/lib/gumdrop/site.rb +295 -0
- data/lib/gumdrop/version.rb +1 -1
- data/lib/gumdrop/view_helpers.rb +1 -1
- data/lib/gumdrop.rb +7 -114
- data/templates/backbone/Gumdrop +8 -8
- data/templates/backbone/config.ru +0 -4
- data/templates/backbone/source/default.htaccess.erb +2 -1
- data/templates/backbone/source/index.html.erb +1 -1
- data/templates/backbone/source/theme/templates/site.template.slim +1 -1
- data/templates/default/Gumdrop +7 -5
- data/templates/default/config.ru +0 -3
- data/templates/default/source/default.htaccess.erb +2 -1
- data/templates/default/source/theme/templates/site.template.slim +1 -1
- metadata +100 -97
- data/lib/gumdrop/build.rb +0 -116
- data/lib/gumdrop/dsl.rb +0 -30
- data/lib/gumdrop/logging.rb +0 -35
- data/lib/gumdrop/pager.rb +0 -49
- data/lib/gumdrop/utils.rb +0 -20
data/lib/gumdrop.rb
CHANGED
@@ -4,119 +4,31 @@ require 'tilt'
|
|
4
4
|
require 'fileutils'
|
5
5
|
require 'active_support/all'
|
6
6
|
|
7
|
-
DEFAULT_OPTIONS= {
|
8
|
-
cache_data: false,
|
9
|
-
relative_paths: true,
|
10
|
-
auto_run: false,
|
11
|
-
force_reload: false,
|
12
|
-
proxy_enabled: true,
|
13
|
-
output_dir: "./output",
|
14
|
-
lib_dir: "./lib",
|
15
|
-
source_dir: "./source",
|
16
|
-
data_dir: './data',
|
17
|
-
log_level: :info,
|
18
|
-
log: 'logs/build.log'
|
19
|
-
}
|
20
|
-
|
21
|
-
LOG_LEVELS = {
|
22
|
-
info: 0,
|
23
|
-
warning: 1,
|
24
|
-
error: 2
|
25
|
-
}
|
26
|
-
|
27
7
|
module Gumdrop
|
28
|
-
|
29
|
-
autoload :Build, "gumdrop/build"
|
8
|
+
|
30
9
|
autoload :Context, "gumdrop/context"
|
31
10
|
autoload :Content, "gumdrop/content"
|
32
11
|
autoload :DataManager, "gumdrop/data_manager"
|
33
|
-
autoload :DSL, "gumdrop/dsl"
|
34
12
|
autoload :Generator, "gumdrop/generator"
|
35
|
-
autoload :GeneratedrContent, "gumdrop/generator"
|
36
13
|
autoload :HashObject, "gumdrop/hash_object"
|
37
|
-
autoload :
|
38
|
-
autoload :Pager, "gumdrop/pager"
|
14
|
+
autoload :Pager, "gumdrop/data_manager"
|
39
15
|
autoload :Server, "gumdrop/server"
|
40
|
-
autoload :
|
16
|
+
autoload :Site, "gumdrop/site"
|
41
17
|
autoload :VERSION, "gumdrop/version"
|
42
18
|
autoload :ViewHelpers, "gumdrop/view_helpers"
|
43
19
|
|
44
20
|
class << self
|
45
|
-
|
46
|
-
attr_accessor :root_path,
|
47
|
-
:source_path,
|
48
|
-
:site,
|
49
|
-
:layouts,
|
50
|
-
:generators,
|
51
|
-
:partials,
|
52
|
-
:redirects,
|
53
|
-
:config,
|
54
|
-
:data,
|
55
|
-
:content_filters,
|
56
|
-
:blacklist,
|
57
|
-
:greylist,
|
58
|
-
:log,
|
59
|
-
:last_run
|
60
|
-
|
21
|
+
|
61
22
|
def run(opts={})
|
62
23
|
site_file= Gumdrop.fetch_site_file
|
63
|
-
|
64
24
|
unless site_file.nil?
|
65
|
-
|
66
|
-
@content_filters = []
|
67
|
-
@blacklist = []
|
68
|
-
@greylist = []
|
69
|
-
@redirects = []
|
70
|
-
|
71
|
-
# In server mode, we want to reload it every time... right?
|
72
|
-
load_site_file site_file
|
25
|
+
site= Site.new site_file, opts
|
73
26
|
|
74
|
-
|
75
|
-
|
76
|
-
root= File.expand_path File.dirname(site_file)
|
77
|
-
Dir.chdir root
|
78
|
-
|
79
|
-
src= File.expand_path Gumdrop.config.source_dir #File.join root, 'source'
|
80
|
-
lib_path= File.expand_path Gumdrop.config.lib_dir
|
81
|
-
|
82
|
-
@root_path = root.split '/'
|
83
|
-
@source_path = src.split '/'
|
84
|
-
@site = Hash.new {|h,k| h[k]= nil }
|
85
|
-
@layouts = Hash.new {|h,k| h[k]= nil }
|
86
|
-
@partials = Hash.new {|h,k| h[k]= nil }
|
87
|
-
@data = Gumdrop::DataManager.new( Gumdrop.config.data_dir )
|
88
|
-
@last_run = Time.now
|
89
|
-
|
90
|
-
begin
|
91
|
-
@log = Logger.new Gumdrop.config.log, 'daily'
|
92
|
-
rescue
|
93
|
-
@log = Logger.new STDOUT
|
94
|
-
end
|
95
|
-
@log.formatter = proc do |severity, datetime, progname, msg|
|
96
|
-
"#{datetime}: #{msg}\n"
|
97
|
-
end
|
98
|
-
|
99
|
-
Build.run root, src, opts
|
27
|
+
site.build
|
100
28
|
|
101
29
|
puts "Done."
|
102
|
-
|
103
30
|
else
|
104
31
|
puts "Not in a valid Gumdrop site directory."
|
105
|
-
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
# levels: info, warning, error
|
110
|
-
def report(msg, level=:info)
|
111
|
-
ll= Gumdrop.config.log_level
|
112
|
-
case level
|
113
|
-
when :info
|
114
|
-
@log.info msg
|
115
|
-
when :warning
|
116
|
-
@log.warn msg
|
117
|
-
else
|
118
|
-
puts msg
|
119
|
-
@log.error msg
|
120
32
|
end
|
121
33
|
end
|
122
34
|
|
@@ -124,12 +36,6 @@ module Gumdrop
|
|
124
36
|
!fetch_site_file(filename).nil?
|
125
37
|
end
|
126
38
|
|
127
|
-
def load_site_file(site_file=nil)
|
128
|
-
site_file= fetch_site_file if site_file.nil?
|
129
|
-
source= IO.readlines( site_file ).join('')
|
130
|
-
DSL.class_eval source
|
131
|
-
end
|
132
|
-
|
133
39
|
def fetch_site_file(filename="Gumdrop")
|
134
40
|
here= Dir.pwd
|
135
41
|
found= File.file? File.join( here, filename )
|
@@ -144,23 +50,10 @@ module Gumdrop
|
|
144
50
|
end
|
145
51
|
end
|
146
52
|
|
147
|
-
def
|
53
|
+
def site_dirname(filename="Gumdrop")
|
148
54
|
File.dirname( fetch_site_file( filename ) )
|
149
55
|
end
|
150
56
|
|
151
57
|
end
|
152
|
-
|
153
|
-
|
154
|
-
Gumdrop.config= Gumdrop::HashObject.new(DEFAULT_OPTIONS)
|
155
|
-
|
156
|
-
|
157
|
-
module Configurator
|
158
|
-
class << self
|
159
|
-
def set(key,value)
|
160
|
-
# puts "Setting Gumdrop.config.#{key} = #{value}"
|
161
|
-
Gumdrop.config[key.to_sym]= value
|
162
|
-
end
|
163
|
-
end
|
164
|
-
end
|
165
58
|
|
166
59
|
end
|
data/templates/backbone/Gumdrop
CHANGED
@@ -8,24 +8,24 @@ configure do
|
|
8
8
|
set :site_url, "http://www.mysite.com"
|
9
9
|
|
10
10
|
# All the supported build configuration settings and their defaults:
|
11
|
-
|
11
|
+
# set :relative_paths, true
|
12
|
+
# set :proxy_enabled, true
|
12
13
|
# set :output_dir, "./output"
|
13
|
-
# set :lib_dir, "./lib"
|
14
14
|
# set :source_dir, "./source"
|
15
15
|
# set :data_dir, './data'
|
16
|
-
# set :
|
17
|
-
# set :
|
18
|
-
# set :
|
19
|
-
# set :
|
16
|
+
# set :log, './logs/build.log'
|
17
|
+
# set :ignore, %w(.DS_Store .gitignore .git .svn .sass-cache)
|
18
|
+
# set :server_timeout, 15
|
19
|
+
# set :server_port, 4567
|
20
20
|
|
21
21
|
end
|
22
22
|
|
23
23
|
# Skipping files entirely from build process... Like they don't exist.
|
24
24
|
# skip 'file-to-ignore.html'
|
25
|
-
# skip 'dont-show
|
25
|
+
# skip 'dont-show/**/*'
|
26
26
|
|
27
27
|
# Ignores source file(s) from compilation, but does load the content into memory
|
28
|
-
# ignore 'pages
|
28
|
+
# ignore 'pages/**/*'
|
29
29
|
|
30
30
|
# NOTE: Skipping and ignoring matches like a file glob (it use File.fnmatch in fact)
|
31
31
|
# (this doesn't work for files detected by stitch)
|
@@ -10,12 +10,8 @@ end
|
|
10
10
|
|
11
11
|
require 'gumdrop'
|
12
12
|
|
13
|
-
Gumdrop.config.auto_run= false
|
14
|
-
Gumdrop.config.force_reload= true
|
15
|
-
|
16
13
|
#require 'rack/static'
|
17
14
|
#use Rack::Static, :urls => ["/media"], :root => "source"
|
18
15
|
#use Rack::Static, :urls => ["/theme/images"], :root => "source"
|
19
16
|
|
20
|
-
|
21
17
|
run Gumdrop::Server
|
@@ -1,3 +1,4 @@
|
|
1
|
+
<% use_layout nil %>
|
1
2
|
# For clean urls
|
2
3
|
DirectoryIndex index.html
|
3
4
|
|
@@ -21,6 +22,6 @@ DirectoryIndex index.html
|
|
21
22
|
</IfModule>
|
22
23
|
# END Gzip
|
23
24
|
|
24
|
-
<%
|
25
|
+
<% site.redirects.each do |opts| %>
|
25
26
|
# Redirect <%= opts[:from] %> <%= opts[:to] %>
|
26
27
|
<% end %>
|
@@ -1,2 +1,2 @@
|
|
1
|
-
<%
|
1
|
+
<% use_layout 'app' %>
|
2
2
|
<article id="main"></article>
|
data/templates/default/Gumdrop
CHANGED
@@ -8,14 +8,16 @@ configure do
|
|
8
8
|
set :site_url, "http://www.mysite.com"
|
9
9
|
|
10
10
|
# All the supported build configuration settings and their defaults:
|
11
|
+
# set :relative_paths, true
|
12
|
+
# set :proxy_enabled, true
|
11
13
|
# set :output_dir, "./output"
|
12
|
-
# set :lib_dir, "./lib"
|
13
14
|
# set :source_dir, "./source"
|
14
15
|
# set :data_dir, './data'
|
15
|
-
# set :
|
16
|
-
# set :
|
17
|
-
# set :
|
18
|
-
# set :
|
16
|
+
# set :log, './logs/build.log'
|
17
|
+
# set :ignore, %w(.DS_Store .gitignore .git .svn .sass-cache)
|
18
|
+
# set :server_timeout, 15
|
19
|
+
# set :server_port, 4567
|
20
|
+
|
19
21
|
end
|
20
22
|
|
21
23
|
|
data/templates/default/config.ru
CHANGED
@@ -10,9 +10,6 @@ end
|
|
10
10
|
|
11
11
|
require 'gumdrop'
|
12
12
|
|
13
|
-
Gumdrop.config.auto_run= false
|
14
|
-
Gumdrop.config.force_reload= true
|
15
|
-
|
16
13
|
#require 'rack/static'
|
17
14
|
#use Rack::Static, :urls => ["/media"], :root => "source"
|
18
15
|
#use Rack::Static, :urls => ["/theme/images"], :root => "source"
|
@@ -1,3 +1,4 @@
|
|
1
|
+
<% use_layout nil %>
|
1
2
|
# For clean urls
|
2
3
|
DirectoryIndex index.html
|
3
4
|
|
@@ -21,6 +22,6 @@ DirectoryIndex index.html
|
|
21
22
|
</IfModule>
|
22
23
|
# END Gzip
|
23
24
|
|
24
|
-
<%
|
25
|
+
<% site.redirects.each do |opts| %>
|
25
26
|
# Redirect <%= opts[:from] %> <%= opts[:to] %>
|
26
27
|
<% end %>
|
metadata
CHANGED
@@ -1,111 +1,109 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: gumdrop
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 6
|
8
|
+
- 0
|
9
|
+
version: 0.6.0
|
6
10
|
platform: ruby
|
7
|
-
authors:
|
11
|
+
authors:
|
8
12
|
- Matt McCray
|
9
13
|
autorequire:
|
10
14
|
bindir: bin
|
11
15
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
16
|
+
|
17
|
+
date: 2011-07-22 00:00:00 -05:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
15
21
|
name: sinatra
|
16
|
-
requirement: &70136900293340 !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ! '>='
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '0'
|
22
|
-
type: :runtime
|
23
22
|
prerelease: false
|
24
|
-
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: tilt
|
27
|
-
requirement: &70136900292760 !ruby/object:Gem::Requirement
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
28
24
|
none: false
|
29
|
-
requirements:
|
30
|
-
- -
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
version: "0"
|
33
31
|
type: :runtime
|
32
|
+
version_requirements: *id001
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: tilt
|
34
35
|
prerelease: false
|
35
|
-
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
|
-
name: active_support
|
38
|
-
requirement: &70136900292200 !ruby/object:Gem::Requirement
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
37
|
none: false
|
40
|
-
requirements:
|
41
|
-
- -
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
version_requirements: *70136900292200
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: trollop
|
49
|
-
requirement: &70136900291500 !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
|
-
requirements:
|
52
|
-
- - ! '>='
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 0
|
43
|
+
version: "0"
|
55
44
|
type: :runtime
|
45
|
+
version_requirements: *id002
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: active_support
|
56
48
|
prerelease: false
|
57
|
-
|
58
|
-
- !ruby/object:Gem::Dependency
|
59
|
-
name: haml
|
60
|
-
requirement: &70136900291040 !ruby/object:Gem::Requirement
|
49
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
61
50
|
none: false
|
62
|
-
requirements:
|
63
|
-
- -
|
64
|
-
- !ruby/object:Gem::Version
|
65
|
-
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
segments:
|
55
|
+
- 0
|
56
|
+
version: "0"
|
66
57
|
type: :runtime
|
58
|
+
version_requirements: *id003
|
59
|
+
- !ruby/object:Gem::Dependency
|
60
|
+
name: trollop
|
67
61
|
prerelease: false
|
68
|
-
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: sass
|
71
|
-
requirement: &70136900290620 !ruby/object:Gem::Requirement
|
62
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
72
63
|
none: false
|
73
|
-
requirements:
|
74
|
-
- -
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
segments:
|
68
|
+
- 0
|
69
|
+
version: "0"
|
77
70
|
type: :runtime
|
78
|
-
|
79
|
-
|
80
|
-
- !ruby/object:Gem::Dependency
|
71
|
+
version_requirements: *id004
|
72
|
+
- !ruby/object:Gem::Dependency
|
81
73
|
name: i18n
|
82
|
-
|
74
|
+
prerelease: false
|
75
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
83
76
|
none: false
|
84
|
-
requirements:
|
85
|
-
- -
|
86
|
-
- !ruby/object:Gem::Version
|
87
|
-
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
segments:
|
81
|
+
- 0
|
82
|
+
version: "0"
|
88
83
|
type: :runtime
|
89
|
-
|
90
|
-
|
91
|
-
- !ruby/object:Gem::Dependency
|
84
|
+
version_requirements: *id005
|
85
|
+
- !ruby/object:Gem::Dependency
|
92
86
|
name: bundle
|
93
|
-
|
87
|
+
prerelease: false
|
88
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
94
89
|
none: false
|
95
|
-
requirements:
|
96
|
-
- -
|
97
|
-
- !ruby/object:Gem::Version
|
98
|
-
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
segments:
|
94
|
+
- 0
|
95
|
+
version: "0"
|
99
96
|
type: :runtime
|
100
|
-
|
101
|
-
|
102
|
-
description: A simple cms/prototyping tool.
|
97
|
+
version_requirements: *id006
|
98
|
+
description: A sweet 'n simple cms/prototyping tool for creating static html websites and webapps.
|
103
99
|
email: matt@elucidata.net
|
104
|
-
executables:
|
100
|
+
executables:
|
105
101
|
- gumdrop
|
106
102
|
extensions: []
|
103
|
+
|
107
104
|
extra_rdoc_files: []
|
108
|
-
|
105
|
+
|
106
|
+
files:
|
109
107
|
- .gitignore
|
110
108
|
- ChangeLog.md
|
111
109
|
- Gemfile
|
@@ -116,21 +114,17 @@ files:
|
|
116
114
|
- bin/gumdrop
|
117
115
|
- gumdrop.gemspec
|
118
116
|
- lib/gumdrop.rb
|
119
|
-
- lib/gumdrop/build.rb
|
120
117
|
- lib/gumdrop/cli.rb
|
121
118
|
- lib/gumdrop/content.rb
|
122
119
|
- lib/gumdrop/context.rb
|
123
120
|
- lib/gumdrop/data_manager.rb
|
124
|
-
- lib/gumdrop/dsl.rb
|
125
121
|
- lib/gumdrop/generator.rb
|
126
122
|
- lib/gumdrop/hash_object.rb
|
127
|
-
- lib/gumdrop/logging.rb
|
128
|
-
- lib/gumdrop/pager.rb
|
129
123
|
- lib/gumdrop/proxy_handler.rb
|
130
124
|
- lib/gumdrop/server.rb
|
125
|
+
- lib/gumdrop/site.rb
|
131
126
|
- lib/gumdrop/stitch_compilers.rb
|
132
127
|
- lib/gumdrop/stitch_ex.rb
|
133
|
-
- lib/gumdrop/utils.rb
|
134
128
|
- lib/gumdrop/version.rb
|
135
129
|
- lib/gumdrop/view_helpers.rb
|
136
130
|
- specs/content_spec.rb
|
@@ -175,28 +169,37 @@ files:
|
|
175
169
|
- templates/default/source/theme/scripts/app.js.coffee
|
176
170
|
- templates/default/source/theme/styles/_tools.scss
|
177
171
|
- templates/default/source/theme/templates/site.template.slim
|
172
|
+
has_rdoc: true
|
178
173
|
homepage: https://github.com/darthapo/gumdrop
|
179
174
|
licenses: []
|
175
|
+
|
180
176
|
post_install_message:
|
181
177
|
rdoc_options: []
|
182
|
-
|
178
|
+
|
179
|
+
require_paths:
|
183
180
|
- lib
|
184
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
181
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
185
182
|
none: false
|
186
|
-
requirements:
|
187
|
-
- -
|
188
|
-
- !ruby/object:Gem::Version
|
189
|
-
|
190
|
-
|
183
|
+
requirements:
|
184
|
+
- - ">="
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
segments:
|
187
|
+
- 0
|
188
|
+
version: "0"
|
189
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
191
190
|
none: false
|
192
|
-
requirements:
|
193
|
-
- -
|
194
|
-
- !ruby/object:Gem::Version
|
195
|
-
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
segments:
|
195
|
+
- 0
|
196
|
+
version: "0"
|
196
197
|
requirements: []
|
198
|
+
|
197
199
|
rubyforge_project: gumdrop
|
198
|
-
rubygems_version: 1.
|
200
|
+
rubygems_version: 1.3.7
|
199
201
|
signing_key:
|
200
202
|
specification_version: 3
|
201
|
-
summary: A simple cms/prototyping tool.
|
203
|
+
summary: A sweet 'n simple cms/prototyping tool.
|
202
204
|
test_files: []
|
205
|
+
|
data/lib/gumdrop/build.rb
DELETED
@@ -1,116 +0,0 @@
|
|
1
|
-
|
2
|
-
module Gumdrop
|
3
|
-
|
4
|
-
class Build
|
5
|
-
attr_reader :root, :src, :opts
|
6
|
-
|
7
|
-
SKIP= %w(.DS_Store .gitignore .git .svn .sass-cache)
|
8
|
-
|
9
|
-
def initialize(root, src, opts={})
|
10
|
-
@root= root
|
11
|
-
@root_path= root.split('/')
|
12
|
-
@src= src
|
13
|
-
@opts= opts
|
14
|
-
# if opts[:auto_run]
|
15
|
-
# run()
|
16
|
-
# end
|
17
|
-
end
|
18
|
-
|
19
|
-
def build_tree
|
20
|
-
Gumdrop.report "[Scanning from #{src}]", :info
|
21
|
-
# Report blacklists and greylists
|
22
|
-
Gumdrop.blacklist.each do |path|
|
23
|
-
Gumdrop.report " blacklist: #{path}", :info
|
24
|
-
end
|
25
|
-
Gumdrop.greylist.each do |path|
|
26
|
-
Gumdrop.report " greylist: #{path}", :info
|
27
|
-
end
|
28
|
-
|
29
|
-
# Scan Filesystem
|
30
|
-
#puts "Running in: #{root}"
|
31
|
-
Dir.glob("#{src}/**/*", File::FNM_DOTMATCH).each do |path|
|
32
|
-
unless File.directory? path or Build::SKIP.include?( File.basename(path) )
|
33
|
-
file_path = (path.split('/') - @root_path).join '/'
|
34
|
-
node= Content.new(file_path)
|
35
|
-
path= node.to_s
|
36
|
-
|
37
|
-
# Sort out Layouts, Generators, and Partials
|
38
|
-
if File.extname(path) == ".template"
|
39
|
-
Gumdrop.layouts[path]= node
|
40
|
-
Gumdrop.layouts[File.basename(path)]= node
|
41
|
-
|
42
|
-
elsif File.extname(path) == ".generator"
|
43
|
-
Gumdrop.generators[File.basename(path)]= Generator.new( node )
|
44
|
-
|
45
|
-
elsif File.basename(path).starts_with?("_")
|
46
|
-
partial_name= File.basename(path)[1..-1].gsub(File.extname(File.basename(path)), '')
|
47
|
-
partial_node_path= File.join File.dirname(path), partial_name
|
48
|
-
# puts "Creating partial #{partial_name} from #{path}"
|
49
|
-
Gumdrop.partials[partial_name]= node
|
50
|
-
Gumdrop.partials[partial_node_path]= node
|
51
|
-
else
|
52
|
-
Gumdrop.site[path]= node
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
def run_generators
|
60
|
-
Gumdrop.report "[Executing Generators]", :info
|
61
|
-
Gumdrop.generators.each_pair do |path, generator|
|
62
|
-
generator.execute()
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
# Expunge blacklisted files
|
67
|
-
def filter_tree
|
68
|
-
Gumdrop.blacklist.each do |blacklist_pattern|
|
69
|
-
Gumdrop.site.keys.each do |source_path|
|
70
|
-
if path_match source_path, blacklist_pattern
|
71
|
-
Gumdrop.report "-excluding: #{source_path}", :info
|
72
|
-
Gumdrop.site.delete source_path
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def render
|
79
|
-
unless opts[:dry_run]
|
80
|
-
output_base_path= File.expand_path(Gumdrop.config.output_dir)
|
81
|
-
Gumdrop.report "[Compiling to #{output_base_path}]", :info
|
82
|
-
Gumdrop.site.keys.sort.each do |path|
|
83
|
-
unless Gumdrop.greylist.any? {|pattern| path_match path, pattern }
|
84
|
-
node= Gumdrop.site[path]
|
85
|
-
output_path= File.join(output_base_path, node.to_s)
|
86
|
-
FileUtils.mkdir_p File.dirname(output_path)
|
87
|
-
node.renderTo output_path, Gumdrop.content_filters
|
88
|
-
else
|
89
|
-
Gumdrop.report " -ignoring: #{path}", :info
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
def run
|
96
|
-
build_tree()
|
97
|
-
run_generators()
|
98
|
-
filter_tree()
|
99
|
-
render()
|
100
|
-
self
|
101
|
-
end
|
102
|
-
|
103
|
-
# Match a path using a glob-like file pattern
|
104
|
-
def path_match(path, pattern)
|
105
|
-
File.fnmatch pattern, path, File::FNM_PATHNAME | File::FNM_DOTMATCH | File::FNM_CASEFOLD
|
106
|
-
end
|
107
|
-
|
108
|
-
|
109
|
-
class << self
|
110
|
-
def run(root, src, opts={})
|
111
|
-
new(root, src, opts).run()
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
end
|