roger 0.0.1 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.gitignore +2 -0
- data/.travis.yml +12 -0
- data/CHANGELOG.md +102 -0
- data/Gemfile +5 -0
- data/MIT_LICENSE +20 -0
- data/README.md +10 -10
- data/Rakefile +9 -0
- data/bin/roger +5 -0
- data/doc/cli.md +46 -0
- data/doc/mockupfile.md +3 -0
- data/doc/templating.md +88 -0
- data/examples/default_template/.gitignore +2 -0
- data/examples/default_template/CHANGELOG +0 -0
- data/examples/default_template/Gemfile +3 -0
- data/examples/default_template/Mockupfile +1 -0
- data/examples/default_template/html/.empty_directory +0 -0
- data/examples/default_template/partials/.empty_directory +0 -0
- data/lib/roger/cli/command.rb +23 -0
- data/lib/roger/cli/generate.rb +5 -0
- data/lib/roger/cli/release.rb +10 -0
- data/lib/roger/cli/serve.rb +29 -0
- data/lib/roger/cli.rb +123 -0
- data/lib/roger/extractor.rb +95 -0
- data/lib/roger/generators/generator.rb +23 -0
- data/lib/roger/generators/new.rb +67 -0
- data/lib/roger/generators/templates/generator.tt +13 -0
- data/lib/roger/generators.rb +23 -0
- data/lib/roger/mockupfile.rb +63 -0
- data/lib/roger/project.rb +92 -0
- data/lib/roger/rack/html_validator.rb +26 -0
- data/lib/roger/rack/roger.rb +52 -0
- data/lib/roger/rack/sleep.rb +21 -0
- data/lib/roger/release/cleaner.rb +47 -0
- data/lib/roger/release/finalizers/dir.rb +29 -0
- data/lib/roger/release/finalizers/git_branch.rb +92 -0
- data/lib/roger/release/finalizers/rsync.rb +77 -0
- data/lib/roger/release/finalizers/zip.rb +42 -0
- data/lib/roger/release/finalizers.rb +19 -0
- data/lib/roger/release/injector.rb +99 -0
- data/lib/roger/release/processors/mockup.rb +93 -0
- data/lib/roger/release/processors/url_relativizer.rb +45 -0
- data/lib/roger/release/processors.rb +17 -0
- data/lib/roger/release/scm/git.rb +101 -0
- data/lib/roger/release/scm.rb +32 -0
- data/lib/roger/release.rb +363 -0
- data/lib/roger/resolver.rb +119 -0
- data/lib/roger/server.rb +117 -0
- data/lib/roger/template.rb +206 -0
- data/lib/roger/w3c_validator.rb +129 -0
- data/roger.gemspec +35 -0
- data/test/Mockupfile-syntax.rb +85 -0
- data/test/project/.rvmrc +1 -0
- data/test/project/Gemfile +7 -0
- data/test/project/Gemfile.lock +38 -0
- data/test/project/Mockupfile +13 -0
- data/test/project/html/formats/erb.html.erb +5 -0
- data/test/project/html/formats/index.html +1 -0
- data/test/project/html/formats/json.json.erb +0 -0
- data/test/project/html/formats/markdown.md +3 -0
- data/test/project/html/formats/mockup.html +5 -0
- data/test/project/html/front_matter/erb.html.erb +16 -0
- data/test/project/html/front_matter/markdown.md +7 -0
- data/test/project/html/layouts/content-for.html.erb +17 -0
- data/test/project/html/layouts/erb.html.erb +19 -0
- data/test/project/html/mockup/encoding.html +3 -0
- data/test/project/html/partials/erb.html.erb +10 -0
- data/test/project/html/partials/load_path.html.erb +3 -0
- data/test/project/html/partials/mockup.html +13 -0
- data/test/project/html/static/non-relative.html.erb +9 -0
- data/test/project/html/static/relative.html.erb +9 -0
- data/test/project/layouts/test.html.erb +34 -0
- data/test/project/layouts/yield.html.erb +1 -0
- data/test/project/lib/generators/test.rb +9 -0
- data/test/project/partials/formats/erb.html.erb +1 -0
- data/test/project/partials/partials-test.html.erb +1 -0
- data/test/project/partials/test/erb.html.erb +1 -0
- data/test/project/partials/test/front_matter.html.erb +1 -0
- data/test/project/partials/test/json.json.erb +1 -0
- data/test/project/partials/test/markdown.md +1 -0
- data/test/project/partials/test/mockup.part.html +1 -0
- data/test/project/partials/test/simple.html.erb +1 -0
- data/test/project/partials2/partials2-test.html.erb +1 -0
- data/test/unit/cli_test.rb +12 -0
- data/test/unit/generators_test.rb +75 -0
- data/test/unit/release/cleaner_test.rb +47 -0
- data/test/unit/resolver_test.rb +92 -0
- data/test/unit/template_test.rb +127 -0
- metadata +202 -8
@@ -0,0 +1,206 @@
|
|
1
|
+
require 'tilt'
|
2
|
+
require 'mime/types'
|
3
|
+
require 'yaml'
|
4
|
+
require 'ostruct'
|
5
|
+
|
6
|
+
# We're enforcing Encoding to UTF-8
|
7
|
+
Encoding.default_external = "UTF-8"
|
8
|
+
|
9
|
+
module Roger
|
10
|
+
|
11
|
+
class Template
|
12
|
+
|
13
|
+
# The source
|
14
|
+
attr_accessor :source
|
15
|
+
|
16
|
+
# Store the frontmatter
|
17
|
+
attr_accessor :data
|
18
|
+
|
19
|
+
# The actual Tilt template
|
20
|
+
attr_accessor :template
|
21
|
+
|
22
|
+
# The path to the source file for this template
|
23
|
+
attr_accessor :source_path
|
24
|
+
|
25
|
+
class << self
|
26
|
+
def open(path, options = {})
|
27
|
+
raise "Unknown file #{path}" unless File.exist?(path)
|
28
|
+
self.new(File.read(path), options.update(:source_path => path))
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
# @option options [String,Pathname] :source_path The path to the source of the template being processed
|
34
|
+
# @option options [String,Pathname] :layouts_path The path to where all layouts reside
|
35
|
+
# @option options [String,Pathname] :partials_path The path to where all partials reside
|
36
|
+
def initialize(source, options = {})
|
37
|
+
@options = options
|
38
|
+
self.source_path = options[:source_path]
|
39
|
+
self.data, self.source = extract_front_matter(source)
|
40
|
+
self.template = Tilt.new(self.source_path.to_s){ self.source }
|
41
|
+
|
42
|
+
if self.data[:layout] && layout_template_path = self.find_template(self.data[:layout], :layouts_path)
|
43
|
+
@layout_template = Tilt.new(layout_template_path.to_s)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def render(env = {})
|
48
|
+
context = TemplateContext.new(self, env)
|
49
|
+
|
50
|
+
if @layout_template
|
51
|
+
content_for_layout = self.template.render(context, {}) # yields
|
52
|
+
|
53
|
+
@layout_template.render(context, {}) do |content_for|
|
54
|
+
if content_for
|
55
|
+
context._content_for_blocks[content_for]
|
56
|
+
else
|
57
|
+
content_for_layout
|
58
|
+
end
|
59
|
+
end
|
60
|
+
else
|
61
|
+
self.template.render(context, {})
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def find_template(name, path_type)
|
66
|
+
raise(ArgumentError, "path_type must be one of :partials_path or :layouts_path") unless [:partials_path, :layouts_path].include?(path_type)
|
67
|
+
|
68
|
+
return nil unless @options[path_type]
|
69
|
+
|
70
|
+
@resolvers ||= {}
|
71
|
+
@resolvers[path_type] ||= Resolver.new(@options[path_type])
|
72
|
+
|
73
|
+
@resolvers[path_type].find_template(name, :preferred_extension => self.target_extension)
|
74
|
+
end
|
75
|
+
|
76
|
+
# Try to infer the final extension of the output file.
|
77
|
+
def target_extension
|
78
|
+
return @target_extension if @target_extension
|
79
|
+
|
80
|
+
if type = MIME::Types[self.target_mime_type].first
|
81
|
+
# Dirty little hack to enforce the use of .html instead of .htm
|
82
|
+
if type.sub_type == "html"
|
83
|
+
@target_extension = "html"
|
84
|
+
else
|
85
|
+
@target_extension = type.extensions.first
|
86
|
+
end
|
87
|
+
else
|
88
|
+
@target_extension = File.extname(self.source_path.to_s).sub(/^\./, "")
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def source_extension
|
93
|
+
parts = File.basename(File.basename(self.source_path.to_s)).split(".")
|
94
|
+
if parts.size > 2
|
95
|
+
parts[-2..-1].join(".")
|
96
|
+
else
|
97
|
+
File.extname(self.source_path.to_s).sub(/^\./, "")
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
# Try to figure out the mime type based on the Tilt class and if that doesn't
|
102
|
+
# work we try to infer the type by looking at extensions (needed for .erb)
|
103
|
+
def target_mime_type
|
104
|
+
mime = self.template.class.default_mime_type
|
105
|
+
return mime if mime
|
106
|
+
|
107
|
+
path = File.basename(self.source_path.to_s)
|
108
|
+
mime = MIME::Types.type_for(path).first
|
109
|
+
return mime.to_s if mime
|
110
|
+
|
111
|
+
parts = File.basename(path).split(".")
|
112
|
+
if parts.size > 2
|
113
|
+
mime = MIME::Types.type_for(parts[0..-2].join(".")).first
|
114
|
+
return mime.to_s if mime
|
115
|
+
else
|
116
|
+
nil
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
protected
|
121
|
+
|
122
|
+
# Get the front matter portion of the file and extract it.
|
123
|
+
def extract_front_matter(source)
|
124
|
+
fm_regex = /\A(---\s*\n.*?\n?)^(---\s*$\n?)/m
|
125
|
+
|
126
|
+
if match = source.match(fm_regex)
|
127
|
+
source = source.sub(fm_regex, "")
|
128
|
+
|
129
|
+
begin
|
130
|
+
data = (YAML.load(match[1]) || {}).inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
131
|
+
rescue *YAML_ERRORS => e
|
132
|
+
puts "YAML Exception: #{e.message}"
|
133
|
+
return false
|
134
|
+
end
|
135
|
+
else
|
136
|
+
return [{}, source]
|
137
|
+
end
|
138
|
+
|
139
|
+
[data, source]
|
140
|
+
rescue
|
141
|
+
[{}, source]
|
142
|
+
end
|
143
|
+
|
144
|
+
end
|
145
|
+
|
146
|
+
class TemplateContext
|
147
|
+
attr_accessor :_content_for_blocks
|
148
|
+
|
149
|
+
def initialize(template, env={})
|
150
|
+
@_template, @_env = template, @_content_for_blocks = {}, env
|
151
|
+
end
|
152
|
+
|
153
|
+
# The current Roger::Template in use
|
154
|
+
def template
|
155
|
+
@_template
|
156
|
+
end
|
157
|
+
|
158
|
+
# Access to the front-matter of the document (if any)
|
159
|
+
def document
|
160
|
+
@_data ||= OpenStruct.new(self.template.data)
|
161
|
+
end
|
162
|
+
|
163
|
+
# The current environment variables.
|
164
|
+
def env
|
165
|
+
@_env
|
166
|
+
end
|
167
|
+
|
168
|
+
# Capture content in blocks in the template for later use in the layout.
|
169
|
+
# Currently only works in ERB templates. Use like this in the template:
|
170
|
+
#
|
171
|
+
# ```
|
172
|
+
# <% content_for :name %> bla bla <% end %>
|
173
|
+
# ```
|
174
|
+
#
|
175
|
+
# Place it like this in the layout:
|
176
|
+
#
|
177
|
+
# ```
|
178
|
+
# <%= yield :name %>
|
179
|
+
# ```
|
180
|
+
def content_for(block_name, &capture)
|
181
|
+
raise ArgumentError, "content_for works only with ERB Templates" if !self.template.template.kind_of?(Tilt::ERBTemplate)
|
182
|
+
eval "@_erbout_tmp = _erbout", capture.binding
|
183
|
+
eval "_erbout = \"\"", capture.binding
|
184
|
+
t = Tilt::ERBTemplate.new(){ "<%= yield %>" }
|
185
|
+
@_content_for_blocks[block_name] = t.render(&capture)
|
186
|
+
return nil
|
187
|
+
ensure
|
188
|
+
eval "_erbout = @_erbout_tmp", capture.binding
|
189
|
+
end
|
190
|
+
|
191
|
+
def partial(name, options = {})
|
192
|
+
if template_path = self.template.find_template(name, :partials_path)
|
193
|
+
partial_template = Tilt.new(template_path.to_s)
|
194
|
+
partial_template.render(self, options[:locals] || {})
|
195
|
+
elsif template_path = self.template.find_template(name + ".part", :partials_path)
|
196
|
+
template = Tilt::ERBTemplate.new(template_path.to_s)
|
197
|
+
context = MockupTemplate::TemplateContext.new(options[:locals] || {})
|
198
|
+
template.render(context, :env => self.env)
|
199
|
+
else
|
200
|
+
raise ArgumentError, "No such partial #{name}, referenced from #{self.template.source_path}"
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
end
|
205
|
+
|
206
|
+
end
|
@@ -0,0 +1,129 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
require 'net/http'
|
3
|
+
require 'uri'
|
4
|
+
require 'yaml'
|
5
|
+
|
6
|
+
module Roger
|
7
|
+
class W3CValidator
|
8
|
+
|
9
|
+
ValidationUri = "http://validator.w3.org/check"
|
10
|
+
|
11
|
+
class RequestError < StandardError; end
|
12
|
+
|
13
|
+
attr_reader :valid,:response,:errors,:warnings,:status
|
14
|
+
|
15
|
+
class << self
|
16
|
+
def validation_uri
|
17
|
+
@uri ||= URI.parse(ValidationUri)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize(html)
|
22
|
+
@html = html
|
23
|
+
end
|
24
|
+
|
25
|
+
def validate!
|
26
|
+
@status = @warnings = @errors = @response = @valid = nil
|
27
|
+
options = {"output" => "json"}
|
28
|
+
query,headers = build_post_query(options)
|
29
|
+
response = self.request(:post,self.class.validation_uri.path,query,headers)
|
30
|
+
@status,@warnings,@errors = response["x-w3c-validator-status"],response["x-w3c-validator-warnings"].to_i,response["x-w3c-validator-errors"].to_i
|
31
|
+
|
32
|
+
if @status == "Valid" && @warnings == 0 && @errors == 0
|
33
|
+
return @valid = true
|
34
|
+
else
|
35
|
+
begin
|
36
|
+
@response = YAML.load(response.body)
|
37
|
+
rescue
|
38
|
+
end
|
39
|
+
return (@valid = (@errros == 0))
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
protected
|
45
|
+
|
46
|
+
def build_post_query(options)
|
47
|
+
boundary = "validate-this-content-please"
|
48
|
+
headers = {"Content-type" => "multipart/form-data, boundary=" + boundary + " "}
|
49
|
+
|
50
|
+
parts = []
|
51
|
+
options.each do |k,v|
|
52
|
+
parts << post_param(k,v)
|
53
|
+
end
|
54
|
+
parts << file_param("uploaded_file","index.html",@html,"text/html")
|
55
|
+
|
56
|
+
q = parts.map{|p| "--#{boundary}\r\n#{p}"}.join("") + "--#{boundary}--"
|
57
|
+
[q,headers]
|
58
|
+
end
|
59
|
+
|
60
|
+
def post_param(k,v)
|
61
|
+
"Content-Disposition: form-data; name=\"#{CGI::escape(k)}\"\r\n\r\n#{v}\r\n"
|
62
|
+
end
|
63
|
+
|
64
|
+
def file_param(k,filename,content,mime_type)
|
65
|
+
out = []
|
66
|
+
out << "Content-Disposition: form-data; name=\"#{CGI::escape(k)}\"; filename=\"#{filename}\""
|
67
|
+
out << "Content-Transfer-Encoding: binary"
|
68
|
+
out << "Content-Type: #{mime_type}"
|
69
|
+
out.join("\r\n") + "\r\n\r\n" + content + "\r\n"
|
70
|
+
end
|
71
|
+
|
72
|
+
# Makes request to remote service.
|
73
|
+
def request(method, path, *arguments)
|
74
|
+
perform_request(method, path, arguments, 3)
|
75
|
+
end
|
76
|
+
|
77
|
+
def perform_request(method, path, arguments, tries=3)
|
78
|
+
result = nil
|
79
|
+
result = http.send(method, path, *arguments)
|
80
|
+
handle_response(result)
|
81
|
+
rescue RequestError => e
|
82
|
+
if tries > 0
|
83
|
+
perform_request(method, path, arguments, tries-1)
|
84
|
+
else
|
85
|
+
raise
|
86
|
+
end
|
87
|
+
rescue Timeout::Error => e
|
88
|
+
raise
|
89
|
+
end
|
90
|
+
|
91
|
+
# Handles response and error codes from remote service.
|
92
|
+
def handle_response(response)
|
93
|
+
case response.code.to_i
|
94
|
+
when 301,302
|
95
|
+
raise "Redirect"
|
96
|
+
when 200...400
|
97
|
+
response
|
98
|
+
when 400
|
99
|
+
raise "Bad Request"
|
100
|
+
when 401
|
101
|
+
raise "Unauthorized Access"
|
102
|
+
when 403
|
103
|
+
raise "Forbidden Access"
|
104
|
+
when 404
|
105
|
+
raise "Rescoure not found"
|
106
|
+
when 405
|
107
|
+
raise "Method not allowed"
|
108
|
+
when 409
|
109
|
+
raise RequestError.new("Rescource conflict")
|
110
|
+
when 422
|
111
|
+
raise RequestError.new("Resource invalid")
|
112
|
+
when 401...500
|
113
|
+
raise "Client error"
|
114
|
+
when 500...600
|
115
|
+
raise RequestError.new("Server error")
|
116
|
+
else
|
117
|
+
raise "Unknown response: #{response.code.to_i}"
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
def http
|
122
|
+
site = self.class.validation_uri
|
123
|
+
http = Net::HTTP.new(site.host, site.port)
|
124
|
+
# http.use_ssl = site.is_a?(URI::HTTPS)
|
125
|
+
# http.verify_mode = OpenSSL::SSL::VERIFY_NONE if http.use_ssl
|
126
|
+
http
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
data/roger.gemspec
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = "roger"
|
5
|
+
s.version = "0.10.0"
|
6
|
+
|
7
|
+
s.authors = ["Flurin Egger", "Edwin van der Graaf", "Joran Kapteijns"]
|
8
|
+
s.email = ["info@digitpaint.nl", "flurin@digitpaint.nl"]
|
9
|
+
s.homepage = "http://github.com/digitpaint/roger"
|
10
|
+
s.summary = "Roger is a set of tools to create self-containing HTML mockups."
|
11
|
+
s.licenses = ["MIT"]
|
12
|
+
|
13
|
+
s.date = Time.now.strftime("%Y-%m-%d")
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
|
20
|
+
s.extra_rdoc_files = [
|
21
|
+
"README.md"
|
22
|
+
] + `git ls-files -- {doc}/*`.split("\n")
|
23
|
+
|
24
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
25
|
+
|
26
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
27
|
+
|
28
|
+
s.add_dependency("thor", ["~> 0.16.0"])
|
29
|
+
s.add_dependency("rack", [">= 1.0.0"])
|
30
|
+
s.add_dependency("tilt", ["~> 2.0.1"])
|
31
|
+
s.add_dependency("mime-types", ["~> 2.2"])
|
32
|
+
s.add_dependency("hpricot", [">= 0.6.4"])
|
33
|
+
|
34
|
+
s.add_development_dependency("test-unit", "~> 2.5.5")
|
35
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# Example idea for a Mockupfile, a lot of this has to have a sensible default.
|
2
|
+
|
3
|
+
Sass::Plugin.options[:style] = :expanded
|
4
|
+
Sass::Plugin.options[:template_location] = "./html/stylesheets"
|
5
|
+
Sass::Plugin.options[:css_location] = "./html/stylesheets"
|
6
|
+
|
7
|
+
# These are defaults, but can be set here
|
8
|
+
# mockup.project.html_path = mockup.project.path + "html"
|
9
|
+
# mockup.project.partial_path = mockup.project.path + "partials"
|
10
|
+
|
11
|
+
mockup.serve(config) do |server|
|
12
|
+
server.use :sass
|
13
|
+
end
|
14
|
+
|
15
|
+
mockup.release(config) do |release|
|
16
|
+
|
17
|
+
release.target_path # The target path where releases are put
|
18
|
+
release.build_path # The path where the release gets built
|
19
|
+
release.source_path # The source for this mockup
|
20
|
+
|
21
|
+
# Extract mockup
|
22
|
+
# Pass custom config to the extractor, this is optional
|
23
|
+
# release.extract :url_attributes => %w{src href action data-main}
|
24
|
+
|
25
|
+
# Get git version
|
26
|
+
release.scm.previous # Get the previous version SCM op (looks for tags)
|
27
|
+
release.scm.version # Get the git version
|
28
|
+
release.scm.date # Get the git date
|
29
|
+
|
30
|
+
# Create custom banner
|
31
|
+
release.banner do
|
32
|
+
"bla bla bla"
|
33
|
+
end
|
34
|
+
|
35
|
+
# The default banner looks like this:
|
36
|
+
#
|
37
|
+
# =======================
|
38
|
+
# = Version : v1.0.0 =
|
39
|
+
# = Date : 2012-06-20 =
|
40
|
+
# =======================
|
41
|
+
|
42
|
+
# Sassify CSS (this are the defaults too), all options except form :match and :skip are passed to Sass.compile_file
|
43
|
+
# release.use :sass, :match => ["stylesheets/**/*.scss"], :skip => [/_.*\.scss\Z/], :style => :expanded
|
44
|
+
# The previous statement is the same as:
|
45
|
+
release.use :sass
|
46
|
+
|
47
|
+
# Run requirejs optimizer
|
48
|
+
# release.use :requirejs, {
|
49
|
+
# :build_files => {"javascripts/site.build.js" => "javascripts"},
|
50
|
+
# :rjs => release.source_path + "../vendor/requirejs/r.js",
|
51
|
+
# :node => "node"
|
52
|
+
# }
|
53
|
+
release.use :requirejs
|
54
|
+
|
55
|
+
# Minify, will not minify anything above the :delimiter
|
56
|
+
# release.use :yuicompressor, {
|
57
|
+
# :match => ["**/*.{css,js}"],
|
58
|
+
# :skip => [/javascripts\/vendor\/.*\.js\Z/, /_doc\/.*/],
|
59
|
+
# :delimiter => Regexp.escape("/* -------------------------------------------------------------------------------- */")
|
60
|
+
# }
|
61
|
+
# The previous statement is the same as:
|
62
|
+
release.use :yuicompressor
|
63
|
+
|
64
|
+
|
65
|
+
# Inject VERSION / DATE (i.e. in TOC)
|
66
|
+
r.inject({"[VERSION]" => release.scm.version, "[DATE]" => release.scm.date.strftime("%Y-%m-%d")}, :into => %w{_doc/toc.html})
|
67
|
+
|
68
|
+
# Inject Banners on everything matching the regexp in all .css files
|
69
|
+
# The banner will be commented as CSS.
|
70
|
+
release.inject({ /\/\*\s*\[BANNER\]\s*\*\// => r.banner(:comment => :css)}, :into => %w{**/*.css})
|
71
|
+
|
72
|
+
# Inject CHANGELOG
|
73
|
+
release.inject({"[CHANGELOG]" => {:file => "../CHANGELOG", :processor => 'md'}}, :into => %w{_doc/changelog.html})
|
74
|
+
|
75
|
+
# Inject NOTES
|
76
|
+
release.inject({"[NOTES]" => {:file => "../NOTES.md", :processor => 'md'}}, :into => %w{_doc/notes.html})
|
77
|
+
|
78
|
+
# Cleanup on the build
|
79
|
+
release.cleanup "**/.DS_Store"
|
80
|
+
|
81
|
+
# Finalize the release
|
82
|
+
# This is the default finalizer so not required
|
83
|
+
# release.finalize :dir
|
84
|
+
|
85
|
+
end
|
data/test/project/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use ruby-1.9.3-p194@mockup-test-project
|
@@ -0,0 +1,38 @@
|
|
1
|
+
PATH
|
2
|
+
remote: /Users/flurin/Projects.local/libraries/roger
|
3
|
+
specs:
|
4
|
+
roger (0.10.0)
|
5
|
+
hpricot (>= 0.6.4)
|
6
|
+
mime-types (~> 2.2)
|
7
|
+
rack (>= 1.0.0)
|
8
|
+
thor (~> 0.16.0)
|
9
|
+
tilt (~> 2.0.1)
|
10
|
+
|
11
|
+
GEM
|
12
|
+
remote: https://rubygems.org/
|
13
|
+
specs:
|
14
|
+
coderay (1.1.0)
|
15
|
+
hpricot (0.8.6)
|
16
|
+
method_source (0.8.2)
|
17
|
+
mime-types (2.2)
|
18
|
+
pry (0.9.12.6)
|
19
|
+
coderay (~> 1.0)
|
20
|
+
method_source (~> 0.8)
|
21
|
+
slop (~> 3.4)
|
22
|
+
rack (1.5.2)
|
23
|
+
redcarpet (3.1.1)
|
24
|
+
sass (3.3.5)
|
25
|
+
slop (3.5.0)
|
26
|
+
thor (0.16.0)
|
27
|
+
tilt (2.0.1)
|
28
|
+
yui-compressor (0.12.0)
|
29
|
+
|
30
|
+
PLATFORMS
|
31
|
+
ruby
|
32
|
+
|
33
|
+
DEPENDENCIES
|
34
|
+
pry
|
35
|
+
redcarpet
|
36
|
+
roger!
|
37
|
+
sass
|
38
|
+
yui-compressor
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/lib/generators/test"
|
2
|
+
|
3
|
+
mockup.project.options[:verbose] = true;
|
4
|
+
|
5
|
+
mockup.project.partial_path = [mockup.project.path + "partials", mockup.project.path + "partials2"]
|
6
|
+
|
7
|
+
mockup.serve do |s|
|
8
|
+
end
|
9
|
+
|
10
|
+
mockup.release do |r|
|
11
|
+
r.use :mockup
|
12
|
+
r.use :url_relativizer, :skip => [/non-relative.*/]
|
13
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Just an index.html
|
File without changes
|
@@ -0,0 +1,16 @@
|
|
1
|
+
---
|
2
|
+
title : "ERB frontmattter"
|
3
|
+
---
|
4
|
+
|
5
|
+
<h1>Document H1</h1>
|
6
|
+
|
7
|
+
<p>
|
8
|
+
The title of this document is <%= document.title %>
|
9
|
+
</p>
|
10
|
+
|
11
|
+
<p>
|
12
|
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim
|
13
|
+
ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
|
14
|
+
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
|
15
|
+
culpa qui officia deserunt mollit anim id est laborum.
|
16
|
+
</p>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
title : "Markdown frontmattter"
|
3
|
+
---
|
4
|
+
|
5
|
+
# Document H1
|
6
|
+
|
7
|
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
@@ -0,0 +1,17 @@
|
|
1
|
+
---
|
2
|
+
layout : "test"
|
3
|
+
title : "Content for"
|
4
|
+
---
|
5
|
+
Normal Yield
|
6
|
+
|
7
|
+
<% content_for :one do %>
|
8
|
+
Yield for one <%= "bla" %>
|
9
|
+
<% end %>
|
10
|
+
|
11
|
+
And more normal stuff
|
12
|
+
|
13
|
+
<% content_for :two do %>
|
14
|
+
Yield for two <%= "bla" %>
|
15
|
+
<% end %>
|
16
|
+
|
17
|
+
And the end of the normal stuff
|
@@ -0,0 +1,19 @@
|
|
1
|
+
---
|
2
|
+
layout : "test"
|
3
|
+
title : "ERB frontmattter"
|
4
|
+
---
|
5
|
+
|
6
|
+
<h1>Document H1</h1>
|
7
|
+
|
8
|
+
<strong>Var from layout before:</strong>
|
9
|
+
<%= @var_from_layout_before %>
|
10
|
+
<br>
|
11
|
+
<strong>Var from layout after:</strong>
|
12
|
+
<%= @var_from_layout_after %>
|
13
|
+
|
14
|
+
<p>
|
15
|
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim
|
16
|
+
ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
|
17
|
+
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
|
18
|
+
culpa qui officia deserunt mollit anim id est laborum.
|
19
|
+
</p>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<h1>Partials in document</h1>
|
2
|
+
|
3
|
+
<h2>ERB</h2>
|
4
|
+
<!-- [START:test/erb?value=value] -->
|
5
|
+
<!-- [STOP:test/erb] -->
|
6
|
+
|
7
|
+
<h2>MD</h2>
|
8
|
+
<!-- [START:test/markdown] -->
|
9
|
+
<!-- [STOP:test/markdown] -->
|
10
|
+
|
11
|
+
<h2>Mockup</h2>
|
12
|
+
<!-- [START:test/mockup?value=value] -->
|
13
|
+
<!-- [STOP:test/mockup] -->
|