brite 0.5 → 0.6.0

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.
Files changed (79) hide show
  1. data/HISTORY.rdoc +30 -0
  2. data/LICENSE +199 -17
  3. data/README.rdoc +61 -0
  4. data/Syckfile +76 -0
  5. data/bin/brite +3 -3
  6. data/bin/brite-server +4 -0
  7. data/lib/brite.rb +11 -0
  8. data/lib/brite/command.rb +53 -56
  9. data/lib/brite/config.rb +94 -18
  10. data/lib/brite/controller.rb +181 -0
  11. data/lib/brite/layout.rb +24 -19
  12. data/lib/brite/meta/data.rb +26 -0
  13. data/lib/brite/meta/package +8 -0
  14. data/lib/brite/meta/profile +19 -0
  15. data/lib/brite/models/model.rb +97 -0
  16. data/lib/brite/models/page.rb +142 -0
  17. data/lib/brite/models/post.rb +9 -0
  18. data/lib/brite/models/site.rb +46 -0
  19. data/lib/brite/rackup.rb +6 -0
  20. data/lib/brite/server.rb +144 -0
  21. data/lib/plugins/sow/brite/awesome/Sowfile +11 -0
  22. data/lib/plugins/sow/brite/awesome/about.page +28 -0
  23. data/lib/plugins/sow/brite/awesome/assets/custom.less +96 -0
  24. data/lib/plugins/sow/brite/awesome/assets/fade.png +0 -0
  25. data/lib/plugins/sow/brite/awesome/assets/highlight.css +96 -0
  26. data/lib/plugins/sow/brite/awesome/assets/highlight.js +1 -0
  27. data/lib/plugins/sow/brite/awesome/assets/jquery.js +19 -0
  28. data/lib/plugins/sow/brite/awesome/assets/jquery.tabs.js +1 -0
  29. data/lib/plugins/sow/brite/awesome/assets/reset.css +57 -0
  30. data/lib/plugins/sow/brite/awesome/assets/ruby.png +0 -0
  31. data/lib/plugins/sow/brite/awesome/brite.yaml +3 -0
  32. data/lib/plugins/sow/brite/awesome/history.page +15 -0
  33. data/lib/plugins/sow/brite/awesome/index.page +18 -0
  34. data/lib/plugins/sow/brite/awesome/legal.page +28 -0
  35. data/lib/plugins/sow/brite/awesome/logs.page +14 -0
  36. data/lib/plugins/sow/brite/awesome/page.layout +75 -0
  37. data/lib/plugins/sow/brite/blog1/.rsync-filter +12 -0
  38. data/lib/plugins/sow/brite/blog1/2011/01/sample.html +293 -0
  39. data/lib/plugins/sow/brite/blog1/2011/01/sample.post +44 -0
  40. data/lib/plugins/sow/brite/blog1/Sowfile +10 -0
  41. data/lib/plugins/sow/brite/blog1/assets/images/bg.jpg +0 -0
  42. data/lib/plugins/sow/brite/blog1/assets/images/icon.jpg +0 -0
  43. data/lib/plugins/sow/brite/blog1/assets/styles/class.css +15 -0
  44. data/lib/plugins/sow/brite/blog1/assets/styles/id.css +85 -0
  45. data/lib/plugins/sow/brite/blog1/assets/styles/misc.css +0 -0
  46. data/lib/plugins/sow/brite/blog1/assets/styles/print.css +76 -0
  47. data/lib/plugins/sow/brite/blog1/assets/styles/reset.css +77 -0
  48. data/lib/plugins/sow/brite/blog1/assets/styles/tag.css +68 -0
  49. data/lib/plugins/sow/brite/blog1/brite.yml +3 -0
  50. data/lib/plugins/sow/brite/blog1/index.page +23 -0
  51. data/lib/plugins/sow/brite/blog1/page.layout +88 -0
  52. data/lib/plugins/sow/brite/blog1/post.layout +25 -0
  53. data/meta/data.rb +26 -0
  54. data/meta/package +8 -0
  55. data/meta/profile +19 -0
  56. metadata +86 -47
  57. data/HISTORY +0 -16
  58. data/MANIFEST +0 -28
  59. data/README +0 -42
  60. data/lib/brite/page.rb +0 -235
  61. data/lib/brite/part.rb +0 -31
  62. data/lib/brite/post.rb +0 -37
  63. data/lib/brite/site.rb +0 -137
  64. data/lib/brite/template.rb +0 -215
  65. data/meta/authors +0 -1
  66. data/meta/contact +0 -1
  67. data/meta/copyright +0 -1
  68. data/meta/description +0 -4
  69. data/meta/homepage +0 -1
  70. data/meta/license +0 -1
  71. data/meta/name +0 -1
  72. data/meta/repository +0 -1
  73. data/meta/requires +0 -1
  74. data/meta/ruby +0 -2
  75. data/meta/subtitle +0 -1
  76. data/meta/suite +0 -1
  77. data/meta/summary +0 -1
  78. data/meta/title +0 -1
  79. data/meta/version +0 -1
data/lib/brite/part.rb DELETED
@@ -1,31 +0,0 @@
1
- module Brite
2
-
3
- # A Part is the section of a page. Pages can be segmented into
4
- # parts using the '--- FORMAT' notation.
5
- #
6
- class Part
7
- # Markup format (html, rdoc, markdown, textile)
8
- attr :format
9
-
10
- # Body of text as given in the part.
11
- attr :text
12
-
13
- #
14
- def initialize(text, format=nil)
15
- @format = format
16
- @text = text
17
- end
18
-
19
- #
20
- def render(type, attributes)
21
- template_engine.render(type, format, text, attributes)
22
- end
23
-
24
- #
25
- def template_engine
26
- TemplateEngine
27
- end
28
- end
29
-
30
- end
31
-
data/lib/brite/post.rb DELETED
@@ -1,37 +0,0 @@
1
- require 'brite/page'
2
-
3
- module Brite
4
-
5
- # Post class
6
- class Post < Page
7
-
8
- def default_layout
9
- site.defaults.postlayout
10
- end
11
-
12
- #def to_contextual_attributes
13
- # { 'site' => site.to_h, 'post' => to_h }
14
- #end
15
-
16
- =begin
17
- #
18
- def render(content=nil)
19
- attributes = to_contextual_attributes
20
- #attributes['page']['content'] = content if content
21
-
22
- output = parts.map{ |part| part.render(stencil, attributes) }.join("\n")
23
-
24
- # content
25
- @content = output
26
-
27
- if layout
28
- output = site.lookup_layout(layout).render(output)
29
- end
30
- output
31
- end
32
- =end
33
-
34
- end
35
-
36
- end
37
-
data/lib/brite/site.rb DELETED
@@ -1,137 +0,0 @@
1
- ##
2
- # "entia non sunt multiplicanda praeter necessitatem"
3
- # --Ockham's razor
4
- ##
5
-
6
- require 'brite/config'
7
- require 'brite/page'
8
- require 'brite/post'
9
- require 'brite/layout'
10
- require 'brite/template'
11
-
12
- #
13
- module Brite
14
-
15
- # Site class
16
- class Site
17
-
18
- # Location of site.
19
- attr :location
20
- attr :output
21
-
22
- attr :layouts
23
- attr :pages
24
- attr :posts
25
-
26
- attr :dryrun
27
- attr :verbose
28
-
29
- def initialize(options={})
30
- @location = options[:location] || Dir.pwd
31
- @output = options[:output] || Dir.pwd
32
- @dryrun = options[:dryrun]
33
-
34
- @layouts = []
35
- @pages = []
36
- @posts = []
37
- end
38
-
39
- def tags
40
- @tags ||= posts.map{ |p| p.tags }.flatten.uniq.sort
41
- end
42
-
43
- def posts_by_tag
44
- @posts_by_tag ||= (
45
- chart ||= Hash.new{|h,k|h[k]=[]}
46
- posts.each do |post|
47
- post.tags.each do |tag|
48
- chart[tag] << post
49
- end
50
- end
51
- chart
52
- )
53
- end
54
-
55
- def verbose?
56
- true
57
- end
58
-
59
- def build
60
- Dir.chdir(location) do
61
- sort_files
62
- if verbose?
63
- puts "Layouts: " + layouts.join(", ")
64
- puts "Pages: " + pages.join(", ")
65
- puts "Posts: " + posts.join(", ")
66
- puts
67
- end
68
- render
69
- end
70
- end
71
-
72
- def lookup_layout(name)
73
- layouts.find{ |l| name == l.name }
74
- end
75
-
76
- def sort_files
77
- files = Dir['**/*']
78
- files.each do |file|
79
- temp = false
80
- name = File.basename(file)
81
- ext = File.extname(file)
82
- case ext
83
- when '.layout'
84
- layouts << Layout.new(self, file)
85
- when '.page' #*%w{.markdown .rdoc .textile .whtml}
86
- pages << Page.new(self, file)
87
- when '.post'
88
- posts << Post.new(self, file)
89
- end
90
- end
91
- posts.sort!{ |a,b| b.date <=> a.date }
92
- end
93
-
94
- def render
95
- render_posts # renger posts first, so pages can use them
96
- render_pages
97
- end
98
-
99
- def render_pages
100
- pages.each do |page|
101
- page.save(output)
102
- end
103
- end
104
-
105
- def render_posts
106
- posts.each do |post|
107
- post.save(output)
108
- end
109
- end
110
-
111
- def config
112
- @config ||= Config.new
113
- end
114
-
115
- def defaults
116
- config.defaults
117
- end
118
-
119
- def to_h
120
- pbt = {}
121
- posts_by_tag.each do |tag, posts|
122
- pbt[tag] = posts.map{ |p| p.to_h }
123
- end
124
- {
125
- 'posts' => posts.map{ |p| p.to_h },
126
- 'posts_by_tag' => pbt, #posts_by_tag, #.map{ |t, ps| [t, ps.map{|p|p.to_h}] }
127
- 'tags' => tags
128
- }
129
- end
130
-
131
- def to_liquid
132
- to_h
133
- end
134
-
135
- end
136
-
137
- end
@@ -1,215 +0,0 @@
1
- require 'tilt'
2
-
3
- module Brite
4
-
5
- # Stencil controls rendering to a variety
6
- # of back-end templating and markup systems.
7
- #
8
- module TemplateEngine
9
- extend self
10
-
11
- #
12
- def render(stencil, format, text, attributes)
13
- text = render_format(format, text)
14
- text = render_stencil(stencil, text, attributes)
15
- text
16
- end
17
-
18
- #def render_format(format, text)
19
- # case format
20
- # when 'rdoc'
21
- # rdoc(text)
22
- # when 'markdown'
23
- # rdiscount(text)
24
- # when 'textile'
25
- # redcloth(text)
26
- # when 'haml'
27
- # haml(text)
28
- # else # html
29
- # text
30
- # end
31
- #end
32
-
33
- # Format Rendering
34
- # ----------------
35
-
36
- #
37
- def render_format(format, text)
38
- case format
39
- when /^coderay/
40
- coderay(text, format)
41
- when 'rdoc' # TODO: Remove when next version of tilt is released.
42
- rdoc(text)
43
- else
44
- if engine = Tilt[format]
45
- engine.new{text}.render #(context)
46
- else
47
- text
48
- end
49
- end
50
- end
51
-
52
- #
53
- #def redcloth(input)
54
- # RedCloth.new(input).to_html
55
- #end
56
-
57
- #def bluecloth(input)
58
- # BlueCloth.new(input).to_html
59
- #end
60
-
61
- #def rdiscount(input)
62
- # RDiscount.new(input).to_html
63
- #end
64
-
65
- def rdoc(input)
66
- markup = RDoc::Markup::ToHtml.new
67
- markup.convert(input)
68
- end
69
-
70
- #def haml(input)
71
- # Haml::Engine.new(input).render
72
- #end
73
-
74
- def coderay(input, format)
75
- require 'coderay'
76
- format = format.split('.')[1] || :ruby #:plaintext
77
- tokens = CodeRay.scan(input, format.to_sym) #:ruby
78
- tokens.div()
79
- end
80
-
81
- # Stencil Rendering
82
- # -----------------
83
-
84
- #
85
- #def render_stencil(stencil, text, attributes)
86
- # case stencil
87
- # when 'rhtml'
88
- # erb(text, attributes)
89
- # when 'liquid'
90
- # liquid(text, attributes)
91
- # else
92
- # text
93
- # end
94
- #end
95
-
96
- #
97
- def render_stencil(stencil, text, attributes)
98
- if engine = Tilt[stencil]
99
- engine.new{text}.render(nil, attributes)
100
- else
101
- text
102
- end
103
- end
104
-
105
- #
106
- #def erb(input, attributes)
107
- # template = ERB.new(input)
108
- # context = TemplateContext.new(attributes)
109
- # result = template.result(context.__binding__)
110
- # result
111
- #end
112
-
113
- #def liquid(input, attributes)
114
- # template = Liquid::Template.parse(input)
115
- # result = template.render(attributes, :filters => [TemplateFilters])
116
- # result
117
- #end
118
-
119
- # Require Dependencies
120
- # --------------------
121
-
122
- # TODO: Load engines only if used.
123
-
124
- begin ; require 'rubygems' ; rescue LoadError ; end
125
- begin ; require 'erb' ; rescue LoadError ; end
126
- begin ; require 'redcloth' ; rescue LoadError ; end
127
- begin ; require 'bluecloth' ; rescue LoadError ; end
128
- begin ; require 'rdiscount' ; rescue LoadError ; end
129
-
130
- begin
131
- require 'liquid'
132
- #Liquid::Template.register_filter(TemplateFilters)
133
- rescue LoadError
134
- end
135
-
136
- begin
137
- require 'haml'
138
- #Haml::Template.options[:format] = :html5
139
- rescue LoadError
140
- end
141
-
142
- begin
143
- require 'rdoc/markup'
144
- require 'rdoc/markup/to_html'
145
- rescue LoadError
146
- end
147
-
148
- end
149
-
150
- #
151
- #
152
- #
153
-
154
- #module TemplateFilters
155
-
156
- # NOTE: HTML truncate did not work well.
157
-
158
- # # HTML comment regular expression
159
- # REM_RE = %r{<\!--(.*?)-->}
160
- #
161
- # # HTML tag regular expression
162
- # TAG_RE = %r{</?\w+((\s+\w+(\s*=\s*(?:"(.|\n)*?"|'(.|\n)*?'|[^'">\s]+))?)+\s*|\s*)/?>} #'
163
- #
164
- # #
165
- # def truncate_html(html, limit)
166
- # return html unless limit
167
- #
168
- # mask = html.gsub(REM_RE){ |m| "\0" * m.size }
169
- # mask = mask.gsub(TAG_RE){ |m| "\0" * m.size }
170
- #
171
- # i, x = 0, 0
172
- #
173
- # while i < mask.size && x < limit
174
- # x += 1 if mask[i] != "\0"
175
- # i += 1
176
- # end
177
- #
178
- # while x > 0 && mask[x,1] == "\0"
179
- # x -= 1
180
- # end
181
- #
182
- # return html[0..x]
183
- # end
184
-
185
- #end
186
-
187
- # = Clean Rendering Context
188
- #
189
- # The TemplateContext is is used by ERB.
190
-
191
- class TemplateContext
192
- #include TemplateFilters
193
-
194
- instance_methods(true).each{ |m| private m unless m =~ /^__/ }
195
-
196
- def initialize(attributes={})
197
- @attributes = attributes
198
- end
199
-
200
- def __binding__
201
- binding
202
- end
203
-
204
- def to_h
205
- @attributes
206
- end
207
-
208
- def method_missing(s, *a)
209
- s = s.to_s
210
- @attributes.key?(s) ? @attributes[s] : super
211
- end
212
- end
213
-
214
- end
215
-
data/meta/authors DELETED
@@ -1 +0,0 @@
1
- Thomas Sawyer
data/meta/contact DELETED
@@ -1 +0,0 @@
1
- http://googlegroups.com/group/proutils
data/meta/copyright DELETED
@@ -1 +0,0 @@
1
- Copyright (c) 2006,2009 Thomas Sawyer
data/meta/description DELETED
@@ -1,4 +0,0 @@
1
- Brite is a remarkably easy to use, light-weight website
2
- generator. It supports a variety of backend rendering engines
3
- including rhtml via eruby, textile via redcloth, markdown
4
- via rdiscount, with others on the way.
data/meta/homepage DELETED
@@ -1 +0,0 @@
1
- http://proutils.github.com/brite
data/meta/license DELETED
@@ -1 +0,0 @@
1
- GPL
data/meta/name DELETED
@@ -1 +0,0 @@
1
- brite