tdreyno-staticmatic 2.1.0 → 2.1.1
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/staticmatic +2 -14
- data/lib/staticmatic/actionpack_support/remove_controller_caching.rb +7 -0
- data/lib/staticmatic/autoload.rb +16 -14
- data/lib/staticmatic/base.rb +97 -126
- data/lib/staticmatic/builder.rb +64 -86
- data/lib/staticmatic/config.rb +31 -37
- data/lib/staticmatic/previewer.rb +16 -28
- data/lib/staticmatic/template_handlers/haml.rb +6 -10
- data/lib/staticmatic/template_handlers/liquid.rb +3 -7
- data/lib/staticmatic/template_handlers/markdown.rb +3 -7
- data/lib/staticmatic/template_handlers/sass.rb +3 -7
- data/lib/staticmatic/template_handlers/textile.rb +3 -7
- data/lib/staticmatic.rb +16 -12
- data/lib/templates/script/builder +6 -0
- data/lib/templates/script/server +4 -0
- data/spec/action_view_helpers_spec.rb +12 -0
- data/spec/asset_helpers_spec.rb +22 -0
- data/spec/base_spec.rb +42 -0
- data/spec/builder_spec.rb +44 -0
- data/spec/config_spec.rb +31 -0
- data/spec/deprecation_spec.rb +18 -0
- data/spec/fixtures/sample/Rakefile +4 -0
- data/spec/fixtures/sample/build/haml_test.html +11 -0
- data/spec/fixtures/sample/build/hello_world.html +9 -0
- data/spec/fixtures/sample/build/index.html +9 -0
- data/spec/fixtures/sample/build/page_with_error.html +61 -0
- data/spec/fixtures/sample/build/services/index.html +9 -0
- data/spec/fixtures/sample/build/services/web_development.html +9 -0
- data/spec/fixtures/sample/build/stylesheets/site.css +3 -0
- data/spec/fixtures/sample/config.rb +3 -0
- data/spec/fixtures/sample/src/helpers/speech_helper.rb +5 -0
- data/spec/fixtures/sample/src/layouts/site.html.erb +9 -0
- data/spec/fixtures/sample/src/layouts/specified_layout.html.erb +3 -0
- data/spec/fixtures/sample/src/pages/_form.html.erb +1 -0
- data/spec/fixtures/sample/src/pages/haml_test.html.haml +3 -0
- data/spec/fixtures/sample/src/pages/hello_world.html.erb +1 -0
- data/spec/fixtures/sample/src/pages/index.html.erb +1 -0
- data/spec/fixtures/sample/src/pages/liquid_test.html.liquid +3 -0
- data/spec/fixtures/sample/src/pages/markdown_test.html.markdown +3 -0
- data/spec/fixtures/sample/src/pages/page_with_error.html.haml +3 -0
- data/spec/fixtures/sample/src/pages/services/index.html.erb +1 -0
- data/spec/fixtures/sample/src/pages/services/web_development.html.erb +1 -0
- data/spec/fixtures/sample/src/pages/specify_layout.html.erb +1 -0
- data/spec/fixtures/sample/src/pages/textile_test.html.textile +3 -0
- data/spec/fixtures/sample/src/stylesheets/site.css.sass +3 -0
- data/spec/layouts_spec.rb +29 -0
- data/spec/rendering_spec.rb +83 -0
- metadata +78 -22
- data/Rakefile +0 -12
- data/app_generators/staticmatic/staticmatic_generator.rb +0 -74
- data/app_generators/staticmatic/templates/Rakefile +0 -3
- data/lib/staticmatic/rescue.rb +0 -14
- data/lib/tasks/staticmatic.rb +0 -9
- data/staticmatic.gemspec +0 -52
- data/vendor/html-scanner/html/document.rb +0 -68
- data/vendor/html-scanner/html/node.rb +0 -530
- data/vendor/html-scanner/html/sanitizer.rb +0 -173
- data/vendor/html-scanner/html/selector.rb +0 -828
- data/vendor/html-scanner/html/tokenizer.rb +0 -105
- data/vendor/html-scanner/html/version.rb +0 -11
- /data/{app_generators/staticmatic → lib}/templates/src/helpers/site_helper.rb +0 -0
- /data/{app_generators/staticmatic → lib}/templates/src/layouts/site.html.haml +0 -0
- /data/{app_generators/staticmatic → lib}/templates/src/pages/index.html.haml +0 -0
- /data/{app_generators/staticmatic → lib}/templates/src/stylesheets/site.css.sass +0 -0
@@ -1,12 +1,8 @@
|
|
1
1
|
require 'liquid'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
def render(template, local_assigns = {})
|
7
|
-
::Liquid::Template.parse(template.source).render(local_assigns)
|
8
|
-
end
|
9
|
-
end
|
3
|
+
class StaticMatic::TemplateHandlers::Liquid < ActionView::TemplateHandler
|
4
|
+
def render(template, local_assigns = {})
|
5
|
+
::Liquid::Template.parse(template.source).render(local_assigns)
|
10
6
|
end
|
11
7
|
end
|
12
8
|
|
@@ -1,12 +1,8 @@
|
|
1
1
|
require 'bluecloth'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
def render(template, local_assigns = {})
|
7
|
-
::BlueCloth::new(template.source).to_html
|
8
|
-
end
|
9
|
-
end
|
3
|
+
class StaticMatic::TemplateHandlers::Markdown < ActionView::TemplateHandler
|
4
|
+
def render(template, local_assigns = {})
|
5
|
+
::BlueCloth::new(template.source).to_html
|
10
6
|
end
|
11
7
|
end
|
12
8
|
|
@@ -1,12 +1,8 @@
|
|
1
1
|
require 'sass'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
def render(template)
|
7
|
-
::Sass::Engine.new(template.source, StaticMatic::Config[:sass_options]).render
|
8
|
-
end
|
9
|
-
end
|
3
|
+
class StaticMatic::TemplateHandlers::Sass < ActionView::TemplateHandler
|
4
|
+
def render(template)
|
5
|
+
::Sass::Engine.new(template.source, StaticMatic::Config[:sass_options]).render
|
10
6
|
end
|
11
7
|
end
|
12
8
|
|
@@ -1,12 +1,8 @@
|
|
1
1
|
require 'redcloth'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
def render(template, local_assigns = {})
|
7
|
-
::RedCloth::new(template.source).to_html
|
8
|
-
end
|
9
|
-
end
|
3
|
+
class StaticMatic::TemplateHandlers::Textile < ActionView::TemplateHandler
|
4
|
+
def render(template, local_assigns = {})
|
5
|
+
::RedCloth::new(template.source).to_html
|
10
6
|
end
|
11
7
|
end
|
12
8
|
|
data/lib/staticmatic.rb
CHANGED
@@ -1,27 +1,31 @@
|
|
1
|
-
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../vendor/html-scanner"
|
2
1
|
$LOAD_PATH.unshift File.dirname(__FILE__) unless
|
3
2
|
$LOAD_PATH.include?(File.dirname(__FILE__)) ||
|
4
3
|
$LOAD_PATH.include?(File.expand_path(File.dirname(__FILE__)))
|
5
4
|
|
6
5
|
require 'rubygems'
|
7
|
-
require 'active_support'
|
8
|
-
require 'action_view'
|
9
6
|
require 'staticmatic/autoload'
|
10
|
-
require 'staticmatic/base'
|
11
7
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
19
|
-
end
|
8
|
+
require 'active_support'
|
9
|
+
$LOAD_PATH.unshift Gem.required_location('actionpack', 'action_controller/vendor/html-scanner')
|
10
|
+
require 'action_view'
|
11
|
+
require 'staticmatic/actionpack_support/mime'
|
12
|
+
require 'staticmatic/actionpack_support/remove_partial_benchmark'
|
13
|
+
require 'staticmatic/actionpack_support/remove_controller_caching'
|
20
14
|
|
15
|
+
# Load generic helpers
|
21
16
|
ActionView::Base.class_eval do
|
22
17
|
include StaticMatic::Helpers::AssetTagHelper
|
23
18
|
include StaticMatic::Helpers::PageHelper
|
24
19
|
include StaticMatic::Helpers::UrlHelper
|
25
20
|
include StaticMatic::Deprecation
|
26
21
|
include Mime
|
22
|
+
end
|
23
|
+
|
24
|
+
# Load template handlers
|
25
|
+
Dir[File.dirname(__FILE__) + '/staticmatic/template_handlers/*.rb'].each do |handler|
|
26
|
+
begin
|
27
|
+
require "staticmatic/template_handlers/#{File.basename(handler)}"
|
28
|
+
rescue LoadError
|
29
|
+
# Could not load gem or handler
|
30
|
+
end
|
27
31
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "..", "lib", "staticmatic")
|
2
|
+
|
3
|
+
describe "ActionView Helper Integration" do
|
4
|
+
before :all do
|
5
|
+
@sample_site_path = File.dirname(__FILE__) + "/fixtures/sample"
|
6
|
+
@staticmatic = StaticMatic::Base.new(@sample_site_path)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should render partial" do
|
10
|
+
@staticmatic.view.render(:partial => "pages/form").should include("This is a form")
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "..", "lib", "staticmatic")
|
2
|
+
|
3
|
+
describe "Asset Helpers" do
|
4
|
+
ActionView::Base.included_modules.each do |mod|
|
5
|
+
include mod if mod.parents.include?(ActionView::Helpers)
|
6
|
+
end
|
7
|
+
|
8
|
+
include StaticMatic::Helpers::AssetTagHelper
|
9
|
+
before :all do
|
10
|
+
@sample_site_path = File.dirname(__FILE__) + "/fixtures/sample"
|
11
|
+
@staticmatic = StaticMatic::Base.new(@sample_site_path)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should render partial" do
|
15
|
+
@staticmatic.view.render(:partial => "pages/form").should include("This is a form")
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should generate stylesheet link" do
|
19
|
+
@relative_path_to_root = @staticmatic.calculate_relative_path_to_root('pages/services/web_development/costs')
|
20
|
+
stylesheet_link_tag("site").should include("../../stylesheets/site.css")
|
21
|
+
end
|
22
|
+
end
|
data/spec/base_spec.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "..", "lib", "staticmatic")
|
2
|
+
|
3
|
+
describe StaticMatic::Base do
|
4
|
+
before :all do
|
5
|
+
@sample_site_path = File.dirname(__FILE__) + "/fixtures/sample"
|
6
|
+
@staticmatic = StaticMatic::Base.new(@sample_site_path)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should catch any haml template errors" do
|
10
|
+
output = @staticmatic.render("page_with_error")
|
11
|
+
output.should include("Illegal nesting")
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should still render correctly after a haml error occured" do
|
15
|
+
output = @staticmatic.render("page_with_error")
|
16
|
+
@staticmatic.render("hello_world").should include("Hello world!")
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should load custom helpers" do
|
20
|
+
@staticmatic.view.respond_to?(:say).should be_true
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should determine template directory for file" do
|
24
|
+
@staticmatic.full_template_path("stylesheets/site.css").should_not include("pages/")
|
25
|
+
@staticmatic.full_template_path("hello_world.html").should include("pages/")
|
26
|
+
@staticmatic.full_template_path("haml_test").should include("pages/")
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should know if we can render a template or not" do
|
30
|
+
@staticmatic.can_render?("hello_world.html").should_not be_false
|
31
|
+
@staticmatic.can_render?("stylesheets/site.css").should_not be_false
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should add index if needed" do
|
35
|
+
@staticmatic.full_template_path("services").should == "pages/services/index"
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should know the relative path to the base dir" do
|
39
|
+
@staticmatic.calculate_relative_path_to_root("pages/services/web_development/costs").should == "../../"
|
40
|
+
@staticmatic.calculate_relative_path_to_root("pages/services/web_development").should == "../"
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# require File.join(File.dirname(__FILE__), "..", "lib", "staticmatic")
|
2
|
+
# require 'templater'
|
3
|
+
#
|
4
|
+
# describe StaticMatic::Builder do
|
5
|
+
# before :each do
|
6
|
+
# @root_dir = File.dirname(__FILE__) + "/fixtures/builder-test"
|
7
|
+
#
|
8
|
+
# orig_stdout = STDOUT.dup
|
9
|
+
# STDOUT.reopen('/dev/null') # redirect stdout to /dev/null
|
10
|
+
# StaticMatic::Generator.run_cli(File.dirname(@root_dir), 'staticmatic', 1, ["setup", File.basename(@root_dir)])
|
11
|
+
# STDOUT.reopen(orig_stdout) # restore stdout
|
12
|
+
# end
|
13
|
+
#
|
14
|
+
# def build_site
|
15
|
+
# @staticmatic = StaticMatic::Base.new(@root_dir)
|
16
|
+
# @staticmatic.logger = mock("logger")
|
17
|
+
# @staticmatic.logger.should_receive(:info).at_least(:once)
|
18
|
+
# StaticMatic::Builder.build(@staticmatic)
|
19
|
+
# end
|
20
|
+
#
|
21
|
+
# after :each do
|
22
|
+
# FileUtils.rm_rf(@root_dir)
|
23
|
+
# end
|
24
|
+
#
|
25
|
+
# it "should create version tracking file with current build timestamp" do
|
26
|
+
# versions_file = "#{@root_dir}/builds"
|
27
|
+
# about_now = Time.now.strftime("%Y%m%d%H%M")
|
28
|
+
#
|
29
|
+
# build_site
|
30
|
+
# File.exists?(versions_file).should be_true
|
31
|
+
#
|
32
|
+
# versions = File.read(versions_file).split(/\n/)
|
33
|
+
# versions[0].should include(about_now)
|
34
|
+
# end
|
35
|
+
#
|
36
|
+
# it "should not build partial files" do
|
37
|
+
# File.open("#{@root_dir}/src/pages/_partial.html.erb", "w") do |f|
|
38
|
+
# f.puts "Test"
|
39
|
+
# end
|
40
|
+
#
|
41
|
+
# build_site
|
42
|
+
# File.exists?("#{@root_dir}/build/_partial.html").should be_false
|
43
|
+
# end
|
44
|
+
# end
|
data/spec/config_spec.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "..", "lib", "staticmatic")
|
2
|
+
|
3
|
+
describe StaticMatic::Config do
|
4
|
+
before :all do
|
5
|
+
StaticMatic::Config.setup
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should be able to get a configuration key" do
|
9
|
+
StaticMatic::Config[:host].should == StaticMatic::Config.defaults[:host]
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should be able to set a configuration key" do
|
13
|
+
StaticMatic::Config[:bar] = "Hello"
|
14
|
+
StaticMatic::Config[:bar].should == "Hello"
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should be able to #delete a configuration key" do
|
18
|
+
StaticMatic::Config[:bar] = "Hello"
|
19
|
+
StaticMatic::Config[:bar].should == "Hello"
|
20
|
+
StaticMatic::Config.delete(:bar)
|
21
|
+
StaticMatic::Config[:bar].should == nil
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should be able to #fetch a key that does exist" do
|
25
|
+
StaticMatic::Config.fetch(:host, "192.168.2.1").should == StaticMatic::Config.defaults[:host]
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should be able to #fetch a key that does exist" do
|
29
|
+
StaticMatic::Config.fetch(:bar, "heylo").should == "heylo"
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "..", "lib", "staticmatic")
|
2
|
+
|
3
|
+
describe "Deprecation of old methods" do
|
4
|
+
before :all do
|
5
|
+
@sample_site_path = File.dirname(__FILE__) + "/fixtures/sample"
|
6
|
+
@staticmatic = StaticMatic::Base.new(@sample_site_path)
|
7
|
+
@staticmatic.logger = mock("logger") # Mock the logger
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should display a message for deprecated methods" do
|
11
|
+
def deprecate_test
|
12
|
+
@staticmatic.deprecate :alt => "another_method"
|
13
|
+
end
|
14
|
+
|
15
|
+
@staticmatic.logger.should_receive(:warn).with(/has been deprecated/)
|
16
|
+
deprecate_test
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<link rel="stylesheet" href="/stylesheets/application.css">
|
4
|
+
<h1>My Sample Site</h1>
|
5
|
+
</head>
|
6
|
+
<body>
|
7
|
+
Illegal Indentation: Indenting more than once per line is illegal.
|
8
|
+
<pre class='debug_dump'>---
|
9
|
+
- |-
|
10
|
+
In users/stephenbartholomew/sites/curve21/utilities/staticmatic/spec/fixtures/sample/src/pages/page_with_errorhtmlhaml
|
11
|
+
|
12
|
+
|
13
|
+
(haml):1
|
14
|
+
/usr/local/lib/ruby/gems/1.8/gems/haml-1.8.2/lib/haml/precompiler.rb:169:in `precompile'
|
15
|
+
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:609:in `each_with_index'
|
16
|
+
/usr/local/lib/ruby/gems/1.8/gems/haml-1.8.2/lib/haml/precompiler.rb:125:in `each'
|
17
|
+
/usr/local/lib/ruby/gems/1.8/gems/haml-1.8.2/lib/haml/precompiler.rb:125:in `each_with_index'
|
18
|
+
/usr/local/lib/ruby/gems/1.8/gems/haml-1.8.2/lib/haml/precompiler.rb:125:in `precompile'
|
19
|
+
/usr/local/lib/ruby/gems/1.8/gems/haml-1.8.2/lib/haml/engine.rb:75:in `initialize'
|
20
|
+
/usr/local/lib/ruby/gems/1.8/gems/haml-1.8.2/lib/haml/template/plugin.rb:27:in `new'
|
21
|
+
/usr/local/lib/ruby/gems/1.8/gems/haml-1.8.2/lib/haml/template/plugin.rb:27:in `compile'
|
22
|
+
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:520:in `delegate_compile'
|
23
|
+
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:567:in `create_template_source'
|
24
|
+
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:604:in `compile_template'
|
25
|
+
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:637:in `compile_and_render_template'
|
26
|
+
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:367:in `render_template'
|
27
|
+
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:318:in `render_file'
|
28
|
+
../../../lib/staticmatic/base.rb:36:in `render'
|
29
|
+
../../../lib/staticmatic/base.rb:44:in `render_with_layout'
|
30
|
+
../../../lib/staticmatic/builder.rb:26:in `build_pages'
|
31
|
+
../../../lib/staticmatic/builder.rb:13:in `each'
|
32
|
+
../../../lib/staticmatic/builder.rb:13:in `build_pages'
|
33
|
+
../../../lib/staticmatic/builder.rb:12:in `each'
|
34
|
+
../../../lib/staticmatic/builder.rb:12:in `build_pages'
|
35
|
+
../../../lib/staticmatic/builder.rb:8:in `initialize'
|
36
|
+
../../../lib/staticmatic/builder.rb:81:in `new'
|
37
|
+
../../../lib/staticmatic/builder.rb:81:in `build'
|
38
|
+
../../../lib/tasks/staticmatic.rb:4
|
39
|
+
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `call'
|
40
|
+
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `execute'
|
41
|
+
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `each'
|
42
|
+
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `execute'
|
43
|
+
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:508:in `invoke_with_call_chain'
|
44
|
+
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `synchronize'
|
45
|
+
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `invoke_with_call_chain'
|
46
|
+
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:494:in `invoke'
|
47
|
+
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1931:in `invoke_task'
|
48
|
+
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level'
|
49
|
+
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `each'
|
50
|
+
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level'
|
51
|
+
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in `standard_exception_handling'
|
52
|
+
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1903:in `top_level'
|
53
|
+
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1881:in `run'
|
54
|
+
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in `standard_exception_handling'
|
55
|
+
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1878:in `run'
|
56
|
+
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/bin/rake:31
|
57
|
+
/usr/local/bin/rake:19:in `load'
|
58
|
+
/usr/local/bin/rake:19
|
59
|
+
</pre>
|
60
|
+
</body>
|
61
|
+
</html>
|
@@ -0,0 +1 @@
|
|
1
|
+
This is a form
|
@@ -0,0 +1 @@
|
|
1
|
+
Hello world!
|
@@ -0,0 +1 @@
|
|
1
|
+
Welcome
|
@@ -0,0 +1 @@
|
|
1
|
+
<h1>Services</h1>
|
@@ -0,0 +1 @@
|
|
1
|
+
<h1>Web Development</h1>
|
@@ -0,0 +1 @@
|
|
1
|
+
<% @layout = "specified_layout" %>
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "..", "lib", "staticmatic")
|
2
|
+
|
3
|
+
describe StaticMatic::Base do
|
4
|
+
before :all do
|
5
|
+
@sample_site_path = File.dirname(__FILE__) + "/fixtures/sample"
|
6
|
+
@staticmatic = StaticMatic::Base.new(@sample_site_path)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should render with layout" do
|
10
|
+
output = @staticmatic.render("hello_world.html")
|
11
|
+
output.should include("My Sample Site")
|
12
|
+
output.should include("Hello world!")
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should render with layout specified in template" do
|
16
|
+
output = @staticmatic.render("specify_layout")
|
17
|
+
output.should include("This is a Specified Layout")
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should clean layout variable for next request" do
|
21
|
+
output = @staticmatic.render("specify_layout")
|
22
|
+
@staticmatic.view.instance_variable_get("@layout").should be_nil
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should allow disabling the layout" do
|
26
|
+
output = @staticmatic.render("no_layout")
|
27
|
+
output.should_not include("My Sample Site")
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "..", "lib", "staticmatic")
|
2
|
+
|
3
|
+
describe StaticMatic::Base do
|
4
|
+
before :all do
|
5
|
+
@sample_site_path = File.dirname(__FILE__) + "/fixtures/sample"
|
6
|
+
@staticmatic = StaticMatic::Base.new(@sample_site_path)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should render a single template" do
|
10
|
+
@staticmatic.render("hello_world").should include("Hello world!")
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should render a page" do
|
14
|
+
@staticmatic.render("hello_world").should include("Hello world!")
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should render with layout" do
|
18
|
+
output = @staticmatic.render("hello_world.html")
|
19
|
+
|
20
|
+
output.should include("My Sample Site")
|
21
|
+
output.should include("Hello world!")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should render haml template" do
|
25
|
+
output = @staticmatic.render("haml_test")
|
26
|
+
output.should include("<strong>Hello from haml</strong>")
|
27
|
+
end
|
28
|
+
|
29
|
+
if ActionView::Template.template_handler_extensions.include? :markdown
|
30
|
+
it "should render markdown template" do
|
31
|
+
output = @staticmatic.render("markdown_test")
|
32
|
+
output.should match(/<strong>Hello from markdown<\/strong>/)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
if ActionView::Template.template_handler_extensions.include? :textile
|
37
|
+
it "should render textile template" do
|
38
|
+
output = @staticmatic.render("textile_test")
|
39
|
+
output.should match(/<strong>Hello from textile<\/strong>/)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
if ActionView::Template.template_handler_extensions.include? :liquid
|
44
|
+
it "should render liquid template" do
|
45
|
+
output = @staticmatic.render("liquid_test")
|
46
|
+
output.should match(/<strong>Hello from liquid<\/strong>/)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should register a css renderer" do
|
51
|
+
output = @staticmatic.render("stylesheets/site.css")
|
52
|
+
output.should include("body {")
|
53
|
+
output.should include("font-family: verdana")
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should setup up css type correctly" do
|
57
|
+
@staticmatic.determine_format_for("stylesheets/site.css").should == :css
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should determine format for file with extension" do
|
61
|
+
@staticmatic.determine_format_for("stylesheets/site.css.sass").should == :css
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should have sensible defaults for haml & sass" do
|
65
|
+
@staticmatic.determine_format_for("stylesheets/site.sass").should == :css
|
66
|
+
@staticmatic.determine_format_for("pages/test.haml").should == :html
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should render index template from sub-directory" do
|
70
|
+
output = @staticmatic.render("services/")
|
71
|
+
output.should include("Services")
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should render template from sub-directory" do
|
75
|
+
output = @staticmatic.render("services/web_development")
|
76
|
+
output.should include("Web Development")
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should render with layout specified in template" do
|
80
|
+
output = @staticmatic.render("specify_layout")
|
81
|
+
output.should include("This is a Specified Layout")
|
82
|
+
end
|
83
|
+
end
|