hobix 0.6

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 (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,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.expand_path "tags/#{ name }/" %>"><%= 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
@@ -0,0 +1,283 @@
1
+ # Content replication: will replicate and/or update the target with
2
+ # the files generated by Hobix
3
+ # Can handle (currently) copy via FTP and on local filesystem. Plug of sftp should
4
+ # not be hard.
5
+ #
6
+ # == How to use
7
+ # Add the follozing to your hobix.yaml file:
8
+ #
9
+ # - replicate:
10
+ # target: ftp://user:pass@isp.com/foo/bar/
11
+ # production_link: http://www.myisp.com/~me/blog
12
+ #
13
+ # production_link is optionnal and has been stolen from Sebastian Kanthak
14
+ # (http://www.kanthak.net/explorations/blog/hobix/staging_hobix.html)
15
+ #
16
+ # It allows to change the link to the weblog based on the HOBIX_ENV variable
17
+ # which mean that you can have a local test blog (link set to /home/me/foo/blog/htdocs)
18
+ # for example, and a "production" blog (link is http://www.myisp.com/~me/blog) and it should
19
+ # be uploaded to isp.com/foo/bar/ using given user/pass
20
+ #
21
+ # Thus to sum-up:
22
+ #
23
+ # * If the HOBIX_ENV variable is set to "production", then the link is changed
24
+ # to value of production_link (if available) and the page are uploaded to target
25
+ # * If HOBIX_ENV is not set, then the link is not changed and the page go to htdocs
26
+ #
27
+ #
28
+ # == TODO
29
+ # - Beautify/simplify code
30
+ # - Potentially add some other "non-generated" files (for example css files..)
31
+ #
32
+ # Copyright - Frederick Ros
33
+ # License: same as Ruby's one
34
+ #
35
+ # $Id$
36
+ #
37
+ require 'hobix/base'
38
+ require 'net/ftp'
39
+ require 'fileutils'
40
+
41
+ module Publish
42
+
43
+ Target = Struct.new( :path, :host, :user, :passwd )
44
+
45
+ class PublishReplication < Hobix::BasePublish
46
+ attr_reader :production, :replicator, :weblog
47
+
48
+ def initialize( blog, hash_opt )
49
+ @weblog = blog
50
+ hash_opt['items'] = nil
51
+ hash_opt['source'] = weblog.output_path
52
+
53
+ if ENV['HOBIX_ENV'] == "production"
54
+ @production = true
55
+ #
56
+ # Change link if a production one is given
57
+ #
58
+ blog.link = hash_opt['production_link'] || blog.link
59
+ else
60
+ @production = false
61
+ end
62
+
63
+ if hash_opt['target'] =~ /^ftp:\/\/([^:]+):([^@]+)@([^\/]+)(\/.*)$/
64
+ tgt = Target.new($4,$3,$1,$2)
65
+
66
+ @replicator = ReplicateFtp::new(hash_opt, tgt)
67
+ else
68
+ #
69
+ # File replication
70
+ #
71
+ tgt = Target.new(hash_opt['target'])
72
+ @replicator = ReplicateFS.new(hash_opt, tgt)
73
+
74
+ end
75
+ end
76
+
77
+ def watch
78
+ ['index']
79
+ end
80
+
81
+ def publish( page_name )
82
+ return unless production
83
+ replicator.items = weblog.updated_pages.map { |o| o.link }
84
+ replicator.copy do |nb,f,src,tgt|
85
+ puts "## Replicating #{src}"
86
+ end
87
+ end
88
+
89
+ end
90
+ end
91
+
92
+ module Hobix
93
+ class Weblog
94
+ attr_reader :updated_pages
95
+
96
+ alias p_publish_orig p_publish
97
+
98
+ def p_publish( obj )
99
+ @updated_pages ||= []
100
+ @updated_pages << obj
101
+ p_publish_orig( obj )
102
+ end
103
+
104
+ end
105
+ end
106
+
107
+ class Replicate
108
+
109
+ attr_accessor :items, :target, :source
110
+
111
+ def initialize(hash_src, hash_tgt)
112
+ @items = hash_src['items']
113
+ @source = hash_src['source']
114
+ @target = hash_tgt['path']
115
+
116
+ end
117
+
118
+
119
+ DIRFILE = /^(.*\/)?([^\/]*)$/
120
+
121
+ def get_dirs
122
+ dirs = Array.new
123
+
124
+ dirfiles = items.collect do |itm|
125
+ dir,file = DIRFILE.match(itm).captures
126
+
127
+ if dir && dir.strip.size != 0
128
+ dirs.push dir
129
+ end
130
+ end
131
+
132
+ dirs
133
+ end
134
+
135
+ def get_files
136
+ files = Array.new
137
+ dirfiles = items.collect do |itm|
138
+ dir,file = DIRFILE.match(itm).captures
139
+
140
+ if file && file.strip.size != 0
141
+ files.push itm
142
+ end
143
+ end
144
+
145
+ files
146
+ end
147
+
148
+ def check_and_make_dirs
149
+ dirs = get_dirs
150
+
151
+ dirs.each do |dir|
152
+ # Check existence and create if not present
153
+ dir = File.join(target,dir)
154
+ if !directory?(dir)
155
+ # Let's create it !
156
+ mkdir_p(dir)
157
+ end
158
+ end
159
+ end
160
+
161
+
162
+ def copy_files ( &block)
163
+ files = get_files
164
+
165
+ nb_files = files.size
166
+
167
+ files.each do |file|
168
+
169
+ src_f = File.join(source,file)
170
+ tgt_f = File.join(target,file)
171
+
172
+ if block_given?
173
+ yield nb_files,file, src_f, tgt_f
174
+ end
175
+
176
+ cp(src_f,tgt_f)
177
+ end
178
+ end
179
+
180
+
181
+ def copy (&block)
182
+ if respond_to?(:login)
183
+ send :login
184
+ end
185
+
186
+ check_and_make_dirs
187
+
188
+ copy_files &block
189
+
190
+ if respond_to?(:logout)
191
+ send :logout
192
+ end
193
+
194
+ end
195
+
196
+ end
197
+
198
+
199
+ class ReplicateFtp < Replicate
200
+
201
+ attr_accessor :ftp, :passwd, :user, :host
202
+
203
+ def initialize(hash_src, hash_tgt)
204
+ super(hash_src,hash_tgt)
205
+
206
+ @user = hash_tgt['user']
207
+ @passwd = hash_tgt['passwd']
208
+ @host = hash_tgt['host']
209
+
210
+ end
211
+
212
+ def login
213
+ @ftp = Net::FTP.open(host)
214
+ ftp.login user,passwd
215
+ end
216
+
217
+ def logout
218
+ ftp.close
219
+ end
220
+
221
+ def directory?(d)
222
+ old_dir = ftp.pwd
223
+
224
+ begin
225
+ ftp.chdir d
226
+ # If we successfully change to d, we could now return to orig dir
227
+ # otherwise we're in the rescue section ...
228
+ ftp.chdir(old_dir)
229
+ return true
230
+
231
+ rescue Net::FTPPermError
232
+ if $!.to_s[0,3] == "550"
233
+ # 550 : No such file or directory
234
+ return false
235
+ end
236
+ raise Net::FTPPermError, $!
237
+ end
238
+ end
239
+
240
+
241
+ def mkdir_p(tgt)
242
+ old_dir = ftp.pwd
243
+ tgt.split(/\/+/).each do |dir|
244
+ next if dir.size == 0
245
+ # Let's try to go down
246
+ begin
247
+ ftp.chdir(dir)
248
+ # Ok .. So it was already existing ..
249
+ rescue Net::FTPPermError
250
+ if $!.to_s[0,3] == "550"
251
+ # 550 : No such file or directory : let's create ..
252
+ ftp.mkdir(dir)
253
+ # and retry
254
+ retry
255
+ end
256
+ raise Net::FTPPermError, $!
257
+ end
258
+ end
259
+ ftp.chdir(old_dir)
260
+
261
+ end
262
+
263
+
264
+ def cp(src,tgt)
265
+ ftp.putbinaryfile src, tgt
266
+ end
267
+ end
268
+
269
+ class ReplicateFS < Replicate
270
+
271
+ def directory?(d)
272
+ File.directory? d
273
+ end
274
+
275
+ def mkdir_p(tgt)
276
+ FileUtils.mkdir_p tgt
277
+ end
278
+
279
+ def cp(src,tgt)
280
+ FileUtils.cp src, tgt
281
+ end
282
+
283
+ end
@@ -0,0 +1,18 @@
1
+ #
2
+ # = hobix/publisher.rb
3
+ #
4
+ # Hobix command-line weblog system, web-based publishing interface.
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
+
17
+ require 'hobix/facets/publisher'
18
+
@@ -0,0 +1,141 @@
1
+ # Maintain a dictionary mapping words to consecutive integers (the
2
+ # first unique word is 0, the second is 1 and so on)
3
+
4
+ require 'hobix/search/porter_stemmer'
5
+ module Hobix
6
+ module Search
7
+ module Simple
8
+ class Dictionary
9
+ STOP_WORDS = {
10
+ "a" => 1,
11
+ "again" => 1,
12
+ "all" => 1,
13
+ "along" => 1,
14
+ "also" => 1,
15
+ "an" => 1,
16
+ "and" => 1,
17
+ "arialhelvetica" => 1,
18
+ "as" => 1,
19
+ "at" => 1,
20
+ "but" => 1,
21
+ "by" => 1,
22
+ "came" => 1,
23
+ "can" => 1,
24
+ "cant" => 1,
25
+ "couldnt" => 1,
26
+ "did" => 1,
27
+ "didn" => 1,
28
+ "didnt" => 1,
29
+ "do" => 1,
30
+ "doesnt" => 1,
31
+ "dont" => 1,
32
+ "entrytitledetail" => 1,
33
+ "ever" => 1,
34
+ "first" => 1,
35
+ "fontvariant" => 1,
36
+ "from" => 1,
37
+ "have" => 1,
38
+ "her" => 1,
39
+ "here" => 1,
40
+ "him" => 1,
41
+ "how" => 1,
42
+ "i" => 1,
43
+ "if" => 1,
44
+ "in" => 1,
45
+ "into" => 1,
46
+ "is" => 1,
47
+ "isnt" => 1,
48
+ "it" => 1,
49
+ "itll" => 1,
50
+ "just" => 1,
51
+ "last" => 1,
52
+ "least" => 1,
53
+ "like" => 1,
54
+ "most" => 1,
55
+ "my" => 1,
56
+ "new" => 1,
57
+ "no" => 1,
58
+ "not" => 1,
59
+ "now" => 1,
60
+ "of" => 1,
61
+ "on" => 1,
62
+ "or" => 1,
63
+ "should" => 1,
64
+ "sidebartitl" => 1,
65
+ "sinc" => 1,
66
+ "so" => 1,
67
+ "some" => 1,
68
+ "textdecoration" => 1,
69
+ "th" => 1,
70
+ "than" => 1,
71
+ "that" => 1,
72
+ "the" => 1,
73
+ "their" => 1,
74
+ "then" => 1,
75
+ "those" => 1,
76
+ "to" => 1,
77
+ "told" => 1,
78
+ "too" => 1,
79
+ "true" => 1,
80
+ "try" => 1,
81
+ "until" => 1,
82
+ "url" => 1,
83
+ "us" => 1,
84
+ "were" => 1,
85
+ "when" => 1,
86
+ "whether" => 1,
87
+ "while" => 1,
88
+ "with" => 1,
89
+ "within" => 1,
90
+ "yes" => 1,
91
+ "you" => 1,
92
+ "youll" => 1,
93
+ }
94
+
95
+ attr_reader :total, :clsf, :words
96
+
97
+ def initialize
98
+ @total = 0
99
+ @clsf = {}
100
+ @words = {}
101
+ end
102
+
103
+ def add_word(word, classifications = [], mod = 1)
104
+ word = Stemmable::stem_porter(word)
105
+ if STOP_WORDS[word]
106
+ nil
107
+ else
108
+ @words[word] ||= {:pos => @words.size, :clsf => {}}
109
+ classifications.each do |c|
110
+ @clsf[c] ||= {}
111
+ @clsf[c][word] ||= 0
112
+ @clsf[c][word] += mod
113
+ @total += mod
114
+ end
115
+ @words[word][:pos]
116
+ end
117
+ end
118
+
119
+ def remove_word(word, classifications = [])
120
+ add_word(word, classifications, -1)
121
+ end
122
+
123
+ def find(word)
124
+ word = Stemmable::stem_porter(word)
125
+ if @words[word] and not STOP_WORDS[word]
126
+ @words[word][:pos]
127
+ end
128
+ end
129
+
130
+ def size
131
+ @words.size
132
+ end
133
+
134
+ def dump
135
+ puts @words.keys.sort
136
+ end
137
+
138
+ end
139
+ end
140
+ end
141
+ end