Sha256: abc99dcae8b3112a338a639aa185ebd5043f1475f4ffb6cc79047eb1560567f3

Contents?: true

Size: 1.97 KB

Versions: 26

Compression:

Stored size: 1.97 KB

Contents

module Blog
  class Entries < Controller
    map '/entry'
    provide(:rss, :type => 'application/rss+xml', :engine => :Nagoro)
    provide(:atom, :type => 'application/atom+xml', :engine => :Nagoro)

    def index(slug)
      @entry = Entry.from_slug(slug)
      redirect Blog::Main.r('/') unless @entry
      @tabindex = 10 # outsmart the sidebar tabindex for login
    end

    # just making the work in the template easier
    def show
      @id = @entry.id
      @href = @entry.href
      @comment_href = @entry.comment_href
      @respond_href = @entry.respond_href
      @trackback_href = @entry.trackback_href

      @title = h(@entry.title)
      @pub_iso = @entry.published.iso8601
      @pub_formatted = @entry.published.strftime(Blog.options.time_format)

      @comment_count = number_counter(@entry.comments.count, 'comment')
    end

    def edit(slug)
      login_required
      @entry = Entry.from_slug(slug)
      @tags = fetch_tags
    end

    def save
      login_required
      @entry = Entry[request[:id]]
      @entry.update(request)

      redirect @entry.href
    end

    def new
      login_required
      @entry = Entry.new
      @tags = fetch_tags
    end

    def create
      login_required
      @entry = Entry.new
      @entry.update(request)

      redirect @entry.href
    end

    def delete(slug)
      login_required
      Entry.from_slug(slug).destroy
    end

    def trackback(slug)
      render_partial(:index){|a|
        a.method = :index
        a.params << slug
      } + <<-COMMENT.strip
I really have not the faintest idea about what this is supposed to do.<br />
People tell me it's broken, but nobody tells me how to fix it :)<br />
For now I'll just use it to show off how to modify an action that requires a
method parameter.
      COMMENT
    end

    private

    def fetch_tags
      if tags = request[:tags]
        tags.scan(/\S+/).join(' ')
      elsif @entry.id and tags = @entry.tags
        tags.join(' ')
      else
        ''
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 4 rubygems

Version Path
Pistos-ramaze-2009.06.12 examples/app/blog/controller/entry.rb
manveru-ramaze-2009.04.22 examples/app/blog/controller/entry.rb
manveru-ramaze-2009.04 examples/app/blog/controller/entry.rb
manveru-ramaze-2009.05.08 examples/app/blog/controller/entry.rb
manveru-ramaze-2009.05 examples/app/blog/controller/entry.rb
manveru-ramaze-2009.06.04 examples/app/blog/controller/entry.rb
manveru-ramaze-2009.06.12 examples/app/blog/controller/entry.rb
manveru-ramaze-2009.06 examples/app/blog/controller/entry.rb
manveru-ramaze-2009.07 examples/app/blog/controller/entry.rb
rjspotter-ramaze-2009.06.29 examples/app/blog/controller/entry.rb
rjspotter-ramaze-2009.06.31 examples/app/blog/controller/entry.rb
ramaze-2011.07.25 examples/app/blog/controller/entry.rb
ramaze-2011.01.30 examples/app/blog/controller/entry.rb
ramaze-2011.01 examples/app/blog/controller/entry.rb
ramaze-2010.06.18 examples/app/blog/controller/entry.rb
ramaze-2010.04.04 examples/app/blog/controller/entry.rb
ramaze-2010.04 examples/app/blog/controller/entry.rb
ramaze-2010.03 examples/app/blog/controller/entry.rb
ramaze-2010.01 examples/app/blog/controller/entry.rb
ramaze-2009.10 examples/app/blog/controller/entry.rb