forked from Restream/redmine_tagging
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added in-line or external tag edit as a configurable option
- Loading branch information
friflaj
committed
Sep 27, 2010
1 parent
2503419
commit 90262e4
Showing
9 changed files
with
126 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<p> | ||
<%= content_tag(:label, l(:tagging_inline)) %> | ||
<%= check_box_tag("settings[inline]", "1", Setting.plugin_redmine_tagging[:inline] == "1") %> | ||
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# English strings go here for Rails i18n | ||
en: | ||
field_tags: "Tags" | ||
tagging_inline: "Inline editing of tags" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# English strings go here for Rails i18n | ||
nl: | ||
field_tags: "Tags" | ||
tagging_inline: "Tags bewerking in text" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
namespace :redmine do | ||
namespace :tagging do | ||
desc "Reconfigure for inline/separate tag editing" | ||
task :reconfigure => :environment do | ||
|
||
if Setting.plugin_redmine_tagging[:inline] == "1" | ||
puts "Adding inline tags" | ||
|
||
Issue.find(:all).each {|issue| | ||
tag_context = issue.project.identifier.gsub('-', '_') | ||
tags = issue.tag_list_on(tag_context).collect {|tag| tag.gsub(/^#/, '') }.sort.join(', ') | ||
|
||
next if tags.blank? && issue.description.blank? | ||
|
||
tags = "{{tag(#{tags})}}" | ||
|
||
issue.description = '' if issue.description.blank? | ||
issue.description = issue.description.gsub(/[{]{2}tag[(][^)]*[)][}]{2}/i, tags) | ||
issue.description += "\n\n#{tags}" unless issue.description =~ /[{]{2}tag[(][^)]*[)][}]{2}/i | ||
|
||
issue.save! | ||
} | ||
|
||
WikiContent.find(:all).each {|content| | ||
tag_context = content.page.wiki.project.identifier.gsub('-', '_') | ||
tags = content.page.tag_list_on(tag_context).collect {|tag| tag.gsub(/^#/, '') }.sort.join(', ') | ||
|
||
next if tags.blank? && content.text.blank? | ||
|
||
tags = "{{tag(#{tags})}}" | ||
|
||
content.text = '' if content.text.blank? | ||
content.text = content.text.gsub(/[{]{2}tag[(][^)]*[)][}]{2}/i, tags) | ||
content.text += "\n\n#{tags}" unless content.text =~ /[{]{2}tag[(][^)]*[)][}]{2}/i | ||
|
||
content.save! | ||
} | ||
else | ||
puts "Removing inline tags" | ||
Issue.find(:all, :conditions => "lower(description) like '%{{tag(%'").each {|issue| | ||
next if issue.description.blank? | ||
|
||
issue.description = issue.description.gsub(/[{]{2}tag[(][^)]*[)][}]{2}/i, '') | ||
issue.save! | ||
} | ||
|
||
WikiContent.find(:all, :conditions => "lower(text) like '%{{tag(%'").each {|content| | ||
next if content.text.blank? | ||
|
||
content.text = content.text.gsub(/[{]{2}tag[(][^)]*[)][}]{2}/i, '') | ||
content.save! | ||
} | ||
end | ||
|
||
end | ||
end | ||
end |