##// END OF EJS Templates
Add "Table of contents" heading to toc macro (#23179)....
Jean-Philippe Lang -
r15610:af29408e831d
parent child
Show More
@@ -1012,7 +1012,7 module ApplicationHelper
1012 div_class = 'toc'
1012 div_class = 'toc'
1013 div_class << ' right' if right_align
1013 div_class << ' right' if right_align
1014 div_class << ' left' if left_align
1014 div_class << ' left' if left_align
1015 out = "<ul class=\"#{div_class}\"><li>"
1015 out = "<ul class=\"#{div_class}\"><li><strong>#{l :label_table_of_contents}</strong></li><li>"
1016 root = headings.map(&:first).min
1016 root = headings.map(&:first).min
1017 current = root
1017 current = root
1018 started = false
1018 started = false
@@ -1210,6 +1210,7 de:
1210 label_new_project_issue_tab_enabled: Tab "Neues Ticket" anzeigen
1210 label_new_project_issue_tab_enabled: Tab "Neues Ticket" anzeigen
1211 setting_new_item_menu_tab: Menü zum Anlegen neuer Objekte
1211 setting_new_item_menu_tab: Menü zum Anlegen neuer Objekte
1212 label_new_object_tab_enabled: Dropdown-Menü "+" anzeigen
1212 label_new_object_tab_enabled: Dropdown-Menü "+" anzeigen
1213 label_table_of_contents: Inhaltsverzeichnis
1213 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1214 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1214 for which you can create an issue
1215 for which you can create an issue
1215 field_textarea_font: Font used for text areas
1216 field_textarea_font: Font used for text areas
@@ -1000,6 +1000,7 en:
1000 label_relations: Relations
1000 label_relations: Relations
1001 label_new_project_issue_tab_enabled: Display the "New issue" tab
1001 label_new_project_issue_tab_enabled: Display the "New issue" tab
1002 label_new_object_tab_enabled: Display the "+" drop-down
1002 label_new_object_tab_enabled: Display the "+" drop-down
1003 label_table_of_contents: Table of contents
1003 label_font_default: Default font
1004 label_font_default: Default font
1004 label_font_monospace: Monospaced font
1005 label_font_monospace: Monospaced font
1005 label_font_proportional: Proportional font
1006 label_font_proportional: Proportional font
@@ -1009,6 +1009,7 fr:
1009 label_relations: Relations
1009 label_relations: Relations
1010 label_new_project_issue_tab_enabled: Afficher l'onglet "Nouvelle demande"
1010 label_new_project_issue_tab_enabled: Afficher l'onglet "Nouvelle demande"
1011 label_new_object_tab_enabled: Afficher le menu déroulant "+"
1011 label_new_object_tab_enabled: Afficher le menu déroulant "+"
1012 label_table_of_contents: Contenu
1012 label_font_default: Police par défaut
1013 label_font_default: Police par défaut
1013 label_font_monospace: Police non proportionnelle
1014 label_font_monospace: Police non proportionnelle
1014 label_font_proportional: Police proportionnelle
1015 label_font_proportional: Police proportionnelle
@@ -1013,6 +1013,7 div.wiki ul.toc.right { float: right; margin-left: 12px; margin-right: 0; width:
1013 div.wiki ul.toc.left { float: left; margin-right: 12px; margin-left: 0; width: auto; }
1013 div.wiki ul.toc.left { float: left; margin-right: 12px; margin-left: 0; width: auto; }
1014 div.wiki ul.toc ul { margin: 0; padding: 0; }
1014 div.wiki ul.toc ul { margin: 0; padding: 0; }
1015 div.wiki ul.toc li {list-style-type:none; margin: 0; font-size:12px;}
1015 div.wiki ul.toc li {list-style-type:none; margin: 0; font-size:12px;}
1016 div.wiki ul.toc>li:first-child {margin-bottom: .5em; color: #777;}
1016 div.wiki ul.toc li li {margin-left: 1.5em; font-size:10px;}
1017 div.wiki ul.toc li li {margin-left: 1.5em; font-size:10px;}
1017 div.wiki ul.toc a {
1018 div.wiki ul.toc a {
1018 font-size: 0.9em;
1019 font-size: 0.9em;
@@ -1092,6 +1092,8 EXPECTED
1092 end
1092 end
1093
1093
1094 def test_table_of_content
1094 def test_table_of_content
1095 set_language_if_valid 'en'
1096
1095 raw = <<-RAW
1097 raw = <<-RAW
1096 {{toc}}
1098 {{toc}}
1097
1099
@@ -1124,6 +1126,7 h2. "Project Name !/attachments/1234/logo_small.gif! !/attachments/5678/logo_2.p
1124 RAW
1126 RAW
1125
1127
1126 expected = '<ul class="toc">' +
1128 expected = '<ul class="toc">' +
1129 '<li><strong>Table of contents</strong></li>' +
1127 '<li><a href="#Title">Title</a>' +
1130 '<li><a href="#Title">Title</a>' +
1128 '<ul>' +
1131 '<ul>' +
1129 '<li><a href="#Subtitle-with-a-Wiki-link">Subtitle with a Wiki link</a></li>' +
1132 '<li><a href="#Subtitle-with-a-Wiki-link">Subtitle with a Wiki link</a></li>' +
@@ -1153,6 +1156,8 RAW
1153 end
1156 end
1154
1157
1155 def test_table_of_content_should_generate_unique_anchors
1158 def test_table_of_content_should_generate_unique_anchors
1159 set_language_if_valid 'en'
1160
1156 raw = <<-RAW
1161 raw = <<-RAW
1157 {{toc}}
1162 {{toc}}
1158
1163
@@ -1164,6 +1169,7 h2. Subtitle
1164 RAW
1169 RAW
1165
1170
1166 expected = '<ul class="toc">' +
1171 expected = '<ul class="toc">' +
1172 '<li><strong>Table of contents</strong></li>' +
1167 '<li><a href="#Title">Title</a>' +
1173 '<li><a href="#Title">Title</a>' +
1168 '<ul>' +
1174 '<ul>' +
1169 '<li><a href="#Subtitle">Subtitle</a></li>' +
1175 '<li><a href="#Subtitle">Subtitle</a></li>' +
@@ -1180,6 +1186,8 RAW
1180 end
1186 end
1181
1187
1182 def test_table_of_content_should_contain_included_page_headings
1188 def test_table_of_content_should_contain_included_page_headings
1189 set_language_if_valid 'en'
1190
1183 raw = <<-RAW
1191 raw = <<-RAW
1184 {{toc}}
1192 {{toc}}
1185
1193
@@ -1189,6 +1197,7 h1. Included
1189 RAW
1197 RAW
1190
1198
1191 expected = '<ul class="toc">' +
1199 expected = '<ul class="toc">' +
1200 '<li><strong>Table of contents</strong></li>' +
1192 '<li><a href="#Included">Included</a></li>' +
1201 '<li><a href="#Included">Included</a></li>' +
1193 '<li><a href="#Child-page-1">Child page 1</a></li>' +
1202 '<li><a href="#Child-page-1">Child page 1</a></li>' +
1194 '</ul>'
1203 '</ul>'
@@ -239,6 +239,8 class Redmine::WikiFormatting::MacrosTest < Redmine::HelperTest
239 end
239 end
240
240
241 def test_macro_collapse_should_not_break_toc
241 def test_macro_collapse_should_not_break_toc
242 set_language_if_valid 'en'
243
242 text = <<-RAW
244 text = <<-RAW
243 {{toc}}
245 {{toc}}
244
246
@@ -249,7 +251,7 h2. Heading
249 }}"
251 }}"
250 RAW
252 RAW
251
253
252 expected_toc = '<ul class="toc"><li><a href="#Title">Title</a><ul><li><a href="#Heading">Heading</a></li></ul></li></ul>'
254 expected_toc = '<ul class="toc"><li><strong>Table of contents</strong></li><li><a href="#Title">Title</a><ul><li><a href="#Heading">Heading</a></li></ul></li></ul>'
253
255
254 assert_include expected_toc, textilizable(text).gsub(/[\r\n]/, '')
256 assert_include expected_toc, textilizable(text).gsub(/[\r\n]/, '')
255 end
257 end
General Comments 0
You need to be logged in to leave comments. Login now