diff options
author | Andrew Manning <tamanning@zoho.com> | 2016-06-12 14:38:48 -0400 |
---|---|---|
committer | Andrew Manning <tamanning@zoho.com> | 2016-06-12 14:38:48 -0400 |
commit | a1183bf09a93459282078038b94ef89c00297604 (patch) | |
tree | 2e14bec170e37c6615fcd5ff2892233ddffce452 /view/tpl | |
parent | 7fc2b13fe605ad461f6b6aeacd6a187c1ef794de (diff) | |
parent | 1789c3242adcf11fe37f0ef0ec6180966853eeda (diff) | |
download | volse-hubzilla-a1183bf09a93459282078038b94ef89c00297604.tar.gz volse-hubzilla-a1183bf09a93459282078038b94ef89c00297604.tar.bz2 volse-hubzilla-a1183bf09a93459282078038b94ef89c00297604.zip |
Merge remote-tracking branch 'upstream/dev' into embedphotos
Diffstat (limited to 'view/tpl')
-rw-r--r-- | view/tpl/wiki.tpl | 277 | ||||
-rw-r--r-- | view/tpl/wiki_page_history.tpl | 12 | ||||
-rw-r--r-- | view/tpl/wiki_page_list.tpl | 10 | ||||
-rw-r--r-- | view/tpl/wikilist.tpl | 20 |
4 files changed, 319 insertions, 0 deletions
diff --git a/view/tpl/wiki.tpl b/view/tpl/wiki.tpl new file mode 100644 index 000000000..1312f8518 --- /dev/null +++ b/view/tpl/wiki.tpl @@ -0,0 +1,277 @@ +<style type="text/css" media="screen"> + #ace-editor { + position: relative; + width: 100%; + height: 500px; + } + .fade.in { + -webkit-transition: opacity 0.5s 0.5s ease; + -moz-transition: opacity 0.5s 0.5s ease; + -o-transition: opacity 0.5s 0.5s ease; + transition: opacity 0.5s 0.5s ease; + } +</style> +<div class="generic-content-wrapper"> + <div class="section-title-wrapper"> + <div class="pull-right"> + {{if $showNewWikiButton}} + <button class="btn btn-primary btn-xs" onclick="$('#new-page-form-wrapper').hide(); openClose('new-wiki-form-wrapper');">New Wiki</button> + {{/if}} + {{if $showNewPageButton}} + <button class="btn btn-success btn-xs" onclick="$('#new-wiki-form-wrapper').hide(); openClose('new-page-form-wrapper');">New Page</button> + {{/if}} + <button id="fullscreen-btn" type="button" class="btn btn-default btn-xs" onclick="makeFullScreen(); + adjustFullscreenTopBarHeight();"><i class="fa fa-expand"></i></button> + <button id="inline-btn" type="button" class="btn btn-default btn-xs" onclick="makeFullScreen(false); + adjustInlineTopBarHeight();"><i class="fa fa-compress"></i></button> + </div> + <h2>{{$wikiheader}}</h2> + <div class="clear"></div> + </div> + <div id="new-wiki-form-wrapper" class="section-content-tools-wrapper" style="display:none;"> + <form id="new-wiki-form" action="wiki/{{$channel}}/create/wiki" method="post" > + <div class="clear"></div> + {{include file="field_input.tpl" field=$wikiName}} + <div class="btn-group pull-right"> + <div id="profile-jot-submit-right" class="btn-group"> + <button id="dbtn-acl" class="btn btn-default btn-sm" data-toggle="modal" data-target="#aclModal" title="Permission settings" onclick="return false;"> + <i id="jot-perms-icon" class="fa fa-{{$lockstate}} jot-icons">{{$bang}}</i> + </button> + </div> + <button id="new-wiki-submit" class="btn btn-primary" type="submit" name="submit" >Create Wiki</button> + </div> + <div>{{$acl}}</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> + {{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 id="wiki-content-container" class="section-content-wrapper" {{if $hideEditor}}style="display: none;"{{/if}}> + <ul class="nav nav-tabs" id="wiki-nav-tabs"> + <li><a data-toggle="tab" href="#edit-pane">Edit</a></li> + <li class="active"><a data-toggle="tab" href="#preview-pane" id="wiki-get-preview">Preview</a></li> + <li {{if $hidePageHistory}}style="display: none;"{{/if}}><a data-toggle="tab" href="#page-history-pane" id="wiki-get-history">History</a></li> + {{if $showPageControls}} + <li class="dropdown"> + <a data-toggle="dropdown" class="dropdown-toggle" href="#">Page <b class="caret"></b></a> + <ul class="dropdown-menu"> + <li><a id="save-page" data-toggle="tab" href="#">Save</a></li> + <li><a id="delete-page" data-toggle="tab" href="#">Delete</a></li> + </ul> + </li> + {{/if}} + </ul> + <div class="tab-content" id="wiki-page-tabs"> + + <div id="edit-pane" class="tab-pane fade"> + <div id="ace-editor"></div> + </div> + <div id="preview-pane" class="tab-pane fade in active"> + <div id="wiki-preview" class="section-content-wrapper"> + {{$renderedContent}} + </div> + </div> + <div id="page-history-pane" class="tab-pane fade" {{if $hidePageHistory}}style="display: none;"{{/if}}> + <div id="page-history-list" class="section-content-wrapper"> + <table class="table-striped table-responsive table-hover" style="width: 100%;"> + {{foreach $pageHistory as $commit}} + <tr><td> + <table> + <tr><td>Date</td><td>{{$commit.date}}</td></tr> + <tr><td>Name</td><td>{{$commit.name}}</td></tr> + <tr><td>Message</td><td>{{$commit.title}}</td></tr> + </table> + </td></tr> + {{/foreach}} + </table> + </div> + </div> + + + </div> + </div> + {{if $showCommitMsg}} + <div class="section-content-wrapper"> + {{include file="field_input.tpl" field=$commitMsg}} + </div> + {{/if}} +</div> + +<script> + window.wiki_resource_id = '{{$resource_id}}'; + window.wiki_page_name = '{{$page}}'; + window.wiki_page_content = {{$content}}; + + if (window.wiki_page_name === 'Home') { + $('#delete-page').hide(); + } + $(document).ready(function () { + wiki_refresh_page_list(); + // 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); + + $('#wiki-get-preview').click(function (ev) { + $.post("wiki/{{$channel}}/preview", {content: editor.getValue()}, function (data) { + if (data.success) { + $('#wiki-preview').html(data.html); + } 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'); +} + + + $('#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 + } 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; + } + $.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'); + // put contents in editor + editor.getSession().setValue(data.content); + } else { + window.console.log('Error reverting page.'); + } + }, 'json'); + } +</script> diff --git a/view/tpl/wiki_page_history.tpl b/view/tpl/wiki_page_history.tpl new file mode 100644 index 000000000..6ce3ce204 --- /dev/null +++ b/view/tpl/wiki_page_history.tpl @@ -0,0 +1,12 @@ +<table class="table-striped table-responsive table-hover" style="width: 100%;"> + {{foreach $pageHistory as $commit}} + <tr><td> + <table id="rev-{{$commit.hash}}" onclick="$('#details-{{$commit.hash}}').show()" width="100%"> + <tr><td width="10%">Date</td><td width="70%">{{$commit.date}}</td><td rowspan="3" width="20%" align="right"> + <button id="revert-{{$commit.hash}}" class="btn btn-danger btn-xs" onclick="wiki_revert_page('{{$commit.hash}}')">Revert</button></td></tr> + <tr><td>Name</td><td>{{$commit.name}} <{{$commit.email}}></td></tr> + <tr><td>Message</td><td>{{$commit.title}}</td></tr> + </table> + </td></tr> + {{/foreach}} +</table>
\ No newline at end of file diff --git a/view/tpl/wiki_page_list.tpl b/view/tpl/wiki_page_list.tpl new file mode 100644 index 000000000..1c3254465 --- /dev/null +++ b/view/tpl/wiki_page_list.tpl @@ -0,0 +1,10 @@ +{{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> + <ul class="nav nav-pills nav-stacked"> + {{foreach $pages as $page}} + <li><a href="/wiki/{{$channel}}/{{$wikiname}}/{{$page.url}}">{{$page.title}}</a></li> + {{/foreach}} + </ul> +</div> +{{if $not_refresh}}</div>{{/if}} diff --git a/view/tpl/wikilist.tpl b/view/tpl/wikilist.tpl new file mode 100644 index 000000000..be353ca5e --- /dev/null +++ b/view/tpl/wikilist.tpl @@ -0,0 +1,20 @@ +<div id="wiki_list" class="widget"> + <h3>{{$header}}</h3> + <ul class="nav nav-pills nav-stacked"> + {{foreach $wikis as $wiki}} + <li class="dropdown" id="wiki-{{$wiki.resource_id}}"> + <a class="dropdown-toggle" data-toggle="dropdown" href="#"> + <b>{{$wiki.title}}</b><b class="fa fa-caret-down pull-right"></b> + </a> + <ul class="dropdown-menu pull-right"> + <li><a href="/wiki/{{$channel}}/{{$wiki.urlName}}/Home" title="View {{$wiki.title}}">View</a></li> + {{if $showControls}} + <li class="divider"></li> + <li><a href="#" onclick="wiki_delete_wiki('{{$wiki.title}}','{{$wiki.resource_id}}'); return false;" title="Delete {{$wiki.title}}">Delete wiki</a></li> + {{/if}} + </ul> + </li> + {{/foreach}} + </ul> +</div> + |