# # This is the central component to parlement # # An element is just the name for a poll/message/issue # class EltController < ApplicationController def index params[:id] = params[:id].gsub(/.html/, '') show end def show params[:id] = params[:id].gsub(/.html/, '') @elt = Elt.find(params[:id]) @title = @elt.subject+' (parlement)' render :layout => 'top' # TODO rescue ActiveRecord::RecordNotFound => e flash[:error] = "Element '#{params[:id]}' does not exist" headers["Status"] = "301 Moved Permanently" redirect_to '/' end def list @elt = Elt.find(params[:id]) if @elt == nil render :partial => '/elt/list', :locals => { :elt => @elt } end def rss params[:id] = params[:id].gsub(/.rss/, '') @headers["Content-Type"] = "text/xml; charset=utf-8" @elt = Elt.find(params[:id]) if @elt == nil end # Used to initialise the elt, its subject mainly def new @elt = Elt.new @elt.parent = Elt.find(params[:id]) @elt.position = 0 @elt.person = Person.find_by_name(cookies[:person]) @elt.build_person if @elt.person == nil @person = @elt.person if @elt.parent.subject.include? 'Re: ' @elt.subject = @elt.parent.subject else @elt.subject = 'Re: '+@elt.parent.subject end end def preview render :inline => h(format(params[:elt][:body])) end def create @elt = Elt.new(params[:elt]) @elt.person = @session[:person] if params[:submit] == 'preview' or @elt.save render :partial => '/elt/elt', :locals => { :elt => @elt, :eltTop => false } else flash[:notice] = 'Error' render :controller => 'elt', :action => 'new' end end def raw_elt @mail = Elt.find(params[:id]).mail #@elt = TMail::Mail.parse(Elt.find(params[:id]).mail.id) render :inline => "
<%= @mail.file %>", :layout => 'top' end end