frank 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,3 +1,6 @@
1
1
  .DS_Store
2
2
  pkg
3
- lib/frank/output_old.rb
3
+ lib/frank/output_old.rb
4
+ .rvmrc
5
+ .sass-cache
6
+ .bundle
data/Gemfile ADDED
@@ -0,0 +1,27 @@
1
+ source :gemcutter
2
+ gem "rack", ">=1.0"
3
+ gem "mongrel", ">=1.0"
4
+ gem "haml", ">=3.0"
5
+ gem "tilt", "=0.9"
6
+
7
+ # dev dependencies
8
+ gem "jeweler"
9
+ gem "rspec", ">=2.0.0.beta.19"
10
+ gem "rack-test", ">=0.5"
11
+ gem "rake"
12
+
13
+ # tilt dev dependencies
14
+ gem 'contest'
15
+ gem 'builder'
16
+ gem 'erubis'
17
+ gem 'compass', '>= 0.10.2'
18
+ gem 'mustache'
19
+ gem 'rdiscount'
20
+ gem 'liquid'
21
+ gem 'less'
22
+ gem 'coffee-script'
23
+ gem "RedCloth"
24
+
25
+ gem "mini_magick"
26
+
27
+ gem 'ruby-debug'
data/Gemfile.lock ADDED
@@ -0,0 +1,90 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ RedCloth (4.2.3)
5
+ abstract (1.0.0)
6
+ builder (2.1.2)
7
+ cgi_multipart_eof_fix (2.5.0)
8
+ coffee-script (0.3.2)
9
+ columnize (0.3.1)
10
+ compass (0.10.2)
11
+ haml (>= 3.0.4)
12
+ contest (0.1.2)
13
+ daemons (1.1.0)
14
+ diff-lcs (1.1.2)
15
+ erubis (2.6.6)
16
+ abstract (>= 1.0.0)
17
+ fastthread (1.0.7)
18
+ gem_plugin (0.2.3)
19
+ gemcutter (0.6.1)
20
+ git (1.2.5)
21
+ haml (3.0.13)
22
+ jeweler (1.4.0)
23
+ gemcutter (>= 0.1.0)
24
+ git (>= 1.2.5)
25
+ rubyforge (>= 2.0.0)
26
+ json_pure (1.4.3)
27
+ less (1.2.21)
28
+ mutter (>= 0.4.2)
29
+ treetop (>= 1.4.2)
30
+ linecache (0.43)
31
+ liquid (2.1.2)
32
+ mini_magick (1.3.1)
33
+ subexec (~> 0.0.4)
34
+ mongrel (1.1.5)
35
+ cgi_multipart_eof_fix (>= 2.4)
36
+ daemons (>= 1.0.3)
37
+ fastthread (>= 1.0.1)
38
+ gem_plugin (>= 0.2.3)
39
+ mustache (0.11.2)
40
+ mutter (0.5.3)
41
+ polyglot (0.3.1)
42
+ rack (1.2.1)
43
+ rack-test (0.5.4)
44
+ rack (>= 1.0)
45
+ rake (0.8.7)
46
+ rdiscount (1.6.5)
47
+ rspec (2.0.0.beta.19)
48
+ rspec-core (= 2.0.0.beta.19)
49
+ rspec-expectations (= 2.0.0.beta.19)
50
+ rspec-mocks (= 2.0.0.beta.19)
51
+ rspec-core (2.0.0.beta.19)
52
+ rspec-expectations (2.0.0.beta.19)
53
+ diff-lcs (>= 1.1.2)
54
+ rspec-mocks (2.0.0.beta.19)
55
+ ruby-debug (0.10.3)
56
+ columnize (>= 0.1)
57
+ ruby-debug-base (~> 0.10.3.0)
58
+ ruby-debug-base (0.10.3)
59
+ linecache (>= 0.3)
60
+ rubyforge (2.0.4)
61
+ json_pure (>= 1.1.7)
62
+ subexec (0.0.4)
63
+ tilt (0.9)
64
+ treetop (1.4.8)
65
+ polyglot (>= 0.3.1)
66
+
67
+ PLATFORMS
68
+ ruby
69
+
70
+ DEPENDENCIES
71
+ RedCloth
72
+ builder
73
+ coffee-script
74
+ compass (>= 0.10.2)
75
+ contest
76
+ erubis
77
+ haml (>= 3.0)
78
+ jeweler
79
+ less
80
+ liquid
81
+ mini_magick
82
+ mongrel (>= 1.0)
83
+ mustache
84
+ rack (>= 1.0)
85
+ rack-test (>= 0.5)
86
+ rake
87
+ rdiscount
88
+ rspec (>= 2.0.0.beta.19)
89
+ ruby-debug
90
+ tilt (= 0.9)
data/README.md CHANGED
@@ -15,29 +15,34 @@ Overview
15
15
 
16
16
  Create a new project with:
17
17
 
18
- $ frank <project_name>
18
+ $ frank new <project_path>
19
19
 
20
- Then `cd <project_name>` and start up the server with:
21
-
22
- $ frankup
20
+ Then `cd <project_path>` and start up the server with:
21
+
22
+ $ frank server
23
23
 
24
24
  -----------------------
25
25
  Frank's holdin' it down...
26
26
  0.0.0.0:3601
27
27
 
28
- And you're ready to get to work. By default, dynamic templates are served from the `dynamic` folder,
28
+ And you're ready to get to work. By default, dynamic templates are served from the `dynamic` folder,
29
29
  static files are served from the `static` folder, and layouts are served from the `layouts` folder.
30
30
 
31
31
  When you're done working:
32
32
 
33
- $ frankout <dump_dir>
33
+ $ frank export <export_dir>
34
+
35
+ to compile templates and copy them--along with static your assets--into `<export_dir>`. Or,
34
36
 
35
- to compile templates and copy them--along with static your assets--into `<dump_dir>`. Or,
36
-
37
- $ frankout --production <dump_dir>
37
+ $ frank export --production <export_dir>
38
38
 
39
39
  to compile & copy over, but organized to work as a static website in production. (e.g. folders named after your views, with an `index.html` inside)
40
40
 
41
+ Upgrading to 0.4
42
+ -------------------------
43
+
44
+ As of version 0.4, Frank no longer uses settings.yml. However you can use `frank upgrade` in order convert your old settings.yml to the new setup.rb format.
45
+
41
46
  Views & Meta Data
42
47
  -------------------------
43
48
 
@@ -67,13 +72,13 @@ support them--in the view & layout:
67
72
  title: My Rad Page
68
73
  author: My Rad Self
69
74
  ---------------------------------------------META
70
-
75
+
71
76
  %h1= title
72
77
  %h3= 'By ' + author
73
-
78
+
74
79
  layout:
75
80
  %title= title + '--My Rad Site'
76
-
81
+
77
82
 
78
83
 
79
84
  Layouts (updated in 0.3)
@@ -146,12 +151,12 @@ Frank now has a handy automatic page refreshing helper. Just include `= refresh`
146
151
  save a project file. This eliminates the tedium of hundreds of manual refreshes over the course
147
152
  of building a project.
148
153
 
149
- When it's time to `frankout`, Frank will leave out the JavasScript bits of the refresher.
154
+ When it's time export with `frank export`, Frank will leave out the JavasScript bits of the refresher.
150
155
 
151
156
  ### Current Path
152
157
 
153
158
  Frank now has a `current_path` variable that you can use to set selected states on nav items.
154
- It will return the path info from the template being processed. You also, have access to the variable from layouts and from the `frankout` command.
159
+ It will return the path info from the template being processed. You also, have access to the variable from layouts and from the `frank export` command.
155
160
 
156
161
  ### Placeholder Text
157
162
 
@@ -171,38 +176,31 @@ This will return 3 sentences of standard [Lorem Ipsum][11]. `lorem` also has all
171
176
  lorem.first_name
172
177
  lorem.last_name
173
178
  lorem.email
174
-
175
179
 
176
- ### Placeholder Images
177
180
 
178
- Likewise, Frank can generate placeholder images for you, from a selection of 10 pre-made images. For example, to generate `<img />` tag with a random dummy image:
179
-
180
- %img{:src=> lorem.image( 500, 400 ) }
181
-
182
- The `lorem.image` helper returns a special Frank image URL. In this case, the returned image will be 500 pixels wide and 400 pixels tall. By default, Frank caches the images returned for each specific size. So every subsequent request for a `500x400` image will return the same thing. If you'd rather have a random image every time, just pass in `true` for the 3rd image:
183
-
184
- lorem.image( 100, 100, true ) # returns a random 100x100 image every time it's called
181
+ ### Placeholder Images
185
182
 
186
- ( NOTE: Unfortunately, in order to use the placeholder images, you must have a working [ImageMagick][12], and have the `mini_magick` gem installed as well. )
183
+ Frank now uses [placehold.it][14] for placeholder images, the `lorem.image` helper supports background_color, color, random_color, and text options:
187
184
 
188
- If you would like to use the placeholder images in a context where the helper methods are unavailable (e.g. in static CSS or JavaScript), you can access the URL directly with `/_img/500x400.jpg`, or for random images `/_img/500x400.jpg?random`.
185
+ lorem.image('300x400') #=> http://placehold.it/300x400
186
+ lorem.image('300x400', :background_color => '333', :color => 'fff') #=> http://placehold.it/300x400/333/fff
187
+ lorem.image('300x400', :random_color => true) #=> http://placehold.it/300x400/f47av7/9fbc34d
188
+ lorem.image('300x400', :text => 'blah') #=> http://placehold.it/300x400&text=blah
189
189
 
190
190
  ### Replacement Text
191
191
 
192
- All of the lorem helpers accept an optional "replacement" argument. This will be the text rendered when you `frankout`.
193
- For example `lorem.sentence("<%= page.content %>")` will generate a lorem sentence when you view the page using the `frankup` server.
194
- However, when you `frankout` the template will render "<%= page.content %>". This is useful if you plan on moving a frank project
192
+ All of the lorem helpers accept an optional "replacement" argument. This will be the text rendered when you `frank export`.
193
+ For example `lorem.sentence("<%= page.content %>")` will generate a lorem sentence when you view the page using the `frank server` for development.
194
+ However, when you `frank export` the template will render "<%= page.content %>". This is useful if you plan on moving a frank project
195
195
  into a framework. (e.g. rails, sinatra, django, etc)
196
196
 
197
197
 
198
198
  Configuration
199
199
  -------------
200
200
 
201
- In `settings.yml`, you can change your folder names, and server port & host name.
201
+ In `setup.rb`, you can change your folder names, and server port & host name.
202
202
  Check the comments there if you need help.
203
203
 
204
- (NOTE: In order to reduce confusion, Frank no longer checks for a `~/.frank` folder to copy when you run the `frank` command. Instead, the preferred method is just to create a base Frank project wherever you please, and just `cp -r` to the location of your new project, since this is all the `frank` command did anyway)
205
-
206
204
  Installation
207
205
  ------------
208
206
 
@@ -224,3 +222,4 @@ Installation
224
222
  [11]: http://en.wikipedia.org/wiki/Lorem_ipsum
225
223
  [12]: http://www.imagemagick.org/script/binary-releases.php?ImageMagick=4pg9cdfr8e6gn7aru9mtelepr3
226
224
  [13]: http://www.yaml.org/start.html
225
+ [14]: http://placehold.it
data/Rakefile CHANGED
@@ -1,3 +1,4 @@
1
+ $LOAD_PATH << "./lib"
1
2
  require File.dirname(__FILE__) + "/lib/frank.rb"
2
3
 
3
4
  begin
@@ -11,11 +12,11 @@ begin
11
12
  gemspec.homepage = "http://github.com/blahed/frank"
12
13
  gemspec.authors = ["blahed", "nwah"]
13
14
  gemspec.add_dependency 'rack', '>=1.0'
14
- gemspec.add_dependency 'mongrel', '>=1.0'
15
- gemspec.add_dependency 'haml', '>=2.0'
16
- gemspec.add_development_dependency 'rspec'
15
+ gemspec.add_dependency 'haml', '>=3.0'
16
+ gemspec.add_dependency 'tilt', '=0.9'
17
+ gemspec.add_development_dependency 'rspec', ">=2.0.0.beta.19"
17
18
  gemspec.add_development_dependency 'rack-test', '>=0.5'
18
-
19
+
19
20
  end
20
21
  Jeweler::GemcutterTasks.new
21
22
  rescue LoadError
data/bin/frank CHANGED
@@ -2,14 +2,132 @@
2
2
  $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
3
3
 
4
4
  require 'frank'
5
+ require 'optparse'
6
+
7
+ begin
8
+ # try to use bundler if its available
9
+ require 'bundler'
10
+ begin
11
+ Bundler.require
12
+ rescue Bundler::GemfileNotFound
13
+ # revert to using local frank install
14
+ $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
15
+ end
16
+ rescue LoadError
17
+ # revert to using local frank install
18
+ $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
19
+ end
20
+
21
+ options = {:server => {}}
22
+
23
+ banner = <<-USAGE
24
+ Usage:
25
+ frank new PROJECT_PATH
26
+ frank server [options]
27
+ frank export PATH [options]
28
+
29
+ Description:
30
+ The `frank new' command generates a frank template project with the default
31
+ directory structure and configuration at the given path.
32
+
33
+ Once you have a frank project you can use the `frank server' or the aliased 'frank up' commands
34
+ to start the development server and begin developing your project.
35
+
36
+ When you are finished working and ready to export you can use
37
+ the `frank export' or aliased `frank out' commands.
38
+
39
+ Example:
40
+ frank new ~/Dev/blah.com
41
+ cd ~/Dev/blah.com
42
+ frank server
43
+
44
+ # do some development
45
+
46
+ frank export ~/Dev/html/blah.com
47
+ USAGE
48
+
49
+
50
+ opts = OptionParser.new do |opts|
51
+ opts.banner = banner
52
+
53
+ opts.separator ''
54
+ opts.separator 'Options:'
55
+
56
+ opts.on('--server [HANDLER]', 'Set the server handler (frank server)') do |handler|
57
+ options[:server]['handler'] = handler unless handler.nil?
58
+ end
59
+
60
+ opts.on('--hostname [HOSTNAME]', 'Set the server hostname (frank server)') do |hostname|
61
+ options[:server]['hostname'] = hostname unless hostname.nil?
62
+ end
63
+
64
+ opts.on('--port [PORT]', 'Set the server port (frank server)') do |port|
65
+ options[:server]['port'] = port unless port.nil?
66
+ end
67
+
68
+ opts.on('--dynamic_folder [FOLDER]', 'Set the dynamic folder (frank server)') do |folder|
69
+ options[:dynamic_folder] = folder unless folder.nil?
70
+ end
71
+
72
+ opts.on('--static_folder [FOLDER]', 'Set the static folder (frank server)') do |folder|
73
+ options[:static_folder] = folder unless folder.nil?
74
+ end
75
+
76
+ opts.on('--production', 'Production ready export (frank export) i.e. ([FOLDER]/index.html)') do |handler|
77
+ options[:production] = true
78
+ end
79
+
80
+ opts.on('-v', '--version', 'Show the frank version and exit') do
81
+ puts "Frank v#{Frank::VERSION}"
82
+ exit
83
+ end
84
+
85
+ opts.on( '-h', '--help', 'Display this help' ) do
86
+ puts opts
87
+ exit
88
+ end
89
+ end
90
+
91
+ opts.parse!
5
92
 
6
93
  if ARGV.empty?
7
- puts "Usage: frank [PROJECT_NAME]"
8
- puts "Stubs out a template project"
94
+ puts opts
9
95
  exit
10
- elsif ['-v', '--version'].include?(ARGV.first)
11
- puts "Frank v#{Frank::VERSION}"
12
- exit
13
- end
96
+ else
97
+ if %w[server up export out upgrade].include? ARGV.first
98
+ begin
99
+ Frank.bootstrap(Dir.pwd)
100
+ rescue Errno::ENOENT
101
+ if File.exist? File.join(Dir.pwd, 'helpers.rb')
102
+ puts "Frank could not find setup.rb, perhaps you need to upgrade with the `frank upgrade' command"
103
+ else
104
+ puts "Frank could not find setup.rb"
105
+ end
106
+ end
107
+ end
108
+
109
+ case ARGV.first
110
+ when 'new', 'n'
111
+ # stub out the project
112
+ Frank.stub(ARGV[1])
113
+ when 'server', 's', 'up'
114
+ # setup server from options
115
+ server_options = options[:server]
116
+ Frank.server.handler = server_options['handler'] if server_options['handler']
117
+ Frank.server.hostname = server_options['hostname'] if server_options['hostname']
118
+ Frank.server.port = server_options['port'] if server_options['port']
14
119
 
15
- Frank.stub(ARGV.first)
120
+ # setup folder options
121
+ Frank.dynamic_folder = options[:dynamic_folder] if options[:dynamic_folder]
122
+ Frank.static_folder = options[:static_folder] if options[:static_folder]
123
+ Frank.new
124
+ when 'export', 'e', 'out'
125
+ Frank.production! if options[:production]
126
+ Frank::Output.new do
127
+ set :environment, :output
128
+ set :output_folder, ARGV[1]
129
+ end.dump(options[:production])
130
+ when 'upgrade'
131
+ Frank.upgrade!
132
+ end
133
+ end
data/bin/frankout CHANGED
@@ -1,7 +1,22 @@
1
1
  #!/usr/bin/env ruby
2
- $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
3
-
4
2
  require 'optparse'
3
+
4
+ puts "\nthe `frankout' command is deprecated and will be removed in 0.5, use `frank export' or the alias `frank out'"
5
+
6
+ begin
7
+ # try to use bundler if its available
8
+ require 'bundler'
9
+ begin
10
+ Bundler.require
11
+ rescue Bundler::GemfileNotFound
12
+ # revert to using local frank install
13
+ $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
14
+ end
15
+ rescue LoadError
16
+ # revert to using local frank install
17
+ $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
18
+ end
19
+
5
20
  require 'frank'
6
21
 
7
22
  production = false
@@ -10,13 +25,13 @@ opts = OptionParser.new do |opts|
10
25
  opts.banner = "Usage: frankout [OPTIONS] directory\n",
11
26
  "Compiles and dumps a project and it\'s static files to given directory\n",
12
27
  "Example: frankout --production html_dump\n\n"
13
-
28
+
14
29
  opts.separator 'Options:'
15
-
30
+
16
31
  opts.on('--production', 'Production ready dump i.e. ([FOLDER]/index.html)') do |handler|
17
32
  production = true
18
33
  end
19
-
34
+
20
35
  opts.on( '-h', '--help', 'Display this help' ) do
21
36
  puts opts
22
37
  exit
@@ -40,18 +55,13 @@ if File.exists? output_folder
40
55
  end
41
56
 
42
57
  begin
43
- settings = YAML.load_file('settings.yml')
44
- proj_dir = Dir.pwd
45
-
58
+ Frank.production! if production
59
+ Frank.bootstrap(Dir.pwd)
46
60
  Frank::Output.new do
47
- settings.each do |name, value|
48
- set name.to_s, value
49
- end
50
61
  set :environment, :output
51
62
  set :output_folder, output_folder
52
- set :proj_dir, proj_dir
53
63
  end.dump(production)
54
-
64
+
55
65
  rescue Errno::ENOENT
56
- puts "Frank could not find settings.yml."
66
+ puts "Frank could not find setup.rb"
57
67
  end
data/bin/frankup CHANGED
@@ -1,71 +1,69 @@
1
1
  #!/usr/bin/env ruby
2
- $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
3
-
4
2
  require 'optparse'
3
+
4
+ puts "\nthe `frankup' command is deprecated and will be removed in 0.5, use `frank server' or the alias `frank up'"
5
+
6
+ begin
7
+ # try to use bundler if its available
8
+ require 'bundler'
9
+ begin
10
+ Bundler.require
11
+ rescue Bundler::GemfileNotFound
12
+ # revert to using local frank install
13
+ $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
14
+ end
15
+ rescue LoadError
16
+ # revert to using local frank install
17
+ $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
18
+ end
19
+
5
20
  require 'frank'
6
21
 
7
22
  options = {:server => {}}
8
23
 
9
24
  OptionParser.new do |opts|
10
25
  opts.banner = "Usage: frankup [OPTIONS]\n",
11
- "Starts the frank development server using settings.yml\n",
12
- "If settings.yml isn\'t found, a webserver will be started and serve up files from the current directory\n\n"
13
-
26
+ "Starts the frank development server using setup.rb\n",
27
+ "If setup.rb isn\'t found, a webserver will be started and serve up files from the current directory\n\n"
28
+
14
29
  opts.separator 'Options:'
15
-
30
+
16
31
  opts.on('--server [HANDLER]', 'Set the server handler') do |handler|
17
32
  options[:server]['handler'] = handler unless handler.nil?
18
33
  end
19
-
34
+
20
35
  opts.on('--hostname [HOSTNAME]', 'Set the server hostname') do |hostname|
21
36
  options[:server]['hostname'] = hostname unless hostname.nil?
22
37
  end
23
-
38
+
24
39
  opts.on('--port [PORT]', 'Set the server port') do |port|
25
40
  options[:server]['port'] = port unless port.nil?
26
41
  end
27
-
42
+
28
43
  opts.on('--dynamic_folder [FOLDER]', 'Set the dynamic folder') do |folder|
29
44
  options[:dynamic_folder] = folder unless folder.nil?
30
45
  end
31
-
46
+
32
47
  opts.on('--static_folder [FOLDER]', 'Set the static folder') do |folder|
33
48
  options[:static_folder] = folder unless folder.nil?
34
49
  end
35
-
50
+
36
51
  opts.on( '-h', '--help', 'Display this help' ) do
37
52
  puts opts
38
53
  exit
39
54
  end
40
55
  end.parse!
41
56
 
42
- if File.exist? 'settings.yml'
43
- settings = YAML.load_file('settings.yml')
44
- else
45
- settings = {
46
- :server => { 'handler' => 'mongrel', 'hostname' => '0.0.0.0', 'port' => 3601 },
47
- :static_folder => '.',
48
- :dynamic_folder => '.',
49
- :environment => :serving
50
- }
51
- end
57
+ Frank.bootstrap(Dir.pwd)
52
58
 
53
- options.each do |opt, val|
54
- if opt == :server
55
- server = settings['server'] ? settings['server'] : settings[:server]
56
- val.each { |sopt, sval| server[sopt] = sval }
57
- else
58
- settings[opt] = val
59
- end
60
- end
59
+ # setup server from options
60
+ server_options = options[:server]
61
+ Frank.server.handler = server_options['handler'] if server_options['handler']
62
+ Frank.server.hostname = server_options['hostname'] if server_options['hostname']
63
+ Frank.server.port = server_options['port'] if server_options['port']
61
64
 
62
- if settings[:environment] == :serving
63
- puts "Could not find \"settings.yml\", serving up files from the this directory at http://#{settings[:server]['hostname']}:#{settings[:server]['port']}"
64
- end
65
+ # setup folder options
66
+ Frank.dynamic_folder = options[:dynamic_folder] if options[:dynamic_folder]
67
+ Frank.static_folder = options[:static_folder] if options[:static_folder]
65
68
 
66
- Frank.new do
67
- settings.each do |name, value|
68
- set name.to_s, value
69
- end
70
- set :proj_dir, Dir.pwd
71
- end
69
+ Frank.new