frank 0.4.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -42,6 +42,23 @@ Frank.dynamic_folder = "dynamic"
42
42
  #
43
43
  Frank.layouts_folder = "layouts"
44
44
 
45
+ # ----------------------
46
+ # Publish settings:
47
+ #
48
+ # Frank can publish your exported project to
49
+ # a server. All you have to do is tell Frank what host, path, and username.
50
+ # If you have ssh keys setup there is no need for a password.
51
+ # Just uncomment the Publish settings below and
52
+ # make the appropriate changes.
53
+ #
54
+ # Frank.publish.host = "example.com"
55
+ # Frank.publish.path = "/www"
56
+ # Frank.publish.username = 'me'
57
+ # Frank.publish.password = 'secret'
58
+ # Frank.publish.port = 22
59
+ #
60
+
61
+
45
62
 
46
63
  # ----------------------
47
64
  # Initializers:
@@ -6,8 +6,6 @@ describe Frank::Base do
6
6
  def app
7
7
  Frank.bootstrap(File.join(File.dirname(__FILE__), 'template'))
8
8
  Frank.new do
9
- set :environment, :test
10
-
11
9
  # this is just used for a test
12
10
  @blowup_sometimes = true
13
11
  end
@@ -1,11 +1,11 @@
1
1
  require File.dirname(__FILE__) + '/helper'
2
2
 
3
- describe Frank::Output do
3
+ describe Frank::Compile do
4
4
  include Rack::Test::Methods
5
5
 
6
6
  context 'default output' do
7
7
  before :all do
8
- bin_dir = File.join(File.dirname(File.dirname(__FILE__)), 'bin', 'frankout')
8
+ bin_dir = File.join(File.dirname(File.dirname(__FILE__)), 'bin', 'frank export')
9
9
  proj_dir = File.join(File.dirname(__FILE__), 'template')
10
10
  output_dir = File.join(proj_dir, 'output')
11
11
  Dir.chdir proj_dir do
@@ -62,11 +62,6 @@ describe Frank::Output do
62
62
  File.read(output).should == "<div id='p'>/markdown</div>\n<div id='layout'>\n <h1>hello worlds</h1>\n</div>\n"
63
63
  end
64
64
 
65
- it 'creates mustache.html' do
66
- output = File.join(File.dirname(__FILE__), 'template/output/mustache.html')
67
- File.read(output).should == "<div id='p'>/mustache</div>\n<div id='layout'>\n <h1>hello worlds</h1>\n</div>\n"
68
- end
69
-
70
65
  it 'creates liquid.html' do
71
66
  output = File.join(File.dirname(__FILE__), 'template/output/liquid.html')
72
67
  File.read(output).should == "<div id='p'>/liquid</div>\n<div id='layout'>\n <h1>hello worlds</h1>\n</div>\n"
@@ -110,7 +105,7 @@ describe Frank::Output do
110
105
 
111
106
  context 'productions output' do
112
107
  before :all do
113
- bin_dir = File.join(File.dirname(File.dirname(__FILE__)), 'bin', 'frankout')
108
+ bin_dir = File.join(File.dirname(File.dirname(__FILE__)), 'bin', 'frank export')
114
109
  proj_dir = File.join(File.dirname(__FILE__), 'template')
115
110
  output_dir = File.join(proj_dir, 'output')
116
111
  Dir.chdir proj_dir do
@@ -167,11 +162,6 @@ describe Frank::Output do
167
162
  File.read(output).should == "<div id='p'>/markdown</div>\n<div id='layout'>\n <h1>hello worlds</h1>\n</div>\n"
168
163
  end
169
164
 
170
- it 'creates mustache.html' do
171
- output = File.join(File.dirname(__FILE__), 'template/output/mustache/index.html')
172
- File.read(output).should == "<div id='p'>/mustache</div>\n<div id='layout'>\n <h1>hello worlds</h1>\n</div>\n"
173
- end
174
-
175
165
  it 'creates liquid.html' do
176
166
  output = File.join(File.dirname(__FILE__), 'template/output/liquid/index.html')
177
167
  File.read(output).should == "<div id='p'>/liquid</div>\n<div id='layout'>\n <h1>hello worlds</h1>\n</div>\n"
@@ -0,0 +1,23 @@
1
+ require File.dirname(__FILE__) + '/helper'
2
+
3
+ describe Frank::Publish do
4
+ include Rack::Test::Methods
5
+
6
+ before :all do
7
+ @proj_dir = File.join(File.dirname(__FILE__), 'template')
8
+
9
+ bin_dir = File.join(File.dirname(File.dirname(__FILE__)), 'bin')
10
+ Dir.chdir @proj_dir do
11
+ system "#{bin_dir}/frank publish"
12
+ end
13
+ end
14
+
15
+ it 'creates the published folder' do
16
+ File.exist?("/tmp/frankexp-#{@proj_dir.split('/').last}").should be_true
17
+ end
18
+
19
+ after(:all) do
20
+ #FileUtils.rm_r File.join(File.dirname(__FILE__), 'template/output')
21
+ end
22
+
23
+ end
@@ -5,9 +5,7 @@ describe Frank::Render do
5
5
 
6
6
  def app
7
7
  Frank.bootstrap(File.join(File.dirname(__FILE__), 'template'))
8
- Frank.new do
9
- set :environment, :test
10
- end
8
+ Frank.new
11
9
  end
12
10
 
13
11
  before(:all) do
@@ -91,11 +89,6 @@ describe Frank::Render do
91
89
  template.should == "<div id='p'>/markdown</div>\n<div id='layout'>\n <h1>hello worlds</h1>\n</div>\n"
92
90
  end
93
91
 
94
- it 'renders mustache template' do
95
- template = @app.render('mustache.mustache')
96
- template.should == "<div id='p'>/mustache</div>\n<div id='layout'>\n <h1>hello worlds</h1>\n</div>\n"
97
- end
98
-
99
92
  it 'renders liquid template' do
100
93
  template = @app.render('liquid.liquid')
101
94
  template.should == "<div id='p'>/liquid</div>\n<div id='layout'>\n <h1>hello worlds</h1>\n</div>\n"
@@ -1 +1,4 @@
1
- Frank.environment = :test
1
+ Frank.environment = :test
2
+ Frank.publish.path = '/tmp'
3
+ Frank.publish.host = 'linda'
4
+ Frank.publish.user = 'badmin'
@@ -6,9 +6,7 @@ describe Frank::TemplateHelpers do
6
6
  def app
7
7
  Frank.bootstrap(File.join(File.dirname(__FILE__), 'template'))
8
8
  require File.join(Frank.root, 'helpers')
9
- Frank.new do
10
- set :environment, :test
11
- end
9
+ Frank.new
12
10
  end
13
11
 
14
12
  before(:all) do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: frank
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
- - 0
8
- - 4
9
7
  - 1
10
- version: 0.4.1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - blahed
@@ -16,8 +16,8 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-10-15 00:00:00 -04:00
20
- default_executable:
19
+ date: 2010-11-08 00:00:00 -05:00
20
+ default_executable: frank
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: rack
@@ -101,8 +101,6 @@ description: Rapidly develop static sites using any supported templating languag
101
101
  email: travis.dunn@thisismedium.com
102
102
  executables:
103
103
  - frank
104
- - frankout
105
- - frankup
106
104
  extensions: []
107
105
 
108
106
  extra_rdoc_files:
@@ -110,23 +108,23 @@ extra_rdoc_files:
110
108
  - README.md
111
109
  files:
112
110
  - .gitignore
113
- - Featurelist
114
111
  - Gemfile
115
112
  - Gemfile.lock
116
113
  - LICENSE
117
114
  - README.md
118
115
  - Rakefile
116
+ - autotest/discover.rb
119
117
  - bin/frank
120
- - bin/frankout
121
- - bin/frankup
122
118
  - frank.gemspec
123
119
  - lib/frank.rb
124
120
  - lib/frank/base.rb
121
+ - lib/frank/cli.rb
122
+ - lib/frank/compile.rb
125
123
  - lib/frank/lorem.rb
126
124
  - lib/frank/middleware/imager.rb
127
125
  - lib/frank/middleware/refresh.rb
128
126
  - lib/frank/middleware/statik.rb
129
- - lib/frank/output.rb
127
+ - lib/frank/publish.rb
130
128
  - lib/frank/rescue.rb
131
129
  - lib/frank/settings.rb
132
130
  - lib/frank/template_helpers.rb
@@ -155,8 +153,9 @@ files:
155
153
  - lib/template/static/images/frank-med.png
156
154
  - lib/template/static/js/frank.js
157
155
  - spec/base_spec.rb
156
+ - spec/compile_spec.rb
158
157
  - spec/helper.rb
159
- - spec/output_spec.rb
158
+ - spec/publish_spec.rb
160
159
  - spec/render_spec.rb
161
160
  - spec/template/dynamic/500.haml
162
161
  - spec/template/dynamic/_partial.haml
@@ -170,7 +169,6 @@ files:
170
169
  - spec/template/dynamic/lorem_test.haml
171
170
  - spec/template/dynamic/markdown.md
172
171
  - spec/template/dynamic/markdown_in_haml.md
173
- - spec/template/dynamic/mustache.mustache
174
172
  - spec/template/dynamic/nested/child.haml
175
173
  - spec/template/dynamic/nested/deeper/deep.haml
176
174
  - spec/template/dynamic/no_layout.haml
@@ -225,8 +223,9 @@ specification_version: 3
225
223
  summary: Static Site Non-Framework
226
224
  test_files:
227
225
  - spec/base_spec.rb
226
+ - spec/compile_spec.rb
228
227
  - spec/helper.rb
229
- - spec/output_spec.rb
228
+ - spec/publish_spec.rb
230
229
  - spec/render_spec.rb
231
230
  - spec/template/helpers.rb
232
231
  - spec/template/setup.rb
@@ -1,6 +0,0 @@
1
- - DONE - support layouts of a different type than the rendered template
2
- dynamically reload template changes using javascript and a slick url
3
- dynamically reload helpers and settings
4
- - DONE - support yaml variable definition at the top of templates
5
- - DONE - add helper for "selected" css class, this should work with frankup and frankout
6
- - DONE - add frankout replacement fields to lorem helpers
@@ -1,67 +0,0 @@
1
- #!/usr/bin/env ruby
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
-
20
- require 'frank'
21
-
22
- production = false
23
-
24
- opts = OptionParser.new do |opts|
25
- opts.banner = "Usage: frankout [OPTIONS] directory\n",
26
- "Compiles and dumps a project and it\'s static files to given directory\n",
27
- "Example: frankout --production html_dump\n\n"
28
-
29
- opts.separator 'Options:'
30
-
31
- opts.on('--production', 'Production ready dump i.e. ([FOLDER]/index.html)') do |handler|
32
- production = true
33
- end
34
-
35
- opts.on( '-h', '--help', 'Display this help' ) do
36
- puts opts
37
- exit
38
- end
39
- end
40
-
41
- opts.parse!
42
-
43
- if ARGV.empty?
44
- puts opts
45
- exit
46
- end
47
-
48
- output_folder = ARGV.first
49
-
50
- if File.exists? output_folder
51
- print "'#{output_folder}' \033[31malready exists...\033[0m do you want to overwrite it? (y|n) "
52
- resp = STDIN.gets.chomp.strip
53
- exit if resp.downcase.strip != 'y'
54
- FileUtils.rm_rf(output_folder)
55
- end
56
-
57
- begin
58
- Frank.production! if production
59
- Frank.bootstrap(Dir.pwd)
60
- Frank::Output.new do
61
- set :environment, :output
62
- set :output_folder, output_folder
63
- end.dump(production)
64
-
65
- rescue Errno::ENOENT
66
- puts "Frank could not find setup.rb"
67
- end
@@ -1,69 +0,0 @@
1
- #!/usr/bin/env ruby
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
-
20
- require 'frank'
21
-
22
- options = {:server => {}}
23
-
24
- OptionParser.new do |opts|
25
- opts.banner = "Usage: frankup [OPTIONS]\n",
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
-
29
- opts.separator 'Options:'
30
-
31
- opts.on('--server [HANDLER]', 'Set the server handler') do |handler|
32
- options[:server]['handler'] = handler unless handler.nil?
33
- end
34
-
35
- opts.on('--hostname [HOSTNAME]', 'Set the server hostname') do |hostname|
36
- options[:server]['hostname'] = hostname unless hostname.nil?
37
- end
38
-
39
- opts.on('--port [PORT]', 'Set the server port') do |port|
40
- options[:server]['port'] = port unless port.nil?
41
- end
42
-
43
- opts.on('--dynamic_folder [FOLDER]', 'Set the dynamic folder') do |folder|
44
- options[:dynamic_folder] = folder unless folder.nil?
45
- end
46
-
47
- opts.on('--static_folder [FOLDER]', 'Set the static folder') do |folder|
48
- options[:static_folder] = folder unless folder.nil?
49
- end
50
-
51
- opts.on( '-h', '--help', 'Display this help' ) do
52
- puts opts
53
- exit
54
- end
55
- end.parse!
56
-
57
- Frank.bootstrap(Dir.pwd)
58
-
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']
64
-
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]
68
-
69
- Frank.new
@@ -1,63 +0,0 @@
1
- module Frank
2
- class Output < Frank::Base
3
- include Frank::Render
4
-
5
- attr_accessor :environment, :output_folder
6
-
7
- def initialize(&block)
8
- instance_eval &block
9
- end
10
-
11
- # compile the templates
12
- # if production and template isn't index and is html
13
- # name a folder based on the template and compile to index.html
14
- # otherwise compile as is
15
- def compile_templates(production)
16
- dir = File.join(Frank.root, Frank.dynamic_folder)
17
-
18
- Dir[File.join(dir, '**{,/*/**}/*')].each do |path|
19
- if File.file?(path) && !File.basename(path).match(/^(\.|_)/)
20
- path = path[ (dir.size + 1)..-1 ]
21
- ext = File.extname(path)
22
- new_ext = ext_from_handler(ext)
23
- name = File.basename(path, ext)
24
-
25
- if production == true && "#{name}.#{new_ext}" != 'index.html' && new_ext == 'html'
26
- new_file = File.join(@output_folder, path.sub(/(\/?[\w-]+)\.[\w-]+$/, "\\1/index.#{new_ext}"))
27
- else
28
- new_file = File.join(@output_folder, path.sub(/\.[\w-]+$/, ".#{new_ext}"))
29
- end
30
-
31
- create_dirs(new_file)
32
- File.open(new_file, 'w') {|f| f.write render(path) }
33
- puts " - \033[32mCreating\033[0m '#{new_file}'"
34
- end
35
- end
36
- end
37
-
38
- # use path to determine folder name and
39
- # create the required folders if they don't exist
40
- def create_dirs(path)
41
- FileUtils.makedirs path.split('/').reverse[1..-1].reverse.join('/')
42
- end
43
-
44
- # copies over static content
45
- def copy_static
46
- puts " - \033[32mCopying\033[0m static content"
47
- static_folder = File.join(Frank.root, Frank.static_folder)
48
- FileUtils.cp_r(File.join(static_folder, '/.'), @output_folder)
49
- end
50
-
51
- # create the dump dir, compile templates, copy over static assets
52
- def dump(production = false)
53
- FileUtils.mkdir(@output_folder)
54
- puts "\nFrank is..."
55
- puts " - \033[32mCreating\033[0m '#{@output_folder}'"
56
-
57
- compile_templates(production)
58
- copy_static
59
- puts "\n \033[32mCongratulations, project dumped to '#{@output_folder}' successfully!\033[0m"
60
- end
61
- end
62
-
63
- end