Sha256: 65cce055666a3962d254c686881e2778f6e523d2b4cf51bf0dde58f98d2378b5

Contents?: true

Size: 1.99 KB

Versions: 1

Compression:

Stored size: 1.99 KB

Contents

"""
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"
			redirect_to '/'
  end

  #def show
  #  @elt = Elt.find(params[:id]) if @elt == nil
	#	render :partial => 'show'
  #end

  def list
    @elt = Elt.find(params[:id]) if @elt == nil
		render :partial => 'list', :locals => { :elt => @elt }
  end

  def rss
		@headers["Content-Type"] = "text/xml; charset=utf-8" 
    @elt = Elt.find(params[:id]) if @elt == nil
  end

  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
			#cookies[:person] = { :value => @elt.person.name,
			#	:expires => Time.now + 360000 }
      #flash[:notice] = 'Elt was successfully created.'
      #redirect_to :action => 'top', :id => @elt.parent_id
			#render_component(:action => 'show', :id => @elt.id )

			render :partial => 'elt', :locals => { :elt => @elt, :eltTop => false }
    else
      flash[:notice] = 'Error'
      render :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 => "<pre><%= @mail.file %></pre>", :layout => 'top'
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
parlement-0.1 app/controllers/elt_controller.rb