hobix 0.4 → 0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. data/COPYING +18 -0
  2. data/README +18 -0
  3. data/Rakefile +96 -0
  4. data/bin/hobix +7 -3
  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/base.rb +6 -3
  76. data/lib/hobix/bixwik.rb +12 -12
  77. data/lib/hobix/commandline.rb +18 -2
  78. data/lib/hobix/comments.rb +4 -5
  79. data/lib/hobix/entry.rb +2 -1
  80. data/lib/hobix/facets/comments.rb +31 -6
  81. data/lib/hobix/linklist.rb +6 -1
  82. data/lib/hobix/out/atom.rb +29 -20
  83. data/lib/hobix/out/quick.rb +8 -6
  84. data/lib/hobix/out/rss.rb +16 -3
  85. data/lib/hobix/plugin/akismet.rb +196 -0
  86. data/lib/hobix/plugin/calendar.rb +6 -14
  87. data/lib/hobix/plugin/recent_comments.rb +4 -2
  88. data/lib/hobix/plugin/tags.rb +1 -1
  89. data/lib/hobix/storage/filesys.rb +41 -31
  90. data/lib/hobix/trackbacks.rb +1 -2
  91. data/lib/hobix/weblog.rb +73 -40
  92. data/lib/hobix.rb +9 -2
  93. data/share/default-blog/hobix.yaml +16 -0
  94. data/share/default-blog/htdocs/site.css +174 -0
  95. data/share/default-blog/skel/entry.html.quick +0 -0
  96. data/share/default-blog/skel/index.atom.atom +0 -0
  97. data/share/default-blog/skel/index.html.quick-summary +0 -0
  98. data/share/default-blog/skel/index.xml.rss +0 -0
  99. data/share/default-blog/skel/index.yaml.okaynews +0 -0
  100. data/share/default-blog/skel/monthly.html.quick-archive +0 -0
  101. data/share/default-blog/skel/section.html.quick-archive +0 -0
  102. data/share/default-blog/skel/yearly.html.quick-archive +0 -0
  103. data/share/default-blog-modes.yaml +7 -0
  104. data/share/default-blog.apache-cgi.patch +8 -0
  105. data/share/default-blog.apache-ssi.patch +38 -0
  106. data/share/default-blog.apache2-ssi.patch +3 -0
  107. data/share/default-blog.cgi.patch +8 -0
  108. data/share/default-blog.comments.patch +5 -0
  109. data/share/default-blog.prototype.patch +766 -0
  110. data/share/default-blog.publisher.patch +5 -0
  111. data/share/default-blog.wiki.patch +29 -0
  112. data/share/publisher/css/control.css +90 -0
  113. data/share/publisher/css/form.css +238 -0
  114. data/share/publisher/css/form.import.css +72 -0
  115. data/share/publisher/css/main-menu.css +134 -0
  116. data/share/publisher/i/hobix-emblazen-1.png +0 -0
  117. data/share/publisher/i/hobix-emblazen-2.png +0 -0
  118. data/share/publisher/i/hobix-emblazen-3.png +0 -0
  119. data/share/publisher/i/hobix-emblazen-4.png +0 -0
  120. data/share/publisher/i/hobix-emblazen-5.png +0 -0
  121. data/share/publisher/i/hobix-emblazen-6.png +0 -0
  122. data/share/publisher/i/hobix-emblazen-7.png +0 -0
  123. data/share/publisher/index.erb +66 -0
  124. data/share/publisher/js/controls.js +261 -0
  125. data/share/publisher/js/dragdrop.js +476 -0
  126. data/share/publisher/js/effects.js +570 -0
  127. data/share/publisher/js/prototype.js +1011 -0
  128. metadata +196 -53
  129. checksums.yaml +0 -7
data/COPYING ADDED
@@ -0,0 +1,18 @@
1
+ Copyright (c) 2004 why the lucky stiff
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to
5
+ deal in the Software without restriction, including without limitation the
6
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7
+ sell copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16
+ THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,18 @@
1
+ Hi, this is Hobix SVN. I can't imagine inadvertantly pulling
2
+ a checkout on Hobix source code, but if you did: well, then,
3
+ Hobix is a weblahhging tool. It comes with a command-line and
4
+ a buncha libraries.
5
+
6
+ If you want to read all about it, see http://hobix.com/ for the
7
+ full deal.
8
+
9
+ If you want to try Hobix out, I suggest using the online installer,
10
+ which can be activated by running:
11
+
12
+ ruby -ropen-uri -e 'eval(open("http://go.hobix.com/").read)'
13
+
14
+ Or you can install the CVS version here by using:
15
+
16
+ sudo ruby setup.rb
17
+
18
+ Goo* luc*! -- _why
data/Rakefile ADDED
@@ -0,0 +1,96 @@
1
+ require 'rake'
2
+ require 'rake/clean'
3
+ require 'rake/gempackagetask'
4
+ require 'rake/rdoctask'
5
+ require 'grancher/task'
6
+ require 'fileutils'
7
+ include FileUtils
8
+
9
+ NAME = "hobix"
10
+ VERS = "0.6"
11
+ CLEAN.include ['**/.*.sw?', '*.gem', '.config']
12
+ RDOC_OPTS = [ '--quiet', '--title', "The Book of Hobix",
13
+ # "--template", "extras/flipbook_rdoc.rb",
14
+ "--opname", "index.html",
15
+ "--line-numbers",
16
+ "--main", "README",
17
+ "--inline-source" ]
18
+
19
+ desc "Packages up Hobix."
20
+ task :default => [:package]
21
+ task :package => [:clean]
22
+
23
+ task :doc => [:rdoc, :after_doc]
24
+
25
+ Rake::RDocTask.new do |rdoc|
26
+ rdoc.rdoc_dir = 'doc/rdoc'
27
+ rdoc.options += RDOC_OPTS
28
+ # rdoc.template = "extras/flipbook_rdoc.rb"
29
+ rdoc.main = "README"
30
+ rdoc.title = "The Book of Hobix"
31
+ rdoc.rdoc_files.add ['README', 'doc/CHANGELOG', 'COPYING', 'lib/hobix.rb', 'lib/hobix/*.rb']
32
+ end
33
+
34
+ task :after_doc do
35
+ # cp "extras/Camping.gif", "doc/rdoc/"
36
+ # cp "extras/permalink.gif", "doc/rdoc/"
37
+ sh %{scp -r doc/rdoc/* #{ENV['USER']}@rubyforge.org:/var/www/gforge-projects/hobix/}
38
+ end
39
+
40
+ spec =
41
+ Gem::Specification.new do |s|
42
+ s.name = NAME
43
+ s.version = VERS
44
+ s.platform = Gem::Platform::RUBY
45
+ s.has_rdoc = true
46
+ s.extra_rdoc_files = ["README", "doc/CHANGELOG", "COPYING"]
47
+ s.rdoc_options += RDOC_OPTS + ['--exclude', '^(contrib)\/']
48
+ s.summary = "the white pantsuit of weblahhing"
49
+ s.description = s.summary
50
+ s.author = "why the lucky stiff"
51
+ s.email = 'why@ruby-lang.org'
52
+ s.homepage = 'http://hobix.com'
53
+ s.executables = ['hobix']
54
+
55
+ s.add_dependency('RedCloth')
56
+ s.required_ruby_version = '>= 1.8.2'
57
+
58
+ s.files = %w(COPYING README Rakefile git_hobix_update.php) +
59
+ Dir.glob("{bin,doc,test,share,lib,contrib}/**/*") +
60
+ Dir.glob("ext/**/*.{h,c,rb}") +
61
+ Dir.glob("examples/**/*.rb")
62
+
63
+ s.require_path = "lib"
64
+ # s.extensions = FileList["ext/**/extconf.rb"].to_a
65
+ s.bindir = "bin"
66
+ end
67
+
68
+ Rake::GemPackageTask.new(spec) do |p|
69
+ p.need_tar = true
70
+ p.need_zip = true
71
+ p.gem_spec = spec
72
+ end
73
+
74
+ task :install do
75
+ sh %{rake gem}
76
+ sh %{gem install pkg/#{NAME}-#{VERS}}
77
+ end
78
+
79
+ task :uninstall => [:clean] do
80
+ sh %{gem uninstall #{NAME}}
81
+ end
82
+
83
+ Grancher::Task.new do |g|
84
+ g.branch = 'gh-pages'
85
+ g.push_to = 'origin'
86
+ g.message = 'Updated website' # defaults to 'Updated files.'
87
+
88
+ # Put the website-directory in the root
89
+ g.directory 'school/htdocs'
90
+
91
+ # doc -> doc
92
+ g.directory 'doc', 'doc'
93
+
94
+ # README -> README
95
+ g.file 'README', 'README.txt'
96
+ end
data/bin/hobix CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby
1
+ #! /usr/bin/ruby1.8
2
2
  require 'hobix/commandline'
3
3
  require 'optparse'
4
4
 
@@ -58,8 +58,12 @@ elsif cmdline.respond_to? "#{ cmd }_action"
58
58
  puts "*** type `hobix help' and check your spelling."
59
59
  exit
60
60
  end
61
- hobix_weblog = URI::parse( cmdline.config['weblogs'][ weblog ] )
62
- if hobix_weblog.scheme
61
+ begin
62
+ hobix_weblog = URI::parse( cmdline.config['weblogs'][ weblog ] )
63
+ rescue URI::InvalidURIError
64
+ hobix_weblog = URI.parse ''
65
+ end
66
+ if hobix_weblog.scheme and hobix_weblog.scheme.length > 1
63
67
  mname = "#{ hobix_weblog.scheme }_#{ cmd }_remote"
64
68
  unless cmdline.respond_to? mname
65
69
  opts.unshift cmd
@@ -0,0 +1,253 @@
1
+ #!/usr/bin/ruby -w
2
+
3
+ ## VERSION 0.2
4
+ ##
5
+ ## This is a preliminary Blosxom to Hobix entry conversion
6
+ ## script. Right now it's heavily biased towards the plugins and the
7
+ ## subset of Blosxom that I used. Feel free to send me comments (or
8
+ ## patches!) if it's not doing what you want.
9
+ ##
10
+ ## Example usage:
11
+ ##
12
+ ## ./blosxom-to-hobix.rb -e /usr/share/blosxom/plugins/state/.entries_index.index /var/www/blosxom/ /var/www/hobix/entries/ goatlord
13
+ ##
14
+ ## This will run over all the .blog files all in subdirectories of
15
+ ## /var/www/blosxom, and convert them to .yaml files in the
16
+ ## appropriate subdirectory of /var/www/hobix/entries/ (creating
17
+ ## directories as needed), with the author set to 'goatlord'. It will
18
+ ## set the creation times to the corresponding entry in the
19
+ ## entries_index state file, or from the file's mtime otherwise. (If
20
+ ## you don't use the entries_index plugin, you don't worry about the
21
+ ## -e option.)
22
+ ##
23
+ ## Right now this will detect Tiki usage if it sees a //tiki line, and
24
+ ## do some preliminary Tiki -> Textile conversion. I only used a small
25
+ ## subset of the Tiki stuff, so don't expect this to do all the
26
+ ## conversion right off the bat.
27
+ ##
28
+ ## I find that this works best with fold_lines turned on in RedCloth.
29
+ ## I enable them via the following code in lib/local.rb:
30
+ ##
31
+ ## module Hobix
32
+ ##
33
+ ## class RedClothFoldLines < RedCloth
34
+ ## def initialize(*args)
35
+ ## x = super(*args)
36
+ ## x.fold_lines = true
37
+ ## x
38
+ ## end
39
+ ## end
40
+ ##
41
+ ## def Entry::text_processor; RedClothFoldLines; end
42
+ ##
43
+ ## Good luck. --William <wmorgan-b2h@masanjin.net> 9/17/04
44
+ ##
45
+ ## This file is released under the GNU Public License.
46
+
47
+ require 'optparse'
48
+ require 'find'
49
+ require 'yaml'
50
+ require 'hobix'
51
+
52
+ class Options
53
+ def initialize # defaults
54
+ @parse_tiki = true
55
+ @entries_index = nil
56
+ @overwrite = false
57
+
58
+ @blosxom_extension = ".blog"
59
+ @hobix_extension = ".yaml"
60
+ end
61
+
62
+ def parse(args)
63
+ opts = OptionParser.new do |o|
64
+ o.banner = "Usage: blosxom-to-hobix [options] <blosxom-root> <hobix-root>"
65
+ o.separator ""
66
+ o.separator "Where [options] are:"
67
+
68
+ o.on("-t", "--no-parse-tiki", TrueClass,
69
+ "Don't convert Tiki to Textile when found") do |fl|
70
+ @parse_tiki = fl
71
+ end
72
+
73
+ o.on("-e", "--entries-index n", @entries_index.class,
74
+ "Entries_index data file") do |s|
75
+ @entries_index = s
76
+ end
77
+
78
+ o.on("-o", "--overwrite", TrueClass,
79
+ "Overwrite destination files without mercy") do |fl|
80
+ @overwrite = fl
81
+ end
82
+
83
+ o.on("-b", "--blosxom-extension", @blosxom_extension.class,
84
+ "Blosxom filename extension (default: #@blosxom_extension)") do |s|
85
+ @blosxom_extension = s
86
+ end
87
+
88
+ o.on("-x", "--hobix-extension", @hobix_extension.class,
89
+ "Hobix filename extension (default: #@hobix_extension)") do |s|
90
+ @hobix_extension = s
91
+ end
92
+
93
+ o.on_tail("-h", "--help", "Show this message") { puts opts ; exit }
94
+ end
95
+
96
+ opts.parse!(args)
97
+ self
98
+ end
99
+
100
+ def method_missing(meth); instance_eval "@#{meth}"; end
101
+ end
102
+
103
+ def each_file(root, extension)
104
+ Find.find(root) do |fn|
105
+ yield fn if FileTest.file?(fn) && (fn =~ /#{extension}$/)
106
+ end
107
+ end
108
+
109
+ def tiki_to_textile(s)
110
+ @in_bq ||= false # in block-quote mode
111
+ @in_pre ||= false # in pre mode
112
+
113
+ ## this is kind of a mess.
114
+
115
+ xend = '[\s,.\?!-]'
116
+
117
+ map = {
118
+ ## hack alert---inline urls in a pre-block we pull out of the pre block;
119
+ ## otherwise they don't render.
120
+ /^\s+(\w+:\/\/.+)(#{xend}|$)/ => '"\1":\1\2',
121
+
122
+ ## inline urls
123
+ /(^|\s)(\w+:\/\/.+)(#{xend}|$)/ => '\1"\2":\2\3',
124
+
125
+ ## named urls
126
+ /\[(.*?)\]:(.+?)(#{xend}|$)/ => '"\1":\2\3',
127
+
128
+ ## images
129
+ /\{(.*?)\}:(.+?)(#{xend}|$)/ => '!\2(\1)!\3',
130
+
131
+ ## italics
132
+ /(\s|^)\/(.+?)\/(#{xend}|$)/ => '\1_\2_\3',
133
+
134
+ ## these two were local hacks i made to tiki (to emulate latex
135
+ ## hyphenation styles), so they may not apply to you.
136
+ /([^-])--([^-])/ => '\1-\2',
137
+ /([^-])---([^-])/ => '\1--\2',
138
+ }
139
+
140
+ map.each { |k, v| s.gsub! k, v }
141
+
142
+ if @in_bq
143
+ if s =~ /^[^>]$/
144
+ @in_bq = false
145
+ elsif s =~ /^>\s*(\S.*)$/
146
+ s = $1
147
+ end
148
+ elsif s =~ /^>\s*(\S.*)$/
149
+ @in_bq = true
150
+ s = "bq. " + $1
151
+ end
152
+
153
+ if @in_pre
154
+ if (s =~ /^\S/) || (s =~ /^\s*$/)
155
+ @in_pre = false
156
+ s += "</pre>\n"
157
+ end
158
+ elsif s =~ /^\s+\S/
159
+ s = "<pre>\n" + s
160
+ @in_pre = true
161
+ end
162
+
163
+ s
164
+ end
165
+
166
+ def convert(bf, hf, author, date, opts)
167
+ title = bf.readline.chomp
168
+ tiki = false
169
+ content = ""
170
+
171
+ bf.each_line do |l|
172
+ if (l =~ /^\/\/Tiki/i) && opts.parse_tiki
173
+ tiki = true
174
+ else
175
+ l = tiki_to_textile(l) if tiki
176
+ content += l.chomp + "\n" # force newline
177
+ end
178
+ end
179
+
180
+ #puts "content is [#{content.chomp + "\n"}]"
181
+
182
+ hf.write(Hobix::Entry.new do |e|
183
+ e.title = title
184
+ e.content = content.chomp + "\n"
185
+ e.author = author
186
+ e.summary = nil
187
+ e.contributors = nil
188
+ e.tagline = nil
189
+ e.created = date
190
+ end.to_yaml)
191
+ end
192
+
193
+ def rec_mkdir(path)
194
+ if File.exists? path
195
+ true
196
+ else
197
+ unless File.exists? File.dirname(path)
198
+ rec_mkdir File.dirname(path)
199
+ end
200
+ Dir.mkdir path
201
+ end
202
+ end
203
+
204
+ def run(broot, hroot, author, opts)
205
+ entries_index = Hash.new
206
+
207
+ if opts.entries_index
208
+ IO.foreach(opts.entries_index) do |l|
209
+ if l =~ /'(.*?)' => (\d+)/
210
+ entries_index[$1] = $2
211
+ end
212
+ end
213
+ end
214
+
215
+ each_file(broot, opts.blosxom_extension) do |bfn|
216
+ hfn = File.join hroot,
217
+ bfn.gsub(/^#{broot}\//, "").gsub(/#{opts.blosxom_extension}$/,
218
+ opts.hobix_extension)
219
+ unless File.exists? File.dirname(hfn)
220
+ puts "## creating #{File.dirname(hfn)}"
221
+ rec_mkdir File.dirname(hfn)
222
+ end
223
+
224
+ if File.exists?(hfn) && !opts.overwrite
225
+ puts "## File #{hfn} already exists; skipping"
226
+ next
227
+ end
228
+
229
+ puts "#{bfn} => #{hfn}"
230
+ bfile = File.open(bfn, "r")
231
+ hfile = File.open(hfn, "w")
232
+ date = if entries_index[bfn]
233
+ Time.at(entries_index[bfn].to_i)
234
+ else
235
+ File.mtime(bfile)
236
+ end
237
+
238
+ convert bfile, hfile, author, date, opts
239
+ bfile.close
240
+ hfile.close
241
+ end
242
+ end
243
+
244
+ if $0 == __FILE__
245
+ opts = Options.new.parse ARGV
246
+ broot = ARGV.shift or
247
+ raise "First argument must be a Blosxom root. Try '-h'"
248
+ hroot = ARGV.shift or
249
+ raise "Second argument must be a Hobix root. Try '-h'"
250
+ author = ARGV.shift or raise "Third argument must be the author name. Try '-h'"
251
+
252
+ run broot.gsub(/\/$/, ""), hroot.gsub(/\/$/, ""), author, opts
253
+ end
@@ -0,0 +1,56 @@
1
+ #
2
+ # txp_to_hobix.rb
3
+ #
4
+ # Converts a textpattern xml dump file generated with sqldump into a set of Hobix YAML entry files.
5
+ #
6
+ # Hobix::Entry code lifted from http://www.anvilwerks.com/src/wordpress_to_hobix.rb
7
+ #
8
+ # (c) 2005 erngui.com
9
+ #
10
+ require "rexml/document"
11
+ include REXML # so that we don't have to prefix everything with REXML::...
12
+
13
+ require "hobix"
14
+ require "hobix/entry"
15
+ require "fileutils"
16
+ require "parsedate"
17
+
18
+ txpdump = ARGV.shift
19
+ outdir = ARGV.shift
20
+
21
+ usage = <<EOT
22
+ Usage:
23
+
24
+ ruby txp_to_hobix.rb <txp dump file> <output directory>
25
+
26
+ Converts a textpattern xml dump file generated with sqldump into a set of Hobix YAML entry files.
27
+
28
+ EOT
29
+
30
+ unless txpdump and outdir
31
+ puts usage
32
+ exit(1)
33
+ end
34
+
35
+ txpexport = Document.new File.new(txpdump)
36
+ FileUtils.mkdir_p outdir
37
+
38
+ txpexport.elements.each("*/textpattern") do |e|
39
+ entry = Hobix::Entry.new()
40
+ entry.title = e.elements["Title"].text
41
+ entry.author = e.elements["AuthorID"].text
42
+ res = ParseDate.parsedate(e.elements["Posted"].text)
43
+ posted = Time.local(*res)
44
+ entry.created = posted
45
+ entry.summary = e.elements["Excerpt"].text if e.elements["Excerpt"].text
46
+ entry.content = e.elements["Body"].text
47
+
48
+ # use the post title as filename after removing dodgy characters
49
+ yamlfile = File.join(outdir, e.elements["Title"].text.downcase.tr(" :?!", "-").gsub(/[^a-zA-Z0-9-]+/, "") + ".yaml")
50
+
51
+ puts "writing: #{yamlfile}"
52
+ puts yamlfile.gsub(/(\w)\w*/, '\1').tr("-", "")
53
+ File.open(yamlfile, "w") do |f|
54
+ f.write(entry.to_yaml + "\n")
55
+ end
56
+ end
@@ -0,0 +1,20 @@
1
+ #!/usr/local/bin/ruby
2
+ require 'webrick'
3
+ include WEBrick
4
+
5
+ s = HTTPServer.new(
6
+ :Port => 2000,
7
+ :DocumentRoot => Dir::pwd + "/htdocs"
8
+ )
9
+
10
+ ## mount subdirectories
11
+ require 'hobix/config'
12
+ require 'hobix/weblog'
13
+ config = File.open( File.expand_path( "~/.hobixrc" ) ) { |f| YAML::load( f ) }
14
+ config['weblogs'].each do |name, path|
15
+ weblog = Hobix::Weblog.load( path )
16
+ s.mount("/#{ name }", HTTPServlet::FileHandler, weblog.output_path)
17
+ end
18
+
19
+ trap("INT"){ s.shutdown }
20
+ s.start