Added page-preview feature to wiki module.
This commit is contained in:
parent
0fb8ee214f
commit
7de45543c4
7 changed files with 36 additions and 21 deletions
|
@ -18,10 +18,8 @@ class PagesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# GET /pages/new
|
||||
# GET /pages/new.xml
|
||||
def new
|
||||
@page = Page.new(:title => params[:title])
|
||||
@page = Page.new(:title => params[:title].capitalize.gsub("-", " "))
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
|
@ -29,38 +27,39 @@ class PagesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# GET /pages/1/edit
|
||||
def edit
|
||||
@page = Page.find(params[:id])
|
||||
end
|
||||
|
||||
# POST /pages
|
||||
# POST /pages.xml
|
||||
def create
|
||||
@page = current_user.pages.build(params[:page])
|
||||
|
||||
respond_to do |format|
|
||||
if params[:preview]
|
||||
render :action => 'new'
|
||||
else
|
||||
if @page.save
|
||||
flash[:notice] = 'Seite wurde angelegt.'
|
||||
format.html { redirect_to(wiki_page_path(@page.permalink)) }
|
||||
format.xml { render :xml => @page, :status => :created, :location => @page }
|
||||
redirect_to(wiki_page_path(@page.permalink))
|
||||
else
|
||||
format.html { render :action => "new" }
|
||||
format.xml { render :xml => @page.errors, :status => :unprocessable_entity }
|
||||
render :action => "new"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PUT /pages/1
|
||||
# PUT /pages/1.xml
|
||||
def update
|
||||
@page = Page.find(params[:id])
|
||||
@page.attributes = params[:page].merge({:user => current_user})
|
||||
|
||||
if @page.update_attributes(params[:page].merge({:user => current_user}))
|
||||
flash[:notice] = 'Seite wurde aktualisiert.'
|
||||
redirect_to wiki_page_path(@page.permalink)
|
||||
if params[:preview]
|
||||
@page.attributes = params[:page]
|
||||
render :action => 'edit'
|
||||
else
|
||||
render :action => "edit"
|
||||
if @page.save
|
||||
flash[:notice] = 'Seite wurde aktualisiert.'
|
||||
redirect_to wiki_page_path(@page.permalink)
|
||||
else
|
||||
render :action => "edit"
|
||||
end
|
||||
end
|
||||
|
||||
rescue ActiveRecord::StaleObjectError
|
||||
|
@ -68,8 +67,6 @@ class PagesController < ApplicationController
|
|||
redirect_to wiki_page_path(@page.permalink)
|
||||
end
|
||||
|
||||
# DELETE /pages/1
|
||||
# DELETE /pages/1.xml
|
||||
def destroy
|
||||
@page = Page.find(params[:id])
|
||||
@page.destroy
|
||||
|
|
1
app/views/pages/_body.html.haml
Normal file
1
app/views/pages/_body.html.haml
Normal file
|
@ -0,0 +1 @@
|
|||
= wikified_body @page.body
|
|
@ -1,3 +1,7 @@
|
|||
- if params[:preview]
|
||||
%h2 Vorschau
|
||||
#preview= render :partial => 'body'
|
||||
|
||||
#wiki-syntax-help{:style => "float:right"}
|
||||
%p
|
||||
%b Schnelle Formatierungshilfe
|
||||
|
@ -25,6 +29,8 @@
|
|||
%br/
|
||||
= f.text_area :body, :size => "60x30"
|
||||
%p
|
||||
= f.submit "Vorschau", :name => 'preview'
|
||||
|
|
||||
= f.submit "Speichern"
|
||||
|
|
||||
= link_to "Abbrechen", :back
|
|
@ -11,7 +11,7 @@
|
|||
= "(#{User.find(version.updated_by).nick})"
|
||||
|
||||
|
||||
= wikified_body @page.body
|
||||
= render :partial => 'body'
|
||||
|
||||
%hr.clear/
|
||||
%p
|
||||
|
|
|
@ -440,3 +440,7 @@ ul.autocomplete .informal {
|
|||
|
||||
a.new_wiki_link {
|
||||
color: grey; }
|
||||
|
||||
#preview {
|
||||
border: 1px dotted grey;
|
||||
padding: 0 1em; }
|
||||
|
|
|
@ -441,6 +441,10 @@ ul.autocomplete .informal {
|
|||
a.new_wiki_link {
|
||||
color: grey; }
|
||||
|
||||
#preview {
|
||||
border: 1px dotted grey;
|
||||
padding: 0 1em; }
|
||||
|
||||
#logininfo, #header, #footer {
|
||||
display: none; }
|
||||
|
||||
|
|
|
@ -487,4 +487,7 @@ ul.autocomplete
|
|||
|
||||
// *** wiki
|
||||
a.new_wiki_link
|
||||
color: grey
|
||||
color: grey
|
||||
#preview
|
||||
border: 1px dotted grey
|
||||
padding: 0 1em
|
Loading…
Reference in a new issue