mirror of
https://github.com/meineerde/redmine.git
synced 2026-03-11 19:53:07 +00:00
added "preview" functionality when editing wiki page
git-svn-id: http://redmine.rubyforge.org/svn/branches/work@306 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
67b92ae1df
commit
46b13d9f4a
@ -17,7 +17,7 @@
|
||||
|
||||
class WikiController < ApplicationController
|
||||
layout 'base'
|
||||
before_filter :find_wiki, :check_project_privacy
|
||||
before_filter :find_wiki, :check_project_privacy, :except => [:preview]
|
||||
|
||||
# display a page (in editing mode if it doesn't exist)
|
||||
def index
|
||||
@ -88,6 +88,11 @@ class WikiController < ApplicationController
|
||||
end
|
||||
render :action => "special_#{page_title}"
|
||||
end
|
||||
|
||||
def preview
|
||||
@text = params[:content][:text]
|
||||
render :partial => 'preview'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
|
||||
@ -100,10 +100,14 @@ module ApplicationHelper
|
||||
when :anchor
|
||||
wiki_link_format = '"#" + Wiki.titleize($1)'
|
||||
else
|
||||
wiki_link_format = '"/wiki/#{@project.id}/#{Wiki.titleize($1)}"'
|
||||
if @project.nil?
|
||||
wiki_link_format = 'Wiki.titleize($1)'
|
||||
else
|
||||
wiki_link_format = '"/wiki/#{@project.id}/#{Wiki.titleize($1)}"'
|
||||
end
|
||||
end
|
||||
# turn wiki links in textile links: "text":url
|
||||
text = text.gsub(/\[\[([^\]\|]+)(\|([^\]\|]+))?\]\]/) {|m| "\"#{$3 || $1}\":" + (eval wiki_link_format) } if @project
|
||||
text = text.gsub(/\[\[([^\]\|]+)(\|([^\]\|]+))?\]\]/) {|m| "\"#{$3 || $1}\":" + (eval wiki_link_format) }
|
||||
text = (Setting.text_formatting == 'textile') && (ActionView::Helpers::TextHelper.method_defined? "textilize") ? auto_link(RedCloth.new(text, [:filter_html]).to_html) : simple_format(auto_link(h(text)))
|
||||
# turn "#id" patterns into links to issues
|
||||
text = text.gsub(/#(\d+)([^;\d])/, "<a href='/issues/show/\\1'>#\\1</a>\\2")
|
||||
|
||||
3
wiki/app/views/wiki/_preview.rhtml
Normal file
3
wiki/app/views/wiki/_preview.rhtml
Normal file
@ -0,0 +1,3 @@
|
||||
<fieldset><legend><%= l(:label_preview) %></legend>
|
||||
<%= textilizable @text %>
|
||||
</fieldset>
|
||||
@ -4,11 +4,20 @@
|
||||
|
||||
<h2><%= @page.pretty_title %></h2>
|
||||
|
||||
<% form_for :content, @content, :url => {:action => 'edit', :page => @page.title} do |f| %>
|
||||
<% form_for :content, @content, :url => {:action => 'edit', :page => @page.title}, :html => {:id => 'wiki_form'} do |f| %>
|
||||
<%= error_messages_for 'content' %>
|
||||
<p><%= f.text_area :text, :cols => 100, :rows => 25 %></p>
|
||||
<p><%= f.text_area :text, :cols => 100, :rows => 25, :style => "width:99%;" %></p>
|
||||
<p><label><%= l(:field_comment) %></label><br /><%= f.text_field :comment, :size => 120 %></p>
|
||||
<p><%= submit_tag l(:button_save) %></p>
|
||||
<p><%= submit_tag l(:button_save) %>
|
||||
<%= link_to_remote l(:label_preview),
|
||||
{ :url => { :controller => 'wiki', :action => 'preview' },
|
||||
:method => 'get',
|
||||
:update => 'preview',
|
||||
:with => "Form.serialize('wiki_form')",
|
||||
:complete => visual_effect(:highlight, 'preview')
|
||||
} %>
|
||||
</p>
|
||||
|
||||
<% end %>
|
||||
|
||||
<% if Setting.text_formatting == 'textile' %>
|
||||
@ -23,4 +32,6 @@ if (document.getElementById) {
|
||||
}
|
||||
//]]>
|
||||
</script>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<div id="preview" class="wiki"></div>
|
||||
@ -323,6 +323,7 @@ label_result_plural: %d Resultate
|
||||
label_wiki: Wiki
|
||||
label_page_index: Index
|
||||
label_current_version: Gegenwärtige Version
|
||||
label_preview: Vorbetrachtung
|
||||
|
||||
button_login: Einloggen
|
||||
button_submit: Einreichen
|
||||
|
||||
@ -323,6 +323,7 @@ label_result_plural: %d results
|
||||
label_wiki: Wiki
|
||||
label_page_index: Index
|
||||
label_current_version: Current version
|
||||
label_preview: Preview
|
||||
|
||||
button_login: Login
|
||||
button_submit: Submit
|
||||
|
||||
@ -323,6 +323,7 @@ label_result_plural: %d resultados
|
||||
label_wiki: Wiki
|
||||
label_page_index: Índice
|
||||
label_current_version: Versión actual
|
||||
label_preview: Previo
|
||||
|
||||
button_login: Conexión
|
||||
button_submit: Someter
|
||||
|
||||
@ -323,6 +323,7 @@ label_result_plural: %d résultats
|
||||
label_wiki: Wiki
|
||||
label_page_index: Index
|
||||
label_current_version: Version actuelle
|
||||
label_preview: Prévisualisation
|
||||
|
||||
button_login: Connexion
|
||||
button_submit: Soumettre
|
||||
|
||||
@ -324,6 +324,7 @@ label_result_plural: %d results
|
||||
label_wiki: Wiki
|
||||
label_page_index: 索引
|
||||
label_current_version: 最近版
|
||||
label_preview: 下検分
|
||||
|
||||
button_login: ログイン
|
||||
button_submit: 変更
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user