hobix 0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/hobix +90 -0
- data/lib/hobix/api.rb +91 -0
- data/lib/hobix/article.rb +22 -0
- data/lib/hobix/base.rb +477 -0
- data/lib/hobix/bixwik.rb +200 -0
- data/lib/hobix/commandline.rb +661 -0
- data/lib/hobix/comments.rb +99 -0
- data/lib/hobix/config.rb +39 -0
- data/lib/hobix/datamarsh.rb +110 -0
- data/lib/hobix/entry.rb +83 -0
- data/lib/hobix/facets/comments.rb +74 -0
- data/lib/hobix/facets/publisher.rb +314 -0
- data/lib/hobix/facets/trackbacks.rb +80 -0
- data/lib/hobix/linklist.rb +76 -0
- data/lib/hobix/out/atom.rb +92 -0
- data/lib/hobix/out/erb.rb +64 -0
- data/lib/hobix/out/okaynews.rb +55 -0
- data/lib/hobix/out/quick.rb +312 -0
- data/lib/hobix/out/rdf.rb +97 -0
- data/lib/hobix/out/redrum.rb +26 -0
- data/lib/hobix/out/rss.rb +115 -0
- data/lib/hobix/plugin/bloglines.rb +73 -0
- data/lib/hobix/plugin/calendar.rb +220 -0
- data/lib/hobix/plugin/flickr.rb +110 -0
- data/lib/hobix/plugin/recent_comments.rb +82 -0
- data/lib/hobix/plugin/sections.rb +91 -0
- data/lib/hobix/plugin/tags.rb +60 -0
- data/lib/hobix/publish/ping.rb +53 -0
- data/lib/hobix/publish/replicate.rb +283 -0
- data/lib/hobix/publisher.rb +18 -0
- data/lib/hobix/search/dictionary.rb +141 -0
- data/lib/hobix/search/porter_stemmer.rb +203 -0
- data/lib/hobix/search/simple.rb +209 -0
- data/lib/hobix/search/vector.rb +100 -0
- data/lib/hobix/storage/filesys.rb +398 -0
- data/lib/hobix/trackbacks.rb +94 -0
- data/lib/hobix/util/objedit.rb +193 -0
- data/lib/hobix/util/patcher.rb +155 -0
- data/lib/hobix/webapp/cli.rb +195 -0
- data/lib/hobix/webapp/htmlform.rb +107 -0
- data/lib/hobix/webapp/message.rb +177 -0
- data/lib/hobix/webapp/urigen.rb +141 -0
- data/lib/hobix/webapp/webrick-servlet.rb +90 -0
- data/lib/hobix/webapp.rb +723 -0
- data/lib/hobix/weblog.rb +860 -0
- data/lib/hobix.rb +223 -0
- metadata +87 -0
@@ -0,0 +1,312 @@
|
|
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.xml">RSS 2.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
|
+
<a name="<%= day.strftime( "%Y%m%d" ) %>"></a>
|
209
|
+
<+ day_header +>
|
210
|
+
<% day_entries.each do |entry| %>
|
211
|
+
<+ entry +>
|
212
|
+
<% end %>
|
213
|
+
<% end %> }
|
214
|
+
end
|
215
|
+
def day_header_erb; %{ <h2 class="dayHeader"><%= day.strftime( "%A, %B %d, %Y" ) %></h2> }; end
|
216
|
+
def entry_erb
|
217
|
+
%{ <div class="entry">
|
218
|
+
<+ entry_title +>
|
219
|
+
<+ entry_content +>
|
220
|
+
</div>
|
221
|
+
<div class="entryFooter"><+ entry_footer +></div> }
|
222
|
+
end
|
223
|
+
def entry_title_erb
|
224
|
+
%{ <h3 class="entryTitle"><%= entry.title %></h3>
|
225
|
+
<% if entry.respond_to? :tagline and entry.tagline %><div class="entryTagline"><%= entry.tagline %></div><% end %> }
|
226
|
+
end
|
227
|
+
def entry_content_erb
|
228
|
+
%{ <div class="entryContent"><%= entry.content.to_html %></div> }
|
229
|
+
end
|
230
|
+
def entry_footer_erb
|
231
|
+
%{ posted by <%= weblog.authors[entry.author]['name'] %> | <a href="<%= entry.link %>"><%= entry.created.strftime( "%I:%M %p" ) %></a> }
|
232
|
+
end
|
233
|
+
def head_tags_erb; end
|
234
|
+
def css_erb; %{ @import "<%= weblog.expand_path "site.css" %>"; }; end
|
235
|
+
def doctype_erb
|
236
|
+
%{<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">}
|
237
|
+
end
|
238
|
+
def page_erb
|
239
|
+
%{<+ doctype +>
|
240
|
+
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
241
|
+
<head>
|
242
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
243
|
+
<title><+ title +></title>
|
244
|
+
<+ head_tags +>
|
245
|
+
<style type="text/css">
|
246
|
+
<+ css +>
|
247
|
+
</style>
|
248
|
+
</head>
|
249
|
+
<body>
|
250
|
+
|
251
|
+
<div id="page">
|
252
|
+
|
253
|
+
<+ banner +>
|
254
|
+
|
255
|
+
<div id="content">
|
256
|
+
<+ sidebar +>
|
257
|
+
|
258
|
+
<+ blog +>
|
259
|
+
|
260
|
+
</div>
|
261
|
+
|
262
|
+
<+ footer +>
|
263
|
+
|
264
|
+
</div>
|
265
|
+
|
266
|
+
</body>
|
267
|
+
</html>}
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
class QuickSummary < Quick
|
272
|
+
def extension
|
273
|
+
"quick-summary"
|
274
|
+
end
|
275
|
+
def entry_content_erb
|
276
|
+
%{ <div class="entryContent">
|
277
|
+
<% if entry.respond_to? :summary and entry.summary %>
|
278
|
+
<%= entry.summary.to_html %>
|
279
|
+
<p><a href="<%= entry.link %>">Continue to full post.</a></p>
|
280
|
+
<% else %>
|
281
|
+
<%= entry.content.to_html %>
|
282
|
+
<% end %>
|
283
|
+
</div> }
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
class QuickArchive < Quick
|
288
|
+
def extension
|
289
|
+
"quick-archive"
|
290
|
+
end
|
291
|
+
def entry_erb
|
292
|
+
%{ <h3 class="entryTitle"><a href="<%= entry.link %>"><%= entry.title %></a></h3> }
|
293
|
+
end
|
294
|
+
def entries_erb
|
295
|
+
%{ <div id="archives">
|
296
|
+
<ul>
|
297
|
+
<% entries.each_day do |day, day_entries| %>
|
298
|
+
<li><+ day_header +>
|
299
|
+
<ul>
|
300
|
+
<% day_entries.each do |entry| %>
|
301
|
+
<li><+ entry +></li>
|
302
|
+
<% end %>
|
303
|
+
</ul>
|
304
|
+
</li>
|
305
|
+
<% end %>
|
306
|
+
</ul>
|
307
|
+
</div> }
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
end
|
312
|
+
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,115 @@
|
|
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
|
+
|
19
|
+
module Hobix
|
20
|
+
module Out
|
21
|
+
class RSS < Hobix::BaseOutput
|
22
|
+
def initialize( weblog, params = {} )
|
23
|
+
@path = weblog.skel_path
|
24
|
+
@extra_ns = params["namespaces"]
|
25
|
+
@extra_els = params["elements"]
|
26
|
+
@summaries = params["summary-only"]
|
27
|
+
@more_link = params["more-link"]
|
28
|
+
@comment_aname = params["comment-location"]
|
29
|
+
end
|
30
|
+
def extension
|
31
|
+
"rss"
|
32
|
+
end
|
33
|
+
def load( file_name, vars )
|
34
|
+
rssdoc = REXML::Document.new( <<EOXML )
|
35
|
+
<rss version="2.0"
|
36
|
+
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
37
|
+
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
|
38
|
+
xmlns:admin="http://webns.net/mvcb/"
|
39
|
+
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
40
|
+
<channel>
|
41
|
+
<title></title>
|
42
|
+
<link></link>
|
43
|
+
<description></description>
|
44
|
+
<dc:language>en-us</dc:language>
|
45
|
+
<dc:creator></dc:creator>
|
46
|
+
<dc:date></dc:date>
|
47
|
+
<admin:generatorAgent rdf:resource="http://hobix.com/?v=#{ Hobix::VERSION }" />
|
48
|
+
<sy:updatePeriod>hourly</sy:updatePeriod>
|
49
|
+
<sy:updateFrequency>1</sy:updateFrequency>
|
50
|
+
<sy:updateBase>2000-01-01T12:00+00:00</sy:updateBase>
|
51
|
+
</channel>
|
52
|
+
</rss>
|
53
|
+
EOXML
|
54
|
+
rssdoc << REXML::XMLDecl.new
|
55
|
+
rssdoc.elements['/rss/channel/title'].text = vars[:weblog].title
|
56
|
+
rssdoc.elements['/rss/channel/link'].text = vars[:weblog].link.to_s
|
57
|
+
rssdoc.elements['/rss/channel/description'].text = vars[:weblog].tagline
|
58
|
+
rssdoc.elements['/rss/channel/dc:date'].text = Time.now.utc.strftime( "%Y-%m-%dT%H:%M:%S+00:00" )
|
59
|
+
|
60
|
+
@extra_ns.each do |k, v|
|
61
|
+
rssdoc.elements['/rss'].attributes["xmlns:" + k.to_s] = v.to_s
|
62
|
+
end if @extra_ns
|
63
|
+
@extra_els.each do |k, v|
|
64
|
+
extra = REXML::Element.new k.to_s
|
65
|
+
extra.text = v.to_s
|
66
|
+
rssdoc.elements['/rss/channel'].add extra
|
67
|
+
end if @extra_els
|
68
|
+
|
69
|
+
( vars[:entries] || [vars[:entry]] ).each do |e|
|
70
|
+
ele = REXML::Element.new 'item'
|
71
|
+
ele_title = REXML::Element.new 'title'
|
72
|
+
ele_title.text = e.title
|
73
|
+
ele << ele_title
|
74
|
+
ele_link = REXML::Element.new 'link'
|
75
|
+
link = e.link.gsub(/'/,"%27")
|
76
|
+
ele_link.text = "#{ link }"
|
77
|
+
ele << ele_link
|
78
|
+
if @comment_aname
|
79
|
+
ele_comments = REXML::Element.new 'comments'
|
80
|
+
ele_comments.text = "#{ link }##@comment_aname"
|
81
|
+
ele << ele_comments
|
82
|
+
end
|
83
|
+
ele_guid = REXML::Element.new 'guid'
|
84
|
+
ele_guid.attributes['isPermaLink'] = 'false'
|
85
|
+
ele_guid.text = "#{ e.id }@#{ vars[:weblog].link }"
|
86
|
+
ele << ele_guid
|
87
|
+
ele_subject = REXML::Element.new 'dc:subject'
|
88
|
+
ele_subject.text = e.section_id
|
89
|
+
ele << ele_subject
|
90
|
+
e.tags.each do |t|
|
91
|
+
ele_subject = REXML::Element.new 'dc:subject'
|
92
|
+
ele_subject.text = t
|
93
|
+
ele << ele_subject
|
94
|
+
end
|
95
|
+
ele_creator = REXML::Element.new 'dc:creator'
|
96
|
+
ele_creator.text = vars[:weblog].authors[e.author]['name']
|
97
|
+
ele << ele_creator
|
98
|
+
ele_pubDate = REXML::Element.new 'dc:date'
|
99
|
+
ele_pubDate.text = ( e.modified || e.created ).dup.utc.strftime( "%Y-%m-%dT%H:%M:%S+00:00" )
|
100
|
+
ele << ele_pubDate
|
101
|
+
ele_desc = REXML::Element.new 'description'
|
102
|
+
ele_desc.text =
|
103
|
+
if @summaries && e.summary
|
104
|
+
e.summary.to_html + (@more_link ? %{<p><a href="#{e.link}">#@more_link</a></p>} : "")
|
105
|
+
else
|
106
|
+
e.content.to_html
|
107
|
+
end.gsub( /(src|href)="\//, "\\1=\"#{ vars[:weblog].link.rooturi }/" )
|
108
|
+
ele << ele_desc
|
109
|
+
rssdoc.elements['/rss/channel'].add ele
|
110
|
+
end
|
111
|
+
rssdoc.to_s
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
## bloglines.rb -- Hobix Bloglines plugin
|
2
|
+
##
|
3
|
+
## Displays your Bloglines subscriptions on the sidebar. If you use
|
4
|
+
## Bloglines, this is a nice way to automatically build a blogroll.
|
5
|
+
## This is based on the instructions at
|
6
|
+
## http://www.bloglines.com/help/share.
|
7
|
+
##
|
8
|
+
## Bloglines does all the work here. This plugin just generates a
|
9
|
+
## Javascript URL.
|
10
|
+
##
|
11
|
+
## USAGE:
|
12
|
+
##
|
13
|
+
## 1) In hobix.yaml (e.g. by running 'hobix edit <blogname>'), in the
|
14
|
+
## 'required' block, append as follows:
|
15
|
+
##
|
16
|
+
## required:
|
17
|
+
## - hobix/plugin/bloglines:
|
18
|
+
## userid: <your bloglines userid>
|
19
|
+
##
|
20
|
+
## You can also specify any of the following arguments:
|
21
|
+
##
|
22
|
+
## required:
|
23
|
+
## - hobix/plugin/bloglines:
|
24
|
+
## userid: <your bloglines userid>
|
25
|
+
## folder: <bloglines folder to export (default all)>
|
26
|
+
## title: <title (default "Blogroll"), or nil for none>
|
27
|
+
## in-sidebarBox-div: <true or false (default true)>
|
28
|
+
##
|
29
|
+
## NOTES:
|
30
|
+
##
|
31
|
+
## 1) If you redefine 'sidebar_list' in hobix.yaml, you'll need to
|
32
|
+
## explicitly add a 'sidebar_bloglines' item.
|
33
|
+
|
34
|
+
module Hobix
|
35
|
+
|
36
|
+
## we just keep parameters from hobix.yaml here
|
37
|
+
class BloglinesPlugin < BasePlugin
|
38
|
+
def initialize(weblog, params = {})
|
39
|
+
raise %{the bloglines plugin needs a "userid" parameter. see hobix/plugin/bloglines.rb for details} unless params.member? "userid"
|
40
|
+
@@userid = params["userid"]
|
41
|
+
@@folder = params["folder"]
|
42
|
+
@@title = params["title"] || "Blogroll"
|
43
|
+
@@in_sidebarBox_div = lambda { |x| (x.nil? ? true : x) }[params["in-sidebarBox-div"]]
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.userid; @@userid; end
|
47
|
+
def self.folder; @@folder; end
|
48
|
+
def self.title; @@title; end
|
49
|
+
def self.in_sidebarBox_div?; @@in_sidebarBox_div; end
|
50
|
+
end
|
51
|
+
|
52
|
+
class Out::Quick
|
53
|
+
alias bloglines_old_sidebar_list_erb sidebar_list_erb
|
54
|
+
def sidebar_list_erb
|
55
|
+
l = bloglines_old_sidebar_list_erb
|
56
|
+
if l.last == "sidebar_hobix"
|
57
|
+
l[0 ... (l.length - 1)] + ['sidebar_bloglines', 'sidebar_hobix']
|
58
|
+
else
|
59
|
+
l + ['sidebar_bloglines']
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def sidebar_bloglines_erb
|
64
|
+
(BloglinesPlugin.in_sidebarBox_div? ? %{<div class="sidebarBox">} : "") +
|
65
|
+
(BloglinesPlugin.title ? %{<h2 class="sidebarTitle">#{BloglinesPlugin.title}</h2>} : "") +
|
66
|
+
%{<script language="javascript" type="text/javascript" src="http://rpc.bloglines.com/blogroll?id=#{BloglinesPlugin.userid}} +
|
67
|
+
(BloglinesPlugin.folder ? "&folder=#{BloglinesPlugin.folder}" : "") +
|
68
|
+
%{"></script>} +
|
69
|
+
(BloglinesPlugin.in_sidebarBox_div? ? "</div>" : "")
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|