All pastes #971295 Raw Edit

Stuff

public text v1 · immutable
·published 2008-04-04 17:03 UTC
rendered paste body
#!/home/devlinsb/ruby186
# DEVLIN'S CMS FOR ABUTTON AND SULFURAS
require 'cgi'
$get = CGI.new

class Cms
    'Devlin\'s CMS container class.'
    @@skin = '360'

    def handle
        'Determines where the user wants to go, and gets them there.'
        puts "Content-type: text/html\n\n"
        read_page "header", "tmpl/" +@@skin
        if $get['page'] != ""
            read_page $get['page']
        else
            read_page "index", "pages/special"
        end
        read_page "footer", "tmpl/" +@@skin
    end

    def read_page (file, dir='pages')
        'Reads a file, line by line.'
        file = dir +'/' +file +'.html'
        if File.exists?(file)
            filedata = File.new(file, "r")
            while line = filedata.gets
                puts line
            end
        else
            puts "A page or template file that doesn't exist was attempted to be loaded: '" +file +"'"
        end
    end
end

Cms.new.handle