diff -Nu -urNa redmine.orig/app/controllers/wiki_controller.rb redmine/app/controllers/wiki_controller.rb
--- redmine.orig/app/controllers/wiki_controller.rb 2009-05-20 09:10:12 +0200
+++ redmine/app/controllers/wiki_controller.rb 2009-05-20 08:31:11 +0200
@@ -177,7 +177,12 @@
@pages = @wiki.pages.find :all, :order => 'title'
export = render_to_string :action => 'export_multiple', :layout => false
send_data(export, :type => 'text/html', :filename => "wiki.html")
- return
+ return
+ when 'category'
+ @category = params[:category].gsub(/_/, ' ')
+ @pages = @wiki.find_pages_in_category(@category)
+ when 'category_index'
+ @categories = @wiki.find_all_categories
else
# requested special page doesn't exist, redirect to default page
redirect_to :action => 'index', :id => @project, :page => nil and return
diff -Nu -urNa redmine.orig/app/helpers/application_helper.rb redmine/app/helpers/application_helper.rb
--- redmine.orig/app/helpers/application_helper.rb 2009-05-20 09:10:12 +0200
+++ redmine/app/helpers/application_helper.rb 2009-05-20 08:31:11 +0200
@@ -371,6 +371,32 @@
project = options[:project] || @project || (obj && obj.respond_to?(:project) ? obj.project : nil)
+ # Wiki category links
+ #
+ # Examples:
+ # [[category:mycategory]]
+ # [[category:mycategory|mytext]]
+ # wiki links can refer other project wikis, using project name or identifier:
+ # [[myproject:category:mycategory]]
+ # [[myproject:category:mycategory|mytext]]
+ text = text.gsub(/(!)?(\[\[(?:(.+?):)?category:(.+?)(?:\|(.+?))?\]\])/) do |m|
+ esc, all, link_project, category, title = $1, $2, $3, $4, $5
+ if esc.nil?
+ if link_project.nil?
+ link_project = project
+ else
+ link_project = Project.find_by_name(link_project) || Project.find_by_identifier(link_project)
+ end
+ if link_project && link_project.wiki
+ link_to((title || category), :only_path => only_path, :controller => 'wiki', :id => project, :action => 'special', :page => 'category', :category => Wiki.titleize(category))
+ else
+ all
+ end
+ else
+ '!' + all
+ end
+ end
+
# Wiki links
#
# Examples:
diff -Nu -urNa redmine.orig/app/models/wiki.rb redmine/app/models/wiki.rb
--- redmine.orig/app/models/wiki.rb 2009-05-20 09:10:12 +0200
+++ redmine/app/models/wiki.rb 2009-05-20 08:31:11 +0200
@@ -42,7 +42,27 @@
end
page
end
-
+
+ # Find pages which belong to a certain category.
+ # Special category 'None' contains all pages with no particular category set.
+ def find_pages_in_category(category)
+ if category == 'None'
+ pages.find :all, :conditions => "categories = '' OR categories IS NULL", :order=> 'title'
+ else
+ pages.find :all, :conditions => [ "LOWER(categories) LIKE LOWER(?)", "%|#{category.downcase}|%"], :order=> 'title'
+ end
+ end
+
+ # Traverse all pages and compile a list of categories.
+ def find_all_categories
+ categories = {}
+ groups = pages.find :all, :select => :categories, :conditions => "categories != ''", :group => :categories
+ groups.map {|c| c.categories[1..-2].split('|') }.flatten.sort.each do |g|
+ categories[g.downcase] = g # case insensitive uniq
+ end
+ categories.values
+ end
+
# Finds a page by title
# The given string can be of one of the forms: "title" or "project:title"
# Examples:
@@ -61,13 +81,17 @@
end
end
end
-
+
+ # Upcase only the first letter of a title
+ def self.upcase_first(title='')
+ title = (title.slice(0..0).upcase + (title.slice(1..-1) || '')) if title
+ end
+
# turn a string into a valid page title
def self.titleize(title)
# replace spaces with _ and remove unwanted caracters
title = title.gsub(/\s+/, '_').delete(',./?;|:') if title
- # upcase the first letter
- title = (title.slice(0..0).upcase + (title.slice(1..-1) || '')) if title
+ title = self.upcase_first(title)
title
end
end
diff -Nu -urNa redmine.orig/app/models/wiki_content.rb redmine/app/models/wiki_content.rb
--- redmine.orig/app/models/wiki_content.rb 2009-05-20 09:10:12 +0200
+++ redmine/app/models/wiki_content.rb 2009-05-20 08:48:03 +0200
@@ -23,7 +23,21 @@
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
validates_presence_of :text
validates_length_of :comments, :maximum => 255, :allow_nil => true
-
+
+ def after_save
+ page.categories = categories.join('|')
+ page.categories = '|' + page.categories + '|' if !categories.empty?
+ page.save!
+ end
+
+ def categories
+ if text.match(/\{\{categor(?:y|ies)\((.+?)\)\}\}/)
+ $1.split(/\s*,\s*/).map { |c| Wiki.upcase_first(c) }
+ else
+ []
+ end
+ end
+
acts_as_versioned
def project
diff -Nu -urNa redmine.orig/app/views/wiki/_sidebar.rhtml redmine/app/views/wiki/_sidebar.rhtml
--- redmine.orig/app/views/wiki/_sidebar.rhtml 2009-05-20 09:10:12 +0200
+++ redmine/app/views/wiki/_sidebar.rhtml 2009-05-20 08:31:11 +0200
@@ -3,3 +3,13 @@
<%= link_to l(:field_start_page), {:action => 'index', :page => nil} %>
<%= link_to l(:label_index_by_title), {:action => 'special', :page => 'Page_index'} %>
<%= link_to l(:label_index_by_date), {:action => 'special', :page => 'Date_index'} %>
+<%= link_to l(:label_index_by_category), {:action => 'special', :page => 'Category_index'} %>
+
+<% if wiki_categories = @page.categories.sub(/^\|(.*)\|$/, '\1').split('|') rescue nil %>
+ <% if (!wiki_categories.empty?) %>
+
<%= l((wiki_categories.length==1)?(:label_wiki_category):(:label_wiki_category_plural)) %>
+ <% wiki_categories.sort.each do |category| %>
+ <%= link_to category, {:action => 'special', :page => 'category', :category => Wiki.titleize(category)} %>
+ <% end %>
+ <% end %>
+<% end %>
diff -Nu -urNa redmine.orig/app/views/wiki/special_category.rhtml redmine/app/views/wiki/special_category.rhtml
--- redmine.orig/app/views/wiki/special_category.rhtml 1970-01-01 01:00:00 +0100
+++ redmine/app/views/wiki/special_category.rhtml 2009-05-20 08:31:11 +0200
@@ -0,0 +1,27 @@
+<% if @category == 'None' %>
+ <%= l(:label_pages_without_category) %>
+<% else %>
+ <%= l(:label_wiki_category) %>: <%= @category %>
+<% end %>
+
+<% if @pages.empty? %>
+ <%= l(:label_no_data) %>
+<% end %>
+
+<% content_for :sidebar do %>
+ <%= render :partial => 'sidebar' %>
+<% end %>
+
+<% unless @pages.empty? %>
+
+
+ <% group = nil %>
+ <% @pages.each do |page| %>
+ <% if page.title[0,1].upcase != group %>
+
<%= group = page.title[0,1].upcase %>
+ <% end %>
+ - <%= link_to page.pretty_title, {:action => 'index', :page => page.title} %>
+ <% end %>
+
+
+<% end %>
\ No newline at end of file
diff -Nu -urNa redmine.orig/app/views/wiki/special_category_index.rhtml redmine/app/views/wiki/special_category_index.rhtml
--- redmine.orig/app/views/wiki/special_category_index.rhtml 1970-01-01 01:00:00 +0100
+++ redmine/app/views/wiki/special_category_index.rhtml 2009-05-20 08:31:11 +0200
@@ -0,0 +1,28 @@
+<%= l(:label_index_by_category) %>
+
+<% content_for :sidebar do %>
+ <%= render :partial => 'sidebar' %>
+<% end %>
+
+<% unless @categories.empty? %>
+
+
+ <% group = nil %>
+ <% @categories.each do |category| %>
+ <% if category[0,1].upcase != group %>
+
<%= group = category[0,1].upcase %>
+ <% end %>
+ - <%= link_to category, {:action => 'special', :page => 'category', :category => category} %>
+ <% end %>
+
+
+<% end %>
+
+<%= l(:label_special) %>
+
+
+ -
+ <%= link_to l(:label_pages_without_category), {:action => 'special', :page => 'category', :category => 'None'} %>
+
+
+
\ No newline at end of file
diff -Nu -urNa redmine.orig/config/locales/bg.yml redmine/config/locales/bg.yml
--- redmine.orig/config/locales/bg.yml 2009-05-20 09:10:12 +0200
+++ redmine/config/locales/bg.yml 2009-05-20 08:48:03 +0200
@@ -432,6 +432,11 @@
label_wiki_edit_plural: Wiki редакции
label_wiki_page: Wiki page
label_wiki_page_plural: Wiki pages
+ label_wiki_category: Category
+ label_wiki_category_plural: Categories
+ label_wiki_index_by_category: Index by category
+ label_special: Special
+ label_pages_without_category: Pages without category
label_index_by_title: Индекс
label_index_by_date: Индекс по дата
label_current_version: Текуща версия
diff -Nu -urNa redmine.orig/config/locales/bs.yml redmine/config/locales/bs.yml
--- redmine.orig/config/locales/bs.yml 2009-05-20 09:10:12 +0200
+++ redmine/config/locales/bs.yml 2009-05-20 09:01:40 +0200
@@ -590,6 +590,11 @@
label_wiki_edit_plural: ispravke wiki-ja
label_wiki_page: Wiki stranica
label_wiki_page_plural: Wiki stranice
+ label_wiki_category: Category
+ label_wiki_category_plural: Categories
+ label_wiki_index_by_category: Index by category
+ label_special: Special
+ label_pages_without_category: Pages without category
label_index_by_title: Indeks prema naslovima
label_index_by_date: Indeks po datumima
label_current_version: Tekuća verzija
diff -Nu -urNa redmine.orig/config/locales/ca.yml redmine/config/locales/ca.yml
--- redmine.orig/config/locales/ca.yml 2009-05-20 09:10:12 +0200
+++ redmine/config/locales/ca.yml 2009-05-20 08:48:03 +0200
@@ -561,6 +561,11 @@
label_wiki_edit_plural: Edicions wiki
label_wiki_page: Pàgina wiki
label_wiki_page_plural: Pàgines wiki
+ label_wiki_category: Category
+ label_wiki_category_plural: Categories
+ label_wiki_index_by_category: Index by category
+ label_special: Special
+ label_pages_without_category: Pages without category
label_index_by_title: Índex per títol
label_index_by_date: Índex per data
label_current_version: Versió actual
diff -Nu -urNa redmine.orig/config/locales/cs.yml redmine/config/locales/cs.yml
--- redmine.orig/config/locales/cs.yml 2009-05-20 09:10:12 +0200
+++ redmine/config/locales/cs.yml 2009-05-20 08:48:04 +0200
@@ -490,6 +490,11 @@
label_wiki_edit_plural: Wiki úpravy
label_wiki_page: Wiki stránka
label_wiki_page_plural: Wiki stránky
+ label_wiki_category: Category
+ label_wiki_category_plural: Categories
+ label_wiki_index_by_category: Index by category
+ label_special: Special
+ label_pages_without_category: Pages without category
label_index_by_title: Index dle názvu
label_index_by_date: Index dle data
label_current_version: Aktuální verze
diff -Nu -urNa redmine.orig/config/locales/da.yml redmine/config/locales/da.yml
--- redmine.orig/config/locales/da.yml 2009-05-20 09:10:12 +0200
+++ redmine/config/locales/da.yml 2009-05-20 08:48:04 +0200
@@ -508,6 +508,11 @@
label_wiki_edit_plural: Wiki ændringer
label_wiki_page: Wiki side
label_wiki_page_plural: Wiki sider
+ label_wiki_category: Category
+ label_wiki_category_plural: Categories
+ label_wiki_index_by_category: Index by category
+ label_special: Special
+ label_pages_without_category: Pages without category
label_index_by_title: Indhold efter titel
label_index_by_date: Indhold efter dato
label_current_version: Nuværende version
diff -Nu -urNa redmine.orig/config/locales/de.yml redmine/config/locales/de.yml
--- redmine.orig/config/locales/de.yml 2009-05-20 09:10:12 +0200
+++ redmine/config/locales/de.yml 2009-05-20 08:48:04 +0200
@@ -582,6 +582,11 @@
label_wiki_edit_plural: Wiki-Bearbeitungen
label_wiki_page: Wiki-Seite
label_wiki_page_plural: Wiki-Seiten
+ label_wiki_category: Kategorie
+ label_wiki_category_plural: Kategorien
+ label_index_by_category: Seiten nach Kategorie sortiert
+ label_special: Speziell
+ label_pages_without_category: Seiten ohne Kategorie
label_index_by_title: Seiten nach Titel sortiert
label_index_by_date: Seiten nach Datum sortiert
label_current_version: Gegenwärtige Version
diff -Nu -urNa redmine.orig/config/locales/en.yml redmine/config/locales/en.yml
--- redmine.orig/config/locales/en.yml 2009-05-20 09:10:12 +0200
+++ redmine/config/locales/en.yml 2009-05-20 08:48:04 +0200
@@ -571,6 +571,11 @@
label_wiki_edit_plural: Wiki edits
label_wiki_page: Wiki page
label_wiki_page_plural: Wiki pages
+ label_wiki_category: Category
+ label_wiki_category_plural: Categories
+ label_index_by_category: Index by category
+ label_special: Special
+ label_pages_without_category: Pages without category
label_index_by_title: Index by title
label_index_by_date: Index by date
label_current_version: Current version
diff -Nu -urNa redmine.orig/config/locales/es.yml redmine/config/locales/es.yml
--- redmine.orig/config/locales/es.yml 2009-05-20 09:10:12 +0200
+++ redmine/config/locales/es.yml 2009-05-20 08:48:04 +0200
@@ -637,6 +637,11 @@
label_wiki_edit_plural: Wiki edicciones
label_wiki_page: Wiki página
label_wiki_page_plural: Wiki páginas
+ label_wiki_category: Categoría
+ label_wiki_category_plural: Categorías
+ label_index_by_category: Índice por categoría
+ label_special: Especial
+ label_pages_without_category: Páginas sin categoría
label_workflow: Flujo de trabajo
label_year: Año
label_yesterday: ayer
diff -Nu -urNa redmine.orig/config/locales/fi.yml redmine/config/locales/fi.yml
--- redmine.orig/config/locales/fi.yml 2009-05-20 09:10:12 +0200
+++ redmine/config/locales/fi.yml 2009-05-20 08:48:04 +0200
@@ -497,6 +497,11 @@
label_wiki_edit_plural: Wiki muokkaukset
label_wiki_page: Wiki sivu
label_wiki_page_plural: Wiki sivut
+ label_wiki_category: Category
+ label_wiki_category_plural: Categories
+ label_wiki_index_by_category: Index by category
+ label_special: Special
+ label_pages_without_category: Pages without category
label_index_by_title: Hakemisto otsikoittain
label_index_by_date: Hakemisto päivittäin
label_current_version: Nykyinen versio
diff -Nu -urNa redmine.orig/config/locales/fr.yml redmine/config/locales/fr.yml
--- redmine.orig/config/locales/fr.yml 2009-05-20 09:10:12 +0200
+++ redmine/config/locales/fr.yml 2009-05-20 08:48:04 +0200
@@ -601,6 +601,11 @@
label_wiki_edit_plural: Révisions wiki
label_wiki_page: Page wiki
label_wiki_page_plural: Pages wiki
+ label_wiki_category: Catégorie
+ label_wiki_category_plural: Catégories
+ label_label_index_by_category: Index par catégorie
+ label_special: Spécial
+ label_pages_without_category: Pages sans catégorie
label_index_by_title: Index par titre
label_index_by_date: Index par date
label_current_version: Version actuelle
diff -Nu -urNa redmine.orig/config/locales/gl.yml redmine/config/locales/gl.yml
--- redmine.orig/config/locales/gl.yml 2009-05-20 09:10:12 +0200
+++ redmine/config/locales/gl.yml 2009-05-20 08:48:04 +0200
@@ -616,6 +616,11 @@
label_wiki_edit_plural: Wiki edicións
label_wiki_page: Wiki páxina
label_wiki_page_plural: Wiki páxinas
+ label_wiki_category: Category
+ label_wiki_category_plural: Categories
+ label_wiki_index_by_category: Index by category
+ label_special: Special
+ label_pages_without_category: Pages without category
label_workflow: Fluxo de traballo
label_year: Ano
label_yesterday: onte
diff -Nu -urNa redmine.orig/config/locales/he.yml redmine/config/locales/he.yml
--- redmine.orig/config/locales/he.yml 2009-05-20 09:10:12 +0200
+++ redmine/config/locales/he.yml 2009-05-20 08:48:04 +0200
@@ -452,6 +452,11 @@
label_wiki_edit_plural: עריכות Wiki
label_wiki_page: דף Wiki
label_wiki_page_plural: דפי Wiki
+ label_wiki_category: Category
+ label_wiki_category_plural: Categories
+ label_wiki_index_by_category: Index by category
+ label_special: Special
+ label_pages_without_category: Pages without category
label_index_by_title: סדר על פי כותרת
label_index_by_date: סדר על פי תאריך
label_current_version: גירסא נוכאית
diff -Nu -urNa redmine.orig/config/locales/hu.yml redmine/config/locales/hu.yml
--- redmine.orig/config/locales/hu.yml 2009-05-20 09:10:12 +0200
+++ redmine/config/locales/hu.yml 2009-05-20 08:48:04 +0200
@@ -524,6 +524,11 @@
label_wiki_edit_plural: Wiki szerkesztések
label_wiki_page: Wiki oldal
label_wiki_page_plural: Wiki oldalak
+ label_wiki_category: Category
+ label_wiki_category_plural: Categories
+ label_wiki_index_by_category: Index by category
+ label_special: Special
+ label_pages_without_category: Pages without category
label_index_by_title: Cím szerint indexelve
label_index_by_date: Dátum szerint indexelve
label_current_version: Jelenlegi verzió
diff -Nu -urNa redmine.orig/config/locales/it.yml redmine/config/locales/it.yml
--- redmine.orig/config/locales/it.yml 2009-05-20 09:10:12 +0200
+++ redmine/config/locales/it.yml 2009-05-20 08:48:04 +0200
@@ -450,6 +450,11 @@
label_wiki_edit_plural: Modfiche wiki
label_wiki_page: Pagina Wiki
label_wiki_page_plural: Pagine Wiki
+ label_wiki_category: Category
+ label_wiki_category_plural: Categories
+ label_wiki_index_by_category: Index by category
+ label_special: Special
+ label_pages_without_category: Pages without category
label_index_by_title: Ordina per titolo
label_index_by_date: Ordina per data
label_current_version: Versione corrente
diff -Nu -urNa redmine.orig/config/locales/ja.yml redmine/config/locales/ja.yml
--- redmine.orig/config/locales/ja.yml 2009-05-20 09:10:12 +0200
+++ redmine/config/locales/ja.yml 2009-05-20 08:48:04 +0200
@@ -463,6 +463,11 @@
label_wiki_edit_plural: Wiki編集
label_wiki_page: Wiki page
label_wiki_page_plural: Wikiページ
+ label_wiki_category: Category
+ label_wiki_category_plural: Categories
+ label_wiki_index_by_category: Index by category
+ label_special: Special
+ label_pages_without_category: Pages without category
label_index_by_title: 索引(名前順)
label_index_by_date: 索引(日付順)
label_current_version: 最新版
diff -Nu -urNa redmine.orig/config/locales/ko.yml redmine/config/locales/ko.yml
--- redmine.orig/config/locales/ko.yml 2009-05-20 09:10:12 +0200
+++ redmine/config/locales/ko.yml 2009-05-20 08:48:04 +0200
@@ -501,6 +501,11 @@
label_wiki_edit_plural: 위키 편집
label_wiki_page: 위키
label_wiki_page_plural: 위키
+ label_wiki_category: Category
+ label_wiki_category_plural: Categories
+ label_wiki_index_by_category: Index by category
+ label_special: Special
+ label_pages_without_category: Pages without category
label_index_by_title: 제목별 색인
label_index_by_date: 날짜별 색인
label_current_version: 현재 버전
diff -Nu -urNa redmine.orig/config/locales/lt.yml redmine/config/locales/lt.yml
--- redmine.orig/config/locales/lt.yml 2009-05-20 09:10:12 +0200
+++ redmine/config/locales/lt.yml 2009-05-20 08:48:04 +0200
@@ -592,6 +592,11 @@
label_wiki_edit_plural: Wiki redakcijos
label_wiki_page: Wiki puslapis
label_wiki_page_plural: Wiki puslapiai
+ label_wiki_category: Category
+ label_wiki_category_plural: Categories
+ label_wiki_index_by_category: Index by category
+ label_special: Special
+ label_pages_without_category: Pages without category
label_index_by_title: Indeksas prie pavadinimo
label_index_by_date: Indeksas prie datos
label_current_version: Einamoji versija
diff -Nu -urNa redmine.orig/config/locales/nl.yml redmine/config/locales/nl.yml
--- redmine.orig/config/locales/nl.yml 2009-05-20 09:10:12 +0200
+++ redmine/config/locales/nl.yml 2009-05-20 08:48:04 +0200
@@ -572,6 +572,11 @@
label_wiki_edit_plural: Wiki edits
label_wiki_page: Wikipagina
label_wiki_page_plural: Wikipagina's
+ label_wiki_category: Category
+ label_wiki_category_plural: Categories
+ label_wiki_index_by_category: Index by category
+ label_special: Special
+ label_pages_without_category: Pages without category
label_workflow: Workflow
label_year: Jaar
label_yesterday: gisteren
diff -Nu -urNa redmine.orig/config/locales/no.yml redmine/config/locales/no.yml
--- redmine.orig/config/locales/no.yml 2009-05-20 09:10:12 +0200
+++ redmine/config/locales/no.yml 2009-05-20 08:48:04 +0200
@@ -494,6 +494,11 @@
label_wiki_edit_plural: Wiki endringer
label_wiki_page: Wiki-side
label_wiki_page_plural: Wiki-sider
+ label_wiki_category: Category
+ label_wiki_category_plural: Categories
+ label_wiki_index_by_category: Index by category
+ label_special: Special
+ label_pages_without_category: Pages without category
label_index_by_title: Indekser etter tittel
label_index_by_date: Indekser etter dato
label_current_version: Gjeldende versjon
diff -Nu -urNa redmine.orig/config/locales/pl.yml redmine/config/locales/pl.yml
--- redmine.orig/config/locales/pl.yml 2009-05-20 09:10:12 +0200
+++ redmine/config/locales/pl.yml 2009-05-20 08:48:04 +0200
@@ -617,6 +617,11 @@
label_wiki_edit_plural: Edycje wiki
label_wiki_page: Strona wiki
label_wiki_page_plural: Strony wiki
+ label_wiki_category: Category
+ label_wiki_category_plural: Categories
+ label_wiki_index_by_category: Index by category
+ label_special: Special
+ label_pages_without_category: Pages without category
label_workflow: Przepływ
label_year: Rok
label_yesterday: wczoraj
diff -Nu -urNa redmine.orig/config/locales/pt-BR.yml redmine/config/locales/pt-BR.yml
--- redmine.orig/config/locales/pt-BR.yml 2009-05-20 09:10:12 +0200
+++ redmine/config/locales/pt-BR.yml 2009-05-20 08:48:04 +0200
@@ -532,6 +532,11 @@
label_wiki_edit_plural: Edições Wiki
label_wiki_page: Página Wiki
label_wiki_page_plural: páginas Wiki
+ label_wiki_category: Category
+ label_wiki_category_plural: Categories
+ label_wiki_index_by_category: Index by category
+ label_special: Special
+ label_pages_without_category: Pages without category
label_index_by_title: Índice por título
label_index_by_date: Índice por data
label_current_version: Versão atual
diff -Nu -urNa redmine.orig/config/locales/pt.yml redmine/config/locales/pt.yml
--- redmine.orig/config/locales/pt.yml 2009-05-20 09:10:12 +0200
+++ redmine/config/locales/pt.yml 2009-05-20 08:48:04 +0200
@@ -521,6 +521,11 @@
label_wiki_edit_plural: Edições da Wiki
label_wiki_page: Página da Wiki
label_wiki_page_plural: Páginas da Wiki
+ label_wiki_category: Category
+ label_wiki_category_plural: Categories
+ label_wiki_index_by_category: Index by category
+ label_special: Special
+ label_pages_without_category: Pages without category
label_index_by_title: Índice por título
label_index_by_date: Índice por data
label_current_version: Versão actual
diff -Nu -urNa redmine.orig/config/locales/ro.yml redmine/config/locales/ro.yml
--- redmine.orig/config/locales/ro.yml 2009-05-20 09:10:12 +0200
+++ redmine/config/locales/ro.yml 2009-05-20 08:48:04 +0200
@@ -559,6 +559,11 @@
label_wiki_edit_plural: Editari Wiki
label_wiki_page: Pagina Wiki
label_wiki_page_plural: Pagini Wiki
+ label_wiki_category: Category
+ label_wiki_category_plural: Categories
+ label_wiki_index_by_category: Index by category
+ label_special: Special
+ label_pages_without_category: Pages without category
label_index_by_title: Sorteaza dupa titlu
label_index_by_date: Sorteaza dupa data
label_current_version: Versiunea curenta
diff -Nu -urNa redmine.orig/config/locales/ru.yml redmine/config/locales/ru.yml
--- redmine.orig/config/locales/ru.yml 2009-05-20 09:10:12 +0200
+++ redmine/config/locales/ru.yml 2009-05-20 08:48:04 +0200
@@ -699,6 +699,11 @@
label_wiki_edit_plural: Wiki
label_wiki_page: Страница Wiki
label_wiki_page_plural: Страницы Wiki
+ label_wiki_category: Category
+ label_wiki_category_plural: Categories
+ label_wiki_index_by_category: Index by category
+ label_special: Special
+ label_pages_without_category: Pages without category
label_workflow: Последовательность действий
label_x_closed_issues_abbr:
zero: 0 закрыто
diff -Nu -urNa redmine.orig/config/locales/sk.yml redmine/config/locales/sk.yml
--- redmine.orig/config/locales/sk.yml 2009-05-20 09:10:12 +0200
+++ redmine/config/locales/sk.yml 2009-05-20 08:48:04 +0200
@@ -488,6 +488,11 @@
label_wiki_edit_plural: Wiki úpravy
label_wiki_page: Wiki stránka
label_wiki_page_plural: Wiki stránky
+ label_wiki_category: Category
+ label_wiki_category_plural: Categories
+ label_wiki_index_by_category: Index by category
+ label_special: Special
+ label_pages_without_category: Pages without category
label_index_by_title: Index podľa názvu
label_index_by_date: Index podľa dátumu
label_current_version: Aktuálna verzia
diff -Nu -urNa redmine.orig/config/locales/sl.yml redmine/config/locales/sl.yml
--- redmine.orig/config/locales/sl.yml 2009-05-20 09:10:12 +0200
+++ redmine/config/locales/sl.yml 2009-05-20 08:48:04 +0200
@@ -551,6 +551,11 @@
label_wiki_edit_plural: Wiki urejanja
label_wiki_page: Wiki stran
label_wiki_page_plural: Wiki strani
+ label_wiki_category: Category
+ label_wiki_category_plural: Categories
+ label_wiki_index_by_category: Index by category
+ label_special: Special
+ label_pages_without_category: Pages without category
label_index_by_title: Razvrsti po naslovu
label_index_by_date: Razvrsti po datumu
label_current_version: Trenutna verzija
diff -Nu -urNa redmine.orig/config/locales/sr.yml redmine/config/locales/sr.yml
--- redmine.orig/config/locales/sr.yml 2009-05-20 09:10:12 +0200
+++ redmine/config/locales/sr.yml 2009-05-20 08:48:04 +0200
@@ -468,6 +468,11 @@
label_wiki_edit_plural: Wiki promene
label_wiki_page: Wiki stranica
label_wiki_page_plural: Wiki stranice
+ label_wiki_category: Category
+ label_wiki_category_plural: Categories
+ label_wiki_index_by_category: Index by category
+ label_special: Special
+ label_pages_without_category: Pages without category
label_index_by_title: Indeks po naslovima
label_index_by_date: Indeks po datumu
label_current_version: Trenutna verzija
diff -Nu -urNa redmine.orig/config/locales/sv.yml redmine/config/locales/sv.yml
--- redmine.orig/config/locales/sv.yml 2009-05-20 09:10:12 +0200
+++ redmine/config/locales/sv.yml 2009-05-20 08:48:04 +0200
@@ -628,6 +628,11 @@
label_wiki_edit_plural: Wikiändringar
label_wiki_page: Wikisida
label_wiki_page_plural: Wikisidor
+ label_wiki_category: Category
+ label_wiki_category_plural: Categories
+ label_wiki_index_by_category: Index by category
+ label_special: Special
+ label_pages_without_category: Pages without category
label_index_by_title: Innehåll efter titel
label_index_by_date: Innehåll efter datum
label_current_version: Nuvarande version
diff -Nu -urNa redmine.orig/config/locales/th.yml redmine/config/locales/th.yml
--- redmine.orig/config/locales/th.yml 2009-05-20 09:10:12 +0200
+++ redmine/config/locales/th.yml 2009-05-20 08:48:04 +0200
@@ -488,6 +488,11 @@
label_wiki_edit_plural: แก้ไข Wiki
label_wiki_page: หน้า Wiki
label_wiki_page_plural: หน้า Wiki
+ label_wiki_category: Category
+ label_wiki_category_plural: Categories
+ label_wiki_index_by_category: Index by category
+ label_special: Special
+ label_pages_without_category: Pages without category
label_index_by_title: เรียงตามชื่อเรื่อง
label_index_by_date: เรียงตามวัน
label_current_version: รุ่นปัจจุบัน
diff -Nu -urNa redmine.orig/config/locales/tr.yml redmine/config/locales/tr.yml
--- redmine.orig/config/locales/tr.yml 2009-05-20 09:10:12 +0200
+++ redmine/config/locales/tr.yml 2009-05-20 08:48:04 +0200
@@ -523,6 +523,11 @@
label_wiki_edit_plural: Wiki düzenlemeleri
label_wiki_page: Wiki sayfası
label_wiki_page_plural: Wiki sayfaları
+ label_wiki_category: Category
+ label_wiki_category_plural: Categories
+ label_wiki_index_by_category: Index by category
+ label_special: Special
+ label_pages_without_category: Pages without category
label_index_by_title: Başlığa göre diz
label_index_by_date: Tarihe göre diz
label_current_version: Güncel versiyon
diff -Nu -urNa redmine.orig/config/locales/uk.yml redmine/config/locales/uk.yml
--- redmine.orig/config/locales/uk.yml 2009-05-20 09:10:12 +0200
+++ redmine/config/locales/uk.yml 2009-05-20 08:48:04 +0200
@@ -448,6 +448,11 @@
label_wiki_edit_plural: Редагування Wiki
label_wiki_page: Сторінка Wiki
label_wiki_page_plural: Сторінки Wiki
+ label_wiki_category: Category
+ label_wiki_category_plural: Categories
+ label_wiki_index_by_category: Index by category
+ label_special: Special
+ label_pages_without_category: Pages without category
label_index_by_title: Індекс за назвою
label_index_by_date: Індекс за датою
label_current_version: Поточна версія
diff -Nu -urNa redmine.orig/config/locales/vi.yml redmine/config/locales/vi.yml
--- redmine.orig/config/locales/vi.yml 2009-05-20 09:10:12 +0200
+++ redmine/config/locales/vi.yml 2009-05-20 08:48:04 +0200
@@ -567,6 +567,11 @@
label_wiki_edit_plural: Thay đổi wiki
label_wiki_page: Trang wiki
label_wiki_page_plural: Trang wiki
+ label_wiki_category: Category
+ label_wiki_category_plural: Categories
+ label_wiki_index_by_category: Index by category
+ label_special: Special
+ label_pages_without_category: Pages without category
label_index_by_title: Danh sách theo tên
label_index_by_date: Danh sách theo ngày
label_current_version: Bản hiện tại
diff -Nu -urNa redmine.orig/config/locales/zh-TW.yml redmine/config/locales/zh-TW.yml
--- redmine.orig/config/locales/zh-TW.yml 2009-05-20 09:10:12 +0200
+++ redmine/config/locales/zh-TW.yml 2009-05-20 08:48:04 +0200
@@ -678,6 +678,11 @@
label_wiki_edit_plural: Wiki 編輯
label_wiki_page: Wiki 網頁
label_wiki_page_plural: Wiki 網頁
+ label_wiki_category: Category
+ label_wiki_category_plural: Categories
+ label_wiki_index_by_category: Index by category
+ label_special: Special
+ label_pages_without_category: Pages without category
label_index_by_title: 依標題索引
label_index_by_date: 依日期索引
label_current_version: 現行版本
diff -Nu -urNa redmine.orig/config/locales/zh.yml redmine/config/locales/zh.yml
--- redmine.orig/config/locales/zh.yml 2009-05-20 09:10:12 +0200
+++ redmine/config/locales/zh.yml 2009-05-20 08:48:04 +0200
@@ -602,6 +602,11 @@
label_wiki_edit_plural: Wiki 编辑记录
label_wiki_page: Wiki 页面
label_wiki_page_plural: Wiki 页面
+ label_wiki_category: Category
+ label_wiki_category_plural: Categories
+ label_wiki_index_by_category: Index by category
+ label_special: Special
+ label_pages_without_category: Pages without category
label_index_by_title: 按标题索引
label_index_by_date: 按日期索引
label_current_version: 当前版本
diff -Nu -urNa redmine.orig/config/routes.rb redmine/config/routes.rb
--- redmine.orig/config/routes.rb 2009-05-20 09:10:12 +0200
+++ redmine/config/routes.rb 2009-05-20 08:31:11 +0200
@@ -54,13 +54,14 @@
map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :post}
map.with_options :controller => 'wiki' do |wiki_routes|
wiki_routes.with_options :conditions => {:method => :get} do |wiki_views|
- wiki_views.connect 'projects/:id/wiki/:page', :action => 'special', :page => /page_index|date_index|export/i
+ wiki_views.connect 'projects/:id/wiki/:page', :action => 'special', :page => /page_index|date_index|category_index|export/i
wiki_views.connect 'projects/:id/wiki/:page', :action => 'index', :page => nil
wiki_views.connect 'projects/:id/wiki/:page/edit', :action => 'edit'
wiki_views.connect 'projects/:id/wiki/:page/rename', :action => 'rename'
wiki_views.connect 'projects/:id/wiki/:page/history', :action => 'history'
wiki_views.connect 'projects/:id/wiki/:page/diff/:version/vs/:version_from', :action => 'diff'
wiki_views.connect 'projects/:id/wiki/:page/annotate/:version', :action => 'annotate'
+ wiki_views.connect 'projects/:id/wiki/category/:category', :action => 'special', :page => 'category'
end
wiki_routes.connect 'projects/:id/wiki/:page/:action',
diff -Nu -urNa redmine.orig/db/migrate/20090516170318_add_wiki_pages_categories.rb redmine/db/migrate/20090516170318_add_wiki_pages_categories.rb
--- redmine.orig/db/migrate/20090516170318_add_wiki_pages_categories.rb 1970-01-01 01:00:00 +0100
+++ redmine/db/migrate/20090516170318_add_wiki_pages_categories.rb 2009-05-20 08:31:11 +0200
@@ -0,0 +1,9 @@
+class AddWikiPagesCategories < ActiveRecord::Migration
+ def self.up
+ add_column :wiki_pages, :categories, :string
+ end
+
+ def self.down
+ remove_column :wiki_pages, :categories
+ end
+end
\ No newline at end of file
diff -Nu -urNa redmine.orig/lib/redmine/wiki_formatting/macros.rb redmine/lib/redmine/wiki_formatting/macros.rb
--- redmine.orig/lib/redmine/wiki_formatting/macros.rb 2009-05-20 09:10:13 +0200
+++ redmine/lib/redmine/wiki_formatting/macros.rb 2009-05-20 08:31:12 +0200
@@ -116,6 +116,29 @@
@included_wiki_pages.pop
out
end
+
+ desc "Add the current wiki page to a category.\nExample: !{{category(Help)}}"
+ macro :category do |obj, args|
+ '' # categories are listed in the sidebar
+ end
+
+ desc "Add the current wiki page to several categories.\nExample: !{{categories(Help, Snippets)}}"
+ macro :categories do |obj, args|
+ '' # categories are listed in the sidebar
+ end
+
+ desc "Display a list of pages which belong to the specified category.\nExample: !{{pages_in_category(Help)}}"
+ macro :pages_in_category do |obj, args|
+ if !args.first.nil?
+ content_tag :ul, :class => :pages_in_category do
+ @wiki.find_pages_in_category(args.first).map do |p|
+ content_tag :li do
+ link_to p.pretty_title, {:action => 'index', :page => p.title}
+ end
+ end
+ end
+ end
+ end
end
end
end
--- redmine.orig/test/fixtures/wiki_pages.yml 2009-05-20 09:10:13 +0200
+++ redmine/test/fixtures/wiki_pages.yml 2009-05-20 08:31:12 +0200
@@ -6,6 +6,7 @@
wiki_id: 1
protected: true
parent_id:
+ categories: |Examples|Documentation|
wiki_pages_002:
created_on: 2007-03-08 00:18:07 +01:00
title: Another_page
@@ -13,6 +14,7 @@
wiki_id: 1
protected: false
parent_id:
+ categories:
wiki_pages_003:
created_on: 2007-03-08 00:18:07 +01:00
title: Start_page
@@ -20,6 +22,7 @@
wiki_id: 2
protected: false
parent_id:
+ categories:
wiki_pages_004:
created_on: 2007-03-08 00:18:07 +01:00
title: Page_with_an_inline_image
@@ -27,6 +30,7 @@
wiki_id: 1
protected: false
parent_id: 1
+ categories: |Examples|
wiki_pages_005:
created_on: 2007-03-08 00:18:07 +01:00
title: Child_1
@@ -34,6 +38,7 @@
wiki_id: 1
protected: false
parent_id: 2
+ categories: |Examples|
wiki_pages_006:
created_on: 2007-03-08 00:18:07 +01:00
title: Child_2
@@ -41,4 +46,4 @@
wiki_id: 1
protected: false
parent_id: 2
-
\ No newline at end of file
+ categories: |Examples|
diff -Nu -urNa redmine.orig/test/functional/wiki_controller_test.rb redmine/test/functional/wiki_controller_test.rb
--- redmine.orig/test/functional/wiki_controller_test.rb 2009-05-20 09:10:13 +0200
+++ redmine/test/functional/wiki_controller_test.rb 2009-05-20 08:31:12 +0200
@@ -298,6 +298,14 @@
:controller => 'wiki', :action => 'special', :id => '567', :page => 'date_index'
)
assert_routing(
+ {:method => :get, :path => '/projects/567/wiki/category_index'},
+ :controller => 'wiki', :action => 'special', :id => '567', :page => 'category_index'
+ )
+ assert_routing(
+ {:method => :get, :path => '/projects/567/wiki/category/Test'},
+ :controller => 'wiki', :action => 'special', :id => '567', :page => 'category', :category => 'Test'
+ )
+ assert_routing(
{:method => :get, :path => '/projects/567/wiki/export'},
:controller => 'wiki', :action => 'special', :id => '567', :page => 'export'
)
diff -Nu -urNa redmine.orig/test/unit/helpers/application_helper_test.rb redmine/test/unit/helpers/application_helper_test.rb
--- redmine.orig/test/unit/helpers/application_helper_test.rb 2009-05-20 09:10:13 +0200
+++ redmine/test/unit/helpers/application_helper_test.rb 2009-05-20 08:31:12 +0200
@@ -206,6 +206,14 @@
# project does not exist
'[[unknowproject:Start]]' => '[[unknowproject:Start]]',
'[[unknowproject:Start|Page title]]' => '[[unknowproject:Start|Page title]]',
+ # categories
+ '[[category:Test]]' => 'Test',
+ '[[category:Test|Text]]' => 'Text',
+ '[[ecookbook:category:Test]]' => 'Test',
+ '[[ecookbook:category:Test|Text]]' => 'Text',
+ '[[unknownproject:category:Test]]' => '[[unknownproject:category:Test]]',
+ '[[unknownproject:category:Test|Text]]' => '[[unknownproject:category:Test|Text]]',
+ '![[category:Test]]' => '[[category:Test]]',
}
@project = Project.find(1)
to_test.each { |text, result| assert_equal "#{result}
", textilizable(text) }
diff -Nu -urNa redmine.orig/test/unit/wiki_content_test.rb redmine/test/unit/wiki_content_test.rb
--- redmine.orig/test/unit/wiki_content_test.rb 2009-05-20 09:10:13 +0200
+++ redmine/test/unit/wiki_content_test.rb 2009-05-20 08:48:04 +0200
@@ -27,7 +27,7 @@
def test_create
page = WikiPage.new(:wiki => @wiki, :title => "Page")
- page.content = WikiContent.new(:text => "Content text", :author => User.find(1), :comments => "My comment")
+ page.content = WikiContent.new(:text => "{{category(Test)}}Content text", :author => User.find(1), :comments => "My comment")
assert page.save
page.reload
@@ -35,7 +35,8 @@
assert_kind_of WikiContent, content
assert_equal 1, content.version
assert_equal 1, content.versions.length
- assert_equal "Content text", content.text
+ assert_equal "{{category(Test)}}Content text", content.text
+ assert_equal "|Test|", content.page.categories
assert_equal "My comment", content.comments
assert_equal User.find(1), content.author
assert_equal content.text, content.versions.last.text
diff -Nu -urNa redmine.orig/test/unit/wiki_test.rb redmine/test/unit/wiki_test.rb
--- redmine.orig/test/unit/wiki_test.rb 2009-05-20 09:10:13 +0200
+++ redmine/test/unit/wiki_test.rb 2009-05-20 08:31:12 +0200
@@ -19,15 +19,15 @@
class WikiTest < Test::Unit::TestCase
fixtures :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions
-
- def test_create
+
+ def test_create
wiki = Wiki.new(:project => Project.find(2))
assert !wiki.save
assert_equal 1, wiki.errors.count
- wiki.start_page = "Start page"
- assert wiki.save
- end
+ wiki.start_page = "Start page"
+ assert wiki.save
+ end
def test_update
@wiki = Wiki.find(1)
@@ -41,4 +41,21 @@
assert_equal 'Page_title_with_CAPITALES', Wiki.titleize('page title with CAPITALES')
assert_equal 'テスト', Wiki.titleize('テスト')
end
+
+ def test_upcase_first
+ assert_equal 'Page title', Wiki.upcase_first('page title')
+ assert_equal 'テスト', Wiki.titleize('テスト')
+ end
+
+ def test_find_categories
+ @wiki = Wiki.find(1)
+ assert_equal ['Examples', 'Documentation'], @wiki.find_all_categories
+ end
+
+ def test_find_pages_in_category
+ @wiki = Wiki.find(1)
+ assert_equal [1], @wiki.find_pages_in_category('Documentation').map {|c| c.id }.sort
+ assert_equal [1, 4, 5, 6], @wiki.find_pages_in_category('Examples').map {|c| c.id }.sort
+ assert_equal [2], @wiki.find_pages_in_category('None').map {|c| c.id }.sort
+ end
end