/usr/share/doc/ruby-ramaze/examples/app/wiktacular/src/controller.rb is in ruby-ramaze 2012.12.08-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | class MainController < Ramaze::Controller
layout :application
before_all {setup}
def index(handle = "main")
@entry = WikiEntry.new(handle)
@handle = @entry.name
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)
@entry = WikiEntry.new(handle)
@handle = @entry.name
@text = @entry.content
end
def revert(handle)
WikiEntry[handle].revert
redirect route(handle)
end
def unrevert(handle)
WikiEntry[handle].unrevert
redirect route(handle)
end
def delete(handle)
WikiEntry.new(handle).delete
redirect_referer
end
def save
redirect_referer unless request.post?
handle = request['handle']
entry = WikiEntry.new(handle)
entry.save(request['text'])
redirect entry.route
end
def setup
@nodes = WikiEntry.titles.map{|f|
anchor File.basename(f)
}.join("\n")
end
end
|