frank 0.3.0.beta → 0.3.0.beta2

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/bin/frankup CHANGED
@@ -41,7 +41,7 @@ if File.exist? 'settings.yml'
41
41
  settings = YAML.load_file('settings.yml')
42
42
  else
43
43
  settings = {
44
- :server => { 'handler' => 'mongrel', 'hostname' => '127.0.0.1', 'port' => 3601 },
44
+ :server => { 'handler' => 'mongrel', 'hostname' => '0.0.0.0', 'port' => 3601 },
45
45
  :static_folder => '.',
46
46
  :dynamic_folder => '.',
47
47
  :environment => :serving
data/frank.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{frank}
8
- s.version = "0.3.0.beta"
8
+ s.version = "0.3.0.beta2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["blahed", "nwah"]
12
- s.date = %q{2010-06-12}
12
+ s.date = %q{2010-06-18}
13
13
  s.description = %q{Rapidly develop static sites using any supported templating language}
14
14
  s.email = %q{travis.dunn@thisismedium.com}
15
15
  s.executables = ["frank", "frankout", "frankup"]
@@ -65,7 +65,6 @@ Gem::Specification.new do |s|
65
65
  "spec/template/dynamic/500.haml",
66
66
  "spec/template/dynamic/_partial.haml",
67
67
  "spec/template/dynamic/builder.builder",
68
- "spec/template/dynamic/coffee.coffee",
69
68
  "spec/template/dynamic/erb.erb",
70
69
  "spec/template/dynamic/helper_test.haml",
71
70
  "spec/template/dynamic/index.haml",
data/lib/frank/base.rb CHANGED
@@ -6,7 +6,7 @@ require 'frank/middleware/imager'
6
6
  require 'frank/middleware/refresh'
7
7
 
8
8
  module Frank
9
- VERSION = '0.3.0.beta'
9
+ VERSION = '0.3.0.beta2'
10
10
 
11
11
  module Render; end
12
12
 
@@ -83,9 +83,10 @@ module Frank
83
83
 
84
84
  TMPL_EXTS = {
85
85
  :html => %w[haml erb rhtml builder liquid mustache textile md mkd markdown],
86
- :css => %w[sass less],
87
- :js => %w[coffee]
88
- }
86
+ :css => %w[sass less scss]
87
+ }
88
+
89
+ LAYOUT_EXTS = %w[.haml .erb .rhtml .liquid .mustache]
89
90
 
90
91
  # render request path or template path
91
92
  def render(path)
@@ -97,7 +98,7 @@ module Frank
97
98
 
98
99
  # regex for kinds that don't support meta
99
100
  # and define the meta delimiter
100
- nometa, delimiter = /\/_|\.(js|coffee|css|sass|less)$/, /^META-{3,}\n$/
101
+ nometa, delimiter = /\/_|\.(sass|less)$/, /^META-{3,}\n$/
101
102
 
102
103
  # set the layout
103
104
  layout = path.match(nometa) ? nil : layout_for(path)
@@ -164,21 +165,36 @@ module Frank
164
165
  # reverse walks the layouts folder until we find a layout
165
166
  # returns nil if layout is not found
166
167
  def layout_for(path)
167
- default = "default#{File.extname(path)}"
168
- path = path.sub /\/[\w-]+\.[\w-]+$/, ''
169
- folders = path.split('/')
170
-
168
+ layout_exts = LAYOUT_EXTS.dup
169
+ ext = File.extname(path)
170
+ default = 'default' << layout_ext_or_first(layout_exts, ext)
171
+ file_path = path.sub(/\/[\w-]+\.[\w-]+$/, '')
172
+ folders = file_path.split('/')
173
+
171
174
  until File.exist? File.join(@proj_dir, @layouts_folder, folders, default)
172
- break if folders.empty?
173
- folders.pop
175
+ break if layout_exts.empty? && folders.empty?
176
+
177
+ if layout_exts.empty?
178
+ layout_exts = LAYOUT_EXTS.dup
179
+ default = 'default' << layout_ext_or_first(layout_exts, ext)
180
+ folders.pop
181
+ else
182
+ default = 'default' << layout_exts.shift
183
+ end
174
184
  end
175
-
176
- if File.exist? File.join(@proj_dir, @layouts_folder, folders, default)
185
+
186
+ if File.exists? File.join(@proj_dir, @layouts_folder, folders, default)
177
187
  File.join(folders, default)
178
188
  else
179
189
  nil
180
190
  end
181
191
  end
192
+
193
+ # if the given ext is a layout ext, pop it off and return it
194
+ # otherwise return the first layout ext
195
+ def layout_ext_or_first(layout_exts, ext)
196
+ layout_exts.include?(ext) ? layout_exts.delete(ext) : layout_exts.first
197
+ end
182
198
 
183
199
  # setup an object and extend it with TemplateHelpers and Render
184
200
  # then send everything to tilt and get some template markup back
@@ -254,8 +270,10 @@ module Frank
254
270
  def self.stub(project)
255
271
  puts "\nFrank is...\n - \033[32mCreating\033[0m your project '#{project}'"
256
272
  Dir.mkdir project
273
+
257
274
  puts " - \033[32mCopying\033[0m Frank template"
258
275
  FileUtils.cp_r( Dir.glob(File.join(LIBDIR, 'template/*')), project )
276
+
259
277
  puts "\n \033[32mCongratulations, '#{project}' is ready to go!\033[0m"
260
278
  rescue Errno::EEXIST
261
279
  puts "\n \033[31muh oh, directory '#{project}' already exists...\033[0m"
data/lib/frank/lorem.rb CHANGED
@@ -10,9 +10,7 @@ module Frank
10
10
  def word(replacement = nil)
11
11
  words 1, replacement
12
12
  end
13
-
14
- require 'ruby-debug'
15
-
13
+
16
14
  def words(total, replacement = nil)
17
15
  if @environment == :output && replacement
18
16
  replacement
@@ -22,8 +22,6 @@
22
22
 
23
23
  - if path.match(/\.css$/)
24
24
  = "<tt>#{path.match(/([\w\/]+)\./)[1]}.sass</tt>"
25
- - elsif path.match(/\.js$/)
26
- = "<tt>#{path.match(/([\w\/]+)\./)[1]}.coffee</tt>"
27
25
  - else
28
26
  = "<tt>#{path.gsub(/\/$/, '')}.haml</tt>"
29
27
  = "in the <tt>#{dynamic_folder}</tt> folder, or"
data/lib/frank/tilt.rb CHANGED
@@ -526,6 +526,7 @@ module Tilt
526
526
  end
527
527
  end
528
528
  register 'sass', SassTemplate
529
+ register 'scss', SassTemplate
529
530
 
530
531
 
531
532
  # Lessscss template implementation. See:
data/spec/base_spec.rb CHANGED
@@ -51,13 +51,6 @@ describe Frank::Base do
51
51
  last_response.body.should == "#hello-worlds {\n background: red; }\n"
52
52
  end
53
53
 
54
- it 'renders dynamic javascript without a layout' do
55
- get '/coffee.js'
56
-
57
- last_response.should be_ok
58
- last_response.body.should == "(function(){\n var greeting;\n greeting = \"Hello CoffeeScript\";\n})();"
59
- end
60
-
61
54
  it 'renders a 404 page if template not found' do
62
55
  get '/not_here.css'
63
56
 
data/spec/output_spec.rb CHANGED
@@ -51,32 +51,32 @@ describe Frank::Output do
51
51
 
52
52
  it 'creates erb.html' do
53
53
  output = File.join(File.dirname(__FILE__), 'template/output/erb.html')
54
- File.read(output).should == "<h1>hello worlds</h1>\n\n"
54
+ File.read(output).should == "<div id='p'>/erb</div>\n<div id='layout'>\n <h1>hello worlds</h1>\n</div>\n"
55
55
  end
56
56
 
57
57
  it 'creates redcloth.html' do
58
58
  output = File.join(File.dirname(__FILE__), 'template/output/redcloth.html')
59
- File.read(output).should == "<h1>hello worlds</h1>"
59
+ File.read(output).should == "<div id='p'>/redcloth</div>\n<div id='layout'>\n <h1>hello worlds</h1>\n</div>\n"
60
60
  end
61
61
 
62
62
  it 'creates markdown.html' do
63
63
  output = File.join(File.dirname(__FILE__), 'template/output/markdown.html')
64
- File.read(output).should == "<h1>hello worlds</h1>\n"
64
+ File.read(output).should == "<div id='p'>/markdown</div>\n<div id='layout'>\n <h1>hello worlds</h1>\n</div>\n"
65
65
  end
66
66
 
67
67
  it 'creates mustache.html' do
68
68
  output = File.join(File.dirname(__FILE__), 'template/output/mustache.html')
69
- File.read(output).should == "<h1>hello worlds</h1>\n\n"
69
+ File.read(output).should == "<div id='p'>/mustache</div>\n<div id='layout'>\n <h1>hello worlds</h1>\n</div>\n"
70
70
  end
71
71
 
72
72
  it 'creates liquid.html' do
73
73
  output = File.join(File.dirname(__FILE__), 'template/output/liquid.html')
74
- File.read(output).should == "<h1>hello worlds</h1>\n"
74
+ File.read(output).should == "<div id='p'>/liquid</div>\n<div id='layout'>\n <h1>hello worlds</h1>\n</div>\n"
75
75
  end
76
76
 
77
77
  it 'creates builder.html' do
78
78
  output = File.join(File.dirname(__FILE__), 'template/output/builder.html')
79
- File.read(output).should == "<h1>hello worlds</h1>\n"
79
+ File.read(output).should == "<div id='p'>/builder</div>\n<div id='layout'>\n <h1>hello worlds</h1>\n</div>\n"
80
80
  end
81
81
 
82
82
  it 'copies static.html' do
@@ -158,32 +158,32 @@ describe Frank::Output do
158
158
 
159
159
  it 'creates erb.html' do
160
160
  output = File.join(File.dirname(__FILE__), 'template/output/erb/index.html')
161
- File.read(output).should == "<h1>hello worlds</h1>\n\n"
161
+ File.read(output).should == "<div id='p'>/erb</div>\n<div id='layout'>\n <h1>hello worlds</h1>\n</div>\n"
162
162
  end
163
163
 
164
164
  it 'creates redcloth.html' do
165
165
  output = File.join(File.dirname(__FILE__), 'template/output/redcloth/index.html')
166
- File.read(output).should == "<h1>hello worlds</h1>"
166
+ File.read(output).should == "<div id='p'>/redcloth</div>\n<div id='layout'>\n <h1>hello worlds</h1>\n</div>\n"
167
167
  end
168
168
 
169
169
  it 'creates markdown.html' do
170
170
  output = File.join(File.dirname(__FILE__), 'template/output/markdown/index.html')
171
- File.read(output).should == "<h1>hello worlds</h1>\n"
171
+ File.read(output).should == "<div id='p'>/markdown</div>\n<div id='layout'>\n <h1>hello worlds</h1>\n</div>\n"
172
172
  end
173
173
 
174
174
  it 'creates mustache.html' do
175
175
  output = File.join(File.dirname(__FILE__), 'template/output/mustache/index.html')
176
- File.read(output).should == "<h1>hello worlds</h1>\n\n"
176
+ File.read(output).should == "<div id='p'>/mustache</div>\n<div id='layout'>\n <h1>hello worlds</h1>\n</div>\n"
177
177
  end
178
178
 
179
179
  it 'creates liquid.html' do
180
180
  output = File.join(File.dirname(__FILE__), 'template/output/liquid/index.html')
181
- File.read(output).should == "<h1>hello worlds</h1>\n"
181
+ File.read(output).should == "<div id='p'>/liquid</div>\n<div id='layout'>\n <h1>hello worlds</h1>\n</div>\n"
182
182
  end
183
183
 
184
184
  it 'creates builder.html' do
185
185
  output = File.join(File.dirname(__FILE__), 'template/output/builder/index.html')
186
- File.read(output).should == "<h1>hello worlds</h1>\n"
186
+ File.read(output).should == "<div id='p'>/builder</div>\n<div id='layout'>\n <h1>hello worlds</h1>\n</div>\n"
187
187
  end
188
188
 
189
189
  it 'copies static.html' do
data/spec/render_spec.rb CHANGED
@@ -45,62 +45,57 @@ describe Frank::Render do
45
45
  end
46
46
 
47
47
  it 'renders a haml template with no layout' do
48
- template = @app.render('no_layout.haml')
49
- template.should == "<h1>i have no layout</h1>\n"
50
- end
48
+ template = @app.render('no_layout.haml')
49
+ template.should == "<h1>i have no layout</h1>\n"
50
+ end
51
+
52
+ it 'renders haml template' do
53
+ template = @app.render('index.haml')
54
+ template.should == "<div id='p'>/</div>\n<div id='layout'>\n <h1>hello worlds</h1>\n <h2>/</h2>\n</div>\n"
55
+ end
51
56
 
52
- it 'renders haml template' do
53
- template = @app.render('index.haml')
54
- template.should == "<div id='p'>/</div>\n<div id='layout'>\n <h1>hello worlds</h1>\n <h2>/</h2>\n</div>\n"
55
- end
56
-
57
- it 'renders haml template with a haml partial' do
58
- template = @app.render('partial_test.haml')
59
- template.should == "<div id='p'>/partial_test</div>\n<div id='layout'>\n <h1>hello worlds</h1>\n <p>hello from partial</p>\n</div>\n"
60
- end
61
-
62
- it 'renders sass template' do
63
- template = @app.render('sass.sass')
64
- template.should == "#hello-worlds {\n background: red; }\n"
65
- end
66
-
67
- it 'renders coffee template' do
68
- template = @app.render('coffee.coffee')
69
- template.should == "(function(){\n var greeting;\n greeting = \"Hello CoffeeScript\";\n})();"
70
- end
57
+ it 'renders haml template with a haml partial' do
58
+ template = @app.render('partial_test.haml')
59
+ template.should == "<div id='p'>/partial_test</div>\n<div id='layout'>\n <h1>hello worlds</h1>\n <p>hello from partial</p>\n</div>\n"
60
+ end
71
61
 
72
- it 'renders erb template' do
73
- template = @app.render('erb.erb')
74
- template.should == "<h1>hello worlds</h1>\n\n"
75
- end
76
-
77
- it 'renders redcloth template' do
78
- template = @app.render('redcloth.textile')
79
- template.should == "<h1>hello worlds</h1>"
80
- end
81
-
82
- it 'renders rdiscount template' do
83
- template = @app.render('markdown.md')
84
- template.should == "<h1>hello worlds</h1>\n"
85
- end
86
-
87
- it 'renders mustache template' do
88
- template = @app.render('mustache.mustache')
89
- template.should == "<h1>hello worlds</h1>\n\n"
90
- end
91
-
92
- it 'renders liquid template' do
93
- template = @app.render('liquid.liquid')
94
- template.should == "<h1>hello worlds</h1>\n"
95
- end
96
-
97
- it 'renders builder template' do
98
- template = @app.render('builder.builder')
99
- template.should == "<h1>hello worlds</h1>\n"
100
- end
101
-
102
- it 'raise template error' do
103
- lambda { @app.render('not_a.template') }.should raise_error(Frank::TemplateError)
104
- end
62
+ it 'renders sass template' do
63
+ template = @app.render('sass.sass')
64
+ template.should == "#hello-worlds {\n background: red; }\n"
65
+ end
66
+
67
+ it 'renders erb template' do
68
+ template = @app.render('erb.erb')
69
+ template.should == "<div id='p'>/erb</div>\n<div id='layout'>\n <h1>hello worlds</h1>\n</div>\n"
70
+ end
71
+
72
+ it 'renders redcloth template' do
73
+ template = @app.render('redcloth.textile')
74
+ template.should == "<div id='p'>/redcloth</div>\n<div id='layout'>\n <h1>hello worlds</h1>\n</div>\n"
75
+ end
76
+
77
+ it 'renders rdiscount template' do
78
+ template = @app.render('markdown.md')
79
+ template.should == "<div id='p'>/markdown</div>\n<div id='layout'>\n <h1>hello worlds</h1>\n</div>\n"
80
+ end
81
+
82
+ it 'renders mustache template' do
83
+ template = @app.render('mustache.mustache')
84
+ template.should == "<div id='p'>/mustache</div>\n<div id='layout'>\n <h1>hello worlds</h1>\n</div>\n"
85
+ end
86
+
87
+ it 'renders liquid template' do
88
+ template = @app.render('liquid.liquid')
89
+ template.should == "<div id='p'>/liquid</div>\n<div id='layout'>\n <h1>hello worlds</h1>\n</div>\n"
90
+ end
91
+
92
+ it 'renders builder template' do
93
+ template = @app.render('builder.builder')
94
+ template.should == "<div id='p'>/builder</div>\n<div id='layout'>\n <h1>hello worlds</h1>\n</div>\n"
95
+ end
96
+
97
+ it 'raise template error' do
98
+ lambda { @app.render('not_a.template') }.should raise_error(Frank::TemplateError)
99
+ end
105
100
 
106
101
  end
metadata CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
6
6
  - 0
7
7
  - 3
8
8
  - 0
9
- - beta
10
- version: 0.3.0.beta
9
+ - beta2
10
+ version: 0.3.0.beta2
11
11
  platform: ruby
12
12
  authors:
13
13
  - blahed
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-06-12 00:00:00 -04:00
19
+ date: 2010-06-18 00:00:00 -04:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -142,7 +142,6 @@ files:
142
142
  - spec/template/dynamic/500.haml
143
143
  - spec/template/dynamic/_partial.haml
144
144
  - spec/template/dynamic/builder.builder
145
- - spec/template/dynamic/coffee.coffee
146
145
  - spec/template/dynamic/erb.erb
147
146
  - spec/template/dynamic/helper_test.haml
148
147
  - spec/template/dynamic/index.haml
@@ -1 +0,0 @@
1
- greeting: "Hello CoffeeScript"