aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2016-11-15 12:52:48 +1100
committerGitHub <noreply@github.com>2016-11-15 12:52:48 +1100
commit537510f0810976c2b8cd3861d914645a4e2c2b06 (patch)
tree22bb746792ce516befa9fd29ed932735d5bdf1c1
parentdc411ca889e4fbc1201d443674f73bc523b57dc9 (diff)
parent1985502894651b263cca769509220b9e85827b4a (diff)
downloadvolse-hubzilla-537510f0810976c2b8cd3861d914645a4e2c2b06.tar.gz
volse-hubzilla-537510f0810976c2b8cd3861d914645a4e2c2b06.tar.bz2
volse-hubzilla-537510f0810976c2b8cd3861d914645a4e2c2b06.zip
Merge pull request #585 from anaqreon/wiki
Wiki
-rw-r--r--Zotlabs/Module/Wiki.php1
-rw-r--r--view/tpl/wiki.tpl730
-rw-r--r--view/tpl/wiki_page_list.tpl4
-rw-r--r--view/tpl/wikilist.tpl18
4 files changed, 397 insertions, 356 deletions
diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php
index 68731e852..9fd1234e3 100644
--- a/Zotlabs/Module/Wiki.php
+++ b/Zotlabs/Module/Wiki.php
@@ -212,7 +212,6 @@ class Wiki extends \Zotlabs\Web\Controller {
'$hideEditor' => $hide_editor,
'$showPageControls' => $showPageControls,
'$tools_label' => 'Wiki Tools',
- '$showTools' => $showNewWikiButton || $showNewPageButton,
'$showNewWikiButton'=> $showNewWikiButton,
'$showNewPageButton'=> $showNewPageButton,
'$hidePageHistory' => $hidePageHistory,
diff --git a/view/tpl/wiki.tpl b/view/tpl/wiki.tpl
index c26ffd64a..4e76a79be 100644
--- a/view/tpl/wiki.tpl
+++ b/view/tpl/wiki.tpl
@@ -15,24 +15,12 @@
<div class="section-title-wrapper">
<div class="pull-right">
- {{if $showNewWikiButton || $showPageControls}}
+ {{if $showPageControls}}
<div class="btn-group">
<button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-caret-down"></i>&nbsp;{{$tools_label}}
</button>
<ul class="dropdown-menu">
- {{if $showNewWikiButton}}
- <li class="nav-item">
- <a class="nav-link" href="#" onclick="$('#new-page-form-wrapper').hide(); openClose('new-wiki-form-wrapper'); return false;" data-form_id="new-wiki-form"><i class="fa fa-book"></i>&nbsp;New Wiki</a>
- </li>
- {{/if}}
- {{if $showNewPageButton}}
- <li class="nav-item">
- <a class="nav-link" href="#" onclick="$('#new-wiki-form-wrapper').hide(); openClose('new-page-form-wrapper'); return false;" data-form_id="new-page-form"><i class="fa fa-file-text-o"></i>&nbsp;New Page</a>
- </li>
- {{/if}}
- {{if $showPageControls}}
- <li class="divider"></li>
<li class="nav-item">
<a id="rename-page" class="nav-link" href="#"><i class="fa fa-edit"></i>&nbsp;Rename Page</a>
@@ -43,7 +31,7 @@
<li class="nav-item">
<a id="embed-image" class="nav-link" href="#"><i class="fa fa-picture-o"></i>&nbsp;Embed Image</a>
</li>
- {{/if}}
+
</ul>
</div>
@@ -87,6 +75,18 @@
<hr>
</div>
+ <div id="edit-wiki-form-wrapper" class="section-content-tools-wrapper" style="display:none;">
+ <form id="edit-wiki-form" action="wiki/edit/wiki" method="post" >
+ <div class="clear"></div>
+
+ <div class="btn-group pull-right">
+ <!--<button id="edit-wiki-submit" class="btn btn-success" type="submit" name="submit" >Edit Wiki</button>-->
+ <button class="btn btn-md btn-danger" onclick="wiki_delete_wiki(window.wiki_title, window.wiki_resource_id); return false;"><i class="fa fa-trash-o"></i>&nbsp;Delete Wiki</button>
+ </div>
+ </form> <div class="clear"></div>
+ <hr>
+ </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>
@@ -178,338 +178,376 @@
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
+
<script>
- window.wiki_resource_id = '{{$resource_id}}';
- window.wiki_page_name = '{{$page}}';
- window.wiki_page_content = {{$content}};
- window.wiki_page_commit = '{{$commit}}';
-
- if (window.wiki_page_name === 'Home') {
- $('#delete-page').hide();
- $('#rename-page').hide();
- }
-
- $("#generic-modal-ok-{{$wikiModalID}}").removeClass('btn-primary');
- $("#generic-modal-ok-{{$wikiModalID}}").addClass('btn-danger');
-
- $('#rename-page').click(function (ev) {
- $('#rename-page-form-wrapper').show();
- ev.preventDefault();
- });
-
- $( "#rename-page-form" ).submit(function( event ) {
- $.post("wiki/{{$channel}}/rename/page",
- {
- oldName: window.wiki_page_name,
- newName: $('#id_pageRename').val(),
- resource_id: window.wiki_resource_id
- },
- function (data) {
- if (data.success) {
- $('#rename-page-form-wrapper').hide();
- window.console.log('data: ' + JSON.stringify(data));
- window.wiki_page_name = data.name.urlName;
- $('#wiki-header-page').html(data.name.htmlName);
- wiki_refresh_page_list();
- } else {
- window.console.log('Error renaming page.');
- }
- }, 'json');
- event.preventDefault();
- });
-
- $(document).ready(function () {
- 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(1) a").tab('show');
- });
-
- var editor = ace.edit("ace-editor");
- editor.setTheme("ace/theme/github");
- editor.getSession().setMode("ace/mode/markdown");
- editor.getSession().setValue(window.wiki_page_content);
- window.editor = editor; // Store the editor in the window object so the anonymous function can use it.
- $('#edit-pane-tab').click(function (ev) {
- setTimeout(function() {window.editor.focus();}, 500); // Return the focus to the editor allowing immediate text entry
- });
-
- $('#wiki-get-preview').click(function (ev) {
- $.post("wiki/{{$channel}}/preview", {content: editor.getValue(), resource_id: window.wiki_resource_id}, function (data) {
- if (data.success) {
- $('#wiki-preview').html(data.html);
- $("#wiki-toc").toc({content: "#wiki-preview", headings: "h1,h2,h3,h4"});
- } else {
- window.console.log('Error previewing page.');
- }
- }, 'json');
- ev.preventDefault();
- });
-
- $('#wiki-get-history').click(function (ev) {
- $.post("wiki/{{$channel}}/history/page", {name: window.wiki_page_name, resource_id: window.wiki_resource_id}, function (data) {
- if (data.success) {
- $('#page-history-list').html(data.historyHTML);
- } else {
- window.console.log('Error getting page history.');
- }
- }, 'json');
- ev.preventDefault();
- });
-
-function wiki_delete_wiki(wikiHtmlName, resource_id) {
- if(!confirm('Are you sure you want to delete the entire wiki: ' + JSON.stringify(wikiHtmlName))) {
- return;
- }
- $.post("wiki/{{$channel}}/delete/wiki", {resource_id: resource_id}, function (data) {
- if (data.success) {
- window.console.log('Wiki deleted');
- // Refresh list and redirect page as necessary
- window.location = 'wiki/{{$channel}}';
- } else {
- alert('Error deleting wiki!');
- window.console.log('Error deleting wiki.');
- }
- }, 'json');
-}
+ window.wiki_resource_id = '{{$resource_id}}';
+ window.wiki_page_name = '{{$page}}';
+ window.wiki_page_content = {{$content}};
+ window.wiki_page_commit = '{{$commit}}';
-
-function wiki_download_wiki(resource_id) {
- 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;
- }
- $.post("wiki/{{$channel}}/get/page/list/", {resource_id: window.wiki_resource_id}, function (data) {
- if (data.success) {
- $('#wiki_page_list_container').html(data.pages);
- $('#wiki_page_list_container').show();
- } else {
- alert('Error fetching page list!');
- window.console.log('Error fetching page list!');
- }
- }, 'json');
- return false;
- }
-
- $('#save-page').click(function (ev) {
- if (window.wiki_resource_id === '' || window.wiki_page_name === '') {
- window.console.log('You must have a wiki page open in order to edit pages.');
- ev.preventDefault();
- return false;
- }
- var currentContent = editor.getValue();
- if (window.wiki_page_content === currentContent) {
- window.console.log('No edits to save.');
- ev.preventDefault();
- return false;
- }
- $.post("wiki/{{$channel}}/save/page",
- { content: currentContent,
- commitMsg: $('#id_commitMsg').val(),
- name: window.wiki_page_name,
- resource_id: window.wiki_resource_id
- },
- function (data) {
- if (data.success) {
- window.console.log('Page saved successfully.');
- window.wiki_page_content = currentContent;
- $('#id_commitMsg').val(''); // Clear the commit message box
- $('#wiki-get-history').click();
- } else {
- alert('Error saving page.'); // TODO: Replace alerts with auto-timeout popups
- window.console.log('Error saving page.');
- }
- }, 'json');
- ev.preventDefault();
- });
-
- $('#delete-page').click(function (ev) {
- if (window.wiki_resource_id === '' || window.wiki_page_name === '' || window.wiki_page_name === 'Home') {
- window.console.log('You must have a wiki page open in order to delete pages.');
- ev.preventDefault();
- return false;
- }
- if(!confirm('Are you sure you want to delete the page: ' + window.wiki_page_name)) {
+ if (window.wiki_page_name === 'Home') {
+ $('#delete-page').hide();
+ $('#rename-page').hide();
+ }
+
+ $("#generic-modal-ok-{{$wikiModalID}}").removeClass('btn-primary');
+ $("#generic-modal-ok-{{$wikiModalID}}").addClass('btn-danger');
+
+ $('#rename-page').click(function (ev) {
+ $('#rename-page-form-wrapper').show();
+ ev.preventDefault();
+ });
+
+ $( "#rename-page-form" ).submit(function( event ) {
+ $.post("wiki/{{$channel}}/rename/page",
+ {
+ oldName: window.wiki_page_name,
+ newName: $('#id_pageRename').val(),
+ resource_id: window.wiki_resource_id
+ },
+ function (data) {
+ if (data.success) {
+ $('#rename-page-form-wrapper').hide();
+ window.console.log('data: ' + JSON.stringify(data));
+ window.wiki_page_name = data.name.urlName;
+ $('#wiki-header-page').html(data.name.htmlName);
+ wiki_refresh_page_list();
+ } else {
+ window.console.log('Error renaming page.');
+ }
+ }, 'json');
+ event.preventDefault();
+ });
+
+ var editor = ace.edit("ace-editor");
+ editor.setTheme("ace/theme/github");
+ editor.getSession().setMode("ace/mode/markdown");
+ editor.getSession().setValue(window.wiki_page_content);
+ window.editor = editor; // Store the editor in the window object so the anonymous function can use it.
+ $('#edit-pane-tab').click(function (ev) {
+ setTimeout(function() {window.editor.focus();}, 500); // Return the focus to the editor allowing immediate text entry
+ });
+
+ $('#wiki-get-preview').click(function (ev) {
+ $.post("wiki/{{$channel}}/preview", {content: editor.getValue(), resource_id: window.wiki_resource_id}, function (data) {
+ if (data.success) {
+ $('#wiki-preview').html(data.html);
+ $("#wiki-toc").toc({content: "#wiki-preview", headings: "h1,h2,h3,h4"});
+ } else {
+ window.console.log('Error previewing page.');
+ }
+ }, 'json');
ev.preventDefault();
- return;
- }
- $.post("wiki/{{$channel}}/delete/page", {name: window.wiki_page_name, resource_id: window.wiki_resource_id},
- function (data) {
- if (data.success) {
- window.console.log('Page deleted successfully.');
- var url = window.location.href;
- if (url.substr(-1) == '/') url = url.substr(0, url.length - 2);
- url = url.split('/');
- url.pop();
- window.location = url.join('/');
- } else {
- alert('Error deleting page.'); // TODO: Replace alerts with auto-timeout popups
- window.console.log('Error deleting page.');
- }
- }, 'json');
- ev.preventDefault();
- });
-
- function wiki_revert_page(commitHash) {
- if (window.wiki_resource_id === '' || window.wiki_page_name === '') {
- window.console.log('You must have a wiki page open in order to revert pages.');
- return false;
- }
- $.post("wiki/{{$channel}}/revert/page", {commitHash: commitHash, name: window.wiki_page_name, resource_id: window.wiki_resource_id},
- function (data) {
- if (data.success) {
- $('button[id^=revert-]').removeClass('btn-success');
- $('button[id^=revert-]').addClass('btn-danger');
- $('button[id^=revert-]').html('Revert');
- $('#revert-'+commitHash).removeClass('btn-danger');
- $('#revert-'+commitHash).addClass('btn-success');
- $('#revert-'+commitHash).html('Page reverted<br>but not saved');
- window.wiki_page_commit = commitHash;
- // put contents in editor
- editor.getSession().setValue(data.content);
- } else {
- window.console.log('Error reverting page.');
- }
- }, 'json');
- }
-
- function wiki_compare_page(compareCommit) {
- if (window.wiki_resource_id === '' || window.wiki_page_name === '' || window.wiki_page_commit === '') {
- window.console.log('You must have a wiki page open in order to revert pages.');
- return false;
- }
- $.post("wiki/{{$channel}}/compare/page",
- {
- compareCommit: compareCommit,
- currentCommit: window.wiki_page_commit,
- name: window.wiki_page_name,
- resource_id: window.wiki_resource_id
- },
- function (data) {
- if (data.success) {
- var modalBody = $('#generic-modal-body-{{$wikiModalID}}');
- modalBody.html('<div class="descriptive-text">'+data.diff+'</div>');
- $('.modal-dialog').width('80%');
- $("#generic-modal-ok-{{$wikiModalID}}").off('click');
- $("#generic-modal-ok-{{$wikiModalID}}").click(function () {
- wiki_revert_page(compareCommit);
- $('#generic-modal-{{$wikiModalID}}').modal('hide');
- });
- $('#generic-modal-{{$wikiModalID}}').modal();
- } else {
- window.console.log('Error comparing page.');
- }
- }, 'json');
- }
-
- $('#embed-image').click(function (ev) {
- initializeEmbedPhotoDialog();
- ev.preventDefault();
- });
-
-
- var initializeEmbedPhotoDialog = function () {
- $('.embed-photo-selected-photo').each(function (index) {
- $(this).removeClass('embed-photo-selected-photo');
- });
- getPhotoAlbumList();
- $('#embedPhotoModalBodyAlbumDialog').off('click');
- $('#embedPhotoModal').modal();
- };
-
- var choosePhotoFromAlbum = function (album) {
- $.post("embedphotos/album", {name: album},
- function(data) {
- if (data['status']) {
- $('#embedPhotoModalLabel').html('{{$modalchooseimages}}');
- $('#embedPhotoModalBodyAlbumDialog').html('\
- <div><ul class="nav">\n\
- <li><a href="#" onclick="initializeEmbedPhotoDialog();return false;">\n\
- <i class="fa fa-chevron-left"></i>&nbsp\n\
- {{$modaldiffalbum}}\n\
- </a>\n\
- </li>\n\
- </ul><br></div>')
- $('#embedPhotoModalBodyAlbumDialog').append(data['content']);
- $('#embedPhotoModalBodyAlbumDialog').click(function (evt) {
- evt.preventDefault();
- var image = document.getElementById(evt.target.id);
- if (typeof($(image).parent()[0]) !== 'undefined') {
- var imageparent = document.getElementById($(image).parent()[0].id);
- $(imageparent).toggleClass('embed-photo-selected-photo');
- }
- });
- $('#embedPhotoModalBodyAlbumListDialog').addClass('hide');
- $('#embedPhotoModalBodyAlbumDialog').removeClass('hide');
- $('#embed-photo-OKButton').click(function () {
- $('.embed-photo-selected-photo').each(function (index) {
- var href = $(this).attr('href');
- $.post("embedphotos/photolink", {href: href},
- function(ddata) {
- if (ddata['status']) {
- var imgURL = ddata['photolink'].replace( /\[.*\]\[.*\](.*)\[.*\]\[.*\]/, '\n![image]($1)' )
- editor.getSession().insert(editor.getCursorPosition(), imgURL)
- } else {
- window.console.log('{{$modalerrorlink}}' + ':' + ddata['errormsg']);
- }
- return false;
- },
- 'json');
- });
- $('#embedPhotoModalBodyAlbumDialog').html('');
- $('#embedPhotoModalBodyAlbumDialog').off('click');
- $('#embedPhotoModal').modal('hide');
- });
- } else {
- window.console.log('{{$modalerroralbum}} ' + JSON.stringify(album) + ':' + data['errormsg']);
- }
- return false;
- },
- 'json');
- };
-
- var getPhotoAlbumList = function () {
- $.post("embedphotos/albumlist", {},
- function(data) {
- if (data['status']) {
- var albums = data['albumlist']; //JSON.parse(data['albumlist']);
- $('#embedPhotoModalLabel').html('{{$modalchoosealbum}}');
- $('#embedPhotoModalBodyAlbumList').html('<ul class="nav"></ul>');
- for(var i=0; i<albums.length; i++) {
- var albumName = albums[i].text;
- var albumLink = '<li>';
- albumLink += '<a href="#" onclick="choosePhotoFromAlbum(\'' + albumName + '\');return false;">' + albumName + '</a>';
- albumLink += '</li>';
- $('#embedPhotoModalBodyAlbumList').find('ul').append(albumLink);
- }
- $('#embedPhotoModalBodyAlbumDialog').addClass('hide');
- $('#embedPhotoModalBodyAlbumListDialog').removeClass('hide');
- } else {
- window.console.log('{{$modalerrorlist}}' + ':' + data['errormsg']);
- }
- return false;
- },
- 'json');
- };
-
-</script>
+ });
+
+ $('#wiki-get-history').click(function (ev) {
+ $.post("wiki/{{$channel}}/history/page", {name: window.wiki_page_name, resource_id: window.wiki_resource_id}, function (data) {
+ if (data.success) {
+ $('#page-history-list').html(data.historyHTML);
+ } else {
+ window.console.log('Error getting page history.');
+ }
+ }, 'json');
+ ev.preventDefault();
+ });
+
+ function wiki_delete_wiki(wikiHtmlName, resource_id) {
+ if(!confirm('Are you sure you want to delete the entire wiki: ' + JSON.stringify(wikiHtmlName))) {
+ return;
+ }
+ $.post("wiki/{{$channel}}/delete/wiki", {resource_id: resource_id}, function (data) {
+ if (data.success) {
+ window.console.log('Wiki deleted');
+ // Refresh list and redirect page as necessary
+ window.location = 'wiki/{{$channel}}';
+ } else {
+ alert('Error deleting wiki!');
+ window.console.log('Error deleting wiki.');
+ }
+ }, 'json');
+ }
+
+
+ function wiki_download_wiki(resource_id) {
+ 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;
+ }
+ $.post("wiki/{{$channel}}/get/page/list/", {resource_id: window.wiki_resource_id}, function (data) {
+ if (data.success) {
+ $('#wiki_page_list_container').html(data.pages);
+ $('#wiki_page_list_container').show();
+ {{if $showNewPageButton}}
+ $('#new-page-button').show();
+ {{else}}
+ $('#new-page-button').hide();
+ {{/if}}
+ } else {
+ alert('Error fetching page list!');
+ window.console.log('Error fetching page list!');
+ }
+ }, 'json');
+ return false;
+ }
+
+ $('#save-page').click(function (ev) {
+ if (window.wiki_resource_id === '' || window.wiki_page_name === '') {
+ window.console.log('You must have a wiki page open in order to edit pages.');
+ ev.preventDefault();
+ return false;
+ }
+ var currentContent = editor.getValue();
+ if (window.wiki_page_content === currentContent) {
+ window.console.log('No edits to save.');
+ ev.preventDefault();
+ return false;
+ }
+ $.post("wiki/{{$channel}}/save/page",
+ { content: currentContent,
+ commitMsg: $('#id_commitMsg').val(),
+ name: window.wiki_page_name,
+ resource_id: window.wiki_resource_id
+ },
+ function (data) {
+ if (data.success) {
+ window.console.log('Page saved successfully.');
+ window.wiki_page_content = currentContent;
+ $('#id_commitMsg').val(''); // Clear the commit message box
+ $('#wiki-get-history').click();
+ } else {
+ alert('Error saving page.'); // TODO: Replace alerts with auto-timeout popups
+ window.console.log('Error saving page.');
+ }
+ }, 'json');
+ ev.preventDefault();
+ });
+
+ $('#delete-page').click(function (ev) {
+ if (window.wiki_resource_id === '' || window.wiki_page_name === '' || window.wiki_page_name === 'Home') {
+ window.console.log('You must have a wiki page open in order to delete pages.');
+ ev.preventDefault();
+ return false;
+ }
+ if(!confirm('Are you sure you want to delete the page: ' + window.wiki_page_name)) {
+ ev.preventDefault();
+ return;
+ }
+ $.post("wiki/{{$channel}}/delete/page", {name: window.wiki_page_name, resource_id: window.wiki_resource_id},
+ function (data) {
+ if (data.success) {
+ window.console.log('Page deleted successfully.');
+ var url = window.location.href;
+ if (url.substr(-1) == '/') url = url.substr(0, url.length - 2);
+ url = url.split('/');
+ url.pop();
+ window.location = url.join('/');
+ } else {
+ alert('Error deleting page.'); // TODO: Replace alerts with auto-timeout popups
+ window.console.log('Error deleting page.');
+ }
+ }, 'json');
+ ev.preventDefault();
+ });
+
+ function wiki_revert_page(commitHash) {
+ if (window.wiki_resource_id === '' || window.wiki_page_name === '') {
+ window.console.log('You must have a wiki page open in order to revert pages.');
+ return false;
+ }
+ $.post("wiki/{{$channel}}/revert/page", {commitHash: commitHash, name: window.wiki_page_name, resource_id: window.wiki_resource_id},
+ function (data) {
+ if (data.success) {
+ $('button[id^=revert-]').removeClass('btn-success');
+ $('button[id^=revert-]').addClass('btn-danger');
+ $('button[id^=revert-]').html('Revert');
+ $('#revert-'+commitHash).removeClass('btn-danger');
+ $('#revert-'+commitHash).addClass('btn-success');
+ $('#revert-'+commitHash).html('Page reverted<br>but not saved');
+ window.wiki_page_commit = commitHash;
+ // put contents in editor
+ editor.getSession().setValue(data.content);
+ } else {
+ window.console.log('Error reverting page.');
+ }
+ }, 'json');
+ }
+
+ function wiki_compare_page(compareCommit) {
+ if (window.wiki_resource_id === '' || window.wiki_page_name === '' || window.wiki_page_commit === '') {
+ window.console.log('You must have a wiki page open in order to revert pages.');
+ return false;
+ }
+ $.post("wiki/{{$channel}}/compare/page",
+ {
+ compareCommit: compareCommit,
+ currentCommit: window.wiki_page_commit,
+ name: window.wiki_page_name,
+ resource_id: window.wiki_resource_id
+ },
+ function (data) {
+ if (data.success) {
+ var modalBody = $('#generic-modal-body-{{$wikiModalID}}');
+ modalBody.html('<div class="descriptive-text">'+data.diff+'</div>');
+ $('.modal-dialog').width('80%');
+ $("#generic-modal-ok-{{$wikiModalID}}").off('click');
+ $("#generic-modal-ok-{{$wikiModalID}}").click(function () {
+ wiki_revert_page(compareCommit);
+ $('#generic-modal-{{$wikiModalID}}').modal('hide');
+ });
+ $('#generic-modal-{{$wikiModalID}}').modal();
+ } else {
+ window.console.log('Error comparing page.');
+ }
+ }, 'json');
+ }
+
+ $('#embed-image').click(function (ev) {
+ initializeEmbedPhotoDialog();
+ ev.preventDefault();
+ });
+
+
+ var initializeEmbedPhotoDialog = function () {
+ $('.embed-photo-selected-photo').each(function (index) {
+ $(this).removeClass('embed-photo-selected-photo');
+ });
+ getPhotoAlbumList();
+ $('#embedPhotoModalBodyAlbumDialog').off('click');
+ $('#embedPhotoModal').modal();
+ };
+
+ var choosePhotoFromAlbum = function (album) {
+ $.post("embedphotos/album", {name: album},
+ function(data) {
+ if (data['status']) {
+ $('#embedPhotoModalLabel').html('{{$modalchooseimages}}');
+ $('#embedPhotoModalBodyAlbumDialog').html('\
+ <div><ul class="nav">\n\
+ <li><a href="#" onclick="initializeEmbedPhotoDialog();return false;">\n\
+ <i class="fa fa-chevron-left"></i>&nbsp\n\
+ {{$modaldiffalbum}}\n\
+ </a>\n\
+ </li>\n\
+ </ul><br></div>')
+ $('#embedPhotoModalBodyAlbumDialog').append(data['content']);
+ $('#embedPhotoModalBodyAlbumDialog').click(function (evt) {
+ evt.preventDefault();
+ var image = document.getElementById(evt.target.id);
+ if (typeof($(image).parent()[0]) !== 'undefined') {
+ var imageparent = document.getElementById($(image).parent()[0].id);
+ $(imageparent).toggleClass('embed-photo-selected-photo');
+ }
+ });
+ $('#embedPhotoModalBodyAlbumListDialog').addClass('hide');
+ $('#embedPhotoModalBodyAlbumDialog').removeClass('hide');
+ $('#embed-photo-OKButton').click(function () {
+ $('.embed-photo-selected-photo').each(function (index) {
+ var href = $(this).attr('href');
+ $.post("embedphotos/photolink", {href: href},
+ function(ddata) {
+ if (ddata['status']) {
+ var imgURL = ddata['photolink'].replace( /\[.*\]\[.*\](.*)\[.*\]\[.*\]/, '\n![image]($1)' )
+ editor.getSession().insert(editor.getCursorPosition(), imgURL)
+ } else {
+ window.console.log('{{$modalerrorlink}}' + ':' + ddata['errormsg']);
+ }
+ return false;
+ },
+ 'json');
+ });
+ $('#embedPhotoModalBodyAlbumDialog').html('');
+ $('#embedPhotoModalBodyAlbumDialog').off('click');
+ $('#embedPhotoModal').modal('hide');
+ });
+ } else {
+ window.console.log('{{$modalerroralbum}} ' + JSON.stringify(album) + ':' + data['errormsg']);
+ }
+ return false;
+ },
+ 'json');
+ };
+
+ var getPhotoAlbumList = function () {
+ $.post("embedphotos/albumlist", {},
+ function(data) {
+ if (data['status']) {
+ var albums = data['albumlist']; //JSON.parse(data['albumlist']);
+ $('#embedPhotoModalLabel').html('{{$modalchoosealbum}}');
+ $('#embedPhotoModalBodyAlbumList').html('<ul class="nav"></ul>');
+ for(var i=0; i<albums.length; i++) {
+ var albumName = albums[i].text;
+ var albumLink = '<li>';
+ albumLink += '<a href="#" onclick="choosePhotoFromAlbum(\'' + albumName + '\');return false;">' + albumName + '</a>';
+ albumLink += '</li>';
+ $('#embedPhotoModalBodyAlbumList').find('ul').append(albumLink);
+ }
+ $('#embedPhotoModalBodyAlbumDialog').addClass('hide');
+ $('#embedPhotoModalBodyAlbumListDialog').removeClass('hide');
+ } else {
+ window.console.log('{{$modalerrorlist}}' + ':' + data['errormsg']);
+ }
+ return false;
+ },
+ 'json');
+ };
+
+ function wiki_show_new_wiki_form() {
+ $('#new-page-form-wrapper').hide();
+ $('#edit-wiki-form-wrapper').hide();
+ $('#new-wiki-form-wrapper').toggle();
+ return false;
+ }
+
+ function wiki_show_new_page_form() {
+ $('#edit-wiki-form-wrapper').hide();
+ $('#new-wiki-form-wrapper').hide();
+ $('#new-page-form-wrapper').toggle();
+ return false;
+ }
+
+ function wiki_show_edit_wiki_form(wiki_title, wiki_resource_id) {
+ window.wiki_resource_id = wiki_resource_id;
+ window.wiki_title = wiki_title;
+ $('#new-page-form-wrapper').hide();
+ $('#new-wiki-form-wrapper').hide();
+ $('#edit-wiki-form-wrapper').toggle();
+ return false;
+ }
+
+ $(document).ready(function () {
+ 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(1) a").tab('show');
+ {{if $showNewWikiButton}}
+ $('#new-wiki-button').show();
+ {{else}}
+ $('#new-wiki-button').hide();
+ {{/if}}
+ {{if $showPageControls}}
+ $('#edit-wiki-button').show();
+ {{else}}
+ $('#edit-wiki-button').hide();
+ {{/if}}
+ });
+</script> \ No newline at end of file
diff --git a/view/tpl/wiki_page_list.tpl b/view/tpl/wiki_page_list.tpl
index 1c3254465..c5f3ec9a0 100644
--- a/view/tpl/wiki_page_list.tpl
+++ b/view/tpl/wiki_page_list.tpl
@@ -1,6 +1,8 @@
{{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}}
+ <i id="new-page-button" class="pull-right generic-icons fakelink fa fa-plus" title="New page" onclick="wiki_show_new_page_form();"></i>
+ </h3>
<ul class="nav nav-pills nav-stacked">
{{foreach $pages as $page}}
<li><a href="/wiki/{{$channel}}/{{$wikiname}}/{{$page.url}}">{{$page.title}}</a></li>
diff --git a/view/tpl/wikilist.tpl b/view/tpl/wikilist.tpl
index 0828d78fa..42452eb12 100644
--- a/view/tpl/wikilist.tpl
+++ b/view/tpl/wikilist.tpl
@@ -1,14 +1,16 @@
<div id="wiki_list" class="widget">
- <h3>{{$header}}</h3>
+
+ <h3>{{$header}}
+ <i id="new-wiki-button" class="pull-right generic-icons fakelink fa fa-plus" title="New wiki" onclick="wiki_show_new_wiki_form();"></i>
+ </h3>
+
<div>
{{foreach $wikis as $wiki}}
- <div class="form-group" id="wiki-{{$wiki.resource_id}}">
- <a href="/wiki/{{$channel}}/{{$wiki.urlName}}/Home" title="View {{$wiki.title}}"><b>{{$wiki.title}}</b></a>
- {{if $owner}}
- <i class="pull-right drop-icons fakelink fa fa-trash-o" onclick="wiki_delete_wiki('{{$wiki.title}}','{{$wiki.resource_id}}'); return false;" title="Delete {{$wiki.title}}"></i>
- <i class="pull-right generic-icons fakelink fa fa-download" onclick="wiki_download_wiki('{{$wiki.resource_id}}'); return false;" title="Download {{$wiki.title}}"></i>
- {{/if}}
- </div>
+ <div class="form-group" id="wiki-{{$wiki.resource_id}}">
+ <a href="/wiki/{{$channel}}/{{$wiki.urlName}}/Home" title="View {{$wiki.title}}"><b>{{$wiki.title}}</b></a>
+ <i id="edit-wiki-button" class="pull-right generic-icons fakelink fa fa-edit" onclick="wiki_show_edit_wiki_form('{{$wiki.title}}', '{{$wiki.resource_id}}');" title="Edit {{$wiki.title}}"></i>
+ <i class="pull-right generic-icons fakelink fa fa-download" onclick="wiki_download_wiki('{{$wiki.resource_id}}'); return false;" title="Download {{$wiki.title}}"></i>
+ </div>
{{/foreach}}
</div>
</div>