All pastes #90856 Raw Edit

PhilipR

public ruby v1 · immutable
#90856 ·published 2006-07-18 02:25 UTC
rendered paste body
# vim: set expandtab shiftwidth=2 softtabstop=2: class PageController < ApplicationControllertheme Preference.find_by_setting('theme').valuelayout 'default'def index  show  render :action => 'show'enddef 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)  endenddef 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 = "<br />Hi there!!!!<br />"  #@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!")enddef show_urlenddef 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'enddef show_tag  @tag = Tag.find(params[:id])enddef menu  @menu = Page.find(:all, :conditions => "show_in_menu = 1", :order => "name DESC")  render :layout => falseendend