# vim: set expandtab shiftwidth=2 softtabstop=2:
class PageController < ApplicationController
theme Preference.find_by_setting('theme').value
layout 'default'
def index
show
render :action => 'show'
end
def show
if params[:name]
@page = Page.find_by_url(params[:name])
#PHILIP hackery - improve as we go
#Logger::add(Logger::FATAL, "HELP, I'm stuck!")
philip_contact_hack if params[:name].downcase == 'contact'
elsif params[:id]
@page = Page.find(params[:id])
else
@page = Page.find_by_id(Preference.find_by_setting('site_default_page').value) || Page.find(:first)
end
end
def philip_contact_hack
#local_debug = Logger::DEBUG
#Logger::add(local_debug, "HELP, I'm stuck!")
#some_ripped_markup = Net::HTTP.get_response(
#"philipreedtech.com",
#@request.env["REQUEST_URI"] + '.html'
#).body
#some_ripped_markup = "
Hi there!!!!
"
#@page.body_html = some_ripped_markup
#Just this one addition, even with all the rest of the code hacked out, causes
#it to lock up hopelessly both in production (Apache) and on local Webrick. Weird.
Logger::add(DEBUG, "Added markup to body_html, NOT!")
end
def show_url
end
def tags
@tags = Tag.cloud.sort_by{|t| t.name}
total=@tags.inject(0) {|total,tag| total += tag.page_counter }
average = total.to_f / @tags.size.to_f
@sizes = @tags.inject({}) {|h,tag| h[tag] = (tag.page_counter.to_f / average); h} # create a percentage
# apply a lower limit of 50% and an upper limit of 200%
@sizes.each {|tag,size| @sizes[tag] = [[2.0/3.0, size].max, 2].min * 100}
@font_multiplier = 80
@all_tags = Tag.find_all
render :layout => false
rescue
render :text => 'No Tag Cloud'
end
def show_tag
@tag = Tag.find(params[:id])
end
def menu
@menu = Page.find(:all, :conditions => "show_in_menu = 1", :order => "name DESC")
render :layout => false
end
end