Merge pull request #900 from einervonvielen/doc_dev_beginner_corrections

Changed bbcode [toc] and changed doc for beginning deveopers
This commit is contained in:
RedMatrix 2015-02-19 13:40:23 +11:00
commit 4a75d2d754
5 changed files with 57 additions and 54 deletions

View File

@ -49,26 +49,31 @@
<p>Red Matrix specific codes</p> <p>Red Matrix specific codes</p>
<ul class="listbullet" style="list-style-type: circle;"> <ul class="listbullet" style="list-style-type: circle;">
<li>[&amp;copy;] &copy; This works for many HTML entities<br /> <li>[&amp;copy;] &copy; This works for many HTML entities</li>
<li>[zrl]https://redmatrix.me[/zrl] Magic-auth version of [url] tag<br /> <li>[zrl]https://redmatrix.me[/zrl] Magic-auth version of [url] tag</li>
<li>[zmg]https://redmatrix.me/some/photo.jpg[/zmg] Magic-auth version of [img] tag<br /> <li>[zmg]https://redmatrix.me/some/photo.jpg[/zmg] Magic-auth version of [img] tag<br /></li>
<br />
<li>[observer=1]Text to display if observer is authenticated in the matrix[/observer]
<li>[observer=0]Text to display if observer is <strong>not</strong> authenticated in the matrix[/observer]<br />
<li>[observer.baseurl] website of observer <br />
<li>[observer.url] channel URL of observer <br />
<li>[observer.name] name of observer <br />
<li>[observer.address] address (zot-id) of observer <br />
<li>[observer.photo] profile photo of observer <br />
<br />
<li>[spoiler] for hiding spoilers<br /><br />
<li>[rpost=title]Text to post[/rpost] The observer will be returned to their home hub to enter a post with the specified title and body. Both are optional <br /> <li>[observer=1]Text to display if observer is authenticated in the matrix[/observer]</li>
<li>[qr]text to post[/qr] - create a QR code.<br /> <li>[observer=0]Text to display if observer is <strong>not</strong> authenticated in the matrix[/observer]</li>
<li>[toc] - create a table of content in a webpage (level h1,...,h4).<br /> <li>[observer.baseurl] website of observer</li>
<br /><br /> <li>[observer.url] channel URL of observer</li>
<li>[observer.name] name of observer</li>
<li>[observer.address] address (zot-id) of observer</li>
<li>[observer.photo] profile photo of observer<br /></li>
<li>[spoiler] for hiding spoilers<br /><br /></li>
<li>[rpost=title]Text to post[/rpost] The observer will be returned to their home hub to enter a post with the specified title and body. Both are optional</li>
<li>[qr]text to post[/qr] - create a QR code.</li>
<li>[toc] - create a table of content in a webpage. Please refer to the <a href="http://ndabas.github.io/toc/" target="_blank">original jquery toc</a> to get more explanations.
<ul>
<li>Optional param: 'data-toc'. If ommited the default is 'body'</li>
<li>Optional param: 'data-toc-headings'. If ommited the default is 'h1,h2,h3'</li>
<li>Full example: [toc data-toc='div.page-body' data-toc-headings='h1,h2']</li>
</ul>
</li>
</ul> </ul>
<br />
<p>These require a suitable map plugin/addon such as openstreetmap or else the result will be blank</p> <p>These require a suitable map plugin/addon such as openstreetmap or else the result will be blank</p>
<ul> <ul>
<li>[map] Generate an inline map using the current browser coordinates of the poster, if browser location is enabled<br /> <li>[map] Generate an inline map using the current browser coordinates of the poster, if browser location is enabled<br />

View File

@ -188,8 +188,7 @@ If you not want to use GIT from the command line - there is a usefull Eclipse pl
You should have created an account on github and forked the projects befor you procceed. You should have created an account on github and forked the projects befor you procceed.
Delete the directory www Delete the directory www
[code]root@debian /var/www/html $ cd .. [code]root@debian:/var# rm -R www/
rm -R www/
[/code] [/code]
Install git (and optionally git-gui a client gui) Install git (and optionally git-gui a client gui)
@ -211,7 +210,7 @@ root@debian:/var/www# mkdir -p "store/[data]/smarty3"
Create .htconfig.php and make it writable by the webserver Create .htconfig.php and make it writable by the webserver
[code] [code]
root@debian:/var# cd www/ root@debian:/var/www# touch .htconfig.php
root@debian:/var/www# chmod ou+w .htconfig.php root@debian:/var/www# chmod ou+w .htconfig.php
[/code] [/code]
@ -224,6 +223,7 @@ root@debian:/var# chown -R www-data:www-data www/
Add yourself ("surfer" in this example) to the group www-data. Why? Later you want to modify files in eclipse or in another editor. Add yourself ("surfer" in this example) to the group www-data. Why? Later you want to modify files in eclipse or in another editor.
Then make all files writable by the group www-date you are now a member of. Then make all files writable by the group www-date you are now a member of.
[code] [code]
root@debian:/var# cd www/
root@debian:/var/www# usermod -G www-data surfer root@debian:/var/www# usermod -G www-data surfer
root@debian:/var# chmod -R g+w www/ root@debian:/var# chmod -R g+w www/
[/code] [/code]

View File

@ -582,10 +582,15 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
if (strpos($Text,'[h6]') !== false) { if (strpos($Text,'[h6]') !== false) {
$Text = preg_replace("(\[h6\](.*?)\[\/h6\])ism",'<h6>$1</h6>',$Text); $Text = preg_replace("(\[h6\](.*?)\[\/h6\])ism",'<h6>$1</h6>',$Text);
} }
// Check for table of content // Check for table of content without params
if (strpos($Text,'[toc]') !== false) { if (strpos($Text,'[toc]') !== false) {
$Text = preg_replace("/\[toc\]/ism",'<ul id="toc"></ul>',$Text); $Text = preg_replace("/\[toc\]/ism",'<ul id="toc"></ul>',$Text);
} }
// Check for table of content with params
if (strpos($Text,'[toc') !== false) {
$Text = preg_replace("/\[toc([^\]]+?)\]/ism",'<ul$1></ul>',$Text);
}
// Check for centered text // Check for centered text
if (strpos($Text,'[/center]') !== false) { if (strpos($Text,'[/center]') !== false) {
$Text = preg_replace("(\[center\](.*?)\[\/center\])ism","<div style=\"text-align:center;\">$1</div>",$Text); $Text = preg_replace("(\[center\](.*?)\[\/center\])ism","<div style=\"text-align:center;\">$1</div>",$Text);

View File

@ -15,8 +15,6 @@
* *
* The original script was modified to work within the red#martrix * The original script was modified to work within the red#martrix
* - added var pathname * - added var pathname
* - added var textHeading: Accept heading with text only
* Why? At the moment webpages can contain empty title using h3
*/ */
(function ($) { (function ($) {
@ -56,35 +54,30 @@
var elem = $(this), level = $.map(headingSelectors, function (selector, index) { var elem = $(this), level = $.map(headingSelectors, function (selector, index) {
return elem.is(selector) ? index : undefined; return elem.is(selector) ? index : undefined;
})[0]; })[0];
if (level > currentLevel) {
// Accept heading with text only // If the heading is at a deeper level than where we are, start a new nested
var textHeading = elem.text(); // list, but only if we already have some list items in the parent. If we do
if(textHeading != '') { // not, that means that we're skipping levels, so we can just add new list items
if (level > currentLevel) { // at the current level.
// If the heading is at a deeper level than where we are, start a new nested // In the upside-down stack, unshift = push, and stack[0] = the top.
// list, but only if we already have some list items in the parent. If we do var parentItem = stack[0].children("li:last")[0];
// not, that means that we're skipping levels, so we can just add new list items if (parentItem) {
// at the current level. stack.unshift($("<" + listTag + "/>").appendTo(parentItem));
// In the upside-down stack, unshift = push, and stack[0] = the top.
var parentItem = stack[0].children("li:last")[0];
if (parentItem) {
stack.unshift($("<" + listTag + "/>").appendTo(parentItem));
}
} else {
// Truncate the stack to the current level by chopping off the 'top' of the
// stack. We also need to preserve at least one element in the stack - that is
// the containing element.
stack.splice(0, Math.min(currentLevel - level, Math.max(stack.length - 1, 0)));
} }
// the variable pathname was added to the original script. } else {
var pathname = window.location.pathname; // Truncate the stack to the current level by chopping off the 'top' of the
// Add the list item // stack. We also need to preserve at least one element in the stack - that is
$("<li/>").appendTo(stack[0]).append( // the containing element.
$("<a/>").text(elem.text()).attr("href", pathname + "#" + elem.attr("id")) stack.splice(0, Math.min(currentLevel - level, Math.max(stack.length - 1, 0)));
);
currentLevel = level;
} }
// the variable pathname was added to the original script.
var pathname = window.location.pathname;
// Add the list item
$("<li/>").appendTo(stack[0]).append(
$("<a/>").text(elem.text()).attr("href", pathname + "#" + elem.attr("id"))
);
currentLevel = level;
}); });
}); });
}, old = $.fn.toc; }, old = $.fn.toc;

View File

@ -1127,7 +1127,7 @@ $(document).ready(function() {
$(".autotime").timeago(); $(".autotime").timeago();
$("#toc").toc({content: "body", headings: "h1,h2,h3,h4"}); $("#toc").toc();
}); });