class Olelo::Application
Main class of the application
Attributes
page[R]
Public Class Methods
new(app = nil)
click to toggle source
# File lib/olelo/application.rb, line 28 def initialize(app = nil) @app = app end
reserved_path?(path)
click to toggle source
# File lib/olelo/application.rb, line 18 def self.reserved_path?(path) path = '/' + path.cleanpath path.starts_with?('/static') || router.any? do |method, r| r.any? do |name,pattern,keys,function| name !~ /^\/\(?:path\)?$/ && pattern.match(path) end end end
Public Instance Methods
post_attributes()
click to toggle source
# File lib/olelo/application.rb, line 201 def post_attributes page.update_attributes(params) redirect build_path(page.path) if @close && !page.modified? check do |errors| errors << :version_conflict.t if !page.new? && page.version.to_s != params[:version] errors << :no_changes.t if !page.modified? end page.save Page.commit(:attributes_edited.t(page: page.title)) end
post_edit()
click to toggle source
# File lib/olelo/application.rb, line 166 def post_edit raise 'No content' if !params[:content] params[:content].gsub!("\r\n", "\n") message = :page_edited.t(page: page.title) message << " - #{params[:comment]}" if !params[:comment].blank? page.content = if params[:pos] [page.content[0, params[:pos].to_i].to_s, params[:content], page.content[params[:pos].to_i + params[:len].to_i .. -1]].join else params[:content] end redirect build_path(page.path) if @close && !page.modified? check do |errors| errors << :version_conflict.t if !page.new? && page.version.to_s != params[:version] errors << :no_changes.t if !page.modified? end page.save Page.commit(message) params.delete(:comment) end
post_upload()
click to toggle source
# File lib/olelo/application.rb, line 190 def post_upload raise 'No file' if !params[:file] page.content = params[:file][:tempfile].read check do |errors| errors << :version_conflict.t if !page.new? && page.version.to_s != params[:version] errors << :no_changes.t if !page.modified? end page.save Page.commit(:page_uploaded.t(page: page.title)) end
show_page()
click to toggle source
# File lib/olelo/application.rb, line 212 def show_page render(:show, locals: {content: page.try(:content)}) end