Class: Wiki::PagesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Wiki::PagesController
- Defined in:
- app/controllers/wiki/pages_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #log ⇒ Object
- #new ⇒ Object
- #update ⇒ Object
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'app/controllers/wiki/pages_controller.rb', line 25 def create @page = Rails.configuration.wiki.create_page(params[:path]) @page.update(page_params) if @page.save(current_user) redirect_to @page else render :edit end end |
#destroy ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/controllers/wiki/pages_controller.rb', line 50 def destroy return_path = root_path # ext = File.extname(request.path_info).downcase # if ext.blank? || ext == "html" page = Rails.configuration.wiki.find_page(params[:path]) parent_path = page.parent_path if parent_path.empty? return_path = root_path else return_path = page_path(parent_path) end page.destroy!(current_user) # TODO: recurse pages and attachments # else # file = Rails.configuration.wiki.find_file(params[:path] + '.' + params[:format]) # return_path = page_path(file.parent_path) # file.destroy!(current_user) # end # TODO: look for first *valid* parent redirect_to return_path end |
#edit ⇒ Object
35 36 37 38 |
# File 'app/controllers/wiki/pages_controller.rb', line 35 def edit Rails.configuration.wiki.pull_repo @page = Rails.configuration.wiki.find_page(params[:path]) end |
#index ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'app/controllers/wiki/pages_controller.rb', line 5 def index select = params[:select] query = params[:query] if query @query = query @pages = Rails.configuration.wiki.search(query) else @pages = Rails.configuration.wiki.all_pages end end |
#log ⇒ Object
16 17 18 |
# File 'app/controllers/wiki/pages_controller.rb', line 16 def log @changes_by_path = Rails.configuration.wiki.changelog.group_by{|c| c[:path]} end |
#new ⇒ Object
20 21 22 23 |
# File 'app/controllers/wiki/pages_controller.rb', line 20 def new @page = Rails.configuration.wiki.find_page(params[:path]) render :edit end |
#update ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'app/controllers/wiki/pages_controller.rb', line 40 def update @page = Rails.configuration.wiki.find_page(params[:path]) @page.update(page_params) if @page.save(current_user) redirect_to @page else render :edit end end |