tdreyno-staticmatic 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +21 -0
- data/Rakefile +12 -0
- data/bin/staticmatic +12 -0
- data/lib/staticmatic/actionpack_support/mime.rb +5 -0
- data/lib/staticmatic/actionpack_support/remove_partial_benchmark.rb +6 -0
- data/lib/staticmatic/autoload.rb +18 -0
- data/lib/staticmatic/base.rb +171 -0
- data/lib/staticmatic/builder.rb +102 -0
- data/lib/staticmatic/config.rb +47 -0
- data/lib/staticmatic/creator.rb +18 -0
- data/lib/staticmatic/deprecation.rb +26 -0
- data/lib/staticmatic/helpers/asset_tag_helper.rb +37 -0
- data/lib/staticmatic/helpers/deprecated_helpers.rb +48 -0
- data/lib/staticmatic/helpers/page_helper.rb +9 -0
- data/lib/staticmatic/helpers/url_helper.rb +19 -0
- data/lib/staticmatic/previewer.rb +65 -0
- data/lib/staticmatic/rescue.rb +14 -0
- data/lib/staticmatic/template_handlers/haml.rb +19 -0
- data/lib/staticmatic/template_handlers/liquid.rb +13 -0
- data/lib/staticmatic/template_handlers/markdown.rb +13 -0
- data/lib/staticmatic/template_handlers/sass.rb +13 -0
- data/lib/staticmatic/template_handlers/textile.rb +13 -0
- data/lib/staticmatic/templates/default/Rakefile +3 -0
- data/lib/staticmatic/templates/default/config.rb +3 -0
- data/lib/staticmatic/templates/default/src/helpers/site_helper.rb +5 -0
- data/lib/staticmatic/templates/default/src/layouts/site.html.haml +6 -0
- data/lib/staticmatic/templates/default/src/pages/index.html.haml +1 -0
- data/lib/staticmatic/templates/default/src/stylesheets/site.css.sass +3 -0
- data/lib/staticmatic/templates/rescues/default_error.html.erb +2 -0
- data/lib/staticmatic/templates/rescues/template_error.html.erb +19 -0
- data/lib/staticmatic.rb +28 -0
- data/lib/tasks/staticmatic.rb +9 -0
- data/staticmatic.gemspec +53 -0
- data/vendor/html-scanner/html/document.rb +68 -0
- data/vendor/html-scanner/html/node.rb +530 -0
- data/vendor/html-scanner/html/sanitizer.rb +173 -0
- data/vendor/html-scanner/html/selector.rb +828 -0
- data/vendor/html-scanner/html/tokenizer.rb +105 -0
- data/vendor/html-scanner/html/version.rb +11 -0
- metadata +127 -0
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'bluecloth'
|
2
|
+
|
3
|
+
module StaticMatic
|
4
|
+
module TemplateHandlers
|
5
|
+
class Markdown < ActionView::TemplateHandler
|
6
|
+
def render(template, local_assigns = {})
|
7
|
+
::BlueCloth::new(template.source).to_html
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
ActionView::Template.register_template_handler(:markdown, StaticMatic::TemplateHandlers::Markdown)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'sass'
|
2
|
+
|
3
|
+
module StaticMatic
|
4
|
+
module TemplateHandlers
|
5
|
+
class Sass < ActionView::TemplateHandler
|
6
|
+
def render(template)
|
7
|
+
::Sass::Engine.new(template.source, StaticMatic::Config[:sass_options]).render
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
ActionView::Template.register_template_handler(:sass, StaticMatic::TemplateHandlers::Sass)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'redcloth'
|
2
|
+
|
3
|
+
module StaticMatic
|
4
|
+
module TemplateHandlers
|
5
|
+
class Textile < ActionView::TemplateHandler
|
6
|
+
def render(template, local_assigns = {})
|
7
|
+
::RedCloth::new(template.source).to_html
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
ActionView::Template.register_template_handler(:textile, StaticMatic::TemplateHandlers::Textile)
|
@@ -0,0 +1 @@
|
|
1
|
+
%h1 StaticMatic!
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<h1>
|
2
|
+
<%=h @exception.class.to_s %> in
|
3
|
+
<% #= #h request.parameters["controller"].capitalize if request.parameters["controller"]%>#<%=h request.parameters["action"] %>
|
4
|
+
</h1>
|
5
|
+
|
6
|
+
<p>
|
7
|
+
Showing <i><%=h @exception.file_name %></i> where line <b>#<%=h @exception.line_number %></b> raised:
|
8
|
+
<pre><code><%=h @exception.message %></code></pre>
|
9
|
+
</p>
|
10
|
+
|
11
|
+
<p>Extracted source (around line <b>#<%=h @exception.line_number %></b>):
|
12
|
+
<pre><code><%=h @exception.source_extract %></code></pre></p>
|
13
|
+
|
14
|
+
<p><%=h @exception.sub_template_message %></p>
|
15
|
+
|
16
|
+
<% @real_exception = @exception
|
17
|
+
@exception = @exception.original_exception || @exception %>
|
18
|
+
|
19
|
+
<% @exception = @real_exception %>
|
data/lib/staticmatic.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../vendor/html-scanner"
|
2
|
+
$LOAD_PATH.unshift File.dirname(__FILE__) unless
|
3
|
+
$LOAD_PATH.include?(File.dirname(__FILE__)) ||
|
4
|
+
$LOAD_PATH.include?(File.expand_path(File.dirname(__FILE__)))
|
5
|
+
|
6
|
+
require 'rubygems'
|
7
|
+
require 'active_support'
|
8
|
+
require 'action_view'
|
9
|
+
require 'staticmatic/autoload'
|
10
|
+
require 'staticmatic/base'
|
11
|
+
|
12
|
+
# Load template handlers
|
13
|
+
Dir['lib/staticmatic/template_handlers/*.rb'].each do |handler|
|
14
|
+
begin
|
15
|
+
require "staticmatic/template_handlers/#{File.basename(handler)}"
|
16
|
+
rescue
|
17
|
+
# Could not load gem or handler
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
ActionView::Base.class_eval do
|
22
|
+
include StaticMatic::Helpers::AssetTagHelper
|
23
|
+
include StaticMatic::Helpers::DeprecatedHelpers
|
24
|
+
include StaticMatic::Helpers::PageHelper
|
25
|
+
include StaticMatic::Helpers::UrlHelper
|
26
|
+
include Mime
|
27
|
+
include StaticMatic::Deprecation
|
28
|
+
end
|
data/staticmatic.gemspec
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "staticmatic"
|
3
|
+
s.version = "2.0.3"
|
4
|
+
s.date = "2008-07-31"
|
5
|
+
s.authors = ["Stephen Bartholomew", "Thomas Reynolds"]
|
6
|
+
s.email = "steve@curve21.com"
|
7
|
+
s.homepage = "http://github.com/tdreyno/staticmatic"
|
8
|
+
s.summary = "Static sites, the Rails Way"
|
9
|
+
s.files = ["LICENSE",
|
10
|
+
"Rakefile",
|
11
|
+
"staticmatic.gemspec",
|
12
|
+
"bin/staticmatic",
|
13
|
+
"lib/staticmatic.rb",
|
14
|
+
"lib/staticmatic/autoload.rb",
|
15
|
+
"lib/staticmatic/base.rb",
|
16
|
+
"lib/staticmatic/builder.rb",
|
17
|
+
"lib/staticmatic/config.rb",
|
18
|
+
"lib/staticmatic/creator.rb",
|
19
|
+
"lib/staticmatic/deprecation.rb",
|
20
|
+
"lib/staticmatic/previewer.rb",
|
21
|
+
"lib/staticmatic/rescue.rb",
|
22
|
+
"lib/staticmatic/actionpack_support/mime.rb",
|
23
|
+
"lib/staticmatic/actionpack_support/remove_partial_benchmark.rb",
|
24
|
+
"lib/staticmatic/helpers/asset_tag_helper.rb",
|
25
|
+
"lib/staticmatic/helpers/deprecated_helpers.rb",
|
26
|
+
"lib/staticmatic/helpers/page_helper.rb",
|
27
|
+
"lib/staticmatic/helpers/url_helper.rb",
|
28
|
+
"lib/staticmatic/template_handlers/haml.rb",
|
29
|
+
"lib/staticmatic/template_handlers/liquid.rb",
|
30
|
+
"lib/staticmatic/template_handlers/markdown.rb",
|
31
|
+
"lib/staticmatic/template_handlers/sass.rb",
|
32
|
+
"lib/staticmatic/template_handlers/textile.rb",
|
33
|
+
"lib/staticmatic/templates/default/Rakefile",
|
34
|
+
"lib/staticmatic/templates/default/config.rb",
|
35
|
+
"lib/staticmatic/templates/default/src/helpers/site_helper.rb",
|
36
|
+
"lib/staticmatic/templates/default/src/layouts/site.html.haml",
|
37
|
+
"lib/staticmatic/templates/default/src/pages/index.html.haml",
|
38
|
+
"lib/staticmatic/templates/default/src/stylesheets/site.css.sass",
|
39
|
+
"lib/staticmatic/templates/rescues/default_error.html.erb",
|
40
|
+
"lib/staticmatic/templates/rescues/template_error.html.erb",
|
41
|
+
"lib/tasks/staticmatic.rb",
|
42
|
+
"vendor/html-scanner/html/document.rb",
|
43
|
+
"vendor/html-scanner/html/node.rb",
|
44
|
+
"vendor/html-scanner/html/sanitizer.rb",
|
45
|
+
"vendor/html-scanner/html/selector.rb",
|
46
|
+
"vendor/html-scanner/html/tokenizer.rb",
|
47
|
+
"vendor/html-scanner/html/version.rb"]
|
48
|
+
s.executables = %w(staticmatic)
|
49
|
+
s.add_dependency("haml", ">=2.0.1")
|
50
|
+
s.add_dependency("mongrel")
|
51
|
+
s.add_dependency("actionpack", ">=2.1.0")
|
52
|
+
s.add_dependency("activesupport", ">=2.1.0")
|
53
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'html/tokenizer'
|
2
|
+
require 'html/node'
|
3
|
+
require 'html/selector'
|
4
|
+
require 'html/sanitizer'
|
5
|
+
|
6
|
+
module HTML #:nodoc:
|
7
|
+
# A top-level HTMl document. You give it a body of text, and it will parse that
|
8
|
+
# text into a tree of nodes.
|
9
|
+
class Document #:nodoc:
|
10
|
+
|
11
|
+
# The root of the parsed document.
|
12
|
+
attr_reader :root
|
13
|
+
|
14
|
+
# Create a new Document from the given text.
|
15
|
+
def initialize(text, strict=false, xml=false)
|
16
|
+
tokenizer = Tokenizer.new(text)
|
17
|
+
@root = Node.new(nil)
|
18
|
+
node_stack = [ @root ]
|
19
|
+
while token = tokenizer.next
|
20
|
+
node = Node.parse(node_stack.last, tokenizer.line, tokenizer.position, token)
|
21
|
+
|
22
|
+
node_stack.last.children << node unless node.tag? && node.closing == :close
|
23
|
+
if node.tag?
|
24
|
+
if node_stack.length > 1 && node.closing == :close
|
25
|
+
if node_stack.last.name == node.name
|
26
|
+
if node_stack.last.children.empty?
|
27
|
+
node_stack.last.children << Text.new(node_stack.last, node.line, node.position, "")
|
28
|
+
end
|
29
|
+
node_stack.pop
|
30
|
+
else
|
31
|
+
open_start = node_stack.last.position - 20
|
32
|
+
open_start = 0 if open_start < 0
|
33
|
+
close_start = node.position - 20
|
34
|
+
close_start = 0 if close_start < 0
|
35
|
+
msg = <<EOF.strip
|
36
|
+
ignoring attempt to close #{node_stack.last.name} with #{node.name}
|
37
|
+
opened at byte #{node_stack.last.position}, line #{node_stack.last.line}
|
38
|
+
closed at byte #{node.position}, line #{node.line}
|
39
|
+
attributes at open: #{node_stack.last.attributes.inspect}
|
40
|
+
text around open: #{text[open_start,40].inspect}
|
41
|
+
text around close: #{text[close_start,40].inspect}
|
42
|
+
EOF
|
43
|
+
strict ? raise(msg) : warn(msg)
|
44
|
+
end
|
45
|
+
elsif !node.childless?(xml) && node.closing != :close
|
46
|
+
node_stack.push node
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# Search the tree for (and return) the first node that matches the given
|
53
|
+
# conditions. The conditions are interpreted differently for different node
|
54
|
+
# types, see HTML::Text#find and HTML::Tag#find.
|
55
|
+
def find(conditions)
|
56
|
+
@root.find(conditions)
|
57
|
+
end
|
58
|
+
|
59
|
+
# Search the tree for (and return) all nodes that match the given
|
60
|
+
# conditions. The conditions are interpreted differently for different node
|
61
|
+
# types, see HTML::Text#find and HTML::Tag#find.
|
62
|
+
def find_all(conditions)
|
63
|
+
@root.find_all(conditions)
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|