hobix 0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) hide show
  1. data/COPYING +18 -0
  2. data/README +18 -0
  3. data/Rakefile +96 -0
  4. data/bin/hobix +94 -0
  5. data/contrib/blosxom-to-hobix.rb +253 -0
  6. data/contrib/txp-to-hobix.rb +56 -0
  7. data/contrib/webrick-all-mine.rb +20 -0
  8. data/doc/CHANGELOG +285 -0
  9. data/doc/rdoc/classes/Hobix/API.html +382 -0
  10. data/doc/rdoc/classes/Hobix/Article.html +111 -0
  11. data/doc/rdoc/classes/Hobix/BaseContent.html +692 -0
  12. data/doc/rdoc/classes/Hobix/BaseEntry.html +218 -0
  13. data/doc/rdoc/classes/Hobix/BaseFacet.html +205 -0
  14. data/doc/rdoc/classes/Hobix/BaseOutput.html +122 -0
  15. data/doc/rdoc/classes/Hobix/BasePlugin.html +201 -0
  16. data/doc/rdoc/classes/Hobix/BaseProperties/ClassMethods.html +243 -0
  17. data/doc/rdoc/classes/Hobix/BaseProperties.html +218 -0
  18. data/doc/rdoc/classes/Hobix/BasePublish.html +157 -0
  19. data/doc/rdoc/classes/Hobix/BaseStorage.html +417 -0
  20. data/doc/rdoc/classes/Hobix/BixWik/Entry.html +196 -0
  21. data/doc/rdoc/classes/Hobix/BixWik/IndexEntry.html +170 -0
  22. data/doc/rdoc/classes/Hobix/BixWik/WikiRedCloth.html +111 -0
  23. data/doc/rdoc/classes/Hobix/BixWik.html +418 -0
  24. data/doc/rdoc/classes/Hobix/BixWikPlugin.html +158 -0
  25. data/doc/rdoc/classes/Hobix/CommandLine.html +1970 -0
  26. data/doc/rdoc/classes/Hobix/Comment.html +113 -0
  27. data/doc/rdoc/classes/Hobix/Config.html +212 -0
  28. data/doc/rdoc/classes/Hobix/DataMarsh.html +667 -0
  29. data/doc/rdoc/classes/Hobix/Entry.html +178 -0
  30. data/doc/rdoc/classes/Hobix/EntryEnum.html +162 -0
  31. data/doc/rdoc/classes/Hobix/Enumerable.html +170 -0
  32. data/doc/rdoc/classes/Hobix/Facets/WikiEdit.html +180 -0
  33. data/doc/rdoc/classes/Hobix/Facets.html +111 -0
  34. data/doc/rdoc/classes/Hobix/LinkList.html +182 -0
  35. data/doc/rdoc/classes/Hobix/Out/Quick.html +412 -0
  36. data/doc/rdoc/classes/Hobix/Out.html +119 -0
  37. data/doc/rdoc/classes/Hobix/Page.html +381 -0
  38. data/doc/rdoc/classes/Hobix/Trackback.html +113 -0
  39. data/doc/rdoc/classes/Hobix/UriStr.html +198 -0
  40. data/doc/rdoc/classes/Hobix/WebApp/QueryString.html +207 -0
  41. data/doc/rdoc/classes/Hobix/WebApp/QueryValidationFailure.html +111 -0
  42. data/doc/rdoc/classes/Hobix/WebApp.html +1383 -0
  43. data/doc/rdoc/classes/Hobix/Weblog/AuthorNotFound.html +111 -0
  44. data/doc/rdoc/classes/Hobix/Weblog.html +2082 -0
  45. data/doc/rdoc/classes/Hobix.html +399 -0
  46. data/doc/rdoc/classes/Kernel.html +139 -0
  47. data/doc/rdoc/classes/Regexp.html +154 -0
  48. data/doc/rdoc/classes/YAML/Omap.html +144 -0
  49. data/doc/rdoc/classes/YAML.html +111 -0
  50. data/doc/rdoc/created.rid +1 -0
  51. data/doc/rdoc/files/COPYING.html +129 -0
  52. data/doc/rdoc/files/README.html +131 -0
  53. data/doc/rdoc/files/doc/CHANGELOG.html +101 -0
  54. data/doc/rdoc/files/lib/hobix/api_rb.html +119 -0
  55. data/doc/rdoc/files/lib/hobix/article_rb.html +126 -0
  56. data/doc/rdoc/files/lib/hobix/base_rb.html +128 -0
  57. data/doc/rdoc/files/lib/hobix/bixwik_rb.html +126 -0
  58. data/doc/rdoc/files/lib/hobix/commandline_rb.html +140 -0
  59. data/doc/rdoc/files/lib/hobix/comments_rb.html +126 -0
  60. data/doc/rdoc/files/lib/hobix/config_rb.html +125 -0
  61. data/doc/rdoc/files/lib/hobix/datamarsh_rb.html +108 -0
  62. data/doc/rdoc/files/lib/hobix/entry_rb.html +118 -0
  63. data/doc/rdoc/files/lib/hobix/linklist_rb.html +127 -0
  64. data/doc/rdoc/files/lib/hobix/publisher_rb.html +126 -0
  65. data/doc/rdoc/files/lib/hobix/trackbacks_rb.html +128 -0
  66. data/doc/rdoc/files/lib/hobix/webapp_rb.html +127 -0
  67. data/doc/rdoc/files/lib/hobix/weblog_rb.html +135 -0
  68. data/doc/rdoc/files/lib/hobix_rb.html +127 -0
  69. data/doc/rdoc/fr_class_index.html +67 -0
  70. data/doc/rdoc/fr_file_index.html +44 -0
  71. data/doc/rdoc/fr_method_index.html +307 -0
  72. data/doc/rdoc/index.html +24 -0
  73. data/doc/rdoc/rdoc-style.css +208 -0
  74. data/git_hobix_update.php +13 -0
  75. data/lib/hobix/api.rb +91 -0
  76. data/lib/hobix/article.rb +22 -0
  77. data/lib/hobix/base.rb +480 -0
  78. data/lib/hobix/bixwik.rb +200 -0
  79. data/lib/hobix/commandline.rb +677 -0
  80. data/lib/hobix/comments.rb +98 -0
  81. data/lib/hobix/config.rb +39 -0
  82. data/lib/hobix/datamarsh.rb +110 -0
  83. data/lib/hobix/entry.rb +84 -0
  84. data/lib/hobix/facets/comments.rb +99 -0
  85. data/lib/hobix/facets/publisher.rb +314 -0
  86. data/lib/hobix/facets/trackbacks.rb +80 -0
  87. data/lib/hobix/linklist.rb +81 -0
  88. data/lib/hobix/out/atom.rb +101 -0
  89. data/lib/hobix/out/erb.rb +64 -0
  90. data/lib/hobix/out/okaynews.rb +55 -0
  91. data/lib/hobix/out/quick.rb +314 -0
  92. data/lib/hobix/out/rdf.rb +97 -0
  93. data/lib/hobix/out/redrum.rb +26 -0
  94. data/lib/hobix/out/rss.rb +128 -0
  95. data/lib/hobix/plugin/akismet.rb +196 -0
  96. data/lib/hobix/plugin/bloglines.rb +73 -0
  97. data/lib/hobix/plugin/calendar.rb +212 -0
  98. data/lib/hobix/plugin/flickr.rb +110 -0
  99. data/lib/hobix/plugin/recent_comments.rb +84 -0
  100. data/lib/hobix/plugin/sections.rb +91 -0
  101. data/lib/hobix/plugin/tags.rb +60 -0
  102. data/lib/hobix/publish/ping.rb +53 -0
  103. data/lib/hobix/publish/replicate.rb +283 -0
  104. data/lib/hobix/publisher.rb +18 -0
  105. data/lib/hobix/search/dictionary.rb +141 -0
  106. data/lib/hobix/search/porter_stemmer.rb +203 -0
  107. data/lib/hobix/search/simple.rb +209 -0
  108. data/lib/hobix/search/vector.rb +100 -0
  109. data/lib/hobix/storage/filesys.rb +408 -0
  110. data/lib/hobix/trackbacks.rb +93 -0
  111. data/lib/hobix/util/objedit.rb +193 -0
  112. data/lib/hobix/util/patcher.rb +155 -0
  113. data/lib/hobix/webapp/cli.rb +195 -0
  114. data/lib/hobix/webapp/htmlform.rb +107 -0
  115. data/lib/hobix/webapp/message.rb +177 -0
  116. data/lib/hobix/webapp/urigen.rb +141 -0
  117. data/lib/hobix/webapp/webrick-servlet.rb +90 -0
  118. data/lib/hobix/webapp.rb +723 -0
  119. data/lib/hobix/weblog.rb +893 -0
  120. data/lib/hobix.rb +230 -0
  121. data/share/default-blog/hobix.yaml +16 -0
  122. data/share/default-blog/htdocs/site.css +174 -0
  123. data/share/default-blog/skel/entry.html.quick +0 -0
  124. data/share/default-blog/skel/index.atom.atom +0 -0
  125. data/share/default-blog/skel/index.html.quick-summary +0 -0
  126. data/share/default-blog/skel/index.xml.rss +0 -0
  127. data/share/default-blog/skel/index.yaml.okaynews +0 -0
  128. data/share/default-blog/skel/monthly.html.quick-archive +0 -0
  129. data/share/default-blog/skel/section.html.quick-archive +0 -0
  130. data/share/default-blog/skel/yearly.html.quick-archive +0 -0
  131. data/share/default-blog-modes.yaml +7 -0
  132. data/share/default-blog.apache-cgi.patch +8 -0
  133. data/share/default-blog.apache-ssi.patch +38 -0
  134. data/share/default-blog.apache2-ssi.patch +3 -0
  135. data/share/default-blog.cgi.patch +8 -0
  136. data/share/default-blog.comments.patch +5 -0
  137. data/share/default-blog.prototype.patch +766 -0
  138. data/share/default-blog.publisher.patch +5 -0
  139. data/share/default-blog.wiki.patch +29 -0
  140. data/share/publisher/css/control.css +90 -0
  141. data/share/publisher/css/form.css +238 -0
  142. data/share/publisher/css/form.import.css +72 -0
  143. data/share/publisher/css/main-menu.css +134 -0
  144. data/share/publisher/i/hobix-emblazen-1.png +0 -0
  145. data/share/publisher/i/hobix-emblazen-2.png +0 -0
  146. data/share/publisher/i/hobix-emblazen-3.png +0 -0
  147. data/share/publisher/i/hobix-emblazen-4.png +0 -0
  148. data/share/publisher/i/hobix-emblazen-5.png +0 -0
  149. data/share/publisher/i/hobix-emblazen-6.png +0 -0
  150. data/share/publisher/i/hobix-emblazen-7.png +0 -0
  151. data/share/publisher/index.erb +66 -0
  152. data/share/publisher/js/controls.js +261 -0
  153. data/share/publisher/js/dragdrop.js +476 -0
  154. data/share/publisher/js/effects.js +570 -0
  155. data/share/publisher/js/prototype.js +1011 -0
  156. metadata +230 -0
@@ -0,0 +1,55 @@
1
+ #
2
+ # = hobix/out/okaynews.rb
3
+ #
4
+ # YAML !okay/news output for Hobix.
5
+ #
6
+ # Copyright (c) 2003-2004 why the lucky stiff
7
+ #
8
+ # Written & maintained by why the lucky stiff <why@ruby-lang.org>
9
+ #
10
+ # This program is free software, released under a BSD license.
11
+ # See COPYING for details.
12
+ #
13
+ #--
14
+ # $Id$
15
+ #++
16
+ require 'hobix/base'
17
+
18
+ module Hobix
19
+ class Weblog
20
+ def to_okaynews( entries )
21
+ YAML::quick_emit( self.object_id ) do |out|
22
+ out.map( "!okay/news/^feed" ) do |map|
23
+ ['@title', '@tagline', '@link', '@period',
24
+ '@created', '@issued', '@modified',
25
+ '@authors', '@contributors'
26
+ ].each do |m|
27
+ map.add( m[1..-1], instance_variable_get( m ) )
28
+ end
29
+ entries = entries.collect do |e|
30
+ e = e.dup
31
+ e.author = @authors[e.author]
32
+ def e.to_yaml_type
33
+ "!^entry"
34
+ end
35
+ e
36
+ end
37
+ map.add( 'entries', entries )
38
+ end
39
+ end
40
+ end
41
+ end
42
+ module Out
43
+ class OkayNews < Hobix::BaseOutput
44
+ def initialize( weblog )
45
+ @path = weblog.skel_path
46
+ end
47
+ def extension
48
+ "okaynews"
49
+ end
50
+ def load( file_name, vars )
51
+ vars[:weblog].to_okaynews( vars[:entries] || [vars[:entry]] )
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,314 @@
1
+ #
2
+ # = hobix/out/quick.rb
3
+ #
4
+ # Quick YAML + ERb templates which makes templating
5
+ # thirty times easier!!
6
+ #
7
+ # Copyright (c) 2003-2004 why the lucky stiff
8
+ #
9
+ # Written & maintained by why the lucky stiff <why@ruby-lang.org>
10
+ #
11
+ # This program is free software, released under a BSD license.
12
+ # See COPYING for details.
13
+ #
14
+ #--
15
+ # $Id$
16
+ #++
17
+ require 'hobix/base'
18
+ require 'erb'
19
+
20
+ module Hobix
21
+ module Out
22
+ class QuickError < StandardError; end
23
+
24
+ class Quick < Hobix::BaseOutput
25
+ APPEND_TPL_RE = /^(.+)\s*(<<|>>)$/
26
+ # Class method for appending to a method template
27
+ def self.append_def( method, str )
28
+ newstr = "#{ self.allocate.method( method ).call }#{ str }"
29
+ define_method( method ) { newstr }
30
+ end
31
+ # Class method for prepending to a method template
32
+ def self.prepend_def( method, str )
33
+ newstr = "#{ str }#{ self.allocate.method( method ).call }"
34
+ define_method( method ) { newstr }
35
+ end
36
+
37
+ def initialize( weblog, defaults = {} )
38
+ @hobix_path = weblog.path
39
+ @path = weblog.skel_path
40
+ defaults.each do |k, v|
41
+ k = k.gsub( /\W/, '_' )
42
+ k.untaint
43
+ v = v.inspect
44
+ v.untaint
45
+ if k =~ APPEND_TPL_RE
46
+ k = $1.strip
47
+ v = if $2 == ">>"
48
+ "#{ v } + #{ k }_erb_orig"
49
+ else
50
+ "#{ k }_erb_orig + #{ v }"
51
+ end
52
+ instance_eval %{
53
+ alias #{ k }_erb_orig #{ k }_erb
54
+ def #{ k }_erb
55
+ #{ v }
56
+ end
57
+ }
58
+ else
59
+ instance_eval %{
60
+ def #{ k }_erb
61
+ #{ v }
62
+ end
63
+ }
64
+ end
65
+ end
66
+ end
67
+ def setup
68
+ quick_conf = File.join( @hobix_path, 'hobix.out.quick' )
69
+ unless File.exists? quick_conf
70
+ quicksand = {}
71
+ methods.each do |m|
72
+ if m =~ /^(.+)_erb$/
73
+ key = $1
74
+ qtmpl = method( m ).call
75
+ if qtmpl.respond_to? :strip
76
+ qtmpl = "\n#{ qtmpl.strip.gsub( /^ {8}/, '' ) }\n"
77
+ def qtmpl.to_yaml_fold; '|'; end
78
+ end
79
+ quicksand[key] = qtmpl
80
+ end
81
+ end
82
+ File.open( quick_conf, 'w' ) do |f|
83
+ YAML.dump( quicksand, f )
84
+ end
85
+ end
86
+ end
87
+ def extension
88
+ "quick"
89
+ end
90
+ def load( file_name, vars )
91
+ @bind = binding
92
+ @relpath = File.dirname( file_name )
93
+ vars.each do |k, v|
94
+ k.untaint
95
+ k_inspect = k.inspect.untaint
96
+ eval( "#{ k } = vars[#{ k_inspect }]", @bind )
97
+ end
98
+ quick_file = File.read( file_name )
99
+ quick_data = if quick_file.strip.empty?
100
+ {}
101
+ else
102
+ YAML::load( quick_file )
103
+ end
104
+ quick_data.each do |k, v|
105
+ if k =~ APPEND_TPL_RE
106
+ k = $1.strip
107
+ quick_data[k] = if $2 == ">>"
108
+ v + method( "#{ k }_erb" ).call
109
+ else
110
+ method( "#{ k }_erb" ).call + v
111
+ end
112
+ end
113
+ end
114
+ erb_src = make( 'page', quick_data, vars.has_key?( :entries ) )
115
+ erb_src.untaint
116
+ erb = ::ERB.new( erb_src )
117
+ begin
118
+ erb.result( @bind )
119
+ rescue Exception => e
120
+ puts "--- erb source ---"
121
+ puts erb_src
122
+ puts "--- erb source ---"
123
+ puts e.backtrace
124
+ raise QuickError, "Error `#{ e.message }' in erb #{ file_name }."
125
+ end
126
+ end
127
+ def expand( fname )
128
+ if fname =~ /^\//
129
+ File.join( @path, fname )
130
+ else
131
+ File.join( @relpath, fname )
132
+ end
133
+ end
134
+ def make( part, quick_data, has_entries = true )
135
+ if part == 'entries' and not has_entries
136
+ part = 'entry'
137
+ end
138
+ erb = quick_data[part] || method( "#{ part.gsub( /\W+/, '_' ) }_erb" ).call
139
+ if erb.respond_to? :gsub
140
+ erb.gsub( /<\+\s*(\w+)\s*\+>/ ) do
141
+ make( $1, quick_data, has_entries )
142
+ end.gsub( /<\+\s*([\w\.\/\\\-]+)\s*\+>/ ) do
143
+ File.read( expand( $1 ) )
144
+ end
145
+ elsif erb.respond_to? :collect
146
+ erb.collect do |inc|
147
+ make( inc, quick_data, has_entries )
148
+ end.join "\n"
149
+ end
150
+ end
151
+
152
+ #
153
+ # Default quick templates
154
+ #
155
+ def title_erb; '<%= weblog.title %>'; end
156
+ def banner_erb
157
+ %{ <div id="banner">
158
+ <h1 class="title"><a href="<%= weblog.link %>"><%= weblog.title %></a></h1>
159
+ <div class="tagline"><%= weblog.tagline %></div>
160
+ </div> }
161
+ end
162
+ def footer_erb; end
163
+ def sidebar_erb
164
+ %{ <div id="sidebar">
165
+ <+ sidebar_list +>
166
+ </div> }
167
+ end
168
+ def sidebar_list_erb
169
+ ['sidebar_archive', 'sidebar_links', 'sidebar_syndicate', 'sidebar_hobix']
170
+ end
171
+ def sidebar_archive_erb
172
+ %{ <div class="sidebarBox">
173
+ <h2 class="sidebarTitle">Archive</h2>
174
+ <ul>
175
+ <% months = weblog.storage.get_months( weblog.storage.find ) %>
176
+ <% months.reverse.each do |month_start, month_end, month_id| %>
177
+ <li><a href="<%= weblog.expand_path month_id %>"><%= month_start.strftime( "%B %Y" ) %></a></li>
178
+ <% end %>
179
+ </ul>
180
+ </div> }
181
+ end
182
+ def sidebar_links_erb
183
+ %{ <div class="sidebarBox">
184
+ <h2 class="sidebarTitle">Links</h2>
185
+ <%= weblog.linklist.content.to_html %>
186
+ </div> }
187
+ end
188
+ def sidebar_syndicate_erb
189
+ %{ <div class="sidebarBox">
190
+ <h2 class="sidebarTitle">Syndicate</h2>
191
+ <ul>
192
+ <li><a href="<%= weblog.link %>/index.atom">Atom 1.0</a></li>
193
+ </ul>
194
+ </div> }
195
+ end
196
+ def sidebar_hobix_erb
197
+ %{ <div class="sidebarBox">
198
+ <p>Built upon <a href="http://hobix.com">Hobix</a></p>
199
+ </div> }
200
+ end
201
+ def blog_erb
202
+ %{ <div id="blog">
203
+ <+ entries +>
204
+ </div> }
205
+ end
206
+ def entries_erb
207
+ %{ <% entries.each_day do |day, day_entries| %>
208
+ <+ day_header +>
209
+ <% day_entries.each do |entry| %>
210
+ <+ entry +>
211
+ <% end %>
212
+ <% end %> }
213
+ end
214
+ def day_header_erb;
215
+ %{ <h2 class="dayHeader" id="<%= day.strftime( "day%Y%m%d" ) %>"><%= day.strftime( "%A, %B %d, %Y" ) %></h2> };
216
+ end
217
+ def entry_erb
218
+ %{ <div class="entry">
219
+ <+ entry_title +>
220
+ <+ entry_content +>
221
+ </div>
222
+ <div class="entryFooter"><+ entry_footer +></div> }
223
+ end
224
+ def entry_title_erb
225
+ %{ <h3 class="entryTitle"><%= entry.title %></h3>
226
+ <% if entry.respond_to? :tagline and entry.tagline %><div class="entryTagline"><%= entry.tagline %></div><% end %> }
227
+ end
228
+ def entry_content_erb
229
+ %{ <div class="entryContent"><%= entry.content.to_html %></div> }
230
+ end
231
+ def entry_footer_erb
232
+ %{ posted by <%= weblog.authors[entry.author]['name'] %> |
233
+ <a href="<%= weblog.expand_path entry.id %>.html"><%= entry.created.strftime( "%I:%M %p" ) %></a> }
234
+ end
235
+ def head_tags_erb; end
236
+ def css_erb; %{ @import "<%= weblog.expand_path "site.css" %>"; }; end
237
+ def doctype_erb
238
+ %{<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">}
239
+ end
240
+ def page_erb
241
+ %{<+ doctype +>
242
+ <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
243
+ <head>
244
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
245
+ <title><+ title +></title>
246
+ <+ head_tags +>
247
+ <style type="text/css">
248
+ <+ css +>
249
+ </style>
250
+ </head>
251
+ <body>
252
+
253
+ <div id="page">
254
+
255
+ <+ banner +>
256
+
257
+ <div id="content">
258
+ <+ sidebar +>
259
+
260
+ <+ blog +>
261
+
262
+ </div>
263
+
264
+ <+ footer +>
265
+
266
+ </div>
267
+
268
+ </body>
269
+ </html>}
270
+ end
271
+ end
272
+
273
+ class QuickSummary < Quick
274
+ def extension
275
+ "quick-summary"
276
+ end
277
+ def entry_content_erb
278
+ %{ <div class="entryContent">
279
+ <% if entry.respond_to? :summary and entry.summary %>
280
+ <%= entry.summary.to_html %>
281
+ <p><a href="<%= weblog.expand_path entry.id %>">Continue to full post.</a></p>
282
+ <% else %>
283
+ <%= entry.content.to_html %>
284
+ <% end %>
285
+ </div> }
286
+ end
287
+ end
288
+
289
+ class QuickArchive < Quick
290
+ def extension
291
+ "quick-archive"
292
+ end
293
+ def entry_erb
294
+ %{ <h3 class="entryTitle"><a href="<%= weblog.expand_path entry.id %>"><%= entry.title %></a></h3> }
295
+ end
296
+ def entries_erb
297
+ %{ <div id="archives">
298
+ <ul>
299
+ <% entries.each_day do |day, day_entries| %>
300
+ <li><+ day_header +>
301
+ <ul>
302
+ <% day_entries.each do |entry| %>
303
+ <li><+ entry +></li>
304
+ <% end %>
305
+ </ul>
306
+ </li>
307
+ <% end %>
308
+ </ul>
309
+ </div> }
310
+ end
311
+ end
312
+
313
+ end
314
+ end
@@ -0,0 +1,97 @@
1
+ #
2
+ # = hobix/out/rdf.rb
3
+ #
4
+ # RSS (RDF Site Summary) 1.0 output for Hobix.
5
+ #
6
+ # Copyright (c) 2004 Giulio Piancastelli
7
+ #
8
+ # Written & maintained by Giulio Piancastelli <gpian@softhome.net>
9
+ #
10
+ # This program is free software. You can re-distribute and/or
11
+ # modify this program under the same terms of ruby itself ---
12
+ # Ruby Distribution License or GNU General Public License.
13
+ #
14
+ require 'hobix/base'
15
+ require 'rexml/document'
16
+
17
+ module Hobix
18
+ module Out
19
+ class RDF < Hobix::BaseOutput
20
+ def initialize(weblog)
21
+ @path = weblog.skel_path
22
+ end
23
+ def extension
24
+ "rdf"
25
+ end
26
+ def load(file_name, vars)
27
+ rdfdoc = REXML::Document.new(<<EOXML)
28
+ <rdf:RDF
29
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
30
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
31
+ xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
32
+ xmlns:admin="http://webns.net/mvcb/"
33
+ xmlns:cc="http://web.resource.org/cc/"
34
+ xmlns="http://purl.org/rss/1.0/">
35
+ <channel>
36
+ <title></title>
37
+ <link></link>
38
+ <description></description>
39
+ <dc:language>en-us</dc:language>
40
+ <!--<dc:creator></dc:creator>-->
41
+ <dc:date></dc:date>
42
+ <admin:generatorAgent rdf:resource="http://hobix.com/?v=#{ Hobix::VERSION }" />
43
+ <sy:updatePeriod>hourly</sy:updatePeriod>
44
+ <sy:updateFrequency>1</sy:updateFrequency>
45
+ <sy:updateBase>2000-01-01T12:00+00:00</sy:updateBase>
46
+
47
+ <items>
48
+ <rdf:Seq></rdf:Seq>
49
+ </items>
50
+
51
+ </channel>
52
+ </rdf:RDF>
53
+ EOXML
54
+ rdfdoc << REXML::XMLDecl.new
55
+ rdfdoc.elements['/rdf:RDF/channel/'].attributes['rdf:about'] = vars[:weblog].link
56
+ rdfdoc.elements['/rdf:RDF/channel/title'].text = vars[:weblog].title
57
+ rdfdoc.elements['/rdf:RDF/channel/link'].text = vars[:weblog].link
58
+ rdfdoc.elements['/rdf:RDF/channel/description'].text = vars[:weblog].tagline
59
+ rdfdoc.elements['/rdf:RDF/channel/dc:date'].text = Time.now.utc.strftime( "%Y-%m-%dT%H:%M:%S+00:00" )
60
+ (vars[:entries] || [vars[:entry]]).each do |e|
61
+ ele = REXML::Element.new 'item'
62
+ ele.attributes['rdf:about'] = "#{e.link}"
63
+ if e.title
64
+ ele_title = REXML::Element.new 'title'
65
+ ele_title.text = e.title
66
+ ele << ele_title
67
+ end
68
+ ele_link = REXML::Element.new 'link'
69
+ ele_link.text = "#{e.link}"
70
+ ele << ele_link
71
+ ele_subject = REXML::Element.new 'dc:subject'
72
+ ele_subject.text = e.section_id
73
+ ele << ele_subject
74
+ ele_creator = REXML::Element.new 'dc:creator'
75
+ ele_creator.text = vars[:weblog].authors[e.author]['name']
76
+ ele << ele_creator
77
+ ele_pubDate = REXML::Element.new 'dc:date'
78
+ ele_pubDate.text = e.created.dup.utc.strftime( "%Y-%m-%dT%H:%M:%S+00:00" )
79
+ ele << ele_pubDate
80
+ ele_desc = REXML::Element.new 'description'
81
+ if !e.summary
82
+ ele_desc.text = e.content.to_html.gsub(/img src="\//, "img src=\"#{vars[:weblog].link}")
83
+ else
84
+ ele_desc.text = e.summary
85
+ end
86
+ ele << ele_desc
87
+ rdfdoc.elements['/rdf:RDF'].add ele
88
+ # also add an element to the <rdf:Seq> sequence in <items>
89
+ li = REXML::Element.new 'rdf:li'
90
+ li.attributes['rdf:resource'] = "#{e.link}"
91
+ rdfdoc.elements['/rdf:RDF/channel/items/rdf:Seq'] << li
92
+ end
93
+ rdfdoc.to_s
94
+ end
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,26 @@
1
+ #
2
+ # = hobix/out/redrum.rb
3
+ #
4
+ # Hobix processing of ERB + Textile templates.
5
+ #
6
+ # Copyright (c) 2003-2004 why the lucky stiff
7
+ #
8
+ # Written & maintained by why the lucky stiff <why@ruby-lang.org>
9
+ #
10
+ # This program is free software, released under a BSD license.
11
+ # See COPYING for details.
12
+ #
13
+ #--
14
+ # $Id$
15
+ #++
16
+ require 'hobix/out/erb'
17
+
18
+ module Hobix::Out
19
+ class RedRum < ERB
20
+ def extension; "redrum"; end
21
+ alias erb_load load
22
+ def load( file_name, vars )
23
+ RedCloth.new( erb_load( file_name, vars ) ).to_html
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,128 @@
1
+ #
2
+ # = hobix/out/rss.rb
3
+ #
4
+ # RSS 2.0 output for Hobix.
5
+ #
6
+ # Copyright (c) 2003-2004 why the lucky stiff
7
+ #
8
+ # Written & maintained by why the lucky stiff <why@ruby-lang.org>
9
+ #
10
+ # This program is free software, released under a BSD license.
11
+ # See COPYING for details.
12
+ #
13
+ #--
14
+ # $Id$
15
+ #++
16
+ require 'hobix/base'
17
+ require 'rexml/document'
18
+ require 'erb'
19
+
20
+ module Hobix
21
+ module Out
22
+ class RSS < Hobix::BaseOutput
23
+ def initialize( weblog, params = {} )
24
+ @path = weblog.skel_path
25
+ @extra_ns = params["namespaces"]
26
+ @extra_els = params["elements"]
27
+ @summaries = params["summary-only"]
28
+ @more_link = params["more-link"]
29
+ @comment_aname = params["comment-location"]
30
+ end
31
+ def extension
32
+ "rss"
33
+ end
34
+ def load( file_name, vars )
35
+ rssdoc = REXML::Document.new( <<EOXML )
36
+ <rss version="2.0"
37
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
38
+ xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
39
+ xmlns:admin="http://webns.net/mvcb/"
40
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
41
+ <channel>
42
+ <title></title>
43
+ <link></link>
44
+ <description></description>
45
+ <dc:language>en-us</dc:language>
46
+ <dc:creator></dc:creator>
47
+ <dc:date></dc:date>
48
+ <admin:generatorAgent rdf:resource="http://hobix.com/?v=#{ Hobix::VERSION }" />
49
+ <sy:updatePeriod>hourly</sy:updatePeriod>
50
+ <sy:updateFrequency>1</sy:updateFrequency>
51
+ <sy:updateBase>2000-01-01T12:00+00:00</sy:updateBase>
52
+ </channel>
53
+ </rss>
54
+ EOXML
55
+ rssdoc << REXML::XMLDecl.new
56
+ rssdoc.elements['/rss/channel/title'].text = rss_mangle( vars[:weblog].title )
57
+ rssdoc.elements['/rss/channel/link'].text = vars[:weblog].link.to_s
58
+ rssdoc.elements['/rss/channel/description'].text = vars[:weblog].tagline
59
+ rssdoc.elements['/rss/channel/dc:date'].text = Time.now.utc.strftime( "%Y-%m-%dT%H:%M:%S+00:00" )
60
+
61
+ @extra_ns.each do |k, v|
62
+ rssdoc.elements['/rss'].attributes["xmlns:" + k.to_s] = v.to_s
63
+ end if @extra_ns
64
+ @extra_els.each do |k, v|
65
+ extra = REXML::Element.new k.to_s
66
+ extra.text = v.to_s
67
+ rssdoc.elements['/rss/channel'].add extra
68
+ end if @extra_els
69
+
70
+ ( vars[:entries] || [vars[:entry]] ).each do |e|
71
+ ele = REXML::Element.new 'item'
72
+ ele_title = REXML::Element.new 'title'
73
+ ele_title.text = rss_mangle( e.title )
74
+ ele << ele_title
75
+ ele_link = REXML::Element.new 'link'
76
+ link = e.link.gsub(/'/,"%27")
77
+ ele_link.text = "#{ link }"
78
+ ele << ele_link
79
+ if @comment_aname
80
+ ele_comments = REXML::Element.new 'comments'
81
+ ele_comments.text = "#{ link }##@comment_aname"
82
+ ele << ele_comments
83
+ end
84
+ ele_guid = REXML::Element.new 'guid'
85
+ ele_guid.attributes['isPermaLink'] = 'false'
86
+ ele_guid.text = "#{ e.id }@#{ vars[:weblog].link }"
87
+ ele << ele_guid
88
+ ele_subject = REXML::Element.new 'dc:subject'
89
+ ele_subject.text = e.section_id
90
+ ele << ele_subject
91
+ e.tags.each do |t|
92
+ ele_subject = REXML::Element.new 'dc:subject'
93
+ ele_subject.text = t
94
+ ele << ele_subject
95
+ end
96
+ ele_creator = REXML::Element.new 'dc:creator'
97
+ ele_creator.text = vars[:weblog].authors[e.author]['name']
98
+ ele << ele_creator
99
+ ele_pubDate = REXML::Element.new 'dc:date'
100
+ ele_pubDate.text = ( e.modified || e.created ).dup.utc.strftime( "%Y-%m-%dT%H:%M:%S+00:00" )
101
+ ele << ele_pubDate
102
+ ele_desc = REXML::Element.new 'description'
103
+ ele_desc.attributes['xml:space'] = "preserve"
104
+ text =
105
+ if @summaries && e.summary
106
+ e.summary.to_html + (@more_link ? %{<p><a href="#{e.link}">#@more_link</a></p>} : "")
107
+ else
108
+ e.content.to_html
109
+ end.gsub( /(src|href)="\//, "\\1=\"#{ vars[:weblog].link.rooturi }/" )
110
+ # Quote the text ourselves rather than letting REXML do it,
111
+ # due to REXML bug where it fails to quote e.g. &rarr;
112
+ REXML::Text.new ::ERB::Util.h( text ), true, ele_desc, true
113
+ ele << ele_desc
114
+ rssdoc.elements['/rss/channel'].add ele
115
+ end
116
+ rssdoc.to_s
117
+ end
118
+
119
+ private
120
+ def rss_mangle( string )
121
+ string = string.gsub( /&/, '[and]' )
122
+ string.gsub!( /</, '[less-than]' )
123
+ string.gsub!( />/, '[greater-than]' )
124
+ string
125
+ end
126
+ end
127
+ end
128
+ end