class BoardController < ApplicationController def index redirect_to :action => 'view' end def view @title = "Last threads" @page_id = "view" @last_post_id = Post.last_post_id @new_posts = @last_post_id - cookies[:new_posts].to_i cookies[:new_posts] = @last_post_id.to_s @discussions = Discussion.find(:all, :order => "last_age DESC", :limit => 15) end def thread @discussion = Discussion.find(@params[:id]) @title = @discussion.title @page_id = "thread" end def reply @title = "Write a reply" @page_id = "reply" @default_author = cookies[:author] || "" @default_tripcode = cookies[:tripcode] || "" @discussion = Post.find(@params[:id]).discussion @highlight = @params[:id] end def newthread @title = "Start a new thread" @page_id = "newthread" @default_author = cookies[:author] || "" @default_tripcode = cookies[:tripcode] || "" end def post fields = @params[:new_post] fields[:ipaddress] = request.remote_ip fields[:created] = Time.now unless fields[:content] =~ /\S/ flash[:error] = "No content given" redirect_to(:action => 'view') and return end if @params[:remember] == "1" cookies[:author] = fields[:author] cookies[:tripcode] = fields[:tripcode] end unless @params[:new_thread] == "1" discussion = Post.find(fields[:parent]).discussion fields[:discussion] = discussion else if @params[:new_discussion][:title].empty? flash[:error] = "No title given" redirect_to(:action => 'newthread') and return end @params[:new_discussion][:last_age] = Time.now discussion = Discussion.new(@params[:new_discussion]) fields[:discussion] = discussion end newpost = Post.new @params[:new_post] newpost.save! unless fields[:sage] == "1" discussion.last_age = Time.now discussion.save! end if fields[:new_thread] == "1" discussion.post = newpost discussion.save! end cookies[:new_posts] = (cookies[:new_posts].to_i + 1).to_s redirect_to :action => 'view' end def help @page_id = 'help' @title = "Fugi Documentation" end end module ActionView::Helpers::FormTagHelper def check_box_tag_with_description(name, description, value = "1", checked = false, options = {}) html_options = { "type" => "checkbox", "name" => name, "id" => name, "value" => value }.update(options.stringify_keys) html_options["checked"] = "checked" if checked content_tag :input, description, html_options end end