wikistrano

Vedi tutte le pagine e le modifiche recenti o scarica i sorgenti nella pagina


require 'open-uri'

class QbWiki
    def initialize base_url=nil
       @base_url = base_url || 'http://127.0.0.1:3000'
    end

    def run page
        eval get_as_code page
    end

    def get_as_code page    
        load "#{@base_url}/pages/code/#{page}" 
    end

    def get page    
        load "#{@base_url}/pages/#{page}" 
    end

private
    def load url
        (open url).read     
    end
end

def override_require &new_require
    alias original_require require
    $new_require = new_require

    def require filename
        $new_require.call filename
    end
end

def require_first_from wiki

  override_require do |required_resource|
                      begin #local-lookup                    
                          original_require required_resource 
                      rescue LoadError #wiki-lookup
                          wiki.run required_resource         
                      end
                   end
end

Created on June 19, 2007 12:44 by Chiaroscuro (213.92.99.77)