Sha256: bcc9950938f20cb3c571401cac20edceedc2d48e9588de689fd4adb5b1d3138e

Contents?: true

Size: 1.08 KB

Versions: 4

Compression:

Stored size: 1.08 KB

Contents

class MainController < Ramaze::Controller
  

  def index handle = "main"
    @handle = handle
    @entry = WikiEntry.new(handle)
    if @entry.exists?
      @text = EntryView.render(@entry.content)
      @history = @entry.history.map{|f|
        DateTime.strptime(File.basename(f, ".mkd"),
        "%Y-%m-%d_%H-%M-%S")
      }.join("<br />\n")
    else
      @text = "No Entry"
    end
  end

  def edit handle
    @handle = handle
    @entry = WikiEntry[handle]
    @text = @entry.content
  end

  def revert handle
    WikiEntry[handle].revert
    redirect Rs(handle)
  end

  def unrevert handle
    WikiEntry[handle].unrevert
    redirect Rs(handle)
  end

  def delete handle
    WikiEntry[handle].delete
    redirect_referer
  end

  def save
    redirect_referer unless request.post?
    handle = request['handle']
    entry = WikiEntry[handle]
    entry.save(request['text'])
    redirect Rs(:index, handle)
  end

  def html_layout
    @nodes = WikiEntry.titles.map{|f|
        name = File.basename(f)
        %[<a href="/#{name}">#{name}</a>]
      }.join("\n")
  end

  layout '/html_layout'
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ramaze-0.2.0 examples/wiktacular/src/controller.rb
ramaze-0.3.0 examples/wiktacular/src/controller.rb
ramaze-0.3.5 examples/wiktacular/src/controller.rb
ramaze-0.2.1 examples/wiktacular/src/controller.rb