wiki_page_categories_20090520.patch

Patch for the pull request on Github on 2009-05-20 - Sven Schwyn, 2009-05-20 09:11

Download (39.4 KB)

View differences:

redmine/app/controllers/wiki_controller.rb 2009-05-20 08:31:11 +0200
177 177
      @pages = @wiki.pages.find :all, :order => 'title'
178 178
      export = render_to_string :action => 'export_multiple', :layout => false
179 179
      send_data(export, :type => 'text/html', :filename => "wiki.html")
180
      return      
180
      return
181
    when 'category'
182
      @category = params[:category].gsub(/_/, ' ')
183
      @pages = @wiki.find_pages_in_category(@category)
184
    when 'category_index'
185
      @categories = @wiki.find_all_categories
181 186
    else
182 187
      # requested special page doesn't exist, redirect to default page
183 188
      redirect_to :action => 'index', :id => @project, :page => nil and return
redmine/app/helpers/application_helper.rb 2009-05-20 08:31:11 +0200
371 371

  
372 372
    project = options[:project] || @project || (obj && obj.respond_to?(:project) ? obj.project : nil)
373 373

  
374
    # Wiki category links
375
    #
376
    # Examples:
377
    #   [[category:mycategory]]
378
    #   [[category:mycategory|mytext]]
379
    # wiki links can refer other project wikis, using project name or identifier:
380
    #   [[myproject:category:mycategory]]
381
    #   [[myproject:category:mycategory|mytext]]
382
    text = text.gsub(/(!)?(\[\[(?:(.+?):)?category:(.+?)(?:\|(.+?))?\]\])/) do |m|
383
      esc, all, link_project, category, title = $1, $2, $3, $4, $5
384
      if esc.nil?
385
        if link_project.nil?
386
          link_project = project
387
        else
388
          link_project = Project.find_by_name(link_project) || Project.find_by_identifier(link_project)
389
        end
390
        if link_project && link_project.wiki
391
          link_to((title || category), :only_path => only_path, :controller => 'wiki', :id => project, :action => 'special', :page => 'category', :category => Wiki.titleize(category))
392
        else
393
          all
394
        end
395
      else
396
        '!' + all
397
      end
398
    end
399

  
374 400
    # Wiki links
375 401
    #
376 402
    # Examples:
redmine/app/models/wiki.rb 2009-05-20 08:31:11 +0200
42 42
    end
43 43
    page
44 44
  end
45
  
45

  
46
  # Find pages which belong to a certain category.
47
  # Special category 'None' contains all pages with no particular category set.
48
  def find_pages_in_category(category)
49
    if category == 'None'
50
      pages.find :all, :conditions => "categories = '' OR categories IS NULL", :order=> 'title'
51
    else
52
      pages.find :all, :conditions => [ "LOWER(categories) LIKE LOWER(?)", "%|#{category.downcase}|%"], :order=> 'title'
53
    end
54
  end
55

  
56
  # Traverse all pages and compile a list of categories.
57
  def find_all_categories
58
    categories = {}
59
    groups = pages.find :all, :select => :categories, :conditions => "categories != ''", :group => :categories
60
    groups.map {|c| c.categories[1..-2].split('|') }.flatten.sort.each do |g|
61
      categories[g.downcase] = g   # case insensitive uniq
62
    end
63
    categories.values
64
  end
65

  
46 66
  # Finds a page by title
47 67
  # The given string can be of one of the forms: "title" or "project:title"
48 68
  # Examples:
......
61 81
      end
62 82
    end
63 83
  end
64
  
84

  
85
  # Upcase only the first letter of a title
86
  def self.upcase_first(title='')
87
    title = (title.slice(0..0).upcase + (title.slice(1..-1) || '')) if title
88
  end
89

  
65 90
  # turn a string into a valid page title
66 91
  def self.titleize(title)
67 92
    # replace spaces with _ and remove unwanted caracters
68 93
    title = title.gsub(/\s+/, '_').delete(',./?;|:') if title
69
    # upcase the first letter
70
    title = (title.slice(0..0).upcase + (title.slice(1..-1) || '')) if title
94
    title = self.upcase_first(title)
71 95
    title
72 96
  end  
73 97
end
redmine/app/models/wiki_content.rb 2009-05-20 08:48:03 +0200
23 23
  belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
24 24
  validates_presence_of :text
25 25
  validates_length_of :comments, :maximum => 255, :allow_nil => true
26
  
26

  
27
  def after_save
28
    page.categories = categories.join('|')
29
    page.categories = '|' + page.categories + '|' if !categories.empty? 
30
    page.save!
31
  end
32

  
33
  def categories
34
    if text.match(/\{\{categor(?:y|ies)\((.+?)\)\}\}/)
35
      $1.split(/\s*,\s*/).map { |c| Wiki.upcase_first(c) }
36
    else
37
      []
38
    end
39
  end
40

  
27 41
  acts_as_versioned
28 42
    
29 43
  def project
redmine/app/views/wiki/_sidebar.rhtml 2009-05-20 08:31:11 +0200
3 3
<%= link_to l(:field_start_page), {:action => 'index', :page => nil} %><br />
4 4
<%= link_to l(:label_index_by_title), {:action => 'special', :page => 'Page_index'} %><br />
5 5
<%= link_to l(:label_index_by_date), {:action => 'special', :page => 'Date_index'} %><br />
6
<%= link_to l(:label_index_by_category), {:action => 'special', :page => 'Category_index'} %><br />
7

  
8
<% if wiki_categories = @page.categories.sub(/^\|(.*)\|$/, '\1').split('|') rescue nil %>
9
  <% if (!wiki_categories.empty?) %>
10
    <h3><%= l((wiki_categories.length==1)?(:label_wiki_category):(:label_wiki_category_plural)) %></h3>
11
    <% wiki_categories.sort.each do |category| %>
12
      <%= link_to category, {:action => 'special', :page => 'category', :category => Wiki.titleize(category)} %><br />
13
    <% end %>
14
  <% end %>
15
<% end %>
redmine/app/views/wiki/special_category.rhtml 2009-05-20 08:31:11 +0200
1
<% if @category == 'None' %>
2
  <h2><%= l(:label_pages_without_category) %></h2>
3
<% else %>
4
  <h2><%= l(:label_wiki_category) %>: <%= @category %></h2>
5
<% end %>
6

  
7
<% if @pages.empty? %>
8
  <p class="nodata"><%= l(:label_no_data) %></p>
9
<% end %>
10

  
11
<% content_for :sidebar do %>
12
  <%= render :partial => 'sidebar' %>
13
<% end %>
14

  
15
<% unless @pages.empty? %>
16
  <p>
17
    <ul>
18
      <% group = nil %>
19
      <% @pages.each do |page| %>
20
        <% if page.title[0,1].upcase != group %>
21
          </ul><h4><%= group = page.title[0,1].upcase %></h4><ul>
22
        <% end %>
23
        <li><%= link_to page.pretty_title, {:action => 'index', :page => page.title} %></li>
24
      <% end %>
25
    </ul>
26
  </p>
27
<% end %>
redmine/app/views/wiki/special_category_index.rhtml 2009-05-20 08:31:11 +0200
1
<h2><%= l(:label_index_by_category) %></h2>
2

  
3
<% content_for :sidebar do %>
4
  <%= render :partial => 'sidebar' %>
5
<% end %>
6

  
7
<% unless @categories.empty? %>
8
  <p>
9
    <ul>
10
      <% group = nil %>
11
      <% @categories.each do |category| %>
12
        <% if category[0,1].upcase != group %>
13
          </ul><h4><%= group = category[0,1].upcase %></h4><ul>
14
        <% end %>
15
        <li><%= link_to category, {:action => 'special', :page => 'category', :category => category} %></li>
16
      <% end %>
17
    </ul>
18
  </p>
19
<% end %>
20

  
21
<h4><%= l(:label_special) %></h4>
22
<p>
23
  <ul>
24
    <li>
25
      <%= link_to l(:label_pages_without_category), {:action => 'special', :page => 'category', :category => 'None'} %>
26
    </li>
27
  </ul>
28
</p>
redmine/config/locales/bg.yml 2009-05-20 08:48:03 +0200
432 432
  label_wiki_edit_plural: Wiki редакции
433 433
  label_wiki_page: Wiki page
434 434
  label_wiki_page_plural: Wiki pages
435
  label_wiki_category: Category
436
  label_wiki_category_plural: Categories
437
  label_wiki_index_by_category: Index by category
438
  label_special: Special
439
  label_pages_without_category: Pages without category
435 440
  label_index_by_title: Индекс
436 441
  label_index_by_date: Индекс по дата
437 442
  label_current_version: Текуща версия
redmine/config/locales/bs.yml 2009-05-20 09:01:40 +0200
590 590
  label_wiki_edit_plural: ispravke wiki-ja
591 591
  label_wiki_page: Wiki stranica
592 592
  label_wiki_page_plural: Wiki stranice
593
  label_wiki_category: Category
594
  label_wiki_category_plural: Categories
595
  label_wiki_index_by_category: Index by category
596
  label_special: Special
597
  label_pages_without_category: Pages without category
593 598
  label_index_by_title: Indeks prema naslovima
594 599
  label_index_by_date: Indeks po datumima
595 600
  label_current_version: Tekuća verzija
redmine/config/locales/ca.yml 2009-05-20 08:48:03 +0200
561 561
  label_wiki_edit_plural: Edicions wiki
562 562
  label_wiki_page: Pàgina wiki
563 563
  label_wiki_page_plural: Pàgines wiki
564
  label_wiki_category: Category
565
  label_wiki_category_plural: Categories
566
  label_wiki_index_by_category: Index by category
567
  label_special: Special
568
  label_pages_without_category: Pages without category
564 569
  label_index_by_title: Índex per títol
565 570
  label_index_by_date: Índex per data
566 571
  label_current_version: Versió actual
redmine/config/locales/cs.yml 2009-05-20 08:48:04 +0200
490 490
  label_wiki_edit_plural: Wiki úpravy
491 491
  label_wiki_page: Wiki stránka
492 492
  label_wiki_page_plural: Wiki stránky
493
  label_wiki_category: Category
494
  label_wiki_category_plural: Categories
495
  label_wiki_index_by_category: Index by category
496
  label_special: Special
497
  label_pages_without_category: Pages without category
493 498
  label_index_by_title: Index dle názvu
494 499
  label_index_by_date: Index dle data
495 500
  label_current_version: Aktuální verze
redmine/config/locales/da.yml 2009-05-20 08:48:04 +0200
508 508
  label_wiki_edit_plural: Wiki ændringer
509 509
  label_wiki_page: Wiki side
510 510
  label_wiki_page_plural: Wiki sider
511
  label_wiki_category: Category
512
  label_wiki_category_plural: Categories
513
  label_wiki_index_by_category: Index by category
514
  label_special: Special
515
  label_pages_without_category: Pages without category
511 516
  label_index_by_title: Indhold efter titel
512 517
  label_index_by_date: Indhold efter dato
513 518
  label_current_version: Nuværende version
redmine/config/locales/de.yml 2009-05-20 08:48:04 +0200
582 582
  label_wiki_edit_plural: Wiki-Bearbeitungen
583 583
  label_wiki_page: Wiki-Seite
584 584
  label_wiki_page_plural: Wiki-Seiten
585
  label_wiki_category: Kategorie
586
  label_wiki_category_plural: Kategorien
587
  label_index_by_category: Seiten nach Kategorie sortiert
588
  label_special: Speziell
589
  label_pages_without_category: Seiten ohne Kategorie
585 590
  label_index_by_title: Seiten nach Titel sortiert
586 591
  label_index_by_date: Seiten nach Datum sortiert
587 592
  label_current_version: Gegenwärtige Version
redmine/config/locales/en.yml 2009-05-20 08:48:04 +0200
571 571
  label_wiki_edit_plural: Wiki edits
572 572
  label_wiki_page: Wiki page
573 573
  label_wiki_page_plural: Wiki pages
574
  label_wiki_category: Category
575
  label_wiki_category_plural: Categories
576
  label_index_by_category: Index by category
577
  label_special: Special
578
  label_pages_without_category: Pages without category
574 579
  label_index_by_title: Index by title
575 580
  label_index_by_date: Index by date
576 581
  label_current_version: Current version
redmine/config/locales/es.yml 2009-05-20 08:48:04 +0200
637 637
  label_wiki_edit_plural: Wiki edicciones
638 638
  label_wiki_page: Wiki página
639 639
  label_wiki_page_plural: Wiki páginas
640
  label_wiki_category: Categoría
641
  label_wiki_category_plural: Categorías
642
  label_index_by_category: Índice por categoría
643
  label_special: Especial
644
  label_pages_without_category: Páginas sin categoría
640 645
  label_workflow: Flujo de trabajo
641 646
  label_year: Año
642 647
  label_yesterday: ayer
redmine/config/locales/fi.yml 2009-05-20 08:48:04 +0200
497 497
  label_wiki_edit_plural: Wiki muokkaukset
498 498
  label_wiki_page: Wiki sivu
499 499
  label_wiki_page_plural: Wiki sivut
500
  label_wiki_category: Category
501
  label_wiki_category_plural: Categories
502
  label_wiki_index_by_category: Index by category
503
  label_special: Special
504
  label_pages_without_category: Pages without category
500 505
  label_index_by_title: Hakemisto otsikoittain
501 506
  label_index_by_date: Hakemisto päivittäin
502 507
  label_current_version: Nykyinen versio
redmine/config/locales/fr.yml 2009-05-20 08:48:04 +0200
601 601
  label_wiki_edit_plural: Révisions wiki
602 602
  label_wiki_page: Page wiki
603 603
  label_wiki_page_plural: Pages wiki
604
  label_wiki_category: Catégorie
605
  label_wiki_category_plural: Catégories
606
  label_label_index_by_category: Index par catégorie
607
  label_special: Spécial
608
  label_pages_without_category: Pages sans catégorie
604 609
  label_index_by_title: Index par titre
605 610
  label_index_by_date: Index par date
606 611
  label_current_version: Version actuelle
redmine/config/locales/gl.yml 2009-05-20 08:48:04 +0200
616 616
  label_wiki_edit_plural: Wiki edicións
617 617
  label_wiki_page: Wiki páxina
618 618
  label_wiki_page_plural: Wiki páxinas
619
  label_wiki_category: Category
620
  label_wiki_category_plural: Categories
621
  label_wiki_index_by_category: Index by category
622
  label_special: Special
623
  label_pages_without_category: Pages without category
619 624
  label_workflow: Fluxo de traballo
620 625
  label_year: Ano
621 626
  label_yesterday: onte
redmine/config/locales/he.yml 2009-05-20 08:48:04 +0200
452 452
  label_wiki_edit_plural: עריכות Wiki
453 453
  label_wiki_page: דף Wiki
454 454
  label_wiki_page_plural: דפי Wiki
455
  label_wiki_category: Category
456
  label_wiki_category_plural: Categories
457
  label_wiki_index_by_category: Index by category
458
  label_special: Special
459
  label_pages_without_category: Pages without category
455 460
  label_index_by_title: סדר על פי כותרת
456 461
  label_index_by_date: סדר על פי תאריך
457 462
  label_current_version: גירסא נוכאית
redmine/config/locales/hu.yml 2009-05-20 08:48:04 +0200
524 524
  label_wiki_edit_plural: Wiki szerkesztések
525 525
  label_wiki_page: Wiki oldal
526 526
  label_wiki_page_plural: Wiki oldalak
527
  label_wiki_category: Category
528
  label_wiki_category_plural: Categories
529
  label_wiki_index_by_category: Index by category
530
  label_special: Special
531
  label_pages_without_category: Pages without category
527 532
  label_index_by_title: Cím szerint indexelve
528 533
  label_index_by_date: Dátum szerint indexelve
529 534
  label_current_version: Jelenlegi verzió
redmine/config/locales/it.yml 2009-05-20 08:48:04 +0200
450 450
  label_wiki_edit_plural: Modfiche wiki
451 451
  label_wiki_page: Pagina Wiki
452 452
  label_wiki_page_plural: Pagine Wiki
453
  label_wiki_category: Category
454
  label_wiki_category_plural: Categories
455
  label_wiki_index_by_category: Index by category
456
  label_special: Special
457
  label_pages_without_category: Pages without category
453 458
  label_index_by_title: Ordina per titolo
454 459
  label_index_by_date: Ordina per data
455 460
  label_current_version: Versione corrente
redmine/config/locales/ja.yml 2009-05-20 08:48:04 +0200
463 463
  label_wiki_edit_plural: Wiki編集
464 464
  label_wiki_page: Wiki page
465 465
  label_wiki_page_plural: Wikiページ
466
  label_wiki_category: Category
467
  label_wiki_category_plural: Categories
468
  label_wiki_index_by_category: Index by category
469
  label_special: Special
470
  label_pages_without_category: Pages without category
466 471
  label_index_by_title: 索引(名前順)
467 472
  label_index_by_date: 索引(日付順)
468 473
  label_current_version: 最新版
redmine/config/locales/ko.yml 2009-05-20 08:48:04 +0200
501 501
  label_wiki_edit_plural: 위키 편집
502 502
  label_wiki_page: 위키
503 503
  label_wiki_page_plural: 위키
504
  label_wiki_category: Category
505
  label_wiki_category_plural: Categories
506
  label_wiki_index_by_category: Index by category
507
  label_special: Special
508
  label_pages_without_category: Pages without category
504 509
  label_index_by_title: 제목별 색인
505 510
  label_index_by_date: 날짜별 색인
506 511
  label_current_version: 현재 버전
redmine/config/locales/lt.yml 2009-05-20 08:48:04 +0200
592 592
  label_wiki_edit_plural: Wiki redakcijos
593 593
  label_wiki_page: Wiki puslapis
594 594
  label_wiki_page_plural: Wiki puslapiai
595
  label_wiki_category: Category
596
  label_wiki_category_plural: Categories
597
  label_wiki_index_by_category: Index by category
598
  label_special: Special
599
  label_pages_without_category: Pages without category
595 600
  label_index_by_title: Indeksas prie pavadinimo
596 601
  label_index_by_date: Indeksas prie datos
597 602
  label_current_version: Einamoji versija
redmine/config/locales/nl.yml 2009-05-20 08:48:04 +0200
572 572
  label_wiki_edit_plural: Wiki edits
573 573
  label_wiki_page: Wikipagina
574 574
  label_wiki_page_plural: Wikipagina's
575
  label_wiki_category: Category
576
  label_wiki_category_plural: Categories
577
  label_wiki_index_by_category: Index by category
578
  label_special: Special
579
  label_pages_without_category: Pages without category
575 580
  label_workflow: Workflow
576 581
  label_year: Jaar
577 582
  label_yesterday: gisteren
redmine/config/locales/no.yml 2009-05-20 08:48:04 +0200
494 494
  label_wiki_edit_plural: Wiki endringer
495 495
  label_wiki_page: Wiki-side
496 496
  label_wiki_page_plural: Wiki-sider
497
  label_wiki_category: Category
498
  label_wiki_category_plural: Categories
499
  label_wiki_index_by_category: Index by category
500
  label_special: Special
501
  label_pages_without_category: Pages without category
497 502
  label_index_by_title: Indekser etter tittel
498 503
  label_index_by_date: Indekser etter dato
499 504
  label_current_version: Gjeldende versjon
redmine/config/locales/pl.yml 2009-05-20 08:48:04 +0200
617 617
  label_wiki_edit_plural: Edycje wiki
618 618
  label_wiki_page: Strona wiki
619 619
  label_wiki_page_plural: Strony wiki
620
  label_wiki_category: Category
621
  label_wiki_category_plural: Categories
622
  label_wiki_index_by_category: Index by category
623
  label_special: Special
624
  label_pages_without_category: Pages without category
620 625
  label_workflow: Przepływ
621 626
  label_year: Rok
622 627
  label_yesterday: wczoraj
redmine/config/locales/pt-BR.yml 2009-05-20 08:48:04 +0200
532 532
  label_wiki_edit_plural: Edições Wiki
533 533
  label_wiki_page: Página Wiki
534 534
  label_wiki_page_plural: páginas Wiki
535
  label_wiki_category: Category
536
  label_wiki_category_plural: Categories
537
  label_wiki_index_by_category: Index by category
538
  label_special: Special
539
  label_pages_without_category: Pages without category
535 540
  label_index_by_title: Índice por título
536 541
  label_index_by_date: Índice por data
537 542
  label_current_version: Versão atual
redmine/config/locales/pt.yml 2009-05-20 08:48:04 +0200
521 521
  label_wiki_edit_plural: Edições da Wiki
522 522
  label_wiki_page: Página da Wiki
523 523
  label_wiki_page_plural: Páginas da Wiki
524
  label_wiki_category: Category
525
  label_wiki_category_plural: Categories
526
  label_wiki_index_by_category: Index by category
527
  label_special: Special
528
  label_pages_without_category: Pages without category
524 529
  label_index_by_title: Índice por título
525 530
  label_index_by_date: Índice por data
526 531
  label_current_version: Versão actual
redmine/config/locales/ro.yml 2009-05-20 08:48:04 +0200
559 559
  label_wiki_edit_plural: Editari Wiki
560 560
  label_wiki_page: Pagina Wiki
561 561
  label_wiki_page_plural: Pagini Wiki
562
  label_wiki_category: Category
563
  label_wiki_category_plural: Categories
564
  label_wiki_index_by_category: Index by category
565
  label_special: Special
566
  label_pages_without_category: Pages without category
562 567
  label_index_by_title: Sorteaza dupa titlu
563 568
  label_index_by_date: Sorteaza dupa data
564 569
  label_current_version: Versiunea curenta
redmine/config/locales/ru.yml 2009-05-20 08:48:04 +0200
699 699
  label_wiki_edit_plural: Wiki
700 700
  label_wiki_page: Страница Wiki
701 701
  label_wiki_page_plural: Страницы Wiki
702
  label_wiki_category: Category
703
  label_wiki_category_plural: Categories
704
  label_wiki_index_by_category: Index by category
705
  label_special: Special
706
  label_pages_without_category: Pages without category
702 707
  label_workflow: Последовательность действий
703 708
  label_x_closed_issues_abbr:
704 709
    zero:  0 закрыто
redmine/config/locales/sk.yml 2009-05-20 08:48:04 +0200
488 488
  label_wiki_edit_plural: Wiki úpravy
489 489
  label_wiki_page: Wiki stránka
490 490
  label_wiki_page_plural: Wiki stránky
491
  label_wiki_category: Category
492
  label_wiki_category_plural: Categories
493
  label_wiki_index_by_category: Index by category
494
  label_special: Special
495
  label_pages_without_category: Pages without category
491 496
  label_index_by_title: Index podľa názvu
492 497
  label_index_by_date: Index podľa dátumu
493 498
  label_current_version: Aktuálna verzia
redmine/config/locales/sl.yml 2009-05-20 08:48:04 +0200
551 551
  label_wiki_edit_plural: Wiki urejanja
552 552
  label_wiki_page: Wiki stran
553 553
  label_wiki_page_plural: Wiki strani
554
  label_wiki_category: Category
555
  label_wiki_category_plural: Categories
556
  label_wiki_index_by_category: Index by category
557
  label_special: Special
558
  label_pages_without_category: Pages without category
554 559
  label_index_by_title: Razvrsti po naslovu
555 560
  label_index_by_date: Razvrsti po datumu
556 561
  label_current_version: Trenutna verzija
redmine/config/locales/sr.yml 2009-05-20 08:48:04 +0200
468 468
  label_wiki_edit_plural: Wiki promene
469 469
  label_wiki_page: Wiki stranica
470 470
  label_wiki_page_plural: Wiki stranice
471
  label_wiki_category: Category
472
  label_wiki_category_plural: Categories
473
  label_wiki_index_by_category: Index by category
474
  label_special: Special
475
  label_pages_without_category: Pages without category
471 476
  label_index_by_title: Indeks po naslovima
472 477
  label_index_by_date: Indeks po datumu
473 478
  label_current_version: Trenutna verzija
redmine/config/locales/sv.yml 2009-05-20 08:48:04 +0200
628 628
  label_wiki_edit_plural: Wikiändringar
629 629
  label_wiki_page: Wikisida
630 630
  label_wiki_page_plural: Wikisidor
631
  label_wiki_category: Category
632
  label_wiki_category_plural: Categories
633
  label_wiki_index_by_category: Index by category
634
  label_special: Special
635
  label_pages_without_category: Pages without category
631 636
  label_index_by_title: Innehåll efter titel
632 637
  label_index_by_date: Innehåll efter datum
633 638
  label_current_version: Nuvarande version
redmine/config/locales/th.yml 2009-05-20 08:48:04 +0200
488 488
  label_wiki_edit_plural: แก้ไข Wiki
489 489
  label_wiki_page: หน้า Wiki
490 490
  label_wiki_page_plural: หน้า Wiki
491
  label_wiki_category: Category
492
  label_wiki_category_plural: Categories
493
  label_wiki_index_by_category: Index by category
494
  label_special: Special
495
  label_pages_without_category: Pages without category
491 496
  label_index_by_title: เรียงตามชื่อเรื่อง
492 497
  label_index_by_date: เรียงตามวัน
493 498
  label_current_version: รุ่นปัจจุบัน
redmine/config/locales/tr.yml 2009-05-20 08:48:04 +0200
523 523
  label_wiki_edit_plural: Wiki düzenlemeleri
524 524
  label_wiki_page: Wiki sayfası
525 525
  label_wiki_page_plural: Wiki sayfaları
526
  label_wiki_category: Category
527
  label_wiki_category_plural: Categories
528
  label_wiki_index_by_category: Index by category
529
  label_special: Special
530
  label_pages_without_category: Pages without category
526 531
  label_index_by_title: Başlığa göre diz
527 532
  label_index_by_date: Tarihe göre diz
528 533
  label_current_version: Güncel versiyon
redmine/config/locales/uk.yml 2009-05-20 08:48:04 +0200
448 448
  label_wiki_edit_plural: Редагування Wiki 
449 449
  label_wiki_page: Сторінка Wiki
450 450
  label_wiki_page_plural: Сторінки Wiki
451
  label_wiki_category: Category
452
  label_wiki_category_plural: Categories
453
  label_wiki_index_by_category: Index by category
454
  label_special: Special
455
  label_pages_without_category: Pages without category
451 456
  label_index_by_title: Індекс за назвою
452 457
  label_index_by_date: Індекс за датою
453 458
  label_current_version: Поточна версія
redmine/config/locales/vi.yml 2009-05-20 08:48:04 +0200
567 567
  label_wiki_edit_plural: Thay đổi wiki
568 568
  label_wiki_page: Trang wiki
569 569
  label_wiki_page_plural: Trang wiki
570
  label_wiki_category: Category
571
  label_wiki_category_plural: Categories
572
  label_wiki_index_by_category: Index by category
573
  label_special: Special
574
  label_pages_without_category: Pages without category
570 575
  label_index_by_title: Danh sách theo tên
571 576
  label_index_by_date: Danh sách theo ngày
572 577
  label_current_version: Bản hiện tại
redmine/config/locales/zh-TW.yml 2009-05-20 08:48:04 +0200
678 678
  label_wiki_edit_plural: Wiki 編輯
679 679
  label_wiki_page: Wiki 網頁
680 680
  label_wiki_page_plural: Wiki 網頁
681
  label_wiki_category: Category
682
  label_wiki_category_plural: Categories
683
  label_wiki_index_by_category: Index by category
684
  label_special: Special
685
  label_pages_without_category: Pages without category
681 686
  label_index_by_title: 依標題索引
682 687
  label_index_by_date: 依日期索引
683 688
  label_current_version: 現行版本
redmine/config/locales/zh.yml 2009-05-20 08:48:04 +0200
602 602
  label_wiki_edit_plural: Wiki 编辑记录
603 603
  label_wiki_page: Wiki 页面
604 604
  label_wiki_page_plural: Wiki 页面
605
  label_wiki_category: Category
606
  label_wiki_category_plural: Categories
607
  label_wiki_index_by_category: Index by category
608
  label_special: Special
609
  label_pages_without_category: Pages without category
605 610
  label_index_by_title: 按标题索引
606 611
  label_index_by_date: 按日期索引
607 612
  label_current_version: 当前版本
redmine/config/routes.rb 2009-05-20 08:31:11 +0200
54 54
  map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :post}
55 55
  map.with_options :controller => 'wiki' do |wiki_routes|
56 56
    wiki_routes.with_options :conditions => {:method => :get} do |wiki_views|
57
      wiki_views.connect 'projects/:id/wiki/:page', :action => 'special', :page => /page_index|date_index|export/i
57
      wiki_views.connect 'projects/:id/wiki/:page', :action => 'special', :page => /page_index|date_index|category_index|export/i
58 58
      wiki_views.connect 'projects/:id/wiki/:page', :action => 'index', :page => nil
59 59
      wiki_views.connect 'projects/:id/wiki/:page/edit', :action => 'edit'
60 60
      wiki_views.connect 'projects/:id/wiki/:page/rename', :action => 'rename'
61 61
      wiki_views.connect 'projects/:id/wiki/:page/history', :action => 'history'
62 62
      wiki_views.connect 'projects/:id/wiki/:page/diff/:version/vs/:version_from', :action => 'diff'
63 63
      wiki_views.connect 'projects/:id/wiki/:page/annotate/:version', :action => 'annotate'
64
      wiki_views.connect 'projects/:id/wiki/category/:category', :action => 'special', :page => 'category'
64 65
    end
65 66
    
66 67
    wiki_routes.connect 'projects/:id/wiki/:page/:action', 
redmine/db/migrate/20090516170318_add_wiki_pages_categories.rb 2009-05-20 08:31:11 +0200
1
class AddWikiPagesCategories < ActiveRecord::Migration
2
  def self.up
3
    add_column :wiki_pages, :categories, :string
4
  end
5

  
6
  def self.down
7
    remove_column :wiki_pages, :categories
8
  end
9
end
redmine/lib/redmine/wiki_formatting/macros.rb 2009-05-20 08:31:12 +0200
116 116
        @included_wiki_pages.pop
117 117
        out
118 118
      end
119

  
120
      desc "Add the current wiki page to a category.\nExample: !{{category(Help)}}"
121
      macro :category do |obj, args|
122
        ''   # categories are listed in the sidebar
123
      end
124

  
125
      desc "Add the current wiki page to several categories.\nExample: !{{categories(Help, Snippets)}}"
126
      macro :categories do |obj, args|
127
        ''   # categories are listed in the sidebar
128
      end
129

  
130
      desc "Display a list of pages which belong to the specified category.\nExample: !{{pages_in_category(Help)}}"
131
      macro :pages_in_category do |obj, args|
132
        if !args.first.nil?
133
          content_tag :ul, :class => :pages_in_category  do
134
            @wiki.find_pages_in_category(args.first).map do |p|
135
              content_tag :li do
136
                link_to p.pretty_title, {:action => 'index', :page => p.title}
137
              end 
138
            end
139
          end
140
        end
141
      end
119 142
    end
120 143
  end
121 144
end
122
-- redmine.orig/test/fixtures/wiki_pages.yml	2009-05-20 09:10:13 +0200
145
++ redmine/test/fixtures/wiki_pages.yml	2009-05-20 08:31:12 +0200
......
6 6
  wiki_id: 1
7 7
  protected: true
8 8
  parent_id: 
9
  categories: |Examples|Documentation|
9 10
wiki_pages_002: 
10 11
  created_on: 2007-03-08 00:18:07 +01:00
11 12
  title: Another_page
......
13 14
  wiki_id: 1
14 15
  protected: false
15 16
  parent_id: 
17
  categories: 
16 18
wiki_pages_003: 
17 19
  created_on: 2007-03-08 00:18:07 +01:00
18 20
  title: Start_page
......
20 22
  wiki_id: 2
21 23
  protected: false
22 24
  parent_id: 
25
  categories: 
23 26
wiki_pages_004: 
24 27
  created_on: 2007-03-08 00:18:07 +01:00
25 28
  title: Page_with_an_inline_image
......
27 30
  wiki_id: 1
28 31
  protected: false
29 32
  parent_id: 1
33
  categories: |Examples|
30 34
wiki_pages_005: 
31 35
  created_on: 2007-03-08 00:18:07 +01:00
32 36
  title: Child_1
......
34 38
  wiki_id: 1
35 39
  protected: false
36 40
  parent_id: 2
41
  categories: |Examples|
37 42
wiki_pages_006: 
38 43
  created_on: 2007-03-08 00:18:07 +01:00
39 44
  title: Child_2
......
41 46
  wiki_id: 1
42 47
  protected: false
43 48
  parent_id: 2
44
  
49
  categories: |Examples|
redmine/test/functional/wiki_controller_test.rb 2009-05-20 08:31:12 +0200
298 298
      :controller => 'wiki', :action => 'special', :id => '567', :page => 'date_index'
299 299
    )
300 300
    assert_routing(
301
      {:method => :get, :path => '/projects/567/wiki/category_index'},
302
      :controller => 'wiki', :action => 'special', :id => '567', :page => 'category_index'
303
    )
304
    assert_routing(
305
      {:method => :get, :path => '/projects/567/wiki/category/Test'},
306
      :controller => 'wiki', :action => 'special', :id => '567', :page => 'category', :category => 'Test'
307
    )    
308
    assert_routing(
301 309
      {:method => :get, :path => '/projects/567/wiki/export'},
302 310
      :controller => 'wiki', :action => 'special', :id => '567', :page => 'export'
303 311
    )
redmine/test/unit/helpers/application_helper_test.rb 2009-05-20 08:31:12 +0200
206 206
      # project does not exist
207 207
      '[[unknowproject:Start]]' => '[[unknowproject:Start]]',
208 208
      '[[unknowproject:Start|Page title]]' => '[[unknowproject:Start|Page title]]',
209
      # categories
210
      '[[category:Test]]' => '<a href="/projects/ecookbook/wiki/category/Test">Test</a>',
211
      '[[category:Test|Text]]' => '<a href="/projects/ecookbook/wiki/category/Test">Text</a>',
212
      '[[ecookbook:category:Test]]' => '<a href="/projects/ecookbook/wiki/category/Test">Test</a>',
213
      '[[ecookbook:category:Test|Text]]' => '<a href="/projects/ecookbook/wiki/category/Test">Text</a>',
214
      '[[unknownproject:category:Test]]' => '[[unknownproject:category:Test]]',
215
      '[[unknownproject:category:Test|Text]]' => '[[unknownproject:category:Test|Text]]',
216
      '![[category:Test]]' => '[[category:Test]]',
209 217
    }
210 218
    @project = Project.find(1)
211 219
    to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
redmine/test/unit/wiki_content_test.rb 2009-05-20 08:48:04 +0200
27 27
  
28 28
  def test_create
29 29
    page = WikiPage.new(:wiki => @wiki, :title => "Page")  
30
    page.content = WikiContent.new(:text => "Content text", :author => User.find(1), :comments => "My comment")
30
    page.content = WikiContent.new(:text => "{{category(Test)}}Content text", :author => User.find(1), :comments => "My comment")
31 31
    assert page.save
32 32
    page.reload
33 33
    
......
35 35
    assert_kind_of WikiContent, content
36 36
    assert_equal 1, content.version
37 37
    assert_equal 1, content.versions.length
38
    assert_equal "Content text", content.text
38
    assert_equal "{{category(Test)}}Content text", content.text
39
    assert_equal "|Test|", content.page.categories
39 40
    assert_equal "My comment", content.comments
40 41
    assert_equal User.find(1), content.author
41 42
    assert_equal content.text, content.versions.last.text
redmine/test/unit/wiki_test.rb 2009-05-20 08:31:12 +0200
19 19

  
20 20
class WikiTest < Test::Unit::TestCase
21 21
  fixtures :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions
22
  
23
  def test_create
22
  
23
  def test_create
24 24
    wiki = Wiki.new(:project => Project.find(2))
25 25
    assert !wiki.save
26 26
    assert_equal 1, wiki.errors.count
27 27
  
28
    wiki.start_page = "Start page"
29
    assert wiki.save
30
  end
28
    wiki.start_page = "Start page"
29
    assert wiki.save
30
  end
31 31

  
32 32
  def test_update
33 33
    @wiki = Wiki.find(1)
......
41 41
    assert_equal 'Page_title_with_CAPITALES', Wiki.titleize('page title with CAPITALES')
42 42
    assert_equal 'テスト', Wiki.titleize('テスト')
43 43
  end
44

  
45
  def test_upcase_first
46
    assert_equal 'Page title', Wiki.upcase_first('page title')
47
    assert_equal 'テスト', Wiki.titleize('テスト')
48
  end
49

  
50
  def test_find_categories
51
    @wiki = Wiki.find(1)
52
    assert_equal ['Examples', 'Documentation'], @wiki.find_all_categories
53
  end
54

  
55
  def test_find_pages_in_category
56
    @wiki = Wiki.find(1)
57
    assert_equal [1], @wiki.find_pages_in_category('Documentation').map {|c| c.id }.sort
58
    assert_equal [1, 4, 5, 6], @wiki.find_pages_in_category('Examples').map {|c| c.id }.sort
59
    assert_equal [2], @wiki.find_pages_in_category('None').map {|c| c.id }.sort
60
  end
44 61
end