Merge branch 'dev' of https://github.com/redmatrix/hubzilla into dev_merge

This commit is contained in:
zotlabs 2016-12-04 11:43:27 -08:00
commit 16e48a859c
8 changed files with 33 additions and 15 deletions

View File

@ -149,6 +149,7 @@ class Wiki extends \Zotlabs\Web\Controller {
'$wikiName' => array('wikiName', t('Wiki name')),
'$mimeType' => array('mimeType', t('Content type'), '', '', ['text/markdown' => 'Markdown', 'text/bbcode' => 'BB Code']),
'$name' => t('Name'),
'$type' => t('Type'),
'$lockstate' => $x['lockstate'],
'$acl' => $x['acl'],
'$allow_cid' => $x['allow_cid'],
@ -214,7 +215,7 @@ class Wiki extends \Zotlabs\Web\Controller {
$content = ($p['content'] !== '' ? $rawContent : '"# New page\n"');
// Render the Markdown-formatted page content in HTML
if($mimeType == 'text/bbcode') {
$renderedContent = bbcode($content);
$renderedContent = wiki_convert_links(bbcode($content),argv(0).'/'.argv(1).'/'.$wikiUrlName);
}
else {
require_once('library/markdown.php');
@ -314,7 +315,7 @@ class Wiki extends \Zotlabs\Web\Controller {
$mimeType = $w['mimeType'];
if($mimeType == 'text/bbcode') {
$html = bbcode($content);
$html = wiki_convert_links(bbcode($content),$wikiURL);
}
else {
require_once('library/markdown.php');

View File

@ -824,12 +824,14 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $cache = false)
$Text = preg_replace("(\[h6\](.*?)\[\/h6\])ism",'<h6>$1</h6>',$Text);
}
// Check for table of content without params
if (strpos($Text,'[toc]') !== false) {
$Text = preg_replace("/\[toc\]/ism",'<ul id="toc"></ul>',$Text);
while(strpos($Text,'[toc]') !== false) {
$toc_id = 'toc-' . random_string(10);
$Text = preg_replace("/\[toc\]/ism", '<ul id="' . $toc_id . '" class="toc" data-toc=".section-content-wrapper"></ul><script>$("#' . $toc_id . '").toc();</script>', $Text, 1);
}
// Check for table of content with params
if (strpos($Text,'[toc') !== false) {
$Text = preg_replace("/\[toc([^\]]+?)\]/ism",'<ul$1></ul>',$Text);
while(strpos($Text,'[toc') !== false) {
$toc_id = 'toc-' . random_string(10);
$Text = preg_replace("/\[toc([^\]]+?)\]/ism", '<ul id="' . $toc_id . '" class="toc"$1></ul><script>$("#' . $toc_id . '").toc();</script>', $Text, 1);
}
// Check for centered text
if (strpos($Text,'[/center]') !== false) {

View File

@ -19,7 +19,7 @@ function wiki_list($channel, $observer_hash) {
$w['htmlName'] = get_iconfig($w, 'wiki', 'htmlName');
$w['urlName'] = get_iconfig($w, 'wiki', 'urlName');
$w['path'] = get_iconfig($w, 'wiki', 'path');
$w['path'] = get_iconfig($w, 'wiki', 'mimeType');
$w['mimeType'] = get_iconfig($w, 'wiki', 'mimeType');
}
}
// TODO: query db for wikis the observer can access. Return with two lists, for read and write access

View File

@ -336,6 +336,19 @@ a.wall-item-name-link {
/* bb-code */
/* prevent [toc] bbcode links to scroll the titles behind the navbar */
.section-content-wrapper h1,
.section-content-wrapper h2,
.section-content-wrapper h3,
.section-content-wrapper h4 {
padding-top: 60px;
margin-top: -40px;
}
.toc {
margin-top: 1em;
}
code {
font-family: Courier, monospace;
font-size: 1em;

View File

@ -29,13 +29,13 @@
padding: 7px 3px 7px 10px;
}
#wikis-index th:nth-child(2),
#wikis-index td:nth-child(2){
#wikis-index th:nth-child(3),
#wikis-index td:nth-child(3){
padding: 7px 10px 7px 7px;
}
#wikis-index th:nth-child(3),
#wikis-index td:nth-child(3){
#wikis-index th:nth-child(4),
#wikis-index td:nth-child(4){
padding: 7px 10px 7px 7px;
}

View File

@ -1315,7 +1315,6 @@ $(document).ready(function() {
numbers : aStr['t17'],
};
$("#toc").toc();
});
function zFormError(elm,x) {

View File

@ -184,7 +184,9 @@
function (data) {
if (data.success) {
$('#wiki-preview').html(data.html);
{{if !$mimeType || $mimeType == 'text/markdown'}}
$("#wiki-toc").toc({content: "#wiki-preview", headings: "h1,h2,h3,h4"});
{{/if}}
$('#page-tools').hide();
} else {
window.console.log('Error previewing page.');
@ -418,13 +420,12 @@
$(document).ready(function () {
wiki_refresh_page_list();
$("#wiki-toc").toc({content: "#wiki-preview", headings: "h1,h2,h3,h4"});
// This seems obsolete
// Show Edit tab first. Otherwise the Ace editor does not load.
//$("#wiki-nav-tabs li:eq(1) a").tab('show');
{{if !$mimeType || $mimeType == 'text/markdown'}}
$("#wiki-toc").toc({content: "#wiki-preview", headings: "h1,h2,h3,h4"});
window.editor.on("input", function() {
if(window.editor.getSession().getUndoManager().isClean()) {
$('#save-page').addClass('disabled');

View File

@ -27,7 +27,8 @@
<div class="section-content-wrapper-np">
<table id="wikis-index">
<tr>
<th width="98%">{{$name}}</th>
<th width="97%">{{$name}}</th>
<th width="1%">{{$type}}</th>
<th width="1%" class="wikis-index-tool"></th>
{{if $owner}}
<th width="1%"></th>
@ -36,6 +37,7 @@
{{foreach $wikis as $wiki}}
<tr class="wikis-index-row">
<td><a href="/wiki/{{$channel}}/{{$wiki.urlName}}/Home" title="{{$view}}"{{if $wiki.active}} class="active"{{/if}}>{{$wiki.title}}</a></td>
<td>{{$wiki.mimeType}}</td>
<td class="wiki-index-tool"><i class="fa fa-download fakelink" onclick="wiki_download_wiki('{{$wiki.resource_id}}'); return false;"></i></td>
{{if $owner}}
<td><i class="fa fa-trash-o drop-icons" onclick="wiki_delete_wiki('{{$wiki.title}}', '{{$wiki.resource_id}}'); return false;"></i></td>