+ Using WEBrick with Hobix
why the lucky stiff
why at hobix.com
Fri Sep 10 15:53:47 EDT 2004
While the Wiki is still under construction, I'd like this list to become
an archive for Hobix tips. If you have a tip to send to the list, just
prefix it with a plus sign. This indicates that you are adding to our
understanding of how to use Hobix.
Someone asked about serving Hobix sites through WEBrick. Here is an idea.
=== Using WEBrick to Serve Your Blogs ===
Hobix generates static HTML by default, so it'll work with any web server.
For example, here's a WEBrick server which will scan your ~/.hobixrc and
setup a subdirectory for each one.
#!/usr/local/bin/ruby
require 'webrick'
include WEBrick
s = HTTPServer.new(
:Port => 2000,
:DocumentRoot => Dir::pwd + "/htdocs"
)
## mount subdirectories
require 'hobix/config'
require 'hobix/weblog'
config = File.open( File.expand_path( "~/.hobixrc" ) ) { |f|
YAML::load( f ) }
config['weblogs'].each do |name, path|
weblog = Hobix::Weblog.load( path )
s.mount("/#{ name }", HTTPServlet::FileHandler, weblog.output_path)
end
trap("INT"){ s.shutdown }
s.start
So, if you have a blog which you call 'test', it will appear at
http://localhost:2000/test/. In order for this to work right, that URL
needs to be added as the 'link' in that blog's hobix.yaml file.
_why
More information about the Hobix-is-the-way
mailing list