hobix 0.4

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 (48) hide show
  1. checksums.yaml +7 -0
  2. data/bin/hobix +90 -0
  3. data/lib/hobix/api.rb +91 -0
  4. data/lib/hobix/article.rb +22 -0
  5. data/lib/hobix/base.rb +477 -0
  6. data/lib/hobix/bixwik.rb +200 -0
  7. data/lib/hobix/commandline.rb +661 -0
  8. data/lib/hobix/comments.rb +99 -0
  9. data/lib/hobix/config.rb +39 -0
  10. data/lib/hobix/datamarsh.rb +110 -0
  11. data/lib/hobix/entry.rb +83 -0
  12. data/lib/hobix/facets/comments.rb +74 -0
  13. data/lib/hobix/facets/publisher.rb +314 -0
  14. data/lib/hobix/facets/trackbacks.rb +80 -0
  15. data/lib/hobix/linklist.rb +76 -0
  16. data/lib/hobix/out/atom.rb +92 -0
  17. data/lib/hobix/out/erb.rb +64 -0
  18. data/lib/hobix/out/okaynews.rb +55 -0
  19. data/lib/hobix/out/quick.rb +312 -0
  20. data/lib/hobix/out/rdf.rb +97 -0
  21. data/lib/hobix/out/redrum.rb +26 -0
  22. data/lib/hobix/out/rss.rb +115 -0
  23. data/lib/hobix/plugin/bloglines.rb +73 -0
  24. data/lib/hobix/plugin/calendar.rb +220 -0
  25. data/lib/hobix/plugin/flickr.rb +110 -0
  26. data/lib/hobix/plugin/recent_comments.rb +82 -0
  27. data/lib/hobix/plugin/sections.rb +91 -0
  28. data/lib/hobix/plugin/tags.rb +60 -0
  29. data/lib/hobix/publish/ping.rb +53 -0
  30. data/lib/hobix/publish/replicate.rb +283 -0
  31. data/lib/hobix/publisher.rb +18 -0
  32. data/lib/hobix/search/dictionary.rb +141 -0
  33. data/lib/hobix/search/porter_stemmer.rb +203 -0
  34. data/lib/hobix/search/simple.rb +209 -0
  35. data/lib/hobix/search/vector.rb +100 -0
  36. data/lib/hobix/storage/filesys.rb +398 -0
  37. data/lib/hobix/trackbacks.rb +94 -0
  38. data/lib/hobix/util/objedit.rb +193 -0
  39. data/lib/hobix/util/patcher.rb +155 -0
  40. data/lib/hobix/webapp/cli.rb +195 -0
  41. data/lib/hobix/webapp/htmlform.rb +107 -0
  42. data/lib/hobix/webapp/message.rb +177 -0
  43. data/lib/hobix/webapp/urigen.rb +141 -0
  44. data/lib/hobix/webapp/webrick-servlet.rb +90 -0
  45. data/lib/hobix/webapp.rb +723 -0
  46. data/lib/hobix/weblog.rb +860 -0
  47. data/lib/hobix.rb +223 -0
  48. metadata +87 -0
@@ -0,0 +1,220 @@
1
+ ## calendar.rb -- Hobix calendar plugin
2
+ ##
3
+ ## Displays a one-month calendar in the sidebar. The calendar links
4
+ ## individual days to a daily, monthly or yearly index page. Daily and
5
+ ## monthly index pages display the corresponding month in the sidebar;
6
+ ## yearly pages do something arbitrary and likely to be wrong; other
7
+ ## pages display the current month.
8
+ ##
9
+ ## The plugin generates separate sidebar .html file for each month. It
10
+ ## places these files in htdocs/calendar/.
11
+ ##
12
+ ## USAGE:
13
+ ##
14
+ ## 1) In hobix.yaml (e.g. by running 'hobix edit <blogname>'), in the
15
+ ## 'required' block, AFTER the "lib/local" line, append as follows:
16
+ ##
17
+ ## required:
18
+ ## - hobix/plugin/calendar
19
+ ##
20
+ ## The plugin overwrites some of the default definitions in
21
+ ## lib/local.rb, so in most cases it will need to be loaded later.
22
+ ## You can also specify any of the following arguments:
23
+ ##
24
+ ## required:
25
+ ## - hobix/plugin/calendar:
26
+ ## start-on-monday: true
27
+ ## point-to-index: daily
28
+ ## day-symbols: ["Mon" "Tue" "Wed" "Thu" "Fri" "Sat" "Sun"]
29
+ ##
30
+ ## Options for 'point-to-index' are 'daily', 'monthly' and
31
+ ## 'yearly'.
32
+ ##
33
+ ## NOTES:
34
+ ##
35
+ ## 1) If you redefine 'sidebar_list' in hobix.yaml, you'll need to
36
+ ## explicitly add a 'sidebar_calendar' item.
37
+ ## 2) Every sidebar page is regenerated every time you do an
38
+ ## upgen. This is slow.
39
+ ## 3) The sidebar on yearly index pages is December of that year,
40
+ ## regardless of whether that month contains any posts. That's a
41
+ ## little weird.
42
+
43
+ require 'date'
44
+
45
+ class Array
46
+ def uniq_c
47
+ ret = {}
48
+ each { |e| ret[e] = 1 + (ret[e] || 0) }
49
+ ret
50
+ end
51
+ end
52
+
53
+ module Hobix
54
+
55
+ ## we just keep parameters from hobix.yaml here
56
+ class SidebarCalendarPlugin < BasePlugin
57
+ def initialize(weblog, params = {})
58
+ @@start_on_monday = lambda { |x| (x.nil? ? false : x) }[params['start-on-monday']]
59
+ @@point_to_index = (params['point-to-index'] || "monthly").to_sym
60
+ @@day_syms = params['day-symbols'] || (@@start_on_monday ? %w(Mo Tu We Th Fr Sa Su) : %w(Su Mo Tu We Th Fr Sa))
61
+ end
62
+
63
+ def self.start_on_monday?; @@start_on_monday; end
64
+ def self.point_to_index; @@point_to_index; end
65
+ def self.day_syms; @@day_syms; end
66
+
67
+ DIR = "/calendar"
68
+ def self.dir_to(date, ext = true)
69
+ date.strftime("#{DIR}/sidebar-%Y-%m") + (ext ? ".html" : "")
70
+ end
71
+ end
72
+
73
+ class Out::Quick
74
+ alias calendar_old_sidebar_list_erb sidebar_list_erb
75
+ def sidebar_list_erb
76
+ l = calendar_old_sidebar_list_erb
77
+ if l.last == "sidebar_hobix"
78
+ l[0 ... (l.length - 1)] + ['sidebar_calendar', 'sidebar_hobix']
79
+ else
80
+ l + ['sidebar_calendar']
81
+ end
82
+ end
83
+
84
+ def sidebar_calendar_ssi
85
+ %q{<!--#include virtual="<%= weblog.link.path + SidebarCalendarPlugin.dir_to(page.timestamp || Time.now)%>"-->}
86
+ end
87
+
88
+ def sidebar_erb
89
+ sidebar_calendar_ssi
90
+ end
91
+
92
+ ## overwrite the default day header so that we can jump to the
93
+ ## corresponding day in the main body of the monthly/yearly index
94
+ ## files
95
+ def day_header_erb; %{ <h2 class="dayHeader"><a name="<%= day.strftime( "%Y%m%d" ) %>"><%= day.strftime( "%A, %B %d, %Y" ) %></a></h2> }; end
96
+ end
97
+
98
+ class Weblog
99
+ ## generate all the sidebar calendar files
100
+ def skel_sidebar(path_storage)
101
+ months = path_storage.get_months(storage.find)
102
+
103
+ months.extend Hobix::Enumerable
104
+ months.each_with_neighbors do |prev, cur, nexxt|
105
+ month_start, month_end, month_id = cur
106
+
107
+ entries = path_storage.within(month_start, month_end)
108
+ page = Page.new SidebarCalendarPlugin.dir_to(month_start, false)
109
+ page.timestamp = month_start
110
+ page.updated = Time.now #path_storage.last_modified(entries)
111
+ page.prev = prev[0].strftime("/%Y/%m/") if prev
112
+ page.next = nexxt[0].strftime("/%Y/%m/") if nexxt
113
+
114
+ days = entries.map do |entry|
115
+ day = entry.created
116
+ Date.new(day.year, day.mon, day.day)
117
+ end.uniq_c
118
+ offset = (month_start.wday - (SidebarCalendarPlugin.start_on_monday? ? 1 : 0)) % 7
119
+
120
+ yield :page => page, :months => months, :month => month_start, :days => days, :offset => offset, :day_syms => SidebarCalendarPlugin.day_syms, :index => SidebarCalendarPlugin.point_to_index
121
+ end
122
+ end
123
+ end
124
+
125
+ ## generate the HTML
126
+ class Out::Quick
127
+ def sidebar_calendar_erb
128
+ %{
129
+ <style type="text/css">
130
+ .sidebarCalendar a { text-decoration: none; font-weight: bold; }
131
+ .sidebarCalendarHeader { text-align: center; }
132
+ .sidebarCalendarContentRow { color: #888; text-align: right; }
133
+ </style>
134
+
135
+ <div class="sidebarBox">
136
+ <h2 class="sidebarTitle">Calendar</h2>
137
+ <table class="sidebarCalendar">
138
+ <+ sidebar_calendar_caption +>
139
+ <+ sidebar_calendar_header +>
140
+ <+ sidebar_calendar_contents +>
141
+ </table>
142
+ </div>
143
+ }
144
+ end
145
+
146
+ def sidebar_calendar_contents_erb
147
+ %q{
148
+ <tr class="sidebarCalendarContentRow">
149
+ <% offset.times do %>
150
+ <td class="sidebarCalendarFiller"> &nbsp; </td>
151
+ <% end %>
152
+
153
+ <%
154
+ current = offset
155
+ first = Date.new(month.year, month.mon, 1)
156
+ last = (first >> 1) - 1
157
+ %>
158
+
159
+ <% (first .. last).each do |d| %>
160
+ <% if (current % 7) == 0 %>
161
+ </tr><tr class="sidebarCalendarContentRow">
162
+ <% end %>
163
+ <% current += 1 %>
164
+
165
+ <% if days.keys.include? d %>
166
+ <%
167
+ title = d.strftime("%A, %B %e: " + (days[d] == 1 ? "one entry" : "#{days[d]} entries"))
168
+ link = case index
169
+ when :yearly:
170
+ d.strftime("/%Y/#%Y%m%d")
171
+ when :monthly:
172
+ d.strftime("/%Y/%m/#%Y%m%d")
173
+ else
174
+ d.strftime("/%Y/%m/%d.html#%Y%m%d")
175
+ end
176
+ %>
177
+ <td class="sidebarCalendarLinkDay"><a title="<%= title %>" href="<%= weblog.expand_path link %>"><%= d.strftime("%e") %></a></td>
178
+ <% else %>
179
+ <td class="sidebarCalendarEmptyDay"><%= d.strftime("%e") %></td>
180
+ <% end %>
181
+ <% end %>
182
+
183
+ <% (7 - offset).times do %>
184
+ <td class="sidebarCalendarFiller"> &nbsp; </td>
185
+ <% end %>
186
+
187
+ </tr>
188
+ }
189
+ end
190
+
191
+ def sidebar_calendar_header_erb
192
+ %{
193
+ <tr class="sidebarCalendarHeaderRow">
194
+ <% day_syms.each do |d| %>
195
+ <th class="sidebarCalendarHeader"><%= d %></th>
196
+ <% end %>
197
+ </tr>
198
+ }
199
+ end
200
+
201
+ def sidebar_calendar_caption_erb
202
+ %q{
203
+ <caption class="sidebarCalendarCaption">
204
+ <% if page.prev %>
205
+ <a href="<%= weblog.expand_path page.prev %>">&larr;</a>
206
+ <% else %>
207
+ &larr;
208
+ <% end %>
209
+ &nbsp;<a href="<%= weblog.expand_path month.strftime("/%Y/%m/")%>"><%= month.strftime("%B %Y") %></a>&nbsp;
210
+ <% if page.next %>
211
+ <a href="<%= weblog.expand_path page.next %>">&rarr;</a>
212
+ <% else %>
213
+ &rarr;
214
+ <% end %>
215
+ </caption>
216
+ }
217
+ end
218
+ end
219
+
220
+ end
@@ -0,0 +1,110 @@
1
+ ## flickr.rb -- Hobix Flickr plugin
2
+ ##
3
+ ## Displays your Flickr photostream ("badge") on the sidebar. This is
4
+ ## based on the instructions at http://flickr.com/badge_new.gne. That
5
+ ## page provides a lot more functionality in terms of colors and sizes
6
+ ## and whatnot; this plugin just makes it slightly easier to do the
7
+ ## most common thing.
8
+ ##
9
+ ## You'll need to discover your Flickr userid to use this (different
10
+ ## from your username). You can use the tool at
11
+ ## http://eightface.com/code/idgettr/, or simply examine your Flickr
12
+ ## RSS URL for the "id" parameter. It should look something like
13
+ ## this: 34479244@N00.
14
+ ##
15
+ ## USAGE:
16
+ ##
17
+ ## 1) In hobix.yaml (e.g. by running 'hobix edit <blogname>'), in the
18
+ ## 'required' block, append as follows:
19
+ ##
20
+ ## required:
21
+ ## - hobix/plugin/flickr:
22
+ ## userid: <your flickr userid (see above)>
23
+ ##
24
+ ## You can also specify any of the following arguments:
25
+ ##
26
+ ## required:
27
+ ## - hobix/plugin/flickr:
28
+ ## userid: <your flickr userid>
29
+ ## num: <number of pics to use (default 5)>
30
+ ## size: <small, thumbnail or midsize (default small)>
31
+ ## title: <title (default "Recent Pictures"), or nil for none>
32
+ ## in-sidebarBox-div: <true or false (default true)>
33
+ ##
34
+ ## NOTES:
35
+ ##
36
+ ## 1) If you redefine 'sidebar_list' in hobix.yaml, you'll need to
37
+ ## explicitly add a 'sidebar_flickr' item.
38
+
39
+ module Hobix
40
+
41
+ ## we just keep parameters from hobix.yaml here
42
+ class FlickrPlugin < BasePlugin
43
+ def initialize(weblog, params = {})
44
+ raise %{the flickr plugin needs a "userid" parameter. see hobix/plugin/flickr.rb for details} unless params.member? "userid"
45
+ @@userid = params["userid"]
46
+ @@num = params["num"] || 5
47
+ @@size =
48
+ case params["size"]
49
+ when nil, "small"
50
+ "s"
51
+ when "thumbnail"
52
+ "t"
53
+ when "midsize"
54
+ "m"
55
+ else
56
+ raise %{unknown size value "#{params["size"]}" for flickr plugin. use "small", "thumbnail" or "midsize"}
57
+ end
58
+ @@title = params["title"] || "Recent Pictures"
59
+ @@in_sidebarBox_div = lambda { |x| (x.nil? ? true : x) }[params["in-sidebarBox-div"]]
60
+ end
61
+
62
+ def self.userid; @@userid; end
63
+ def self.num; @@num; end
64
+ def self.size; @@size; end
65
+ def self.title; @@title; end
66
+ def self.in_sidebarBox_div?; @@in_sidebarBox_div; end
67
+ end
68
+
69
+ class Out::Quick
70
+ alias flickr_old_sidebar_list_erb sidebar_list_erb
71
+ def sidebar_list_erb
72
+ l = flickr_old_sidebar_list_erb
73
+ if l.last == "sidebar_hobix"
74
+ l[0 ... (l.length - 1)] + ['sidebar_flickr', 'sidebar_hobix']
75
+ else
76
+ l + ['sidebar_flickr']
77
+ end
78
+ end
79
+
80
+ def sidebar_flickr_erb
81
+ (FlickrPlugin.in_sidebarBox_div? ? %{<div class="sidebarBox">} : "") +
82
+ (FlickrPlugin.title ? %{<h2 class="sidebarTitle">#{FlickrPlugin.title}</h2>} : "") +
83
+ %{
84
+ <!-- Start of Flickr Badge -->
85
+ <!-- Start of Flickr Badge -->
86
+ <style type="text/css">
87
+ #flickr_badge_source_txt {padding:0; font: 11px Arial, Helvetica, Sans serif; color:#666666;}
88
+ #flickr_badge_icon {display:block !important; margin:0 !important; border: 1px solid rgb(0, 0, 0) !important;}
89
+ #flickr_icon_td {padding:0 5px 0 0 !important;}
90
+ .flickr_badge_image {text-align:center !important;}
91
+ .flickr_badge_image img {border: 1px solid black !important;}
92
+ #flickr_www {display:block; padding:0 10px 0 10px !important; font: 11px Arial, Helvetica, Sans serif !important; color:#3993ff !important;}
93
+ #flickr_badge_uber_wrapper a:hover,
94
+ #flickr_badge_uber_wrapper a:link,
95
+ #flickr_badge_uber_wrapper a:active,
96
+ #flickr_badge_uber_wrapper a:visited {text-decoration:none !important; background:inherit !important;color:#3993ff;}
97
+ #flickr_badge_wrapper {border: solid 1px #000000}
98
+ #flickr_badge_source {padding:0 !important; font: 11px Arial, Helvetica, Sans serif !important; color:#666666 !important;}
99
+ </style>
100
+ <table id="flickr_badge_uber_wrapper" cellpadding="0" cellspacing="10" border="0"><tr><td><a href="http://www.flickr.com" id="flickr_www">www.<strong style="color:#3993ff">flick<span style="color:#ff1c92">r</span></strong>.com</a><table cellpadding="0" cellspacing="10" border="0" id="flickr_badge_wrapper">
101
+ <script type="text/javascript" src="http://www.flickr.com/badge_code_v2.gne?count=#{FlickrPlugin.num}&display=latest&size=#{FlickrPlugin.size}&layout=v&source=user&user=#{FlickrPlugin.userid}"></script>
102
+ </table>
103
+ </td></tr></table>
104
+ <!-- End of Flickr Badge -->
105
+ } +
106
+ (FlickrPlugin.in_sidebarBox_div? ? "</div>" : "")
107
+ end
108
+ end
109
+
110
+ end
@@ -0,0 +1,82 @@
1
+ ## recent_comments.rb -- Hobix recent comments plugin
2
+ ##
3
+ ## Displays a list of recent comments posted on your blog.
4
+ ##
5
+ ## USAGE:
6
+ ##
7
+ ## 1) In hobix.yaml (e.g. by running 'hobix edit <blogname>'), simply
8
+ ## add 'hobix/plugin/recent_comments' to the 'required' list, as
9
+ ## follows:
10
+ ##
11
+ ## required:
12
+ ## - hobix/plugin/recent_comments
13
+ ##
14
+ ## And that's it!
15
+ ##
16
+ ## You can also specify any of the following arguments:
17
+ ##
18
+ ## required:
19
+ ## - hobix/plugin/recent_comments:
20
+ ## num: <number of comments (default 5)>
21
+ ##
22
+ ## NOTES:
23
+ ##
24
+ ## 1) If you redefine 'sidebar_list' in hobix.yaml, you'll need to
25
+ ## explicitly add a 'sidebar_recent_comments' item.
26
+ ## 2) Currently pretty slow, as it basically take a brute force
27
+ ## approach.
28
+
29
+ module Hobix
30
+
31
+ ## we just keep parameters from hobix.yaml here
32
+ class RecentCommentsPlugin < BasePlugin
33
+ def initialize(weblog, params = {})
34
+ @@num = params["num"] || 5
35
+ end
36
+
37
+ def self.num; @@num; end
38
+ end
39
+
40
+ class Hobix::Out::Quick
41
+ def all_comments(weblog, entries)
42
+ entries.map do |ie|
43
+ begin
44
+ comments = weblog.storage.load_attached(ie.id, "comments")
45
+ e = weblog.storage.load_entry ie.id
46
+ comments.each { |c| yield e.link, e.title, c.author, c.created }
47
+ rescue Errno::ENOENT
48
+ end
49
+ end
50
+ end
51
+
52
+ def recent_comments(weblog, entries, num)
53
+ comments = []
54
+ all_comments(weblog, entries) { |*c| comments.push c }
55
+ comments.map { |x| x }.sort_by { |x| x[3] }.reverse[0 ... num]
56
+ end
57
+
58
+ def sidebar_recent_comments_erb
59
+ %q{
60
+ <div class="sidebarBox">
61
+ <h2 class="sidebarTitle">Recent Comments</h2>
62
+ <ul>
63
+ <% recent_comments( weblog, weblog.storage.find, RecentCommentsPlugin.num ).each do |link, title, auth, created| %>
64
+ <li><a href="<%= link %>"><%= title %></a> by <%= auth %> on <nobr><%= created.strftime "%m/%d at %I:%M %P" %></nobr></li>
65
+ <% end %>
66
+ </ul>
67
+ </div>
68
+ }
69
+ end
70
+
71
+ alias recent_comments_old_sidebar_list_erb sidebar_list_erb
72
+ def sidebar_list_erb
73
+ l = recent_comments_old_sidebar_list_erb
74
+ if l.last == "sidebar_hobix"
75
+ l[0 ... (l.length - 1)] + ['sidebar_recent_comments', 'sidebar_hobix']
76
+ else
77
+ l + ['sidebar_recent_comments']
78
+ end
79
+ end
80
+ end
81
+
82
+ end
@@ -0,0 +1,91 @@
1
+ ## sections.rb -- Hobix section list plugin
2
+ ##
3
+ ## Displays a list of all the sections of your blog.
4
+ ##
5
+ ## USAGE:
6
+ ##
7
+ ## 1) In hobix.yaml (e.g. by running 'hobix edit <blogname>'), simply
8
+ ## add 'hobix/plugin/sections' to the 'required' list, as follows:
9
+ ##
10
+ ## required:
11
+ ## - hobix/plugin/sections
12
+ ##
13
+ ## And that's it!
14
+ ##
15
+ ## NOTES:
16
+ ##
17
+ ## 1) If you redefine 'sidebar_list' in hobix.yaml, you'll need to
18
+ ## explicitly add a 'sidebar_section_list' item.
19
+ ## 2) The default Hobix CSS doesn't indent lists, so the hierarchy is
20
+ ## lost upon display. You can add something like this to your CSS file
21
+ ## to fix this:
22
+ ##
23
+ ## .sidebarBox ul {
24
+ ## margin:7px;
25
+ ## padding:0px;
26
+ ## }
27
+
28
+ class Hobix::Out::Quick
29
+ def section_list( entries, topname = "top level" )
30
+ counts = {}
31
+ entries.each do |entry|
32
+ path = ( entry.id.split("/")[0 ... -1] || [] ) # nil in ruby 1.8.1 if path is ""
33
+ counts[path] = 1 + ( counts[path] || 0 )
34
+ end
35
+
36
+ list = []; seen = {}
37
+ counts[[]] ||= 0 # force the root
38
+ counts.sort.each do |path, count|
39
+ if path == []
40
+ list.push [topname, "", 0, counts[path]]
41
+ else
42
+ path.inject( "." ) do |s, x|
43
+ prefix = s + "/" + x
44
+ unless seen[prefix]
45
+ length = prefix.count '/'
46
+ list.push [x, prefix, length, ( length == path.length ? count : 0 ) ]
47
+ seen[prefix] = true
48
+ end
49
+ prefix
50
+ end
51
+ end
52
+ end
53
+ list
54
+ end
55
+
56
+ def sidebar_section_list_erb
57
+ %q{
58
+ <div class="sidebarBox">
59
+ <h2 class="sidebarTitle">Sections</h2>
60
+ <% curlev = -1 %>
61
+ <% section_list( weblog.storage.find ).each do |name, path, lev, num| %>
62
+ <% if ( lev > curlev ) %>
63
+ <% ( lev - curlev ).times do %> <ul> <% end %>
64
+ <% else # less than or equal %>
65
+ </li>
66
+ <% end %>
67
+ <% if ( curlev > lev ) %>
68
+ <% ( curlev - lev ).times do %> </ul></li> <% end %>
69
+ <% end %>
70
+
71
+ <% curlev = lev %>
72
+ <li>
73
+ <a href="<%= weblog.expand_path path %>"><%= name %></a><% if num != 0 then %>: <%= num %> <% end %>
74
+ <% end %>
75
+ <% ( curlev + 1 ).times do %>
76
+ </li></ul>
77
+ <% end %>
78
+ </div>
79
+ }
80
+ end
81
+
82
+ alias sections_old_sidebar_list_erb sidebar_list_erb
83
+ def sidebar_list_erb
84
+ l = sections_old_sidebar_list_erb
85
+ if l.last == "sidebar_hobix"
86
+ l[0 ... (l.length - 1)] + ['sidebar_section_list', 'sidebar_hobix']
87
+ else
88
+ l + ['sidebar_section_list']
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,60 @@
1
+ ## tags.rb -- Hobix tag list plugin
2
+ ##
3
+ ## Displays a list of all the tags of your blog.
4
+ ##
5
+ ## USAGE:
6
+ ##
7
+ ## 1) In hobix.yaml (e.g. by running 'hobix edit <blogname>'), simply
8
+ ## add 'hobix/plugin/tags' to the 'required' list, as follows:
9
+ ##
10
+ ## required:
11
+ ## - hobix/plugin/tags
12
+ ##
13
+ ## And that's it!
14
+ ##
15
+ ## NOTES:
16
+ ##
17
+ ## 1) If you redefine 'sidebar_list' in hobix.yaml, you'll need to
18
+ ## explicitly add a 'sidebar_tag_list' item.
19
+
20
+ class Hobix::Out::Quick
21
+ def tags_list(entries)
22
+ tags = { }
23
+ entries.each do |e|
24
+ if e.tags
25
+ e.tags.each do |t|
26
+ tags[t] ||= 0
27
+ tags[t] += 1
28
+ end
29
+ end
30
+ end
31
+ tags
32
+ end
33
+
34
+ def sidebar_tag_list_erb
35
+ %q{
36
+ <div class="sidebarBox">
37
+ <h2 class="sidebarTitle">Tags</h2>
38
+ <ul>
39
+ <% tags_list(weblog.storage.find).sort.each do |name, count| %>
40
+ <li>
41
+ <a href="<%= weblog.link %>/tags/<%=name%>/index.html"><%= name
42
+ %></a>:&nbsp;<%=count%>
43
+ </li>
44
+ <% end %>
45
+ </ul>
46
+ </div>
47
+ }
48
+ end
49
+
50
+ alias tags_old_sidebar_list_erb sidebar_list_erb
51
+ def sidebar_list_erb
52
+ l = tags_old_sidebar_list_erb
53
+ if l.last == "sidebar_hobix"
54
+ l[0 ... (l.length - 1)] + ['sidebar_tag_list', 'sidebar_hobix']
55
+ else
56
+ l + ['sidebar_tag_list']
57
+ end
58
+ end
59
+
60
+ end
@@ -0,0 +1,53 @@
1
+ #
2
+ # = hobix/out/ping.rb
3
+ #
4
+ # XML-RPC pingt 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 'xmlrpc/client'
18
+
19
+ module Hobix
20
+ module Publish
21
+ class Ping < Hobix::BasePublish
22
+ def initialize( weblog, urls )
23
+ @title = weblog.title
24
+ @link = weblog.link
25
+ @urls = urls
26
+ end
27
+ def watch
28
+ ['index']
29
+ end
30
+ def publish( pages )
31
+ @urls.each do |u|
32
+ link = @link.to_s
33
+ u, link = u.keys.first, u.values.first if Hash === u
34
+ puts "pinging #{ u }..."
35
+ u = URI::parse( u )
36
+ begin
37
+ server = XMLRPC::Client.new( u.host, u.path, u.port )
38
+
39
+ begin
40
+ result = server.call( "weblogUpdates.ping", @title, link )
41
+ rescue XMLRPC::FaultException => e
42
+ puts "Error: "
43
+ puts e.faultCode
44
+ puts e.faultString
45
+ end
46
+ rescue Exception => e
47
+ puts "Error: #{ e.message }"
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end