frank 0.2.6 → 0.3.0.beta
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/Featurelist +6 -0
- data/README.md +44 -32
- data/Rakefile +3 -3
- data/frank.gemspec +51 -45
- data/lib/frank.rb +1 -0
- data/lib/frank/base.rb +144 -94
- data/lib/frank/lorem.rb +77 -36
- data/lib/frank/middleware/imager.rb +43 -0
- data/lib/frank/middleware/refresh.rb +42 -0
- data/lib/frank/middleware/statik.rb +41 -0
- data/lib/frank/output.rb +25 -37
- data/lib/frank/rescue.rb +13 -6
- data/lib/frank/template_helpers.rb +34 -3
- data/lib/frank/templates/404.haml +1 -0
- data/lib/frank/templates/500.haml +2 -0
- data/lib/frank/tilt.rb +389 -141
- data/lib/template/{dynamic/layout.haml → layouts/default.haml} +0 -0
- data/lib/template/settings.yml +15 -28
- data/spec/base_spec.rb +88 -0
- data/{test → spec}/helper.rb +0 -7
- data/spec/output_spec.rb +220 -0
- data/spec/render_spec.rb +106 -0
- data/spec/template/dynamic/500.haml +1 -0
- data/{test → spec}/template/dynamic/_partial.haml +0 -0
- data/{test → spec}/template/dynamic/builder.builder +0 -0
- data/{test → spec}/template/dynamic/coffee.coffee +0 -0
- data/{test → spec}/template/dynamic/erb.erb +0 -0
- data/{test → spec}/template/dynamic/helper_test.haml +0 -0
- data/spec/template/dynamic/index.haml +5 -0
- data/spec/template/dynamic/layout2_test.haml +4 -0
- data/{test → spec}/template/dynamic/liquid.liquid +0 -0
- data/spec/template/dynamic/lorem_test.haml +7 -0
- data/{test → spec}/template/dynamic/markdown.md +0 -0
- data/spec/template/dynamic/markdown_in_haml.md +4 -0
- data/{test → spec}/template/dynamic/mustache.mustache +0 -0
- data/spec/template/dynamic/nested/child.haml +1 -0
- data/spec/template/dynamic/nested/deeper/deep.haml +1 -0
- data/spec/template/dynamic/no_layout.haml +4 -0
- data/spec/template/dynamic/partial_test.haml +2 -0
- data/{test → spec}/template/dynamic/redcloth.textile +0 -0
- data/spec/template/dynamic/refresh.haml +1 -0
- data/{test → spec}/template/dynamic/sass.sass +0 -0
- data/{test → spec}/template/helpers.rb +0 -0
- data/spec/template/layouts/default.haml +3 -0
- data/{test/template/dynamic → spec/template/layouts/explicit}/layout2.haml +0 -0
- data/spec/template/layouts/nested/default.haml +2 -0
- data/spec/template/settings.yml +45 -0
- data/{test/template/static → spec/template/static/files}/static.html +0 -0
- data/spec/template_helpers_spec.rb +78 -0
- metadata +57 -49
- data/lib/frank/imager.rb +0 -39
- data/lib/frank/statik.rb +0 -39
- data/test/suite.rb +0 -4
- data/test/template/dynamic/index.haml +0 -2
- data/test/template/dynamic/layout.haml +0 -2
- data/test/template/dynamic/layout2_test.haml +0 -1
- data/test/template/dynamic/layout_test.haml +0 -1
- data/test/template/dynamic/lorem_test.haml +0 -7
- data/test/template/dynamic/partial_test.haml +0 -2
- data/test/template/settings.yml +0 -62
- data/test/test_base.rb +0 -81
- data/test/test_helpers.rb +0 -71
- data/test/test_output.rb +0 -160
- data/test/test_render.rb +0 -89
@@ -0,0 +1 @@
|
|
1
|
+
= non_method if @environment == :test
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,7 @@
|
|
1
|
+
%p.words= lorem.words 3, 'replace-this'
|
2
|
+
%p.sentences= lorem.sentences 2, 'replace-this'
|
3
|
+
%p.paragraphs= lorem.paragraphs 1, 'replace-this'
|
4
|
+
%p.date= lorem.date '%Y-%m-%d', 'replace-this'
|
5
|
+
%p.name= lorem.name 'replace-this'
|
6
|
+
%p.email= lorem.email 'replace-this'
|
7
|
+
%img{:src => lorem.image(400, 300, true, 'replace-this')}
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
%h1 hello from child
|
@@ -0,0 +1 @@
|
|
1
|
+
%h1 really deep
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
=refresh
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,45 @@
|
|
1
|
+
env: test
|
2
|
+
# ----------------------
|
3
|
+
# Server settings:
|
4
|
+
#
|
5
|
+
# Change the server host/port to bind rack to.
|
6
|
+
# 'server' can be any Rack-supported server, e.g.
|
7
|
+
# Mongrel, Thin, WEBrick
|
8
|
+
#
|
9
|
+
server:
|
10
|
+
handler: mongrel
|
11
|
+
hostname: 0.0.0.0
|
12
|
+
port: 3601
|
13
|
+
|
14
|
+
# ----------------------
|
15
|
+
# Static folder:
|
16
|
+
#
|
17
|
+
# All files in this folder will be served up
|
18
|
+
# directly, without interpretation
|
19
|
+
#
|
20
|
+
static_folder: static
|
21
|
+
|
22
|
+
# ----------------------
|
23
|
+
# Dynamic folder:
|
24
|
+
#
|
25
|
+
# Frank will try to interpret any of the files
|
26
|
+
# in this folder based on their extension
|
27
|
+
#
|
28
|
+
dynamic_folder: dynamic
|
29
|
+
|
30
|
+
# ----------------------
|
31
|
+
# Layouts folder:
|
32
|
+
#
|
33
|
+
# Frank will look for layouts in this folder
|
34
|
+
# the default layout is `default'
|
35
|
+
# it respects nested layouts that correspond to nested
|
36
|
+
# folders in the `dynamic_folder'
|
37
|
+
# for example: a template: `dynamic_folder/blog/a-blog-post.haml'
|
38
|
+
# would look for a layout: `layouts/blog/default.haml'
|
39
|
+
# and if not found use the default: `layouts/default.haml'
|
40
|
+
#
|
41
|
+
# Frank also supports defining layouts on an
|
42
|
+
# individual template basis using meta data
|
43
|
+
# you can do this by defining a meta field `layout: my_layout.haml'
|
44
|
+
#
|
45
|
+
layouts_folder: layouts
|
File without changes
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/helper'
|
2
|
+
|
3
|
+
describe Frank::TemplateHelpers do
|
4
|
+
include Rack::Test::Methods
|
5
|
+
|
6
|
+
def app
|
7
|
+
proj_dir = File.join(File.dirname(__FILE__), 'template')
|
8
|
+
settings = YAML.load_file(File.join(proj_dir, 'settings.yml'))
|
9
|
+
require File.join(proj_dir, 'helpers')
|
10
|
+
Frank.new do
|
11
|
+
settings.each do |name, value|
|
12
|
+
set name.to_s, value
|
13
|
+
end
|
14
|
+
set :environment, :test
|
15
|
+
set :proj_dir, proj_dir
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
before(:all) do
|
20
|
+
@app = app
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'render haml and use hello_helper' do
|
24
|
+
template = @app.render('helper_test.haml')
|
25
|
+
template.should == "<div id='p'>/helper_test</div>\n<div id='layout'>\n <h1>hello from helper</h1>\n</div>\n"
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should render the refresh javascript' do
|
29
|
+
template = @app.render('refresh.haml')
|
30
|
+
template.should include("<script type=\"text/javascript\">\n (function(){")
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'Lorem' do
|
34
|
+
it 'render haml with 3 random lorem words' do
|
35
|
+
template = @app.render('lorem_test.haml')
|
36
|
+
reg = /<p class='words'>(?:\w+\s?){3}<\/p>/
|
37
|
+
template.should =~ reg
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'render haml with 2 random lorem sentences' do
|
41
|
+
template = @app.render('lorem_test.haml')
|
42
|
+
reg = /<p class='sentences'>(?:[^.]+.){2}<\/p>/
|
43
|
+
template.should =~ reg
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'render haml with 1 random lorem paragraph' do
|
47
|
+
template = @app.render('lorem_test.haml')
|
48
|
+
reg = /<p class='paragraphs'>(?:[^\n]+(?:\n\n)?){1}<\/p>/m
|
49
|
+
template.should =~ reg
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'render haml with lorem name' do
|
53
|
+
template = @app.render('lorem_test.haml')
|
54
|
+
reg = /<p class='name'>[\w']+\s[\w']+<\/p>/m
|
55
|
+
template.should =~ reg
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'render haml with lorem email' do
|
59
|
+
template = @app.render('lorem_test.haml')
|
60
|
+
reg = /<p class='email'>[\w-]+@\w+\.\w+<\/p>/m
|
61
|
+
template.should =~ reg
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'render haml with lorem date' do
|
65
|
+
template = @app.render('lorem_test.haml')
|
66
|
+
reg = /<p class='date'>\d{4}-\d{2}-\d{2}<\/p>/m
|
67
|
+
template.should =~ reg
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'render image url using imager' do
|
71
|
+
template = @app.render('lorem_test.haml')
|
72
|
+
reg = /<img src='\/_img\/400x300.jpg\?random\d{5}' \/>/
|
73
|
+
template.should =~ reg
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: frank
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
4
|
+
prerelease: true
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
|
7
|
+
- 3
|
8
|
+
- 0
|
9
|
+
- beta
|
10
|
+
version: 0.3.0.beta
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- blahed
|
@@ -15,7 +16,7 @@ autorequire:
|
|
15
16
|
bindir: bin
|
16
17
|
cert_chain: []
|
17
18
|
|
18
|
-
date: 2010-
|
19
|
+
date: 2010-06-12 00:00:00 -04:00
|
19
20
|
default_executable:
|
20
21
|
dependencies:
|
21
22
|
- !ruby/object:Gem::Dependency
|
@@ -58,16 +59,15 @@ dependencies:
|
|
58
59
|
type: :runtime
|
59
60
|
version_requirements: *id003
|
60
61
|
- !ruby/object:Gem::Dependency
|
61
|
-
name:
|
62
|
+
name: rspec
|
62
63
|
prerelease: false
|
63
64
|
requirement: &id004 !ruby/object:Gem::Requirement
|
64
65
|
requirements:
|
65
66
|
- - ">="
|
66
67
|
- !ruby/object:Gem::Version
|
67
68
|
segments:
|
68
|
-
- 2
|
69
69
|
- 0
|
70
|
-
version: "
|
70
|
+
version: "0"
|
71
71
|
type: :development
|
72
72
|
version_requirements: *id004
|
73
73
|
- !ruby/object:Gem::Dependency
|
@@ -83,7 +83,7 @@ dependencies:
|
|
83
83
|
version: "0.5"
|
84
84
|
type: :development
|
85
85
|
version_requirements: *id005
|
86
|
-
description:
|
86
|
+
description: Rapidly develop static sites using any supported templating language
|
87
87
|
email: travis.dunn@thisismedium.com
|
88
88
|
executables:
|
89
89
|
- frank
|
@@ -96,6 +96,7 @@ extra_rdoc_files:
|
|
96
96
|
- README.md
|
97
97
|
files:
|
98
98
|
- .gitignore
|
99
|
+
- Featurelist
|
99
100
|
- LICENSE
|
100
101
|
- README.md
|
101
102
|
- Rakefile
|
@@ -105,11 +106,12 @@ files:
|
|
105
106
|
- frank.gemspec
|
106
107
|
- lib/frank.rb
|
107
108
|
- lib/frank/base.rb
|
108
|
-
- lib/frank/imager.rb
|
109
109
|
- lib/frank/lorem.rb
|
110
|
+
- lib/frank/middleware/imager.rb
|
111
|
+
- lib/frank/middleware/refresh.rb
|
112
|
+
- lib/frank/middleware/statik.rb
|
110
113
|
- lib/frank/output.rb
|
111
114
|
- lib/frank/rescue.rb
|
112
|
-
- lib/frank/statik.rb
|
113
115
|
- lib/frank/template_helpers.rb
|
114
116
|
- lib/frank/templates/404.haml
|
115
117
|
- lib/frank/templates/500.haml
|
@@ -128,37 +130,42 @@ files:
|
|
128
130
|
- lib/frank/tilt.rb
|
129
131
|
- lib/template/dynamic/css/frank.sass
|
130
132
|
- lib/template/dynamic/index.haml
|
131
|
-
- lib/template/dynamic/layout.haml
|
132
133
|
- lib/template/helpers.rb
|
134
|
+
- lib/template/layouts/default.haml
|
133
135
|
- lib/template/settings.yml
|
134
136
|
- lib/template/static/images/frank-med.png
|
135
137
|
- lib/template/static/js/frank.js
|
136
|
-
-
|
137
|
-
-
|
138
|
-
-
|
139
|
-
-
|
140
|
-
-
|
141
|
-
-
|
142
|
-
-
|
143
|
-
-
|
144
|
-
-
|
145
|
-
-
|
146
|
-
-
|
147
|
-
-
|
148
|
-
-
|
149
|
-
-
|
150
|
-
-
|
151
|
-
-
|
152
|
-
-
|
153
|
-
-
|
154
|
-
-
|
155
|
-
-
|
156
|
-
-
|
157
|
-
-
|
158
|
-
-
|
159
|
-
-
|
160
|
-
-
|
161
|
-
-
|
138
|
+
- spec/base_spec.rb
|
139
|
+
- spec/helper.rb
|
140
|
+
- spec/output_spec.rb
|
141
|
+
- spec/render_spec.rb
|
142
|
+
- spec/template/dynamic/500.haml
|
143
|
+
- spec/template/dynamic/_partial.haml
|
144
|
+
- spec/template/dynamic/builder.builder
|
145
|
+
- spec/template/dynamic/coffee.coffee
|
146
|
+
- spec/template/dynamic/erb.erb
|
147
|
+
- spec/template/dynamic/helper_test.haml
|
148
|
+
- spec/template/dynamic/index.haml
|
149
|
+
- spec/template/dynamic/layout2_test.haml
|
150
|
+
- spec/template/dynamic/liquid.liquid
|
151
|
+
- spec/template/dynamic/lorem_test.haml
|
152
|
+
- spec/template/dynamic/markdown.md
|
153
|
+
- spec/template/dynamic/markdown_in_haml.md
|
154
|
+
- spec/template/dynamic/mustache.mustache
|
155
|
+
- spec/template/dynamic/nested/child.haml
|
156
|
+
- spec/template/dynamic/nested/deeper/deep.haml
|
157
|
+
- spec/template/dynamic/no_layout.haml
|
158
|
+
- spec/template/dynamic/partial_test.haml
|
159
|
+
- spec/template/dynamic/redcloth.textile
|
160
|
+
- spec/template/dynamic/refresh.haml
|
161
|
+
- spec/template/dynamic/sass.sass
|
162
|
+
- spec/template/helpers.rb
|
163
|
+
- spec/template/layouts/default.haml
|
164
|
+
- spec/template/layouts/explicit/layout2.haml
|
165
|
+
- spec/template/layouts/nested/default.haml
|
166
|
+
- spec/template/settings.yml
|
167
|
+
- spec/template/static/files/static.html
|
168
|
+
- spec/template_helpers_spec.rb
|
162
169
|
has_rdoc: true
|
163
170
|
homepage: http://github.com/blahed/frank
|
164
171
|
licenses: []
|
@@ -177,23 +184,24 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
177
184
|
version: "0"
|
178
185
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
179
186
|
requirements:
|
180
|
-
- - "
|
187
|
+
- - ">"
|
181
188
|
- !ruby/object:Gem::Version
|
182
189
|
segments:
|
183
|
-
-
|
184
|
-
|
190
|
+
- 1
|
191
|
+
- 3
|
192
|
+
- 1
|
193
|
+
version: 1.3.1
|
185
194
|
requirements: []
|
186
195
|
|
187
196
|
rubyforge_project:
|
188
197
|
rubygems_version: 1.3.6
|
189
198
|
signing_key:
|
190
199
|
specification_version: 3
|
191
|
-
summary:
|
200
|
+
summary: Static Site Non-Framework
|
192
201
|
test_files:
|
193
|
-
-
|
194
|
-
-
|
195
|
-
-
|
196
|
-
-
|
197
|
-
-
|
198
|
-
-
|
199
|
-
- test/test_render.rb
|
202
|
+
- spec/base_spec.rb
|
203
|
+
- spec/helper.rb
|
204
|
+
- spec/output_spec.rb
|
205
|
+
- spec/render_spec.rb
|
206
|
+
- spec/template/helpers.rb
|
207
|
+
- spec/template_helpers_spec.rb
|
data/lib/frank/imager.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
module Frank
|
2
|
-
begin
|
3
|
-
require 'mini_magick'
|
4
|
-
rescue LoadError
|
5
|
-
end
|
6
|
-
|
7
|
-
class Imager
|
8
|
-
|
9
|
-
def initialize(app, options={})
|
10
|
-
@app = app
|
11
|
-
end
|
12
|
-
|
13
|
-
# choose a random image if random is in the query
|
14
|
-
def image_filename(dims, query)
|
15
|
-
if query.include?('random')
|
16
|
-
"frank#{rand(10)}.jpg"
|
17
|
-
else
|
18
|
-
"frank#{dims.hash.to_s[-1..-1]}.jpg"
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
# catch a request for _img/0x0, get an image, resize it to given dims
|
23
|
-
def call(env)
|
24
|
-
path = env['PATH_INFO']
|
25
|
-
image_path = File.expand_path(File.dirname(__FILE__)) + '/templates/imager/'
|
26
|
-
|
27
|
-
if defined?(MiniMagick) && path.include?('_img')
|
28
|
-
dims = '!' + path.split('/').last.match(/\d+x\d+/i).to_s
|
29
|
-
filename = image_filename(dims, env['QUERY_STRING'])
|
30
|
-
|
31
|
-
image = MiniMagick::Image.from_file(image_path + filename)
|
32
|
-
image.resize dims
|
33
|
-
return [ 200, { 'Content-Type' => 'image/jpg' }, image.to_blob ]
|
34
|
-
end
|
35
|
-
@app.call(env)
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
39
|
-
end
|
data/lib/frank/statik.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
module Frank
|
2
|
-
class Statik
|
3
|
-
|
4
|
-
def initialize(app, options={})
|
5
|
-
@app = app
|
6
|
-
frank_root = File.expand_path(File.dirname(__FILE__)) + '/templates'
|
7
|
-
root = options[:root] || Dir.pwd
|
8
|
-
@frank_server = Rack::File.new(frank_root)
|
9
|
-
@static_server = Rack::File.new(root)
|
10
|
-
end
|
11
|
-
|
12
|
-
# handles serving from __frank__
|
13
|
-
# looks for static access, if not found,
|
14
|
-
# passes request to frank
|
15
|
-
def call(env)
|
16
|
-
path = env['PATH_INFO'].dup
|
17
|
-
|
18
|
-
if path.include? '__frank__'
|
19
|
-
env['PATH_INFO'].gsub!('/__frank__', '')
|
20
|
-
result = @frank_server.call(env)
|
21
|
-
else
|
22
|
-
env['PATH_INFO'] << '/' unless path.match(/(\.\w+|\/)$/)
|
23
|
-
env['PATH_INFO'] << 'index.html' if path[-1..-1] == '/'
|
24
|
-
result = @static_server.call(env)
|
25
|
-
end
|
26
|
-
|
27
|
-
# return if static assets found
|
28
|
-
# else reset the path and pass to frank
|
29
|
-
if result[0] == 200
|
30
|
-
result
|
31
|
-
else
|
32
|
-
env['PATH_INFO'] = path
|
33
|
-
@app.call(env)
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
39
|
-
end
|