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
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 ADDED
@@ -0,0 +1,94 @@
1
+ #! /usr/bin/ruby1.8
2
+ require 'hobix/commandline'
3
+ require 'optparse'
4
+
5
+ cmdline = Class.new
6
+ cmdline.extend Hobix::CommandLine
7
+
8
+ def print_usage( cmdline )
9
+ puts "hobix #{ Hobix::VERSION } on ruby #{ ::RUBY_VERSION } (#{ ::RUBY_RELEASE_DATE }) [#{ ::RUBY_PLATFORM }]"
10
+ puts "Usage: hobix command weblog-name [command-options]"
11
+ puts "Commands are"
12
+ ['app', 'weblog', 'action'].each do |cmd_type|
13
+ cmdline.methods.collect do |m|
14
+ if m =~ /^(\w+)_(#{ cmd_type })$/
15
+ [$1, $&]
16
+ end
17
+ end.compact.sort.each do |cmd, m|
18
+ args = "#{ cmd } #{ cmdline.method( "#{ m }_args" ).call.join( ' ' ) }"
19
+ exp = cmdline.method( "#{ m }_explain" ).call.gsub( /\n/, "\n" + ( " " * 40 ) )
20
+ puts " %-38s%-40s" % [args, exp]
21
+ end
22
+ puts
23
+ end
24
+ exit
25
+ end
26
+
27
+ config = nil
28
+ opts = OptionParser.new
29
+ opts.on( "-c", "--config FILE", String ) { |val| config = val }
30
+
31
+ args = opts.parse( *ARGV )
32
+ print_usage( cmdline ) if args.length < 1 or args[0] == 'help'
33
+
34
+ # unfreeze the arguments
35
+ cmd, *opts = args.collect do |arg|
36
+ arg.dup
37
+ end
38
+ args.clear
39
+
40
+ cmdline.login( config )
41
+
42
+ mname = nil
43
+ if cmd == 'setup_blogs'
44
+ mname = cmd
45
+ elsif cmdline.respond_to? "#{ cmd }_app"
46
+ mname = "#{ cmd }_app"; opts = [YAML::load( DATA )]
47
+ elsif cmdline.respond_to? "#{ cmd }_weblog"
48
+ mname = "#{ cmd }_weblog"
49
+ elsif cmdline.respond_to? "#{ cmd }_action"
50
+ weblog = opts.shift
51
+ unless cmdline.config['weblogs'].respond_to? :has_key?
52
+ puts "*** no weblogs found in your configuration."
53
+ puts "*** use `hobix create' or `hobix add' to setup."
54
+ exit
55
+ end
56
+ unless cmdline.config['weblogs'].has_key? weblog
57
+ puts "*** no weblog `#{ weblog }' found in your configuration."
58
+ puts "*** type `hobix help' and check your spelling."
59
+ exit
60
+ end
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
67
+ mname = "#{ hobix_weblog.scheme }_#{ cmd }_remote"
68
+ unless cmdline.respond_to? mname
69
+ opts.unshift cmd
70
+ mname = hobix_weblog.scheme
71
+ end
72
+ else
73
+ hobix_weblog = Hobix::Weblog.load( cmdline.config['weblogs'][ weblog ] )
74
+ mname = "#{ cmd }_action"
75
+ end
76
+ opts.unshift hobix_weblog
77
+ end
78
+ unless mname
79
+ abort "*** no hobix command `#{ cmd }'. use `hobix' without arguments to get help."
80
+ end
81
+ m = cmdline.method( mname )
82
+ if m.arity == opts.length or (m.arity < 0 and opts.length >= m.arity.abs - 1)
83
+ m.call( *opts )
84
+ else
85
+ arglist = [cmd] + cmdline.method( "#{ mname }_args" ).call
86
+ need = m.arity
87
+ need = need.abs - 1 if need < 0
88
+ puts "*** wrong arguments (#{opts.length} given, #{need} needed)"
89
+ puts "*** use syntax: `hobix #{ arglist.join( ' ' ) }'"
90
+ end
91
+
92
+ __END__
93
+ # configuration
94
+ --- {}
@@ -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