tdreyno-staticmatic 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/LICENSE +21 -0
  2. data/Rakefile +12 -0
  3. data/bin/staticmatic +12 -0
  4. data/lib/staticmatic/actionpack_support/mime.rb +5 -0
  5. data/lib/staticmatic/actionpack_support/remove_partial_benchmark.rb +6 -0
  6. data/lib/staticmatic/autoload.rb +18 -0
  7. data/lib/staticmatic/base.rb +171 -0
  8. data/lib/staticmatic/builder.rb +102 -0
  9. data/lib/staticmatic/config.rb +47 -0
  10. data/lib/staticmatic/creator.rb +18 -0
  11. data/lib/staticmatic/deprecation.rb +26 -0
  12. data/lib/staticmatic/helpers/asset_tag_helper.rb +37 -0
  13. data/lib/staticmatic/helpers/deprecated_helpers.rb +48 -0
  14. data/lib/staticmatic/helpers/page_helper.rb +9 -0
  15. data/lib/staticmatic/helpers/url_helper.rb +19 -0
  16. data/lib/staticmatic/previewer.rb +65 -0
  17. data/lib/staticmatic/rescue.rb +14 -0
  18. data/lib/staticmatic/template_handlers/haml.rb +19 -0
  19. data/lib/staticmatic/template_handlers/liquid.rb +13 -0
  20. data/lib/staticmatic/template_handlers/markdown.rb +13 -0
  21. data/lib/staticmatic/template_handlers/sass.rb +13 -0
  22. data/lib/staticmatic/template_handlers/textile.rb +13 -0
  23. data/lib/staticmatic/templates/default/Rakefile +3 -0
  24. data/lib/staticmatic/templates/default/config.rb +3 -0
  25. data/lib/staticmatic/templates/default/src/helpers/site_helper.rb +5 -0
  26. data/lib/staticmatic/templates/default/src/layouts/site.html.haml +6 -0
  27. data/lib/staticmatic/templates/default/src/pages/index.html.haml +1 -0
  28. data/lib/staticmatic/templates/default/src/stylesheets/site.css.sass +3 -0
  29. data/lib/staticmatic/templates/rescues/default_error.html.erb +2 -0
  30. data/lib/staticmatic/templates/rescues/template_error.html.erb +19 -0
  31. data/lib/staticmatic.rb +28 -0
  32. data/lib/tasks/staticmatic.rb +9 -0
  33. data/staticmatic.gemspec +53 -0
  34. data/vendor/html-scanner/html/document.rb +68 -0
  35. data/vendor/html-scanner/html/node.rb +530 -0
  36. data/vendor/html-scanner/html/sanitizer.rb +173 -0
  37. data/vendor/html-scanner/html/selector.rb +828 -0
  38. data/vendor/html-scanner/html/tokenizer.rb +105 -0
  39. data/vendor/html-scanner/html/version.rb +11 -0
  40. metadata +127 -0
@@ -0,0 +1,105 @@
1
+ require 'strscan'
2
+
3
+ module HTML #:nodoc:
4
+
5
+ # A simple HTML tokenizer. It simply breaks a stream of text into tokens, where each
6
+ # token is a string. Each string represents either "text", or an HTML element.
7
+ #
8
+ # This currently assumes valid XHTML, which means no free < or > characters.
9
+ #
10
+ # Usage:
11
+ #
12
+ # tokenizer = HTML::Tokenizer.new(text)
13
+ # while token = tokenizer.next
14
+ # p token
15
+ # end
16
+ class Tokenizer #:nodoc:
17
+
18
+ # The current (byte) position in the text
19
+ attr_reader :position
20
+
21
+ # The current line number
22
+ attr_reader :line
23
+
24
+ # Create a new Tokenizer for the given text.
25
+ def initialize(text)
26
+ @scanner = StringScanner.new(text)
27
+ @position = 0
28
+ @line = 0
29
+ @current_line = 1
30
+ end
31
+
32
+ # Return the next token in the sequence, or +nil+ if there are no more tokens in
33
+ # the stream.
34
+ def next
35
+ return nil if @scanner.eos?
36
+ @position = @scanner.pos
37
+ @line = @current_line
38
+ if @scanner.check(/<\S/)
39
+ update_current_line(scan_tag)
40
+ else
41
+ update_current_line(scan_text)
42
+ end
43
+ end
44
+
45
+ private
46
+
47
+ # Treat the text at the current position as a tag, and scan it. Supports
48
+ # comments, doctype tags, and regular tags, and ignores less-than and
49
+ # greater-than characters within quoted strings.
50
+ def scan_tag
51
+ tag = @scanner.getch
52
+ if @scanner.scan(/!--/) # comment
53
+ tag << @scanner.matched
54
+ tag << (@scanner.scan_until(/--\s*>/) || @scanner.scan_until(/\Z/))
55
+ elsif @scanner.scan(/!\[CDATA\[/)
56
+ tag << @scanner.matched
57
+ tag << @scanner.scan_until(/\]\]>/)
58
+ elsif @scanner.scan(/!/) # doctype
59
+ tag << @scanner.matched
60
+ tag << consume_quoted_regions
61
+ else
62
+ tag << consume_quoted_regions
63
+ end
64
+ tag
65
+ end
66
+
67
+ # Scan all text up to the next < character and return it.
68
+ def scan_text
69
+ "#{@scanner.getch}#{@scanner.scan(/[^<]*/)}"
70
+ end
71
+
72
+ # Counts the number of newlines in the text and updates the current line
73
+ # accordingly.
74
+ def update_current_line(text)
75
+ text.scan(/\r?\n/) { @current_line += 1 }
76
+ end
77
+
78
+ # Skips over quoted strings, so that less-than and greater-than characters
79
+ # within the strings are ignored.
80
+ def consume_quoted_regions
81
+ text = ""
82
+ loop do
83
+ match = @scanner.scan_until(/['"<>]/) or break
84
+
85
+ delim = @scanner.matched
86
+ if delim == "<"
87
+ match = match.chop
88
+ @scanner.pos -= 1
89
+ end
90
+
91
+ text << match
92
+ break if delim == "<" || delim == ">"
93
+
94
+ # consume the quoted region
95
+ while match = @scanner.scan_until(/[\\#{delim}]/)
96
+ text << match
97
+ break if @scanner.matched == delim
98
+ text << @scanner.getch # skip the escaped character
99
+ end
100
+ end
101
+ text
102
+ end
103
+ end
104
+
105
+ end
@@ -0,0 +1,11 @@
1
+ module HTML #:nodoc:
2
+ module Version #:nodoc:
3
+
4
+ MAJOR = 0
5
+ MINOR = 5
6
+ TINY = 3
7
+
8
+ STRING = [ MAJOR, MINOR, TINY ].join(".")
9
+
10
+ end
11
+ end
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tdreyno-staticmatic
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Stephen Bartholomew
8
+ - Thomas Reynolds
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2008-07-31 00:00:00 -07:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: haml
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.0.1
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: mongrel
27
+ version_requirement:
28
+ version_requirements: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: "0"
33
+ version:
34
+ - !ruby/object:Gem::Dependency
35
+ name: actionpack
36
+ version_requirement:
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: 2.1.0
42
+ version:
43
+ - !ruby/object:Gem::Dependency
44
+ name: activesupport
45
+ version_requirement:
46
+ version_requirements: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 2.1.0
51
+ version:
52
+ description:
53
+ email: steve@curve21.com
54
+ executables:
55
+ - staticmatic
56
+ extensions: []
57
+
58
+ extra_rdoc_files: []
59
+
60
+ files:
61
+ - LICENSE
62
+ - Rakefile
63
+ - staticmatic.gemspec
64
+ - bin/staticmatic
65
+ - lib/staticmatic.rb
66
+ - lib/staticmatic/autoload.rb
67
+ - lib/staticmatic/base.rb
68
+ - lib/staticmatic/builder.rb
69
+ - lib/staticmatic/config.rb
70
+ - lib/staticmatic/creator.rb
71
+ - lib/staticmatic/deprecation.rb
72
+ - lib/staticmatic/previewer.rb
73
+ - lib/staticmatic/rescue.rb
74
+ - lib/staticmatic/actionpack_support/mime.rb
75
+ - lib/staticmatic/actionpack_support/remove_partial_benchmark.rb
76
+ - lib/staticmatic/helpers/asset_tag_helper.rb
77
+ - lib/staticmatic/helpers/deprecated_helpers.rb
78
+ - lib/staticmatic/helpers/page_helper.rb
79
+ - lib/staticmatic/helpers/url_helper.rb
80
+ - lib/staticmatic/template_handlers/haml.rb
81
+ - lib/staticmatic/template_handlers/liquid.rb
82
+ - lib/staticmatic/template_handlers/markdown.rb
83
+ - lib/staticmatic/template_handlers/sass.rb
84
+ - lib/staticmatic/template_handlers/textile.rb
85
+ - lib/staticmatic/templates/default/Rakefile
86
+ - lib/staticmatic/templates/default/config.rb
87
+ - lib/staticmatic/templates/default/src/helpers/site_helper.rb
88
+ - lib/staticmatic/templates/default/src/layouts/site.html.haml
89
+ - lib/staticmatic/templates/default/src/pages/index.html.haml
90
+ - lib/staticmatic/templates/default/src/stylesheets/site.css.sass
91
+ - lib/staticmatic/templates/rescues/default_error.html.erb
92
+ - lib/staticmatic/templates/rescues/template_error.html.erb
93
+ - lib/tasks/staticmatic.rb
94
+ - vendor/html-scanner/html/document.rb
95
+ - vendor/html-scanner/html/node.rb
96
+ - vendor/html-scanner/html/sanitizer.rb
97
+ - vendor/html-scanner/html/selector.rb
98
+ - vendor/html-scanner/html/tokenizer.rb
99
+ - vendor/html-scanner/html/version.rb
100
+ has_rdoc: false
101
+ homepage: http://github.com/tdreyno/staticmatic
102
+ post_install_message:
103
+ rdoc_options: []
104
+
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: "0"
112
+ version:
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: "0"
118
+ version:
119
+ requirements: []
120
+
121
+ rubyforge_project:
122
+ rubygems_version: 1.2.0
123
+ signing_key:
124
+ specification_version: 2
125
+ summary: Static sites, the Rails Way
126
+ test_files: []
127
+