aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Manning <tamanning@zoho.com>2016-11-18 21:55:29 -0500
committerAndrew Manning <tamanning@zoho.com>2016-11-18 21:55:29 -0500
commitd24e867603fd253ea42050057896422beeba59db (patch)
treea8bae0233152a1c9985d23a98c3dd328cbe41f8f
parentd5c14a513d435aade7d16d792a7e7a22ff9b01ff (diff)
downloadvolse-hubzilla-d24e867603fd253ea42050057896422beeba59db.tar.gz
volse-hubzilla-d24e867603fd253ea42050057896422beeba59db.tar.bz2
volse-hubzilla-d24e867603fd253ea42050057896422beeba59db.zip
Move page list back out to the side menu, but with the new page form below the new page button like the new wiki form. Disable text editing if viewer lacks edit permission, and change the tab label to Source instead of Edit in that case.
-rw-r--r--Zotlabs/Module/Wiki.php1
-rw-r--r--include/widgets.php1
-rw-r--r--view/pdl/mod_wiki.pdl2
-rw-r--r--view/tpl/wiki.tpl49
-rw-r--r--view/tpl/wiki_page_list.tpl35
-rw-r--r--view/tpl/wikilist.tpl2
6 files changed, 49 insertions, 41 deletions
diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php
index edcd6ec58..45a0ab4d6 100644
--- a/Zotlabs/Module/Wiki.php
+++ b/Zotlabs/Module/Wiki.php
@@ -211,6 +211,7 @@ class Wiki extends \Zotlabs\Web\Controller {
'$wikiheaderPage' => $wikiheaderPage,
'$hideEditor' => $hide_editor,
'$showPageControls' => $showPageControls,
+ '$editOrSourceLabel' => (($showPageControls) ? t('Edit') : t('Source')),
'$tools_label' => 'Wiki Tools',
'$showNewWikiButton'=> $showNewWikiButton,
'$showNewPageButton'=> $showNewPageButton,
diff --git a/include/widgets.php b/include/widgets.php
index c0cc15e34..1441fbeb3 100644
--- a/include/widgets.php
+++ b/include/widgets.php
@@ -1017,6 +1017,7 @@ function widget_wiki_pages($arr) {
'$pages' => $pages,
'$canadd' => $can_create,
'$addnew' => t('Add new page'),
+ '$pageName' => array('pageName', t('Enter the name of the new page:'), '', ''),
));
}
diff --git a/view/pdl/mod_wiki.pdl b/view/pdl/mod_wiki.pdl
index 9d2160935..76ed1c70c 100644
--- a/view/pdl/mod_wiki.pdl
+++ b/view/pdl/mod_wiki.pdl
@@ -1,4 +1,4 @@
[region=aside]
[widget=wiki_list][/widget]
-[comment][widget=wiki_pages][/widget][/comment]
+[widget=wiki_pages][/widget]
[/region]
diff --git a/view/tpl/wiki.tpl b/view/tpl/wiki.tpl
index fd983ebdf..e23f9d286 100644
--- a/view/tpl/wiki.tpl
+++ b/view/tpl/wiki.tpl
@@ -62,8 +62,7 @@
<div id="wiki-content-container" class="section-content-wrapper" {{if $hideEditor}}style="display: none;"{{/if}}>
<ul class="nav nav-tabs" id="wiki-nav-tabs">
- <li id="wiki-header-page"><a data-toggle="tab" href="#pages-pane" id="wiki-show-page-list"><i class="fa fa-file-text-o" style="margin-right: 10px"></i>&nbsp Pages</a></li>
- <li id="edit-pane-tab"><a data-toggle="tab" href="#edit-pane">Edit</a></li>
+ <li id="edit-pane-tab"><a data-toggle="tab" href="#edit-pane">{{$editOrSourceLabel}}</a></li>
<li class="active"><a data-toggle="tab" href="#preview-pane" id="wiki-get-preview">View</a></li>
<li {{if $hidePageHistory}}style="display: none;"{{/if}}><a data-toggle="tab" href="#page-history-pane" id="wiki-get-history">History</a></li>
@@ -98,23 +97,8 @@
<div id="page-history-pane" class="tab-pane fade" {{if $hidePageHistory}}style="display: none;"{{/if}}>
<div id="page-history-list" class="section-content-wrapper">
</div>
- </div>
- <div id="pages-pane" class="tab-pane">
- <div id="wiki_page_list_container" style="display: none;">
- <div id="wiki_page_list" class="section-content-wrapper">
-
- </div>
- </div>
- <div id="new-page-form-wrapper" class="section-content-tools-wrapper" style="display:none;">
- <form id="new-page-form" action="wiki/create/page" method="post" >
- <div class="clear"></div>
- {{include file="field_input.tpl" field=$pageName}}
- <div class="btn-group pull-right">
- <button id="new-page-submit" class="btn btn-success" type="submit" name="submit" >Create Page</button>
- </div>
- </form> <div class="clear"></div>
- <hr>
- </div>
+ </div>
+
</div>
@@ -203,7 +187,9 @@
editor.getSession().setValue(window.wiki_page_content);
window.editor = editor; // Store the editor in the window object so the anonymous function can use it.
-
+ {{if !$showPageControls}}
+ editor.setReadOnly(true); // Disable editing if the viewer lacks edit permission
+ {{/if}}
$('#edit-pane-tab').click(function (ev) {
setTimeout(function() {window.editor.focus();}, 500); // Return the focus to the editor allowing immediate text entry
});
@@ -252,23 +238,6 @@
window.location = "wiki/{{$channel}}/download/wiki/" + resource_id;
}
- $('#new-page-submit').click(function (ev) {
- if (window.wiki_resource_id === '') {
- window.console.log('You must have a wiki open in order to create pages.');
- ev.preventDefault();
- return false;
- }
- $.post("wiki/{{$channel}}/create/page", {name: $('#id_pageName').val(), resource_id: window.wiki_resource_id},
- function (data) {
- if (data.success) {
- window.location = data.url;
- } else {
- window.console.log('Error creating page.');
- }
- }, 'json');
- ev.preventDefault();
- });
-
function wiki_refresh_page_list() {
if (window.wiki_resource_id === '') {
return false;
@@ -493,6 +462,7 @@
};
function wiki_show_new_wiki_form() {
+ $('div[id^=\'edit-wiki-form-wrapper\']').hide();
$('#new-page-form-wrapper').hide();
$('#edit-wiki-form-wrapper').hide();
$('#new-wiki-form-wrapper').toggle();
@@ -500,6 +470,7 @@
}
function wiki_show_new_page_form() {
+ $('div[id^=\'edit-wiki-form-wrapper\']').hide();
$('#edit-wiki-form-wrapper').hide();
$('#new-wiki-form-wrapper').hide();
$('#new-page-form-wrapper').toggle();
@@ -509,6 +480,7 @@
function wiki_show_edit_wiki_form(wiki_title, wiki_resource_id) {
window.wiki_resource_id = wiki_resource_id;
window.wiki_title = wiki_title;
+ $('div[id^=\'edit-wiki-form-wrapper\']').hide();
$('#new-page-form-wrapper').hide();
$('#new-wiki-form-wrapper').hide();
$('#edit-wiki-form-wrapper').toggle();
@@ -519,11 +491,12 @@
wiki_refresh_page_list();
$("#wiki-toc").toc({content: "#wiki-preview", headings: "h1,h2,h3,h4"});
// Show Edit tab first. Otherwise the Ace editor does not load.
- $("#wiki-nav-tabs li:eq(2) a").tab('show');
+ $("#wiki-nav-tabs li:eq(1) a").tab('show');
{{if $showNewWikiButton}}
$('#new-wiki-button').show();
{{else}}
$('#new-wiki-button').hide();
{{/if}}
+
});
</script>
diff --git a/view/tpl/wiki_page_list.tpl b/view/tpl/wiki_page_list.tpl
index afb14c6a9..c0eeecff8 100644
--- a/view/tpl/wiki_page_list.tpl
+++ b/view/tpl/wiki_page_list.tpl
@@ -1,6 +1,6 @@
{{if $not_refresh}}<div id="wiki_page_list_container" {{if $hide}} style="display: none;" {{/if}}>{{/if}}
<div id="wiki_page_list" class="widget" >
- <!--<h3>{{$header}}</h3>-->
+ <h3>{{$header}}</h3>
<ul class="nav nav-pills nav-stacked">
{{if $pages}}
@@ -10,5 +10,38 @@
{{/if}}
{{if $canadd}}<li><a href="#" onclick="wiki_show_new_page_form(); return false;"><i class="fa fa-plus-circle"></i>&nbsp;{{$addnew}}</a></li>{{/if}}
</ul>
+ {{if $canadd}}
+ <div id="new-page-form-wrapper" class="sub-menu" style="display:none;">
+ <form id="new-page-form" action="wiki/{{$channel}}/create/page" method="post" >
+ <div class="clear"></div>
+ {{include file="field_input.tpl" field=$pageName}}
+ <div class="btn-group pull-right">
+ <button id="new-page-submit" class="btn btn-success" type="submit" name="submit" >Create Page</button>
+ </div>
+ </form>
+ <div class="clear"></div>
+ <hr>
+ </div>
+ {{/if}}
</div>
{{if $not_refresh}}</div>{{/if}}
+
+<script>
+
+ $('#new-page-submit').click(function (ev) {
+ if (window.wiki_resource_id === '') {
+ window.console.log('You must have a wiki open in order to create pages.');
+ ev.preventDefault();
+ return false;
+ }
+ $.post("wiki/{{$channel}}/create/page", {name: $('#id_pageName').val(), resource_id: window.wiki_resource_id},
+ function (data) {
+ if (data.success) {
+ window.location = data.url;
+ } else {
+ window.console.log('Error creating page.');
+ }
+ }, 'json');
+ ev.preventDefault();
+ });
+</script> \ No newline at end of file
diff --git a/view/tpl/wikilist.tpl b/view/tpl/wikilist.tpl
index b8da88ec4..51eccad90 100644
--- a/view/tpl/wikilist.tpl
+++ b/view/tpl/wikilist.tpl
@@ -21,7 +21,7 @@
{{/foreach}}
{{/if}}
{{if $owner}}
- <li><a href="#" class="fakelink" onclick="$('div[id^=\'edit-wiki-form-wrapper\']').hide(); openClose('new-wiki-form-wrapper'); return false;"><i id="new-wiki-button" class="fa fa-plus-circle"></i>&nbsp;{{$addnew}}</a></li>
+ <li><a href="#" class="fakelink" onclick="wiki_show_new_wiki_form(); return false;"><i id="new-wiki-button" class="fa fa-plus-circle"></i>&nbsp;{{$addnew}}</a></li>
{{/if}}
</ul>
{{if $owner}}