ChiliProject is not maintained anymore. Please be advised that there will be no more updates.
We do not recommend that you setup new ChiliProject instances and we urge all existing users to migrate their data to a maintained system, e.g. Redmine. We will provide a migration script later. In the meantime, you can use the instructions by Christian Daehn.
tag.patch
| b/app/controllers/wiki_controller.rb | ||
|---|---|---|
| 49 | 49 |
@pages_by_date = @pages.group_by {|p| p.updated_on.to_date}
|
| 50 | 50 |
end |
| 51 | 51 | |
| 52 |
def tag_index |
|
| 53 |
@tags = Tagging.all(:order => 'context',:conditions => ["taggable_type = 'Wiki'"]) |
|
| 54 |
@tags_by_context = @tags.group_by(&:context) |
|
| 55 |
end |
|
| 56 | ||
| 52 | 57 |
# display a page (in editing mode if it doesn't exist) |
| 53 | 58 |
def show |
| 54 | 59 |
page_title = params[:id] |
| ... | ... | |
| 91 | 96 |
@content.text = initial_page_content(@page) if @content.text.blank? |
| 92 | 97 |
# don't keep previous comment |
| 93 | 98 |
@content.comments = nil |
| 99 |
tags = Tagging.find_by_wiki_id(@page.id) |
|
| 100 |
@tag_string = "" |
|
| 101 |
tags.each{ |tag|
|
|
| 102 |
@tag_string += tag.context + ", " |
|
| 103 |
} |
|
| 94 | 104 | |
| 95 | 105 |
# To prevent StaleObjectError exception when reverting to a previous version |
| 96 | 106 |
@content.lock_version = @page.content.lock_version |
| ... | ... | |
| 108 | 118 |
# don't keep previous comment |
| 109 | 119 |
@content.comments = nil |
| 110 | 120 | |
| 111 |
if !@page.new_record? && params[:content].present? && @content.text == params[:content][:text] |
|
| 121 |
if !@page.new_record? && params[:content].present? && @content.text == params[:content][:text] && @tag_string == params[:tags][:tags]
|
|
| 112 | 122 |
attachments = Attachment.attach_files(@page, params[:attachments]) |
| 113 | 123 |
render_attachment_warning_if_needed(@page) |
| 114 | 124 |
# don't save if text wasn't changed |
| ... | ... | |
| 121 | 131 |
# if page is new @page.save will also save content, but not if page isn't a new record |
| 122 | 132 |
if (@page.new_record? ? @page.save : @content.save) |
| 123 | 133 |
attachments = Attachment.attach_files(@page, params[:attachments]) |
| 134 |
tag_change = false |
|
| 135 |
added_tags = [] |
|
| 136 |
params[:tags][:tags].split(",").each{ |tag|
|
|
| 137 |
tag = tag.strip.downcase |
|
| 138 |
next if tag == '' |
|
| 139 |
t = Tagging.find_or_new_tag(tag,"Wiki",@page.id) |
|
| 140 |
if t.new_record? |
|
| 141 |
t.taggable_id = @page.id |
|
| 142 |
t.tagger_id = User.current.id |
|
| 143 |
t.tagger_type = "User" |
|
| 144 |
t.taggable_type = "Wiki" |
|
| 145 |
t.context = tag |
|
| 146 |
t.save |
|
| 147 |
tag_change = true |
|
| 148 |
end |
|
| 149 |
added_tags << tag |
|
| 150 |
} |
|
| 151 |
# Delete Tags that got removed. |
|
| 152 |
tags = Tagging.find_by_wiki_id(@page.id) |
|
| 153 |
tags.each{ |tag|
|
|
| 154 |
if (!added_tags.include?(tag.context)) |
|
| 155 |
tag.delete |
|
| 156 |
tag_change = true |
|
| 157 |
end |
|
| 158 |
} |
|
| 124 | 159 |
render_attachment_warning_if_needed(@page) |
| 125 | 160 |
call_hook(:controller_wiki_edit_after_save, { :params => params, :page => @page})
|
| 126 | 161 |
redirect_to :action => 'show', :project_id => @project, :id => @page.title |
| ... | ... | |
| 128 | 163 |
render :action => 'edit' |
| 129 | 164 |
end |
| 130 | 165 | |
| 166 | ||
| 131 | 167 |
rescue ActiveRecord::StaleObjectError |
| 132 | 168 |
# Optimistic locking exception |
| 133 | 169 |
flash.now[:error] = l(:notice_locking_conflict) |
| ... | ... | |
| 202 | 238 |
return |
| 203 | 239 |
end |
| 204 | 240 |
end |
| 241 |
tags = Tagging.find_by_wiki_id(@page.id) |
|
| 242 |
tags.each{ |tag|
|
|
| 243 |
tag.delete |
|
| 244 |
} |
|
| 205 | 245 |
@page.destroy |
| 206 | 246 |
redirect_to :action => 'index', :project_id => @project |
| 207 | 247 |
end |
| b/app/models/tagging.rb | ||
|---|---|---|
| 1 | ||
| 2 |
class Tagging < ActiveRecord::Base |
|
| 3 |
def self.find_or_new_tag(context, taggable_type, wiki_id) |
|
| 4 |
tag = Tagging.first(:conditions => ["context = ? AND taggable_type = ? AND taggable_id = ?", context, taggable_type, wiki_id]) |
|
| 5 |
tag || Tagging.new() |
|
| 6 |
end |
|
| 7 | ||
| 8 |
def self.find_by_wiki_id(wiki_id) |
|
| 9 |
Tagging.find(:all, :conditions => ["taggable_id = ? AND taggable_type = 'Wiki'", wiki_id]) |
|
| 10 |
end |
|
| 11 |
end |
|
| b/app/views/wiki/_sidebar.rhtml | ||
|---|---|---|
| 7 | 7 |
<%= link_to l(:field_start_page), {:action => 'show', :id => nil} %><br />
|
| 8 | 8 |
<%= link_to l(:label_index_by_title), {:action => 'index'} %><br />
|
| 9 | 9 |
<%= link_to l(:label_index_by_date), {:action => 'date_index'} %><br />
|
| 10 |
<%= link_to l(:label_index_by_tag), {:action => 'tag_index'} %><br />
|
|
| b/app/views/wiki/edit.rhtml | ||
|---|---|---|
| 6 | 6 | |
| 7 | 7 |
<p><%= f.text_area :text, :cols => 100, :rows => 25, :class => 'wiki-edit', :accesskey => accesskey(:edit) %></p> |
| 8 | 8 |
<p><label><%= l(:field_comments) %></label><br /><%= f.text_field :comments, :size => 120 %></p> |
| 9 |
<p><label><%= l(:label_tag) %></label><br /><%= text_field :tags, :tags, :value => @tag_string , :size => 120 %></p> |
|
| 9 | 10 |
<p><label><%=l(:label_attachment_plural)%></label><br /><%= render :partial => 'attachments/form' %></p> |
| 10 | 11 | |
| 11 | 12 |
<p><%= submit_tag l(:button_save) %> |
| b/app/views/wiki/tag_index.html.erb | ||
|---|---|---|
| 1 |
<div class="contextual"> |
|
| 2 |
<%= watcher_link(@wiki, User.current) %> |
|
| 3 |
</div> |
|
| 4 | ||
| 5 |
<h2><%= l(:label_index_by_tag) %></h2> |
|
| 6 | ||
| 7 |
<% if @tags.empty? %> |
|
| 8 |
<p class="nodata"><%= l(:label_no_data) %></p> |
|
| 9 |
<% end %> |
|
| 10 | ||
| 11 |
<% @tags_by_context.keys.sort.each do |context| %> |
|
| 12 |
<h3><%= context %></h3> |
|
| 13 |
<ul> |
|
| 14 |
<% @tags_by_context[context].each do |tag| %> |
|
| 15 |
<% page = WikiPage.find(tag.taggable_id) %> |
|
| 16 |
<li><%= link_to h(page.pretty_title), :action => 'show', :id => page.title, :project_id => page.project %></li> |
|
| 17 |
<% end %> |
|
| 18 |
</ul> |
|
| 19 |
<% end %> |
|
| 20 | ||
| 21 |
<% content_for :sidebar do %> |
|
| 22 |
<%= render :partial => 'sidebar' %> |
|
| 23 |
<% end %> |
|
| 24 | ||
| 25 |
<% unless @tags.empty? %> |
|
| 26 |
<% other_formats_links do |f| %> |
|
| 27 |
<%= f.link_to 'Atom', :url => {:controller => 'activities', :action => 'index', :id => @project, :show_wiki_edits => 1, :key => User.current.rss_key} %>
|
|
| 28 |
<%= f.link_to('HTML', :url => {:action => 'export'}) if User.current.allowed_to?(:export_wiki_pages, @project) %>
|
|
| 29 |
<% end %> |
|
| 30 |
<% end %> |
|
| 31 | ||
| 32 |
<% content_for :header_tags do %> |
|
| 33 |
<%= auto_discovery_link_tag(:atom, :controller => 'activities', :action => 'index', :id => @project, :show_wiki_edits => 1, :format => 'atom', :key => User.current.rss_key) %> |
|
| 34 |
<% end %> |
|
| b/config/locales/en.yml | ||
|---|---|---|
| 674 | 674 |
label_wiki_page_plural: Wiki pages |
| 675 | 675 |
label_index_by_title: Index by title |
| 676 | 676 |
label_index_by_date: Index by date |
| 677 |
label_index_by_tag: Index by tag |
|
| 677 | 678 |
label_current_version: Current version |
| 678 | 679 |
label_preview: Preview |
| 679 | 680 |
label_feed_plural: Feeds |
| b/config/routes.rb | ||
|---|---|---|
| 176 | 176 |
:add_attachment => :post |
| 177 | 177 |
}, :collection => {
|
| 178 | 178 |
:export => :get, |
| 179 |
:date_index => :get |
|
| 179 |
:date_index => :get, |
|
| 180 |
:tag_index => :get |
|
| 180 | 181 |
} |
| 181 | 182 | |
| 182 | 183 |
end |
| b/lib/redmine.rb | ||
|---|---|---|
| 130 | 130 |
map.permission :manage_wiki, {:wikis => [:edit, :destroy]}, :require => :member
|
| 131 | 131 |
map.permission :rename_wiki_pages, {:wiki => :rename}, :require => :member
|
| 132 | 132 |
map.permission :delete_wiki_pages, {:wiki => :destroy}, :require => :member
|
| 133 |
map.permission :view_wiki_pages, :wiki => [:index, :show, :special, :date_index] |
|
| 133 |
map.permission :view_wiki_pages, :wiki => [:index, :show, :special, :date_index, :tag_index]
|
|
| 134 | 134 |
map.permission :export_wiki_pages, :wiki => [:export] |
| 135 | 135 |
map.permission :view_wiki_edits, :wiki => [:history, :diff, :annotate] |
| 136 | 136 |
map.permission :edit_wiki_pages, :wiki => [:edit, :update, :preview, :add_attachment] |
| ... | ... | |
| 337 | 337 |
:param => :project_id, |
| 338 | 338 |
:if => Proc.new { |p| p.wiki && !p.wiki.new_record? }
|
| 339 | 339 |
}) |
| 340 |
menu.push(:wiki_by_tag, { :controller => 'wiki', :action => 'tag_index'}, {
|
|
| 341 |
:caption => :label_index_by_tag, |
|
| 342 |
:parent => :wiki, |
|
| 343 |
:param => :project_id, |
|
| 344 |
:if => Proc.new { |p| p.wiki && !p.wiki.new_record? }
|
|
| 345 |
}) |
|
| 340 | 346 |
menu.push(:boards, { :controller => 'boards', :action => 'index', :id => nil }, {
|
| 341 | 347 |
:param => :project_id, |
| 342 | 348 |
:caption => :label_board_plural, |