gumdrop 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog.md +6 -0
- data/Notes.md +26 -4
- data/lib/gumdrop/build.rb +11 -3
- data/lib/gumdrop/context.rb +1 -1
- data/lib/gumdrop/{deferred_loader.rb → data_manager.rb} +73 -21
- data/lib/gumdrop/version.rb +1 -1
- data/lib/gumdrop.rb +2 -2
- data/templates/backbone/Gumdrop +2 -3
- data/templates/default/Gumdrop +4 -5
- metadata +18 -18
data/ChangeLog.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
# v0.5.2
|
2
|
+
- DeferredLoader changed to DataManager
|
3
|
+
- Added YamlDoc support to data collections -- a data format (.yamldoc) that strips YAML front matter and puts the content under the key 'content', or it will use a custom key from the front matter if the value of the pair is '_YAMLDOC_'
|
4
|
+
- Templates are stored under their short name and full path now.
|
5
|
+
- skip/ignore (blacklist and greylist) now use File.fnmatch instead of starts_with? for matching paths
|
6
|
+
|
1
7
|
# v0.5.1
|
2
8
|
- Bugfix: dev server was rescanning source files multiple times per pages load if build time exceeded 2 seconds... Will now wait 10 seconds before rescanning source.
|
3
9
|
|
data/Notes.md
CHANGED
@@ -1,15 +1,37 @@
|
|
1
1
|
# Future Features/Changes
|
2
|
-
- HTML Manifest generation??
|
3
2
|
- Some kind of admin? What would that even do?
|
4
3
|
- If you could specify a 'prototype' for data collections, could be cool.
|
5
4
|
- Multiple source_dir?
|
6
5
|
- `set :source_dir, ['./source/a', './source/b']
|
7
6
|
- What would happen with conflicts, last one in wins?
|
8
7
|
- Multiple data_dir too?
|
8
|
+
- Refactor code to not use Gumdrop as a singleton (static really)
|
9
|
+
- Add YamlDoc support for nodes?
|
10
|
+
|
9
11
|
|
10
12
|
# TODO:
|
11
13
|
- New/Update Doc Site
|
12
14
|
- API for retrieving pages and pages under a path (simple query)
|
13
|
-
-
|
14
|
-
|
15
|
-
|
15
|
+
- Need test coverage.
|
16
|
+
|
17
|
+
|
18
|
+
# Possible New Internals
|
19
|
+
- Gumdrop (module)
|
20
|
+
- Site (class)
|
21
|
+
- SiteFileDSL (was DSL)
|
22
|
+
- Node (was Content)
|
23
|
+
- NodeGenerator (was Generator)
|
24
|
+
- Data (module)
|
25
|
+
- Manager (was DataManager)
|
26
|
+
- Collection
|
27
|
+
- Object
|
28
|
+
- Pager
|
29
|
+
- Server (module)
|
30
|
+
- NodeHandler
|
31
|
+
- ProxyHandler
|
32
|
+
- Render (module)
|
33
|
+
- Context
|
34
|
+
- ViewHelpers
|
35
|
+
- StitchCompilers
|
36
|
+
- Utils (module)
|
37
|
+
- Logging
|
data/lib/gumdrop/build.rb
CHANGED
@@ -36,6 +36,7 @@ module Gumdrop
|
|
36
36
|
|
37
37
|
# Sort out Layouts, Generators, and Partials
|
38
38
|
if File.extname(path) == ".template"
|
39
|
+
Gumdrop.layouts[path]= node
|
39
40
|
Gumdrop.layouts[File.basename(path)]= node
|
40
41
|
|
41
42
|
elsif File.extname(path) == ".generator"
|
@@ -62,10 +63,11 @@ module Gumdrop
|
|
62
63
|
end
|
63
64
|
end
|
64
65
|
|
66
|
+
# Expunge blacklisted files
|
65
67
|
def filter_tree
|
66
|
-
Gumdrop.blacklist.each do |
|
68
|
+
Gumdrop.blacklist.each do |blacklist_pattern|
|
67
69
|
Gumdrop.site.keys.each do |source_path|
|
68
|
-
if source_path
|
70
|
+
if path_match source_path, blacklist_pattern
|
69
71
|
Gumdrop.report "-excluding: #{source_path}", :info
|
70
72
|
Gumdrop.site.delete source_path
|
71
73
|
end
|
@@ -78,7 +80,7 @@ module Gumdrop
|
|
78
80
|
output_base_path= File.expand_path(Gumdrop.config.output_dir)
|
79
81
|
Gumdrop.report "[Compiling to #{output_base_path}]", :info
|
80
82
|
Gumdrop.site.keys.sort.each do |path|
|
81
|
-
unless Gumdrop.greylist.any? {|
|
83
|
+
unless Gumdrop.greylist.any? {|pattern| path_match path, pattern }
|
82
84
|
node= Gumdrop.site[path]
|
83
85
|
output_path= File.join(output_base_path, node.to_s)
|
84
86
|
FileUtils.mkdir_p File.dirname(output_path)
|
@@ -98,6 +100,12 @@ module Gumdrop
|
|
98
100
|
self
|
99
101
|
end
|
100
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
|
+
|
101
109
|
class << self
|
102
110
|
def run(root, src, opts={})
|
103
111
|
new(root, src, opts).run()
|
data/lib/gumdrop/context.rb
CHANGED
@@ -70,7 +70,7 @@ module Gumdrop
|
|
70
70
|
|
71
71
|
def reset_data(preset={})
|
72
72
|
# TODO: Add a setting for reloading data on every request/page
|
73
|
-
|
73
|
+
# was this for the server?
|
74
74
|
Gumdrop.data.reset if !Gumdrop.config.cache_data
|
75
75
|
@state = preset
|
76
76
|
end
|
@@ -19,11 +19,10 @@ end
|
|
19
19
|
|
20
20
|
module Gumdrop
|
21
21
|
|
22
|
-
class
|
22
|
+
class DataManager
|
23
23
|
attr_reader :cache
|
24
24
|
|
25
25
|
def initialize(data_dir="data")
|
26
|
-
#puts "@!@"
|
27
26
|
@dir= data_dir
|
28
27
|
@cache= {}
|
29
28
|
@persisted= {}
|
@@ -48,16 +47,22 @@ module Gumdrop
|
|
48
47
|
end
|
49
48
|
end
|
50
49
|
|
50
|
+
# TODO: This is not a great place for this. MOVE IT!
|
51
|
+
# This'll go on the Site class for query support: .find()/.all()/.paths()/.nodes()
|
51
52
|
def site
|
52
|
-
# TODO: This is not a great place for this!
|
53
53
|
site= Hash.new {|h,k| h[k]= nil }
|
54
54
|
Gumdrop.site.keys.sort.each do |path|
|
55
|
-
unless Gumdrop.greylist.any? {|
|
55
|
+
unless Gumdrop.greylist.any? {|pattern| path_match path, pattern }
|
56
56
|
site[path]= Gumdrop.site[path]
|
57
57
|
end
|
58
58
|
end
|
59
59
|
site
|
60
60
|
end
|
61
|
+
# Oh dear god! This belongs elsewhere!
|
62
|
+
def path_match(path, pattern)
|
63
|
+
File.fnmatch pattern, path, File::FNM_PATHNAME | File::FNM_DOTMATCH | File::FNM_CASEFOLD
|
64
|
+
end
|
65
|
+
|
61
66
|
|
62
67
|
def site_all
|
63
68
|
Gumdrop.site
|
@@ -87,27 +92,70 @@ module Gumdrop
|
|
87
92
|
path=get_filename(key)
|
88
93
|
return nil if path.nil?
|
89
94
|
if File.extname(path) == ".yamldb"
|
90
|
-
|
91
|
-
File.open(path, 'r') do |f|
|
92
|
-
YAML.load_documents(f) do |doc|
|
93
|
-
docs << hashes2ostruct( doc ) unless doc.has_key?("__proto__")
|
94
|
-
end
|
95
|
-
end
|
96
|
-
docs
|
95
|
+
load_from_yamldb path
|
97
96
|
elsif File.extname(path) == ""
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
97
|
+
load_from_directory path
|
98
|
+
else
|
99
|
+
load_from_file path
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def load_from_file( filename )
|
104
|
+
ext=File.extname(filename)
|
105
|
+
if ext == '.yamldoc' or ext == '.ymldoc'
|
106
|
+
load_from_yamldoc filename
|
107
|
+
elsif ext == '.yaml' or ext == '.yml' or ext == '.json'
|
108
|
+
hashes2ostruct( YAML.load_file(filename) )
|
109
|
+
else
|
110
|
+
raise "Unknown data type (#{ext}) for #{filename}"
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def load_from_yamldb( filename )
|
115
|
+
docs=[]
|
116
|
+
File.open(filename, 'r') do |f|
|
117
|
+
YAML.load_documents(f) do |doc|
|
118
|
+
docs << hashes2ostruct( doc ) unless doc.has_key?("__proto__")
|
106
119
|
end
|
107
|
-
|
120
|
+
end
|
121
|
+
docs
|
122
|
+
end
|
123
|
+
|
124
|
+
def load_from_yamldoc( filename )
|
125
|
+
source = File.read(filename)
|
126
|
+
|
127
|
+
if source =~ /^(\s*---(.+)---\s*)/m
|
128
|
+
yaml = $2.strip
|
129
|
+
content = source.sub($1, '')
|
130
|
+
data= YAML.load(yaml)
|
108
131
|
else
|
109
|
-
|
132
|
+
content= source
|
133
|
+
data={}
|
134
|
+
end
|
135
|
+
|
136
|
+
content_set= false
|
137
|
+
data.each_pair do |key, value|
|
138
|
+
if value == '_YAMLDOC_'
|
139
|
+
data[key]= content
|
140
|
+
content_set= true
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
data['content']= content unless content_set
|
145
|
+
|
146
|
+
hashes2ostruct(data)
|
147
|
+
end
|
148
|
+
|
149
|
+
def load_from_directory( filepath )
|
150
|
+
all=[]
|
151
|
+
Dir[ File.join( "#{filepath}", "{*.yaml,*.json,*.yml,*.yamldoc,*.ymldoc}" ) ].each do |filename|
|
152
|
+
# Gumdrop.report ">> Loading data file: #{filename}"
|
153
|
+
id= File.basename filename
|
154
|
+
obj_hash= load_from_file filename
|
155
|
+
obj_hash._id = id
|
156
|
+
all << obj_hash
|
110
157
|
end
|
158
|
+
all
|
111
159
|
end
|
112
160
|
|
113
161
|
def get_filename(path)
|
@@ -133,4 +181,8 @@ module Gumdrop
|
|
133
181
|
File.join(@dir.to_s, filename.to_s)
|
134
182
|
end
|
135
183
|
end
|
184
|
+
|
185
|
+
class YamlDoc
|
186
|
+
|
187
|
+
end
|
136
188
|
end
|
data/lib/gumdrop/version.rb
CHANGED
data/lib/gumdrop.rb
CHANGED
@@ -29,7 +29,7 @@ module Gumdrop
|
|
29
29
|
autoload :Build, "gumdrop/build"
|
30
30
|
autoload :Context, "gumdrop/context"
|
31
31
|
autoload :Content, "gumdrop/content"
|
32
|
-
autoload :
|
32
|
+
autoload :DataManager, "gumdrop/data_manager"
|
33
33
|
autoload :DSL, "gumdrop/dsl"
|
34
34
|
autoload :Generator, "gumdrop/generator"
|
35
35
|
autoload :GeneratedrContent, "gumdrop/generator"
|
@@ -84,7 +84,7 @@ module Gumdrop
|
|
84
84
|
@site = Hash.new {|h,k| h[k]= nil }
|
85
85
|
@layouts = Hash.new {|h,k| h[k]= nil }
|
86
86
|
@partials = Hash.new {|h,k| h[k]= nil }
|
87
|
-
@data = Gumdrop::
|
87
|
+
@data = Gumdrop::DataManager.new( Gumdrop.config.data_dir )
|
88
88
|
@last_run = Time.now
|
89
89
|
|
90
90
|
begin
|
data/templates/backbone/Gumdrop
CHANGED
@@ -27,9 +27,8 @@ end
|
|
27
27
|
# Ignores source file(s) from compilation, but does load the content into memory
|
28
28
|
# ignore 'pages/'
|
29
29
|
|
30
|
-
# NOTE: Skipping and ignoring matches
|
31
|
-
#
|
32
|
-
# doesn't work for files detected by stitch)
|
30
|
+
# NOTE: Skipping and ignoring matches like a file glob (it use File.fnmatch in fact)
|
31
|
+
# (this doesn't work for files detected by stitch)
|
33
32
|
|
34
33
|
|
35
34
|
# Example site-level generator
|
data/templates/default/Gumdrop
CHANGED
@@ -21,14 +21,13 @@ end
|
|
21
21
|
|
22
22
|
# Skipping files entirely from build process... Like they don't exist.
|
23
23
|
# skip 'file-to-ignore.html'
|
24
|
-
# skip 'dont-show
|
24
|
+
# skip 'dont-show/**/*'
|
25
25
|
|
26
26
|
# Ignores source file(s) from compilation, but does load the content into memory
|
27
|
-
# ignore 'pages
|
27
|
+
# ignore 'pages/**/*.*'
|
28
28
|
|
29
|
-
# NOTE: Skipping and ignoring matches
|
30
|
-
#
|
31
|
-
# doesn't work for files detected by stitch)
|
29
|
+
# NOTE: Skipping and ignoring matches like a file glob (it use File.fnmatch in fact)
|
30
|
+
# (this doesn't work for files detected by stitch)
|
32
31
|
|
33
32
|
|
34
33
|
# Example site-level generator
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gumdrop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-07-22 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sinatra
|
16
|
-
requirement: &
|
16
|
+
requirement: &70136900293340 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70136900293340
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: tilt
|
27
|
-
requirement: &
|
27
|
+
requirement: &70136900292760 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70136900292760
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: active_support
|
38
|
-
requirement: &
|
38
|
+
requirement: &70136900292200 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70136900292200
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: trollop
|
49
|
-
requirement: &
|
49
|
+
requirement: &70136900291500 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70136900291500
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: haml
|
60
|
-
requirement: &
|
60
|
+
requirement: &70136900291040 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70136900291040
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: sass
|
71
|
-
requirement: &
|
71
|
+
requirement: &70136900290620 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70136900290620
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: i18n
|
82
|
-
requirement: &
|
82
|
+
requirement: &70136900290080 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :runtime
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70136900290080
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: bundle
|
93
|
-
requirement: &
|
93
|
+
requirement: &70136900289660 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,7 +98,7 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :runtime
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70136900289660
|
102
102
|
description: A simple cms/prototyping tool.
|
103
103
|
email: matt@elucidata.net
|
104
104
|
executables:
|
@@ -120,7 +120,7 @@ files:
|
|
120
120
|
- lib/gumdrop/cli.rb
|
121
121
|
- lib/gumdrop/content.rb
|
122
122
|
- lib/gumdrop/context.rb
|
123
|
-
- lib/gumdrop/
|
123
|
+
- lib/gumdrop/data_manager.rb
|
124
124
|
- lib/gumdrop/dsl.rb
|
125
125
|
- lib/gumdrop/generator.rb
|
126
126
|
- lib/gumdrop/hash_object.rb
|