Skip to content

Commit c473fae

Browse files
committed
Add support for resouces, conversations and bbcode help
1 parent 8557c1f commit c473fae

24 files changed

+68
-36
lines changed

BbCode/TagRenderer.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,13 @@ private static function getAnchorId($uniqueId, $tagChildren)
4444
private static function getEntityId($entity)
4545
{
4646
if (!isset($entity)) {
47-
\XF::logError('Can not get post/resource id: $entity is not defined.');
47+
//\XF::logError('Can not get post/resource id: $entity is not defined.');
4848
return 0;
4949
}
5050
if ($entity instanceof \XF\Entity\Post)
5151
return $entity->post_id;
52+
if ($entity instanceof \XF\Entity\ConversationMessage)
53+
return $entity->message_id;
5254
if (class_exists('\XFRM\Entity\ResourceUpdate')
5355
&& $entity instanceof \XFRM\Entity\ResourceUpdate)
5456
return $entity->resource_id;

_files/js/inforge/posttoc/toc-renderer.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@ function getNameFromDepth(depth)
1616
switch (depth) {
1717
case 0:
1818
return 'chapter';
19+
case 1:
20+
return 'section';
1921
case 2:
2022
return 'subsection';
2123
case 3:
2224
return 'subsubsection';
2325
case 4:
2426
return 'paragraph';
2527
default:
26-
return 'section';
28+
return '';
2729
}
2830
}
2931

@@ -46,6 +48,7 @@ function fillTableOfContents(entries, idx, depth, toc)
4648
title: 'Go to ' + getNameFromDepth(depth),
4749
href: entry.anchor,
4850
});
51+
$(link).addClass('posttoc-' + getNameFromDepth(depth))
4952
$(item).append(link);
5053
}
5154
$(toc).append(item);
@@ -72,7 +75,7 @@ function subtreeModifiedHandler()
7275

7376
function initTocForEachPost()
7477
{
75-
$('article.message').each(function() {
78+
$('article.message, article.resourceBody-main, blockquote.message-body, div.bbCodeDemoBlock').each(function() {
7679
createTocForPost(this);
7780
});
7881
}

_output/bb_codes/_metadata.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
{
22
"chapter.json": {
3-
"hash": "5c2ec57c2423499514d9c96296c0d3a0"
3+
"hash": "8c54f0ac305fb862e2ac6b5cb479a204"
44
},
55
"paragraph.json": {
6-
"hash": "a4437679487267d2dd9da8a67622eef4"
6+
"hash": "8fa8f56973fd63b78d21886e9b07de23"
77
},
88
"section.json": {
9-
"hash": "806032dc7b6d33fe9f69aaecb9bcd437"
9+
"hash": "7025a6662b1a179e15e49b80bb5e0af2"
1010
},
1111
"subsection.json": {
12-
"hash": "c655333b22283384eab3f650d9157641"
12+
"hash": "4c4c1316e44d3edbc9ca6501498ef3af"
1313
},
1414
"subsubsection.json": {
15-
"hash": "3055cded7ae3c55aee7c4e22b4e78981"
15+
"hash": "f95a15ed29f9255fdf83c23012b5c7f2"
1616
},
1717
"toc.json": {
1818
"hash": "7b6e8a89f99e43e802149162cb367ef9"

_output/bb_codes/chapter.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"callback_class": "Inforge\\PostTOC\\BbCode\\TagRenderer",
88
"callback_method": "renderChapterTag",
99
"option_regex": "",
10-
"trim_lines_after": 0,
10+
"trim_lines_after": 1,
1111
"plain_children": true,
1212
"disable_smilies": false,
1313
"disable_nl2br": false,

_output/bb_codes/paragraph.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"callback_class": "Inforge\\PostTOC\\BbCode\\TagRenderer",
88
"callback_method": "renderParagraphTag",
99
"option_regex": "",
10-
"trim_lines_after": 0,
10+
"trim_lines_after": 1,
1111
"plain_children": true,
1212
"disable_smilies": false,
1313
"disable_nl2br": false,

_output/bb_codes/section.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"callback_class": "Inforge\\PostTOC\\BbCode\\TagRenderer",
88
"callback_method": "renderSectionTag",
99
"option_regex": "",
10-
"trim_lines_after": 0,
10+
"trim_lines_after": 1,
1111
"plain_children": true,
1212
"disable_smilies": false,
1313
"disable_nl2br": false,

_output/bb_codes/subsection.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"callback_class": "Inforge\\PostTOC\\BbCode\\TagRenderer",
88
"callback_method": "renderSubsectionTag",
99
"option_regex": "",
10-
"trim_lines_after": 0,
10+
"trim_lines_after": 1,
1111
"plain_children": true,
1212
"disable_smilies": false,
1313
"disable_nl2br": false,

_output/bb_codes/subsubsection.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"callback_class": "Inforge\\PostTOC\\BbCode\\TagRenderer",
88
"callback_method": "renderSubsubsectionTag",
99
"option_regex": "",
10-
"trim_lines_after": 0,
10+
"trim_lines_after": 1,
1111
"plain_children": true,
1212
"disable_smilies": false,
1313
"disable_nl2br": false,

_output/phrases/_metadata.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,31 @@
33
"global_cache": false,
44
"version_id": 1000070,
55
"version_string": "1.0.0",
6-
"hash": "bf5b784755d525df644dc5590832c39a"
6+
"hash": "7329aa363eb13edc2aca86a117a165bf"
77
},
88
"custom_bb_code_desc.paragraph.txt": {
99
"global_cache": false,
1010
"version_id": 1000070,
1111
"version_string": "1.0.0",
12-
"hash": "b95fcc6305cacfd5e7c07dda933c7bc7"
12+
"hash": "c89c1e9bd4effbadd3c4294e5a509a9f"
1313
},
1414
"custom_bb_code_desc.section.txt": {
1515
"global_cache": false,
1616
"version_id": 1000070,
1717
"version_string": "1.0.0",
18-
"hash": "121848e324f28e21afa4b4122eb15ee5"
18+
"hash": "8aeadad233eba0915e768912f482dce9"
1919
},
2020
"custom_bb_code_desc.subsection.txt": {
2121
"global_cache": false,
2222
"version_id": 1000070,
2323
"version_string": "1.0.0",
24-
"hash": "374d63167e76c00f7baa74c793e3d1b2"
24+
"hash": "d1b1e8be0465bea72e88a95e2a1529c8"
2525
},
2626
"custom_bb_code_desc.subsubsection.txt": {
2727
"global_cache": false,
2828
"version_id": 1000070,
2929
"version_string": "1.0.0",
30-
"hash": "3f7fcd34b0ecf98fb08db8249ad8f9b1"
30+
"hash": "54fd85f8ea23ea777fd13572f3b4694d"
3131
},
3232
"custom_bb_code_desc.toc.txt": {
3333
"global_cache": false,
@@ -39,37 +39,37 @@
3939
"global_cache": false,
4040
"version_id": 1000070,
4141
"version_string": "1.0.0",
42-
"hash": "0c6c00dd85bc759fada847f471bef504"
42+
"hash": "d7d3292efbbd58a0b878f8c35ebc495e"
4343
},
4444
"custom_bb_code_example.paragraph.txt": {
4545
"global_cache": false,
4646
"version_id": 1000070,
4747
"version_string": "1.0.0",
48-
"hash": "d41d8cd98f00b204e9800998ecf8427e"
48+
"hash": "dd00cb98088a2aee8a76b8c5f88582de"
4949
},
5050
"custom_bb_code_example.section.txt": {
5151
"global_cache": false,
5252
"version_id": 1000070,
5353
"version_string": "1.0.0",
54-
"hash": "d41d8cd98f00b204e9800998ecf8427e"
54+
"hash": "f4c931318d2769bd3bf3bcaf75de18f7"
5555
},
5656
"custom_bb_code_example.subsection.txt": {
5757
"global_cache": false,
5858
"version_id": 1000070,
5959
"version_string": "1.0.0",
60-
"hash": "d41d8cd98f00b204e9800998ecf8427e"
60+
"hash": "3b65a5e5c47c4642c058d5f0ebab089c"
6161
},
6262
"custom_bb_code_example.subsubsection.txt": {
6363
"global_cache": false,
6464
"version_id": 1000070,
6565
"version_string": "1.0.0",
66-
"hash": "d41d8cd98f00b204e9800998ecf8427e"
66+
"hash": "aa2f16f25a09ce95f9d41059f2871e1e"
6767
},
6868
"custom_bb_code_example.toc.txt": {
6969
"global_cache": false,
7070
"version_id": 1000070,
7171
"version_string": "1.0.0",
72-
"hash": "4833c9c666ab08eab843f927b5354097"
72+
"hash": "1b58c2e6ec1750c0e257fdf4c130abb8"
7373
},
7474
"custom_bb_code_output.chapter.txt": {
7575
"global_cache": false,
@@ -105,7 +105,7 @@
105105
"global_cache": false,
106106
"version_id": 1000070,
107107
"version_string": "1.0.0",
108-
"hash": "674d9b64be6bdb41b567eb7b0fafebae"
108+
"hash": "d41d8cd98f00b204e9800998ecf8427e"
109109
},
110110
"custom_bb_code_title.chapter.txt": {
111111
"global_cache": false,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
A chapter.
1+
Defines a new chapter (1st level section).
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
A Paragraph.
1+
Defines a new paragraph (5th level section).
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
A Section.
1+
Defines a new section (2nd level section).
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
A Subsection.
1+
Defines a new subsection (3rd level section).
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
A Subsubsection.
1+
Defines a new subsubsection (4th level section).
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
[CHAPTER]My Chapter[/CHAPTER]
1+
[CHAPTER]My Chapter[/CHAPTER]
2+
[CHAPTER=nonum]Unnumbered Chapter[/CHAPTER]
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[PARAGRAPH]My Paragraph[/PARAGRAPH]
2+
[PARAGRAPH=num]Numbered Paragraph[/PARAGRAPH]
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[SECTION]My Section[/SECTION]
2+
[SECTION=nonum]Unnumbered Section[/SECTION]
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[SUBSECTION]My Subsection[/SUBSECTION]
2+
[SUBSECTION=nonum]Unnumbered Subsection[/SUBSECTION]
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[SUBSUBSECTION]My Subsubsection[/SUBSUBSECTION]
2+
[SUBSUBSECTION=num]Numbered Subsubsection[/SUBSUBSECTION]
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
1-
[TOC][/TOC]
1+
[TOC][/TOC]
2+
[CHAPTER=1]A Chapter[/CHAPTER]
3+
[CHAPTER]Another Chapter[/CHAPTER]
4+
[SECTION=1]A Section[/SECTION]
5+
[SUBSECTION=1]A Subsection[/SUBSECTION]
6+
[SUBSUBSECTION=1,num]A Subsubsection[/SUBSUBSECTION]
7+
[PARAGRAPH=1,num,toc]A Paragraph[/PARAGRAPH]
8+
[SECTION]Another Section[/SECTION]
9+
[CHAPTER=notoc]Chapter not in TOC[/CHAPTER]
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +0,0 @@
1-
[TOC][/TOC]
2-
[CHAPTER]First Chapter[/CHAPTER]
3-
[CHAPTER]Second Chapter[/CHAPTER]

_output/templates/_metadata.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
{
2+
"public/if_toc_bb_code.less": {
3+
"version_id": 1000070,
4+
"version_string": "1.0.0",
5+
"hash": "3d5d645acb27da2715be8230c68b10f4"
6+
},
27
"public/if_toc_bb_code_tag_toc.html": {
38
"version_id": 1000070,
49
"version_string": "1.0.0",
5-
"hash": "1293a7c624f8a134fdeabdc18e558210"
10+
"hash": "c320b1afc0b3b3b31444a38ef650b74c"
611
}
712
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
div.bbTocBlock-toc ul {
2+
list-style-type: none;
3+
}
4+
5+
div.bbTocBlock-toc li a.posttoc-chapter {
6+
font-weight: bold;
7+
}

_output/templates/public/if_toc_bb_code_tag_toc.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<xf:css src="if_toc_bb_code.less" />
12
<xf:js addon="Inforge/PostTOC" src="inforge/posttoc/toc-renderer.js" min="1" />
23

34
<div class="bbTocBlock">

0 commit comments

Comments
 (0)