gumdrop 0.6.4 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog.md +3 -0
- data/lib/gumdrop/data_manager.rb +21 -17
- data/lib/gumdrop/generator.rb +56 -0
- data/lib/gumdrop/server.rb +2 -2
- data/lib/gumdrop/sprockets_support.rb +3 -0
- data/lib/gumdrop/version.rb +1 -1
- data/lib/gumdrop.rb +3 -3
- data/templates/backbone/Gemfile +1 -0
- data/templates/backbone/config.ru +3 -0
- data/templates/default/Gemfile +1 -0
- data/templates/default/config.ru +3 -0
- metadata +4 -3
data/ChangeLog.md
CHANGED
data/lib/gumdrop/data_manager.rb
CHANGED
@@ -44,6 +44,25 @@ module Gumdrop
|
|
44
44
|
Pager.new( data, base_path, page_size )
|
45
45
|
end
|
46
46
|
|
47
|
+
# Exposing these publicly because, well, they're useful:
|
48
|
+
def load_from_file( filename )
|
49
|
+
ext=File.extname(filename)
|
50
|
+
if ext == '.yamldoc' or ext == '.ymldoc'
|
51
|
+
load_from_yamldoc filename
|
52
|
+
elsif ext == '.yamldb' or ext == '.ymldb'
|
53
|
+
load_from_yamldb filename
|
54
|
+
elsif ext == '.yaml' or ext == '.yml' or ext == '.json'
|
55
|
+
hashes2ostruct( YAML.load_file(filename) )
|
56
|
+
else
|
57
|
+
# raise "Unknown data type (#{ext}) for #{filename}"
|
58
|
+
Gumdrop.report "Unknown data type (#{ext}) for #{filename}", :warning
|
59
|
+
nil
|
60
|
+
end
|
61
|
+
end
|
62
|
+
def load_yamldoc(filename, source=nil)
|
63
|
+
load_from_yamldoc filename, source
|
64
|
+
end
|
65
|
+
|
47
66
|
|
48
67
|
private
|
49
68
|
|
@@ -61,21 +80,6 @@ module Gumdrop
|
|
61
80
|
end
|
62
81
|
end
|
63
82
|
|
64
|
-
def load_from_file( filename )
|
65
|
-
ext=File.extname(filename)
|
66
|
-
if ext == '.yamldoc' or ext == '.ymldoc'
|
67
|
-
load_from_yamldoc filename
|
68
|
-
elsif ext == '.yamldb' or ext == '.ymldb'
|
69
|
-
load_from_yamldb filename
|
70
|
-
elsif ext == '.yaml' or ext == '.yml' or ext == '.json'
|
71
|
-
hashes2ostruct( YAML.load_file(filename) )
|
72
|
-
else
|
73
|
-
# raise "Unknown data type (#{ext}) for #{filename}"
|
74
|
-
Gumdrop.report "Unknown data type (#{ext}) for #{filename}", :warning
|
75
|
-
nil
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
83
|
def load_from_yamldb( filename )
|
80
84
|
docs=[]
|
81
85
|
File.open(filename, 'r') do |f|
|
@@ -86,8 +90,8 @@ module Gumdrop
|
|
86
90
|
docs
|
87
91
|
end
|
88
92
|
|
89
|
-
def load_from_yamldoc( filename )
|
90
|
-
source = File.read(filename)
|
93
|
+
def load_from_yamldoc( filename, source=nil )
|
94
|
+
source = File.read(filename) if source.nil?
|
91
95
|
|
92
96
|
if source =~ /^(\s*---(.+)---\s*)/m
|
93
97
|
yaml = $2.strip
|
data/lib/gumdrop/generator.rb
CHANGED
@@ -78,6 +78,62 @@ module Gumdrop
|
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
|
+
def sprockets(name, opts)
|
82
|
+
require 'gumdrop/sprockets_support'
|
83
|
+
# require 'pp'
|
84
|
+
env = Sprockets::Environment.new @site.root_path
|
85
|
+
env.append_path @site.src_path
|
86
|
+
opts[:paths].each do |path|
|
87
|
+
# path = File.expand_path path
|
88
|
+
# puts ">>>> adding path #{path}"
|
89
|
+
env.append_path(path)
|
90
|
+
end
|
91
|
+
|
92
|
+
content= env[ opts[:src] ].to_s
|
93
|
+
# pp env
|
94
|
+
# pp opts[:src]
|
95
|
+
# pp env[ opts[:src] ]
|
96
|
+
# puts "RENDERED OUTPUT!"
|
97
|
+
# pp content
|
98
|
+
page name do
|
99
|
+
case opts[:compress]
|
100
|
+
|
101
|
+
when true, :jsmin
|
102
|
+
require 'jsmin'
|
103
|
+
JSMin.minify content
|
104
|
+
|
105
|
+
when :yuic
|
106
|
+
require "yui/compressor"
|
107
|
+
compressor = YUI::JavaScriptCompressor.new(:munge => opts[:obfuscate])
|
108
|
+
compressor.compress(content)
|
109
|
+
|
110
|
+
when :uglify
|
111
|
+
require "uglifier"
|
112
|
+
Uglifier.compile( content, :mangle=>opts[:obfuscate])
|
113
|
+
|
114
|
+
when false
|
115
|
+
content
|
116
|
+
|
117
|
+
else
|
118
|
+
# UNKNOWN Compressor type!
|
119
|
+
@site.report "Unknown javascript compressor type! (#{ opts[:compressor] })", :warning
|
120
|
+
content
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
if opts[:prune] and opts[:root]
|
125
|
+
sp = File.expand_path( @site.config.source_dir )
|
126
|
+
rp = File.expand_path(opts[:root])
|
127
|
+
relative_root = rp.gsub(sp, '')[1..-1]
|
128
|
+
rrlen= relative_root.length - 1
|
129
|
+
@site.node_tree.keys.each do |path|
|
130
|
+
if path[0..rrlen] == relative_root and name != path
|
131
|
+
@site.node_tree.delete path
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
81
137
|
def stitch(name, opts)
|
82
138
|
require 'gumdrop/stitch_support'
|
83
139
|
content= Stitch::Package.new(opts).compile
|
data/lib/gumdrop/server.rb
CHANGED
@@ -11,7 +11,7 @@ module Gumdrop
|
|
11
11
|
site_file= Gumdrop.fetch_site_file
|
12
12
|
unless site_file.nil?
|
13
13
|
site= Site.new site_file
|
14
|
-
site.
|
14
|
+
site.rescan()
|
15
15
|
|
16
16
|
set :port, site.config.server_port if site.config.server_port
|
17
17
|
|
@@ -48,7 +48,7 @@ module Gumdrop
|
|
48
48
|
content_type :js if content.ext == '.js' # Meh?
|
49
49
|
content_type :xml if content.ext == '.xml' # Meh?
|
50
50
|
output= content.render
|
51
|
-
site.content_filters.each {|f| output= f.call(output,
|
51
|
+
site.content_filters.each {|f| output= f.call(output, content) }
|
52
52
|
output
|
53
53
|
else
|
54
54
|
site.report "[#{$$}] *Static: #{file_path}"
|
data/lib/gumdrop/version.rb
CHANGED
data/lib/gumdrop.rb
CHANGED
@@ -23,14 +23,14 @@ module Gumdrop
|
|
23
23
|
site_file= Gumdrop.fetch_site_file
|
24
24
|
unless site_file.nil?
|
25
25
|
site= Site.new site_file, opts
|
26
|
-
|
26
|
+
|
27
27
|
old= Dir.pwd
|
28
28
|
Dir.chdir site.root_path
|
29
|
-
|
29
|
+
|
30
30
|
site.build
|
31
31
|
|
32
32
|
Dir.chdir old
|
33
|
-
|
33
|
+
|
34
34
|
puts "Done."
|
35
35
|
else
|
36
36
|
puts "Not in a valid Gumdrop site directory."
|
data/templates/backbone/Gemfile
CHANGED
data/templates/default/Gemfile
CHANGED
data/templates/default/config.ru
CHANGED
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 7
|
8
|
+
- 0
|
9
|
+
version: 0.7.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Matt McCray
|
@@ -123,6 +123,7 @@ files:
|
|
123
123
|
- lib/gumdrop/proxy_handler.rb
|
124
124
|
- lib/gumdrop/server.rb
|
125
125
|
- lib/gumdrop/site.rb
|
126
|
+
- lib/gumdrop/sprockets_support.rb
|
126
127
|
- lib/gumdrop/stitch_support.rb
|
127
128
|
- lib/gumdrop/version.rb
|
128
129
|
- lib/gumdrop/view_helpers.rb
|