2012-02-19 09:35:31 -05:00
|
|
|
class WikisController < ApplicationController
|
|
|
|
before_filter :project
|
2012-02-19 12:47:49 -05:00
|
|
|
before_filter :add_project_abilities
|
2012-02-19 09:35:31 -05:00
|
|
|
layout "project"
|
|
|
|
|
|
|
|
def show
|
2012-02-19 14:52:05 -05:00
|
|
|
if params[:old_page_id]
|
|
|
|
@wiki = @project.wikis.find(params[:old_page_id])
|
|
|
|
else
|
|
|
|
@wiki = @project.wikis.where(:slug => params[:id]).order("created_at").last
|
|
|
|
end
|
2012-02-19 09:35:31 -05:00
|
|
|
respond_to do |format|
|
2012-02-19 12:05:35 -05:00
|
|
|
if @wiki
|
|
|
|
format.html
|
|
|
|
else
|
|
|
|
@wiki = @project.wikis.new(:slug => params[:id])
|
|
|
|
format.html { render "edit" }
|
|
|
|
end
|
2012-02-19 09:35:31 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
2012-02-19 12:05:35 -05:00
|
|
|
@wiki = @project.wikis.where(:slug => params[:id]).order("created_at").last
|
|
|
|
@wiki = Wiki.regenerate_from @wiki
|
2012-02-19 09:35:31 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
2012-02-19 12:05:35 -05:00
|
|
|
@wiki = @project.wikis.new(params[:wiki])
|
2012-02-19 14:52:05 -05:00
|
|
|
@wiki.user = current_user
|
2012-02-19 09:35:31 -05:00
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
if @wiki.save
|
2012-02-19 12:05:35 -05:00
|
|
|
format.html { redirect_to [@project, @wiki], notice: 'Wiki was successfully updated.' }
|
2012-02-19 09:35:31 -05:00
|
|
|
else
|
|
|
|
format.html { render action: "edit" }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2012-02-19 14:52:05 -05:00
|
|
|
|
|
|
|
def history
|
|
|
|
@wikis = @project.wikis.where(:slug => params[:id]).order("created_at")
|
|
|
|
end
|
2012-02-19 12:05:35 -05:00
|
|
|
|
2012-02-19 09:35:31 -05:00
|
|
|
def destroy
|
2012-02-19 12:05:35 -05:00
|
|
|
@wiki = @project.wikis.find(params[:id])
|
2012-02-19 09:35:31 -05:00
|
|
|
@wiki.destroy
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html { redirect_to wikis_url }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|