hobix 0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +18 -0
- data/README +18 -0
- data/Rakefile +96 -0
- data/bin/hobix +94 -0
- data/contrib/blosxom-to-hobix.rb +253 -0
- data/contrib/txp-to-hobix.rb +56 -0
- data/contrib/webrick-all-mine.rb +20 -0
- data/doc/CHANGELOG +285 -0
- data/doc/rdoc/classes/Hobix/API.html +382 -0
- data/doc/rdoc/classes/Hobix/Article.html +111 -0
- data/doc/rdoc/classes/Hobix/BaseContent.html +692 -0
- data/doc/rdoc/classes/Hobix/BaseEntry.html +218 -0
- data/doc/rdoc/classes/Hobix/BaseFacet.html +205 -0
- data/doc/rdoc/classes/Hobix/BaseOutput.html +122 -0
- data/doc/rdoc/classes/Hobix/BasePlugin.html +201 -0
- data/doc/rdoc/classes/Hobix/BaseProperties/ClassMethods.html +243 -0
- data/doc/rdoc/classes/Hobix/BaseProperties.html +218 -0
- data/doc/rdoc/classes/Hobix/BasePublish.html +157 -0
- data/doc/rdoc/classes/Hobix/BaseStorage.html +417 -0
- data/doc/rdoc/classes/Hobix/BixWik/Entry.html +196 -0
- data/doc/rdoc/classes/Hobix/BixWik/IndexEntry.html +170 -0
- data/doc/rdoc/classes/Hobix/BixWik/WikiRedCloth.html +111 -0
- data/doc/rdoc/classes/Hobix/BixWik.html +418 -0
- data/doc/rdoc/classes/Hobix/BixWikPlugin.html +158 -0
- data/doc/rdoc/classes/Hobix/CommandLine.html +1970 -0
- data/doc/rdoc/classes/Hobix/Comment.html +113 -0
- data/doc/rdoc/classes/Hobix/Config.html +212 -0
- data/doc/rdoc/classes/Hobix/DataMarsh.html +667 -0
- data/doc/rdoc/classes/Hobix/Entry.html +178 -0
- data/doc/rdoc/classes/Hobix/EntryEnum.html +162 -0
- data/doc/rdoc/classes/Hobix/Enumerable.html +170 -0
- data/doc/rdoc/classes/Hobix/Facets/WikiEdit.html +180 -0
- data/doc/rdoc/classes/Hobix/Facets.html +111 -0
- data/doc/rdoc/classes/Hobix/LinkList.html +182 -0
- data/doc/rdoc/classes/Hobix/Out/Quick.html +412 -0
- data/doc/rdoc/classes/Hobix/Out.html +119 -0
- data/doc/rdoc/classes/Hobix/Page.html +381 -0
- data/doc/rdoc/classes/Hobix/Trackback.html +113 -0
- data/doc/rdoc/classes/Hobix/UriStr.html +198 -0
- data/doc/rdoc/classes/Hobix/WebApp/QueryString.html +207 -0
- data/doc/rdoc/classes/Hobix/WebApp/QueryValidationFailure.html +111 -0
- data/doc/rdoc/classes/Hobix/WebApp.html +1383 -0
- data/doc/rdoc/classes/Hobix/Weblog/AuthorNotFound.html +111 -0
- data/doc/rdoc/classes/Hobix/Weblog.html +2082 -0
- data/doc/rdoc/classes/Hobix.html +399 -0
- data/doc/rdoc/classes/Kernel.html +139 -0
- data/doc/rdoc/classes/Regexp.html +154 -0
- data/doc/rdoc/classes/YAML/Omap.html +144 -0
- data/doc/rdoc/classes/YAML.html +111 -0
- data/doc/rdoc/created.rid +1 -0
- data/doc/rdoc/files/COPYING.html +129 -0
- data/doc/rdoc/files/README.html +131 -0
- data/doc/rdoc/files/doc/CHANGELOG.html +101 -0
- data/doc/rdoc/files/lib/hobix/api_rb.html +119 -0
- data/doc/rdoc/files/lib/hobix/article_rb.html +126 -0
- data/doc/rdoc/files/lib/hobix/base_rb.html +128 -0
- data/doc/rdoc/files/lib/hobix/bixwik_rb.html +126 -0
- data/doc/rdoc/files/lib/hobix/commandline_rb.html +140 -0
- data/doc/rdoc/files/lib/hobix/comments_rb.html +126 -0
- data/doc/rdoc/files/lib/hobix/config_rb.html +125 -0
- data/doc/rdoc/files/lib/hobix/datamarsh_rb.html +108 -0
- data/doc/rdoc/files/lib/hobix/entry_rb.html +118 -0
- data/doc/rdoc/files/lib/hobix/linklist_rb.html +127 -0
- data/doc/rdoc/files/lib/hobix/publisher_rb.html +126 -0
- data/doc/rdoc/files/lib/hobix/trackbacks_rb.html +128 -0
- data/doc/rdoc/files/lib/hobix/webapp_rb.html +127 -0
- data/doc/rdoc/files/lib/hobix/weblog_rb.html +135 -0
- data/doc/rdoc/files/lib/hobix_rb.html +127 -0
- data/doc/rdoc/fr_class_index.html +67 -0
- data/doc/rdoc/fr_file_index.html +44 -0
- data/doc/rdoc/fr_method_index.html +307 -0
- data/doc/rdoc/index.html +24 -0
- data/doc/rdoc/rdoc-style.css +208 -0
- data/git_hobix_update.php +13 -0
- data/lib/hobix/api.rb +91 -0
- data/lib/hobix/article.rb +22 -0
- data/lib/hobix/base.rb +480 -0
- data/lib/hobix/bixwik.rb +200 -0
- data/lib/hobix/commandline.rb +677 -0
- data/lib/hobix/comments.rb +98 -0
- data/lib/hobix/config.rb +39 -0
- data/lib/hobix/datamarsh.rb +110 -0
- data/lib/hobix/entry.rb +84 -0
- data/lib/hobix/facets/comments.rb +99 -0
- data/lib/hobix/facets/publisher.rb +314 -0
- data/lib/hobix/facets/trackbacks.rb +80 -0
- data/lib/hobix/linklist.rb +81 -0
- data/lib/hobix/out/atom.rb +101 -0
- data/lib/hobix/out/erb.rb +64 -0
- data/lib/hobix/out/okaynews.rb +55 -0
- data/lib/hobix/out/quick.rb +314 -0
- data/lib/hobix/out/rdf.rb +97 -0
- data/lib/hobix/out/redrum.rb +26 -0
- data/lib/hobix/out/rss.rb +128 -0
- data/lib/hobix/plugin/akismet.rb +196 -0
- data/lib/hobix/plugin/bloglines.rb +73 -0
- data/lib/hobix/plugin/calendar.rb +212 -0
- data/lib/hobix/plugin/flickr.rb +110 -0
- data/lib/hobix/plugin/recent_comments.rb +84 -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 +408 -0
- data/lib/hobix/trackbacks.rb +93 -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 +893 -0
- data/lib/hobix.rb +230 -0
- data/share/default-blog/hobix.yaml +16 -0
- data/share/default-blog/htdocs/site.css +174 -0
- data/share/default-blog/skel/entry.html.quick +0 -0
- data/share/default-blog/skel/index.atom.atom +0 -0
- data/share/default-blog/skel/index.html.quick-summary +0 -0
- data/share/default-blog/skel/index.xml.rss +0 -0
- data/share/default-blog/skel/index.yaml.okaynews +0 -0
- data/share/default-blog/skel/monthly.html.quick-archive +0 -0
- data/share/default-blog/skel/section.html.quick-archive +0 -0
- data/share/default-blog/skel/yearly.html.quick-archive +0 -0
- data/share/default-blog-modes.yaml +7 -0
- data/share/default-blog.apache-cgi.patch +8 -0
- data/share/default-blog.apache-ssi.patch +38 -0
- data/share/default-blog.apache2-ssi.patch +3 -0
- data/share/default-blog.cgi.patch +8 -0
- data/share/default-blog.comments.patch +5 -0
- data/share/default-blog.prototype.patch +766 -0
- data/share/default-blog.publisher.patch +5 -0
- data/share/default-blog.wiki.patch +29 -0
- data/share/publisher/css/control.css +90 -0
- data/share/publisher/css/form.css +238 -0
- data/share/publisher/css/form.import.css +72 -0
- data/share/publisher/css/main-menu.css +134 -0
- data/share/publisher/i/hobix-emblazen-1.png +0 -0
- data/share/publisher/i/hobix-emblazen-2.png +0 -0
- data/share/publisher/i/hobix-emblazen-3.png +0 -0
- data/share/publisher/i/hobix-emblazen-4.png +0 -0
- data/share/publisher/i/hobix-emblazen-5.png +0 -0
- data/share/publisher/i/hobix-emblazen-6.png +0 -0
- data/share/publisher/i/hobix-emblazen-7.png +0 -0
- data/share/publisher/index.erb +66 -0
- data/share/publisher/js/controls.js +261 -0
- data/share/publisher/js/dragdrop.js +476 -0
- data/share/publisher/js/effects.js +570 -0
- data/share/publisher/js/prototype.js +1011 -0
- metadata +230 -0
@@ -0,0 +1,196 @@
|
|
1
|
+
## akismet.rb -- Hobix akismet plugin
|
2
|
+
##
|
3
|
+
## Adds spam comment blocking to Hobix comments support. It does this
|
4
|
+
## using David Czarnecki's Ruby API (included in the plugin) for Akismet
|
5
|
+
## (http://akismet.com/personal/). When loaded comments that get submitted
|
6
|
+
## are fed to Akismet on-line and rejected if they are considered to be
|
7
|
+
## spam comments.
|
8
|
+
##
|
9
|
+
## Note that this plugin needs a network connection to verify the comments
|
10
|
+
## and it needs an Akismet API key to function. For personal use, Akismet
|
11
|
+
## API keys are free and will be sent to you on signing up at WordPress.
|
12
|
+
## See also: http://wordpress.com/signup/.
|
13
|
+
##
|
14
|
+
## USAGE:
|
15
|
+
##
|
16
|
+
## 1) In hobix.yaml (e.g. by running 'hobix edit <blogname>'), simply
|
17
|
+
## add 'hobix/plugin/akismet' to the 'required' block.
|
18
|
+
##
|
19
|
+
## required:
|
20
|
+
## [...]
|
21
|
+
## - hobix/plugin/akismet
|
22
|
+
##
|
23
|
+
## 2) Specify the API key you received/already had as parameter for the
|
24
|
+
## plugin.
|
25
|
+
##
|
26
|
+
## required:
|
27
|
+
## [...]
|
28
|
+
## - hobix/plugin/akismet:
|
29
|
+
## api-key: 123456789abc
|
30
|
+
##
|
31
|
+
## And that's it!
|
32
|
+
##
|
33
|
+
## NOTES:
|
34
|
+
##
|
35
|
+
## 1) This plugin is not useful when the Hobix comments support is not loaded,
|
36
|
+
## i.e. 'hobix/comments' is not required.
|
37
|
+
|
38
|
+
module Hobix
|
39
|
+
|
40
|
+
class AkismetKey < BasePlugin
|
41
|
+
|
42
|
+
def initialize(weblog, params = {})
|
43
|
+
raise %{The Akismet plugin is not configured, the API key is missing. See hobix/plugin/akismet.rb for details} unless params.member?("api-key")
|
44
|
+
@@key = params["api-key"]
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.key; @@key; end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
# Akismet
|
54
|
+
#
|
55
|
+
# Author:: David Czarnecki
|
56
|
+
# Copyright:: Copyright (c) 2005 - David Czarnecki
|
57
|
+
# License:: BSD
|
58
|
+
# Modified by Dieter Komendera, Sparkling Studios:
|
59
|
+
# append blog= to data string (Akismet said it is required)
|
60
|
+
# changed require 'net/HTTP' to require 'net/http' (to work for me unter GNU/Linux)
|
61
|
+
|
62
|
+
class Akismet
|
63
|
+
|
64
|
+
require 'net/http'
|
65
|
+
require 'uri'
|
66
|
+
|
67
|
+
STANDARD_HEADERS = {
|
68
|
+
'User-Agent' => 'Akismet Ruby API/1.0',
|
69
|
+
'Content-Type' => 'application/x-www-form-urlencoded'
|
70
|
+
}
|
71
|
+
|
72
|
+
# Instance variables
|
73
|
+
@apiKey
|
74
|
+
@blog
|
75
|
+
@verifiedKey
|
76
|
+
@proxyPort = nil
|
77
|
+
@proxyHost = nil
|
78
|
+
|
79
|
+
# Create a new instance of the Akismet class
|
80
|
+
#
|
81
|
+
# apiKey
|
82
|
+
# Your Akismet API key
|
83
|
+
# blog
|
84
|
+
# The blog associated with your api key
|
85
|
+
|
86
|
+
def initialize(blog, apiKey)
|
87
|
+
@apiKey = apiKey
|
88
|
+
@blog = blog
|
89
|
+
@verifiedKey = false
|
90
|
+
end
|
91
|
+
|
92
|
+
# Set proxy information
|
93
|
+
#
|
94
|
+
# proxyHost
|
95
|
+
# Hostname for the proxy to use
|
96
|
+
# proxyPort
|
97
|
+
# Port for the proxy
|
98
|
+
def setProxy(proxyHost, proxyPort)
|
99
|
+
@proxyPort = proxyPort
|
100
|
+
@proxyHost = proxyHost
|
101
|
+
end
|
102
|
+
|
103
|
+
# Call to check and verify your API key. You may then call the #hasVerifiedKey method to see if your key has been validated.
|
104
|
+
def verifyAPIKey()
|
105
|
+
http = Net::HTTP.new('rest.akismet.com', 80, @proxyHost, @proxyPort)
|
106
|
+
path = '/1.1/verify-key'
|
107
|
+
|
108
|
+
data="key=#{@apiKey}&blog=#{@blog}"
|
109
|
+
|
110
|
+
resp, data = http.post(path, data, STANDARD_HEADERS)
|
111
|
+
@verifiedKey = (data == "valid")
|
112
|
+
end
|
113
|
+
|
114
|
+
# Returns <tt>true</tt> if the API key has been verified, <tt>false</tt> otherwise
|
115
|
+
def hasVerifiedKey()
|
116
|
+
return @verifiedKey
|
117
|
+
end
|
118
|
+
|
119
|
+
# Internal call to Akismet. Prepares the data for posting to the Akismet service.
|
120
|
+
#
|
121
|
+
# akismet_function
|
122
|
+
# The Akismet function that should be called
|
123
|
+
# user_ip (required)
|
124
|
+
# IP address of the comment submitter.
|
125
|
+
# user_agent (required)
|
126
|
+
# User agent information.
|
127
|
+
# referrer (note spelling)
|
128
|
+
# The content of the HTTP_REFERER header should be sent here.
|
129
|
+
# permalink
|
130
|
+
# The permanent location of the entry the comment was submitted to.
|
131
|
+
# comment_type
|
132
|
+
# May be blank, comment, trackback, pingback, or a made up value like "registration".
|
133
|
+
# comment_author
|
134
|
+
# Submitted name with the comment
|
135
|
+
# comment_author_email
|
136
|
+
# Submitted email address
|
137
|
+
# comment_author_url
|
138
|
+
# Commenter URL.
|
139
|
+
# comment_content
|
140
|
+
# The content that was submitted.
|
141
|
+
# Other server enviroment variables
|
142
|
+
# In PHP there is an array of enviroment variables called $_SERVER which contains information about the web server itself as well as a key/value for every HTTP header sent with the request. This data is highly useful to Akismet as how the submited content interacts with the server can be very telling, so please include as much information as possible.
|
143
|
+
def callAkismet(akismet_function, user_ip, user_agent, referrer, permalink, comment_type, comment_author, comment_author_email, comment_author_url, comment_content, other)
|
144
|
+
http = Net::HTTP.new("#{@apiKey}.rest.akismet.com", 80, @proxyHost, @proxyPort)
|
145
|
+
path = "/1.1/#{akismet_function}"
|
146
|
+
|
147
|
+
data = "blog=#{@blog}&user_ip=#{user_ip}&user_agent=#{user_agent}&referrer=#{referrer}&permalink=#{permalink}&comment_type=#{comment_type}&comment_author=#{comment_author}&comment_author_email=#{comment_author_email}&comment_author_url=#{comment_author_url}&comment_content=#{comment_content}"
|
148
|
+
if (other != nil)
|
149
|
+
other.each_pair {|key, value| data.concat("&#{key}=#{value}")}
|
150
|
+
end
|
151
|
+
|
152
|
+
resp, data = http.post(path, data, STANDARD_HEADERS)
|
153
|
+
|
154
|
+
return (data != "false")
|
155
|
+
end
|
156
|
+
|
157
|
+
protected :callAkismet
|
158
|
+
|
159
|
+
# This is basically the core of everything. This call takes a number of arguments and characteristics about the submitted content and then returns a thumbs up or thumbs down. Almost everything is optional, but performance can drop dramatically if you exclude certain elements.
|
160
|
+
#
|
161
|
+
# user_ip (required)
|
162
|
+
# IP address of the comment submitter.
|
163
|
+
# user_agent (required)
|
164
|
+
# User agent information.
|
165
|
+
# referrer (note spelling)
|
166
|
+
# The content of the HTTP_REFERER header should be sent here.
|
167
|
+
# permalink
|
168
|
+
# The permanent location of the entry the comment was submitted to.
|
169
|
+
# comment_type
|
170
|
+
# May be blank, comment, trackback, pingback, or a made up value like "registration".
|
171
|
+
# comment_author
|
172
|
+
# Submitted name with the comment
|
173
|
+
# comment_author_email
|
174
|
+
# Submitted email address
|
175
|
+
# comment_author_url
|
176
|
+
# Commenter URL.
|
177
|
+
# comment_content
|
178
|
+
# The content that was submitted.
|
179
|
+
# Other server enviroment variables
|
180
|
+
# In PHP there is an array of enviroment variables called $_SERVER which contains information about the web server itself as well as a key/value for every HTTP header sent with the request. This data is highly useful to Akismet as how the submited content interacts with the server can be very telling, so please include as much information as possible.
|
181
|
+
def commentCheck(user_ip, user_agent, referrer, permalink, comment_type, comment_author, comment_author_email, comment_author_url, comment_content, other)
|
182
|
+
return callAkismet('comment-check', user_ip, user_agent, referrer, permalink, comment_type, comment_author, comment_author_email, comment_author_url, comment_content, other)
|
183
|
+
end
|
184
|
+
|
185
|
+
# This call is for submitting comments that weren't marked as spam but should have been. It takes identical arguments as comment check.
|
186
|
+
# The call parameters are the same as for the #commentCheck method.
|
187
|
+
def submitSpam(user_ip, user_agent, referrer, permalink, comment_type, comment_author, comment_author_email, comment_author_url, comment_content, other)
|
188
|
+
callAkismet('submit-spam', user_ip, user_agent, referrer, permalink, comment_type, comment_author, comment_author_email, comment_author_url, comment_content, other)
|
189
|
+
end
|
190
|
+
|
191
|
+
# This call is intended for the marking of false positives, things that were incorrectly marked as spam. It takes identical arguments as comment check and submit spam.
|
192
|
+
# The call parameters are the same as for the #commentCheck method.
|
193
|
+
def submitHam(user_ip, user_agent, referrer, permalink, comment_type, comment_author, comment_author_email, comment_author_url, comment_content, other)
|
194
|
+
callAkismet('submit-ham', user_ip, user_agent, referrer, permalink, comment_type, comment_author, comment_author_email, comment_author_url, comment_content, other)
|
195
|
+
end
|
196
|
+
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
|
@@ -0,0 +1,212 @@
|
|
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
|
+
end
|
92
|
+
|
93
|
+
class Weblog
|
94
|
+
## generate all the sidebar calendar files
|
95
|
+
def skel_sidebar( path_storage, section_path )
|
96
|
+
months = path_storage.get_months(storage.find)
|
97
|
+
|
98
|
+
months.extend Hobix::Enumerable
|
99
|
+
months.each_with_neighbors do |prev, cur, nexxt|
|
100
|
+
month_start, month_end, month_id = cur
|
101
|
+
|
102
|
+
entries = path_storage.within(month_start, month_end)
|
103
|
+
entry_path = SidebarCalendarPlugin.dir_to(month_start, false)
|
104
|
+
page = Page.new( entry_path, section_path )
|
105
|
+
page.timestamp = month_start
|
106
|
+
page.updated = Time.now #path_storage.last_modified(entries)
|
107
|
+
page.prev = prev[0].strftime("/%Y/%m/") if prev
|
108
|
+
page.next = nexxt[0].strftime("/%Y/%m/") if nexxt
|
109
|
+
|
110
|
+
days = entries.map do |entry|
|
111
|
+
day = entry.created
|
112
|
+
Date.new(day.year, day.mon, day.day)
|
113
|
+
end.uniq_c
|
114
|
+
offset = (month_start.wday - (SidebarCalendarPlugin.start_on_monday? ? 1 : 0)) % 7
|
115
|
+
|
116
|
+
yield :page => page, :months => months, :month => month_start, :days => days, :offset => offset, :day_syms => SidebarCalendarPlugin.day_syms, :index => SidebarCalendarPlugin.point_to_index
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
## generate the HTML
|
122
|
+
class Out::Quick
|
123
|
+
def sidebar_calendar_erb
|
124
|
+
%{
|
125
|
+
<style type="text/css">
|
126
|
+
.sidebarCalendar a { text-decoration: none; font-weight: bold; }
|
127
|
+
.sidebarCalendarHeader { text-align: center; }
|
128
|
+
.sidebarCalendarContentRow { color: #888; text-align: right; }
|
129
|
+
</style>
|
130
|
+
|
131
|
+
<div class="sidebarBox">
|
132
|
+
<h2 class="sidebarTitle">Calendar</h2>
|
133
|
+
<table class="sidebarCalendar">
|
134
|
+
<+ sidebar_calendar_caption +>
|
135
|
+
<+ sidebar_calendar_header +>
|
136
|
+
<+ sidebar_calendar_contents +>
|
137
|
+
</table>
|
138
|
+
</div>
|
139
|
+
}
|
140
|
+
end
|
141
|
+
|
142
|
+
def sidebar_calendar_contents_erb
|
143
|
+
%q{
|
144
|
+
<tr class="sidebarCalendarContentRow">
|
145
|
+
<% offset.times do %>
|
146
|
+
<td class="sidebarCalendarFiller"> </td>
|
147
|
+
<% end %>
|
148
|
+
|
149
|
+
<%
|
150
|
+
current = offset
|
151
|
+
first = Date.new(month.year, month.mon, 1)
|
152
|
+
last = (first >> 1) - 1
|
153
|
+
%>
|
154
|
+
|
155
|
+
<% (first .. last).each do |d| %>
|
156
|
+
<% if (current % 7) == 0 %>
|
157
|
+
</tr><tr class="sidebarCalendarContentRow">
|
158
|
+
<% end %>
|
159
|
+
<% current += 1 %>
|
160
|
+
|
161
|
+
<% if days.keys.include? d %>
|
162
|
+
<%
|
163
|
+
title = d.strftime("%A, %B %e: " + (days[d] == 1 ? "one entry" : "#{days[d]} entries"))
|
164
|
+
link = case index
|
165
|
+
when :yearly:
|
166
|
+
d.strftime("/%Y/#day%Y%m%d")
|
167
|
+
when :monthly:
|
168
|
+
d.strftime("/%Y/%m/#day%Y%m%d")
|
169
|
+
else
|
170
|
+
d.strftime("/%Y/%m/%d.html#day%Y%m%d")
|
171
|
+
end
|
172
|
+
%>
|
173
|
+
<td class="sidebarCalendarLinkDay"><a title="<%= title %>" href="<%= weblog.expand_path link %>"><%= d.strftime("%e") %></a></td>
|
174
|
+
<% else %>
|
175
|
+
<td class="sidebarCalendarEmptyDay"><%= d.strftime("%e") %></td>
|
176
|
+
<% end %>
|
177
|
+
<% end %>
|
178
|
+
|
179
|
+
</tr>
|
180
|
+
}
|
181
|
+
end
|
182
|
+
|
183
|
+
def sidebar_calendar_header_erb
|
184
|
+
%{
|
185
|
+
<tr class="sidebarCalendarHeaderRow">
|
186
|
+
<% day_syms.each do |d| %>
|
187
|
+
<th class="sidebarCalendarHeader"><%= d %></th>
|
188
|
+
<% end %>
|
189
|
+
</tr>
|
190
|
+
}
|
191
|
+
end
|
192
|
+
|
193
|
+
def sidebar_calendar_caption_erb
|
194
|
+
%q{
|
195
|
+
<caption class="sidebarCalendarCaption">
|
196
|
+
<% if page.prev %>
|
197
|
+
<a href="<%= weblog.expand_path page.prev %>">←</a>
|
198
|
+
<% else %>
|
199
|
+
←
|
200
|
+
<% end %>
|
201
|
+
<a href="<%= weblog.expand_path month.strftime("/%Y/%m/")%>"><%= month.strftime("%B %Y") %></a>
|
202
|
+
<% if page.next %>
|
203
|
+
<a href="<%= weblog.expand_path page.next %>">→</a>
|
204
|
+
<% else %>
|
205
|
+
→
|
206
|
+
<% end %>
|
207
|
+
</caption>
|
208
|
+
}
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
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,84 @@
|
|
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
|
+
<% reccomm = recent_comments( weblog, weblog.storage.find, RecentCommentsPlugin.num ) %>
|
64
|
+
<% reccomm.each do |link, title, auth, created| %>
|
65
|
+
<li><a href="<%= link %>"><%= title %></a> by <%= auth %> on <nobr><%= created.strftime "%d %b at %H:%M" %></nobr></li>
|
66
|
+
<% end %>
|
67
|
+
<%= "<li>No comments (yet)!</li>" if reccomm.empty? %>
|
68
|
+
</ul>
|
69
|
+
</div>
|
70
|
+
}
|
71
|
+
end
|
72
|
+
|
73
|
+
alias recent_comments_old_sidebar_list_erb sidebar_list_erb
|
74
|
+
def sidebar_list_erb
|
75
|
+
l = recent_comments_old_sidebar_list_erb
|
76
|
+
if l.last == "sidebar_hobix"
|
77
|
+
l[0 ... (l.length - 1)] + ['sidebar_recent_comments', 'sidebar_hobix']
|
78
|
+
else
|
79
|
+
l + ['sidebar_recent_comments']
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|