tdreyno-staticmatic 2.9.0 → 2.9.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/sm-build +19 -2
- data/bin/sm-init +2 -2
- data/bin/sm-server +12 -2
- data/lib/builder.rb +46 -0
- data/lib/generator.rb +27 -0
- data/lib/merb/init.rb +31 -0
- data/lib/merb/router.rb +3 -0
- data/lib/merb/site.rb +41 -0
- data/lib/{templates → template}/helpers/site_helper.rb +3 -1
- data/lib/{templates/layouts → template/layout}/site.html.haml +1 -1
- data/lib/{templates → template}/pages/index.html.haml +0 -0
- data/lib/{templates/stylesheets/site.css.sass → template/stylesheets/sass/site.sass} +0 -0
- data/spec/builder_spec.rb +31 -16
- data/spec/fixtures/sample/helpers/speech_helper.rb +5 -3
- data/spec/fixtures/sample/{layouts → pages/layout}/site.html.erb +0 -0
- data/spec/fixtures/sample/{layouts → pages/layout}/specified_layout.html.erb +0 -0
- data/spec/fixtures/sample/pages/partial_test.html.erb +1 -1
- data/spec/fixtures/sample/stylesheets/{site.css.sass → sass/site.sass} +0 -0
- metadata +27 -76
- data/lib/staticmatic/actionpack_support/mime.rb +0 -5
- data/lib/staticmatic/actionpack_support/remove_controller_caching.rb +0 -7
- data/lib/staticmatic/actionpack_support/remove_partial_benchmark.rb +0 -6
- data/lib/staticmatic/autoload.rb +0 -18
- data/lib/staticmatic/base.rb +0 -77
- data/lib/staticmatic/builder/dotnet.rb +0 -44
- data/lib/staticmatic/builder/html.rb +0 -23
- data/lib/staticmatic/builder.rb +0 -86
- data/lib/staticmatic/config.rb +0 -41
- data/lib/staticmatic/deprecation.rb +0 -26
- data/lib/staticmatic/generator.rb +0 -28
- data/lib/staticmatic/helpers/asset_tag_helper.rb +0 -11
- data/lib/staticmatic/helpers/page_helper.rb +0 -9
- data/lib/staticmatic/helpers/url_helper.rb +0 -19
- data/lib/staticmatic/previewer.rb +0 -54
- data/lib/staticmatic/template.rb +0 -97
- data/lib/staticmatic/template_handlers/haml.rb +0 -15
- data/lib/staticmatic/template_handlers/liquid.rb +0 -9
- data/lib/staticmatic/template_handlers/markdown.rb +0 -9
- data/lib/staticmatic/template_handlers/sass.rb +0 -9
- data/lib/staticmatic/template_handlers/textile.rb +0 -9
- data/lib/staticmatic/templates/rescues/default_error.html.erb +0 -2
- data/lib/staticmatic/templates/rescues/template_error.html.erb +0 -19
- data/lib/staticmatic.rb +0 -32
- data/spec/action_view_helpers_spec.rb +0 -12
- data/spec/asset_helpers_spec.rb +0 -24
- data/spec/base_spec.rb +0 -54
- data/spec/config_spec.rb +0 -31
- data/spec/deprecation_spec.rb +0 -18
- data/spec/fixtures/sample/build/haml_test.html +0 -11
- data/spec/fixtures/sample/build/hello_world.html +0 -9
- data/spec/fixtures/sample/build/index.html +0 -9
- data/spec/fixtures/sample/build/page_with_error.html +0 -61
- data/spec/fixtures/sample/build/services/index.html +0 -9
- data/spec/fixtures/sample/build/services/web_development.html +0 -9
- data/spec/fixtures/sample/build/stylesheets/site.css +0 -3
- data/spec/fixtures/sample/pages/liquid_test.html.liquid +0 -3
- data/spec/fixtures/sample/pages/markdown_test.html.markdown +0 -3
- data/spec/fixtures/sample/pages/page_with_error.html.haml +0 -3
- data/spec/fixtures/sample/pages/textile_test.html.textile +0 -3
- data/spec/layouts_spec.rb +0 -28
- data/spec/rendering_spec.rb +0 -62
data/bin/sm-build
CHANGED
|
@@ -1,4 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
|
|
3
|
+
require 'rubygems'
|
|
4
|
+
require 'merb-core'
|
|
5
|
+
|
|
6
|
+
# Setup Default Options
|
|
7
|
+
ARGV.push *['--pid', "/var/tmp/staticmatic.%s.pid"]
|
|
8
|
+
ARGV.push *['--init-file', File.join(File.dirname(__FILE__), '..', 'lib', 'merb', 'init.rb')]
|
|
9
|
+
|
|
10
|
+
# Start Merb
|
|
11
|
+
Merb.start
|
|
12
|
+
|
|
13
|
+
class MerbProxy
|
|
14
|
+
include Merb::Test::RequestHelper
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
Sass::Plugin.options = Merb::Config[:sass] if Merb::Config[:sass]
|
|
18
|
+
Sass::Plugin.update_stylesheets
|
|
19
|
+
|
|
20
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'builder')
|
|
21
|
+
Generators.run_cli(Dir.pwd, 'sm-build', 1, %w(build --force).concat(ARGV))
|
data/bin/sm-init
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
|
-
require File.join(File.dirname(__FILE__), '..', 'lib', '
|
|
4
|
-
|
|
3
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'generator')
|
|
4
|
+
Generators.run_cli(Dir.pwd, 'sm-init', 1, %w(setup).concat(ARGV))
|
data/bin/sm-server
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
# Require Merb
|
|
4
|
+
require 'rubygems'
|
|
5
|
+
require 'merb-core'
|
|
6
|
+
|
|
7
|
+
# Setup Default Options
|
|
8
|
+
ARGV.push *['--adapter', "mongrel"]
|
|
9
|
+
ARGV.push *['--pid', "/var/tmp/staticmatic.%s.pid"]
|
|
10
|
+
ARGV.push *['--init-file', File.join(File.dirname(__FILE__), '..', 'lib', 'merb', 'init.rb')]
|
|
11
|
+
|
|
12
|
+
# Start Merb
|
|
13
|
+
puts "Welcome to StaticMatic"
|
|
14
|
+
Merb.start
|
data/lib/builder.rb
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'templater'
|
|
3
|
+
|
|
4
|
+
module Generators
|
|
5
|
+
extend Templater::Manifold
|
|
6
|
+
desc "Build a staticmatic site"
|
|
7
|
+
|
|
8
|
+
class Builder < Templater::Generator
|
|
9
|
+
# Define source and desintation
|
|
10
|
+
def self.source_root; Dir.pwd; end
|
|
11
|
+
def destination_root; File.join(Dir.pwd, 'build'); end
|
|
12
|
+
|
|
13
|
+
# Override template to ask staticmatic for the correct extension to output
|
|
14
|
+
def self.template(name, *args, &block)
|
|
15
|
+
return if args.first.include?('/layout/')
|
|
16
|
+
return if File.basename(args.first)[0,1] == '_'
|
|
17
|
+
|
|
18
|
+
if (args[0] === args[1])
|
|
19
|
+
args[1] = args[0].gsub(File.extname(args.first), '').gsub('pages/', '')
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
super(name, *args, &block)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def self.file(name, *args, &block)
|
|
26
|
+
return if args.first.include?('/sass/')
|
|
27
|
+
args[1] = args[0].gsub('pages/', '') if (args[0] === args[1])
|
|
28
|
+
super(name, *args, &block)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
glob! "images", [] # No templates
|
|
32
|
+
glob! "javascripts", [] # No templates
|
|
33
|
+
glob! "stylesheets", [] # No templates (Sass is pregenerated)
|
|
34
|
+
glob! "pages", %w(haml erb)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
add :build, Builder
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Monkey-patch to use a dynamic renderer, not just ERb
|
|
41
|
+
class Templater::Actions::Template
|
|
42
|
+
def render
|
|
43
|
+
request_path = destination.gsub(File.join(Dir.pwd, 'build'), "")
|
|
44
|
+
::MerbProxy.new.get(request_path).body
|
|
45
|
+
end
|
|
46
|
+
end
|
data/lib/generator.rb
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'templater'
|
|
3
|
+
|
|
4
|
+
module Generators
|
|
5
|
+
extend Templater::Manifold
|
|
6
|
+
desc "Generator for streamlining staticmatic"
|
|
7
|
+
|
|
8
|
+
class NewSite < Templater::Generator
|
|
9
|
+
desc "Creates a new staticmatic scaffold."
|
|
10
|
+
first_argument :location, :required => true, :desc => "Project location"
|
|
11
|
+
|
|
12
|
+
def destination_root
|
|
13
|
+
File.expand_path(location)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def self.source_root
|
|
17
|
+
File.join(File.dirname(__FILE__), 'template')
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
glob!
|
|
21
|
+
empty_directory :build, "build"
|
|
22
|
+
empty_directory :javascripts, "javascripts"
|
|
23
|
+
empty_directory :images, "images"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
add :setup, NewSite
|
|
27
|
+
end
|
data/lib/merb/init.rb
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
dependency 'merb-assets', ">=1.0.0"
|
|
2
|
+
dependency 'merb-helpers', ">=1.0.0"
|
|
3
|
+
dependency 'merb-haml', ">=1.0.0"
|
|
4
|
+
|
|
5
|
+
Merb::Config.use do |c|
|
|
6
|
+
c[:name] = 'sm-server'
|
|
7
|
+
c[:exception_details] = true
|
|
8
|
+
|
|
9
|
+
# Append random numbers to assets in dev mode, but not build mode
|
|
10
|
+
c[:reload_templates] = (Merb::Config[:adapter] == 'mongrel')
|
|
11
|
+
|
|
12
|
+
c[:reload_classes] = true
|
|
13
|
+
c[:reload_time] = 0.5
|
|
14
|
+
c[:ignore_tampered_cookies] = true
|
|
15
|
+
c[:log_auto_flush ] = true
|
|
16
|
+
c[:log_level] = :error
|
|
17
|
+
c[:log_stream] = STDOUT
|
|
18
|
+
c[:log_file] = nil
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
Merb.push_path(:controller, File.dirname(__FILE__))
|
|
22
|
+
Merb.push_path(:router, File.dirname(__FILE__), "router.rb")
|
|
23
|
+
Merb.push_path(:public, Merb.root, nil)
|
|
24
|
+
Merb.push_path(:stylesheet, Merb.root / "stylesheets", nil)
|
|
25
|
+
Merb.push_path(:javascript, Merb.root / "javascripts", nil)
|
|
26
|
+
Merb.push_path(:image, Merb.root / "images", nil)
|
|
27
|
+
Merb.push_path(:view, Merb.root)
|
|
28
|
+
Merb.push_path(:helper, Merb.root / "helpers")
|
|
29
|
+
|
|
30
|
+
Merb::Plugins.config[:sass][:css_location] = Merb.dir_for(:stylesheet)
|
|
31
|
+
Merb::Plugins.config[:sass][:template_location] = Merb.dir_for(:stylesheet) / "sass"
|
data/lib/merb/router.rb
ADDED
data/lib/merb/site.rb
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Intercept all requests
|
|
2
|
+
class Site < ::Merb::Controller
|
|
3
|
+
def index
|
|
4
|
+
render :template => File.join("pages", current_page)
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
override! :partial
|
|
8
|
+
def partial(template, opts={})
|
|
9
|
+
super(File.join("pages", template.to_s), opts)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
override! :asset_path
|
|
13
|
+
def asset_path(*args)
|
|
14
|
+
relative_path(super)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
override! :image_tag
|
|
18
|
+
def image_tag(img, opts={})
|
|
19
|
+
super(img, opts.merge(:path => relative_path('/images/')))
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
override! :link_to
|
|
23
|
+
def link_to(name, url='', opts={})
|
|
24
|
+
absolute_path = (opts[:href] || url)
|
|
25
|
+
absolute_path = "/" + absolute_path if absolute_path.length > 0
|
|
26
|
+
super(name, url, opts.merge(:href => relative_path(absolute_path)))
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
protected
|
|
30
|
+
def current_page
|
|
31
|
+
path = request.uri
|
|
32
|
+
path << "index.html" if path[path.length-1,1] == '/'
|
|
33
|
+
path[1..request.uri.length]
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
private
|
|
37
|
+
def relative_path(absolute_path)
|
|
38
|
+
depth = current_page.split('/').length - 1
|
|
39
|
+
absolute_path.gsub(/^\//, "../" * depth)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
File without changes
|
|
File without changes
|
data/spec/builder_spec.rb
CHANGED
|
@@ -1,29 +1,44 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'fileutils'
|
|
2
2
|
|
|
3
|
-
describe
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
describe "Builder" do
|
|
4
|
+
def project_file(*parts)
|
|
5
|
+
File.expand_path(File.join(File.dirname(__FILE__), "..", *parts))
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
before :all do
|
|
9
|
+
@root_dir = project_file("spec", "fixtures", "sample")
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
before :each do
|
|
13
|
+
build_cmd = project_file("bin", "sm-build")
|
|
14
|
+
`cd #{@root_dir} && #{build_cmd}`
|
|
10
15
|
end
|
|
11
16
|
|
|
12
17
|
after :each do
|
|
13
|
-
FileUtils.rm_rf(@root_dir)
|
|
18
|
+
FileUtils.rm_rf(File.join(@root_dir, "build"))
|
|
14
19
|
end
|
|
15
20
|
|
|
16
21
|
it "should build normal files" do
|
|
17
|
-
|
|
18
|
-
|
|
22
|
+
File.exists?("#{@root_dir}/build/index.html").should be_true
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "should build static files" do
|
|
26
|
+
File.exists?("#{@root_dir}/build/static.html").should be_true
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "should build subdirectory files" do
|
|
30
|
+
File.exists?("#{@root_dir}/build/services/index.html").should be_true
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "should build sass files" do
|
|
34
|
+
File.exists?("#{@root_dir}/build/stylesheets/site.css").should be_true
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "should build static css files" do
|
|
38
|
+
File.exists?("#{@root_dir}/build/stylesheets/static.css").should be_true
|
|
19
39
|
end
|
|
20
40
|
|
|
21
41
|
it "should not build partial files" do
|
|
22
|
-
File.open("#{@root_dir}/pages/_partial.html.erb", "w") do |f|
|
|
23
|
-
f.puts "Test"
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
`cd #{@root_dir} && #{@build_cmd}`
|
|
27
42
|
File.exists?("#{@root_dir}/build/_partial.html").should be_false
|
|
28
43
|
end
|
|
29
44
|
end
|
|
File without changes
|
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<%=
|
|
1
|
+
<%= partial "./form" %>
|
|
File without changes
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: tdreyno-staticmatic
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.9.
|
|
4
|
+
version: 2.9.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Stephen Bartholomew
|
|
@@ -10,62 +10,44 @@ autorequire:
|
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
12
|
|
|
13
|
-
date: 2008-
|
|
13
|
+
date: 2008-12-18 00:00:00 -08:00
|
|
14
14
|
default_executable:
|
|
15
15
|
dependencies:
|
|
16
16
|
- !ruby/object:Gem::Dependency
|
|
17
|
-
name:
|
|
17
|
+
name: templater
|
|
18
18
|
version_requirement:
|
|
19
19
|
version_requirements: !ruby/object:Gem::Requirement
|
|
20
20
|
requirements:
|
|
21
21
|
- - ">="
|
|
22
22
|
- !ruby/object:Gem::Version
|
|
23
|
-
version:
|
|
23
|
+
version: 0.5.0
|
|
24
24
|
version:
|
|
25
25
|
- !ruby/object:Gem::Dependency
|
|
26
|
-
name:
|
|
26
|
+
name: merb-core
|
|
27
27
|
version_requirement:
|
|
28
28
|
version_requirements: !ruby/object:Gem::Requirement
|
|
29
29
|
requirements:
|
|
30
30
|
- - ">="
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version:
|
|
32
|
+
version: 1.0.0
|
|
33
33
|
version:
|
|
34
34
|
- !ruby/object:Gem::Dependency
|
|
35
|
-
name:
|
|
35
|
+
name: merb-haml
|
|
36
36
|
version_requirement:
|
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
|
38
38
|
requirements:
|
|
39
39
|
- - ">="
|
|
40
40
|
- !ruby/object:Gem::Version
|
|
41
|
-
version: 0.
|
|
41
|
+
version: 1.0.0
|
|
42
42
|
version:
|
|
43
43
|
- !ruby/object:Gem::Dependency
|
|
44
|
-
name:
|
|
44
|
+
name: merb-assets
|
|
45
45
|
version_requirement:
|
|
46
46
|
version_requirements: !ruby/object:Gem::Requirement
|
|
47
47
|
requirements:
|
|
48
48
|
- - ">="
|
|
49
49
|
- !ruby/object:Gem::Version
|
|
50
|
-
version:
|
|
51
|
-
version:
|
|
52
|
-
- !ruby/object:Gem::Dependency
|
|
53
|
-
name: actionpack
|
|
54
|
-
version_requirement:
|
|
55
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
56
|
-
requirements:
|
|
57
|
-
- - "="
|
|
58
|
-
- !ruby/object:Gem::Version
|
|
59
|
-
version: 2.1.2
|
|
60
|
-
version:
|
|
61
|
-
- !ruby/object:Gem::Dependency
|
|
62
|
-
name: activesupport
|
|
63
|
-
version_requirement:
|
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
-
requirements:
|
|
66
|
-
- - "="
|
|
67
|
-
- !ruby/object:Gem::Version
|
|
68
|
-
version: 2.1.2
|
|
50
|
+
version: 1.0.0
|
|
69
51
|
version:
|
|
70
52
|
description:
|
|
71
53
|
email: tdreyno@gmail.com
|
|
@@ -82,42 +64,17 @@ files:
|
|
|
82
64
|
- bin/sm-init
|
|
83
65
|
- bin/sm-build
|
|
84
66
|
- bin/sm-server
|
|
85
|
-
- lib/
|
|
86
|
-
- lib/
|
|
87
|
-
- lib/
|
|
88
|
-
- lib/
|
|
89
|
-
- lib/
|
|
90
|
-
- lib/
|
|
91
|
-
- lib/
|
|
92
|
-
- lib/
|
|
93
|
-
- lib/
|
|
94
|
-
- lib/staticmatic/previewer.rb
|
|
95
|
-
- lib/staticmatic/template.rb
|
|
96
|
-
- lib/staticmatic/actionpack_support/mime.rb
|
|
97
|
-
- lib/staticmatic/actionpack_support/remove_partial_benchmark.rb
|
|
98
|
-
- lib/staticmatic/actionpack_support/remove_controller_caching.rb
|
|
99
|
-
- lib/staticmatic/helpers/asset_tag_helper.rb
|
|
100
|
-
- lib/staticmatic/helpers/page_helper.rb
|
|
101
|
-
- lib/staticmatic/helpers/url_helper.rb
|
|
102
|
-
- lib/staticmatic/template_handlers/haml.rb
|
|
103
|
-
- lib/staticmatic/template_handlers/liquid.rb
|
|
104
|
-
- lib/staticmatic/template_handlers/markdown.rb
|
|
105
|
-
- lib/staticmatic/template_handlers/sass.rb
|
|
106
|
-
- lib/staticmatic/template_handlers/textile.rb
|
|
107
|
-
- lib/staticmatic/templates/rescues/default_error.html.erb
|
|
108
|
-
- lib/staticmatic/templates/rescues/template_error.html.erb
|
|
109
|
-
- lib/templates/helpers/site_helper.rb
|
|
110
|
-
- lib/templates/layouts/site.html.haml
|
|
111
|
-
- lib/templates/pages/index.html.haml
|
|
112
|
-
- lib/templates/stylesheets/site.css.sass
|
|
113
|
-
- spec/action_view_helpers_spec.rb
|
|
114
|
-
- spec/asset_helpers_spec.rb
|
|
67
|
+
- lib/builder.rb
|
|
68
|
+
- lib/generator.rb
|
|
69
|
+
- lib/merb/init.rb
|
|
70
|
+
- lib/merb/router.rb
|
|
71
|
+
- lib/merb/site.rb
|
|
72
|
+
- lib/template/helpers/site_helper.rb
|
|
73
|
+
- lib/template/layout/site.html.haml
|
|
74
|
+
- lib/template/pages/index.html.haml
|
|
75
|
+
- lib/template/stylesheets/sass/site.sass
|
|
115
76
|
- spec/base_spec.rb
|
|
116
77
|
- spec/builder_spec.rb
|
|
117
|
-
- spec/config_spec.rb
|
|
118
|
-
- spec/deprecation_spec.rb
|
|
119
|
-
- spec/layouts_spec.rb
|
|
120
|
-
- spec/rendering_spec.rb
|
|
121
78
|
- spec/fixtures/sample/build/haml_test.html
|
|
122
79
|
- spec/fixtures/sample/build/hello_world.html
|
|
123
80
|
- spec/fixtures/sample/build/index.html
|
|
@@ -126,8 +83,8 @@ files:
|
|
|
126
83
|
- spec/fixtures/sample/build/services/web_development.html
|
|
127
84
|
- spec/fixtures/sample/build/stylesheets/site.css
|
|
128
85
|
- spec/fixtures/sample/helpers/speech_helper.rb
|
|
129
|
-
- spec/fixtures/sample/
|
|
130
|
-
- spec/fixtures/sample/
|
|
86
|
+
- spec/fixtures/sample/pages/layout/site.html.erb
|
|
87
|
+
- spec/fixtures/sample/pages/layout/specified_layout.html.erb
|
|
131
88
|
- spec/fixtures/sample/pages/_form.html.erb
|
|
132
89
|
- spec/fixtures/sample/pages/haml_test.html.haml
|
|
133
90
|
- spec/fixtures/sample/pages/hello_world.html.erb
|
|
@@ -135,13 +92,13 @@ files:
|
|
|
135
92
|
- spec/fixtures/sample/pages/partial_test.html.erb
|
|
136
93
|
- spec/fixtures/sample/pages/liquid_test.html.liquid
|
|
137
94
|
- spec/fixtures/sample/pages/markdown_test.html.markdown
|
|
138
|
-
- spec/fixtures/sample/pages/page_with_error.html.
|
|
95
|
+
- spec/fixtures/sample/pages/page_with_error.html.nothaml
|
|
139
96
|
- spec/fixtures/sample/pages/specify_layout.html.erb
|
|
140
97
|
- spec/fixtures/sample/pages/static.html
|
|
141
98
|
- spec/fixtures/sample/pages/textile_test.html.textile
|
|
142
99
|
- spec/fixtures/sample/pages/services/index.html.erb
|
|
143
100
|
- spec/fixtures/sample/pages/services/web_development.html.erb
|
|
144
|
-
- spec/fixtures/sample/stylesheets/site.
|
|
101
|
+
- spec/fixtures/sample/stylesheets/sass/site.sass
|
|
145
102
|
has_rdoc: false
|
|
146
103
|
homepage: http://github.com/tdreyno/staticmatic
|
|
147
104
|
post_install_message:
|
|
@@ -169,14 +126,8 @@ signing_key:
|
|
|
169
126
|
specification_version: 2
|
|
170
127
|
summary: Static sites, the Rails Way
|
|
171
128
|
test_files:
|
|
172
|
-
- spec/action_view_helpers_spec.rb
|
|
173
|
-
- spec/asset_helpers_spec.rb
|
|
174
129
|
- spec/base_spec.rb
|
|
175
130
|
- spec/builder_spec.rb
|
|
176
|
-
- spec/config_spec.rb
|
|
177
|
-
- spec/deprecation_spec.rb
|
|
178
|
-
- spec/layouts_spec.rb
|
|
179
|
-
- spec/rendering_spec.rb
|
|
180
131
|
- spec/fixtures/sample/build/haml_test.html
|
|
181
132
|
- spec/fixtures/sample/build/hello_world.html
|
|
182
133
|
- spec/fixtures/sample/build/index.html
|
|
@@ -185,8 +136,8 @@ test_files:
|
|
|
185
136
|
- spec/fixtures/sample/build/services/web_development.html
|
|
186
137
|
- spec/fixtures/sample/build/stylesheets/site.css
|
|
187
138
|
- spec/fixtures/sample/helpers/speech_helper.rb
|
|
188
|
-
- spec/fixtures/sample/
|
|
189
|
-
- spec/fixtures/sample/
|
|
139
|
+
- spec/fixtures/sample/pages/layout/site.html.erb
|
|
140
|
+
- spec/fixtures/sample/pages/layout/specified_layout.html.erb
|
|
190
141
|
- spec/fixtures/sample/pages/_form.html.erb
|
|
191
142
|
- spec/fixtures/sample/pages/haml_test.html.haml
|
|
192
143
|
- spec/fixtures/sample/pages/hello_world.html.erb
|
|
@@ -194,10 +145,10 @@ test_files:
|
|
|
194
145
|
- spec/fixtures/sample/pages/partial_test.html.erb
|
|
195
146
|
- spec/fixtures/sample/pages/liquid_test.html.liquid
|
|
196
147
|
- spec/fixtures/sample/pages/markdown_test.html.markdown
|
|
197
|
-
- spec/fixtures/sample/pages/page_with_error.html.
|
|
148
|
+
- spec/fixtures/sample/pages/page_with_error.html.nothaml
|
|
198
149
|
- spec/fixtures/sample/pages/specify_layout.html.erb
|
|
199
150
|
- spec/fixtures/sample/pages/static.html
|
|
200
151
|
- spec/fixtures/sample/pages/textile_test.html.textile
|
|
201
152
|
- spec/fixtures/sample/pages/services/index.html.erb
|
|
202
153
|
- spec/fixtures/sample/pages/services/web_development.html.erb
|
|
203
|
-
- spec/fixtures/sample/stylesheets/site.
|
|
154
|
+
- spec/fixtures/sample/stylesheets/sass/site.sass
|
data/lib/staticmatic/autoload.rb
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
module StaticMatic
|
|
2
|
-
autoload :Base, File.join(File.dirname(__FILE__), 'base')
|
|
3
|
-
autoload :Template, File.join(File.dirname(__FILE__), 'template')
|
|
4
|
-
autoload :Config, File.join(File.dirname(__FILE__), 'config')
|
|
5
|
-
autoload :Builder, File.join(File.dirname(__FILE__), 'builder')
|
|
6
|
-
autoload :Generator, File.join(File.dirname(__FILE__), 'generator')
|
|
7
|
-
autoload :Deprecation, File.join(File.dirname(__FILE__), 'deprecation')
|
|
8
|
-
autoload :Previewer, File.join(File.dirname(__FILE__), 'previewer')
|
|
9
|
-
|
|
10
|
-
module Helpers
|
|
11
|
-
autoload :AssetTagHelper, File.join(File.dirname(__FILE__), 'helpers', 'asset_tag_helper')
|
|
12
|
-
autoload :PageHelper, File.join(File.dirname(__FILE__), 'helpers', 'page_helper')
|
|
13
|
-
autoload :UrlHelper, File.join(File.dirname(__FILE__), 'helpers', 'url_helper')
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
module TemplateHandlers
|
|
17
|
-
end
|
|
18
|
-
end
|
data/lib/staticmatic/base.rb
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
module StaticMatic
|
|
2
|
-
class Base
|
|
3
|
-
include StaticMatic::Deprecation
|
|
4
|
-
|
|
5
|
-
attr_accessor :logger, :root_dir, :build_dir, :extentions, :guard
|
|
6
|
-
|
|
7
|
-
def initialize(root_dir)
|
|
8
|
-
@root_dir = root_dir
|
|
9
|
-
@build_dir = File.join(@root_dir, "build")
|
|
10
|
-
@guard = Mutex.new
|
|
11
|
-
|
|
12
|
-
# Setup logger
|
|
13
|
-
@logger = Logger.new(STDERR)
|
|
14
|
-
@logger.level = Logger::INFO
|
|
15
|
-
|
|
16
|
-
# User config
|
|
17
|
-
StaticMatic::Config.setup
|
|
18
|
-
config_file = File.join(@root_dir, "config.rb")
|
|
19
|
-
require config_file if File.exists? config_file
|
|
20
|
-
|
|
21
|
-
@extentions = ActionView::Template.template_handler_extensions.map { |ext| ext.to_s }
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def helpers
|
|
25
|
-
Dir[File.join(@root_dir, 'helpers', '**', '*_helper.rb')]
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def layouts
|
|
29
|
-
@layouts ||= Dir[File.join(@root_dir, "layouts", "*")].select do |path|
|
|
30
|
-
!File.directory?(path)
|
|
31
|
-
end.map do |path|
|
|
32
|
-
File.basename(path)
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def template(filename)
|
|
37
|
-
filename = full_template_path(filename)
|
|
38
|
-
@templates ||= {}
|
|
39
|
-
@templates[filename] ||= Template.new(filename, self)
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def pages
|
|
43
|
-
@pages ||= Dir[File.join(@root_dir, "pages", "**/*")].select do |path|
|
|
44
|
-
!File.directory?(path) && File.basename(path) !~ /^_/
|
|
45
|
-
end.map do |path|
|
|
46
|
-
path.gsub("#{@root_dir}/", "")
|
|
47
|
-
end.partition do |relative_path|
|
|
48
|
-
can_render?(relative_path)
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
# Aliases
|
|
53
|
-
def dynamic_pages; pages.first; end
|
|
54
|
-
def static_pages; pages.last; end
|
|
55
|
-
|
|
56
|
-
# Delegate to Template class
|
|
57
|
-
def render(filename); template(filename).render; end
|
|
58
|
-
def rendered_ext(filename); template(filename).rendered_ext; end
|
|
59
|
-
def can_render?(filename)
|
|
60
|
-
return false if filename =~ /images\/|javascripts\//
|
|
61
|
-
template(filename).can_render?
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
protected
|
|
65
|
-
# Full path to a template, relative to src/
|
|
66
|
-
def full_template_path(template)
|
|
67
|
-
template = template.gsub("#{@root_dir}/", '')
|
|
68
|
-
directory = template.match(/^(\/)?(layouts|stylesheets|pages)/) ? "" : "pages"
|
|
69
|
-
template = File.join(directory, template) unless directory.empty?
|
|
70
|
-
|
|
71
|
-
path = File.join(File.expand_path(@root_dir), template)
|
|
72
|
-
template = File.join(template, "index") if File.directory? path
|
|
73
|
-
|
|
74
|
-
template
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
end
|