Right or wrong, I’m using Radiant CMS for a static website that will change very infrequently. I’ll be the one administering those changes and therefore won’t need a publically accessible admin for managing the content. Oh… and I’m cheap and lazy. I don’t want to pay for ruby hosting resources and I don’t want to have to deploy another rails site (although it’s not too difficult anymore).
Maybe Radiant’s not the best choice for this, but it was a prime opportunity to dabble and learn. Along with learning Radiant I’ve also had to learn how to deploy it statically. I was under the impression that there was an extension to do this already, but after spending a short time looking I decided to hack out my own non-extension.
It’s a combination of using wget and doing a little file movement & renaming to accomodate an HTTP server:
#!/usr/bin/ruby # cp_radiant.rb require 'fileutils' def process_dir(dir_path) Dir.chdir(dir_path) do (all=Dir["*"]).each do |file_name| if File.directory?(file_name) if all.include?(source_index="#{file_name}.html") FileUtils.cp("#{source_index}", (dest_index=File.join(file_name, "index.html"))) puts "...RESTRUCTURED #{source_index} to #{dest_index}" end process_dir(File.expand_path(file_name)) end end end end if(url = ARGV.first) puts "FETCHING SITE... #{url}" `wget -E --no-verbose --no-cache --mirror #{url}` puts puts result_dir = File.join(Dir.pwd, url.gsub(/http:\/\//,'')) puts "POST PROCESSING #{result_dir}" process_dir(result_dir) else puts "MISSING URL ARGUMENT" end
Using it like so will copy the entire site down locally in a new directory named “http://localhost:3000″:
ruby cp_radiant.rb http://localhost:3000
I’m also using Apache as my HTTP server and have added the following entry to my .htaccess file to accommodate URLs without the file extension:
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^\.]+)$ $1.html [NC,L]Once again… this is just a hack to get something done, but I figure it may help someone else with their misuse of Radiant.
Enjoy!
