Class: Homeland::Wiki::PagesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Homeland::Wiki::PagesController
- Defined in:
- app/controllers/homeland/wiki/pages_controller.rb
Instance Method Summary collapse
- #comments ⇒ Object
- #create ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #preview ⇒ Object
- #recent ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Methods inherited from ApplicationController
Instance Method Details
#comments ⇒ Object
32 33 34 |
# File 'app/controllers/homeland/wiki/pages_controller.rb', line 32 def comments render_404 if @page.blank? end |
#create ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/controllers/homeland/wiki/pages_controller.rb', line 51 def create :create, Page @page = Page.new(page_params) @page.user_id = current_user.id @page.version_enable = true if @page.save redirect_to page_path(@page.slug), notice: t('common.create_success') else render action: 'new' end end |
#edit ⇒ Object
47 48 49 |
# File 'app/controllers/homeland/wiki/pages_controller.rb', line 47 def edit :edit, @page end |
#index ⇒ Object
8 9 10 |
# File 'app/controllers/homeland/wiki/pages_controller.rb', line 8 def index fresh_when(Setting.wiki_index_html) end |
#new ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'app/controllers/homeland/wiki/pages_controller.rb', line 36 def new :create, Page @page = Page.new @page.slug = params[:title] respond_to do |format| format.html # new.html.erb format.json { render json: @page } end end |
#preview ⇒ Object
78 79 80 |
# File 'app/controllers/homeland/wiki/pages_controller.rb', line 78 def preview render plain: Homeland::Markdown.call(params[:body]) end |
#recent ⇒ Object
12 13 14 15 |
# File 'app/controllers/homeland/wiki/pages_controller.rb', line 12 def recent @pages = Page.recent.page(params[:page]) fresh_when(@pages) end |
#show ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/homeland/wiki/pages_controller.rb', line 17 def show if @page.blank? if current_user.blank? render_404 return end redirect_to new_page_path(title: params[:id]), notice: 'Page not Found, Please create a new page' return end @page.hits.incr(1) fresh_when(@page) end |
#update ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'app/controllers/homeland/wiki/pages_controller.rb', line 65 def update :update, @page @page.version_enable = true @page.user_id = current_user.id if @page.update(page_params) redirect_to page_path(@page.slug), notice: t('common.update_success') else render action: 'edit' end end |