gollum/gollum — pull request #896 by bambycha (2014-11-12 17:32:16+00:00)
Title: Add function to disable editing, resolves #879

It works like next.
If editing is blocked all requests except GET is blocked as 403 HTTP CODE with message 'Forbidden'.
````
unless (env["REQUEST_METHOD"] == "GET") || App::settings.wiki_options[:allow_editing]
return [403, {'Content-Type' => 'text/html', 'Content-Length' => '9'}, ['Forbidden']]
end
````
If editing is blocked and user try to access not existing page, app as alternative to redirect to creation page shown error page with message that says "The page doesn't exist"
````
def show_page_or_file(fullpath)
...#loooking if page exist etc.
else #until page not found and then
unless @allow_editing
@message = "The page you are looking is not exist."
status 404
return mustache :error
end #so it's shown clear answer for user who is get lost
page_path = [path, name].compact.join('/')
redirect to("/create/#{clean_url(encodeURIComponent(page_path))}")
end
````
Also it's blocking other get requests that is unnecessary when editing blocked.
````
@message = "You can't do it. Editing is disabled."
status 403
halt mustache :error

#so for those who used CRUD would receive nice error
````