aboutsummaryrefslogtreecommitdiffstats
path: root/view/tpl
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2016-11-30 13:30:50 +0100
committerMario Vavti <mario@mariovavti.com>2016-11-30 13:30:50 +0100
commitafffbb6487d8dc1806767ed2b2728ab56bf06669 (patch)
tree4f24bdcf1d1522c804db4fd0820acca4ffae94a7 /view/tpl
parent53e4b55ea3722a161b308e4891a2e84ad9ba77af (diff)
downloadvolse-hubzilla-afffbb6487d8dc1806767ed2b2728ab56bf06669.tar.gz
volse-hubzilla-afffbb6487d8dc1806767ed2b2728ab56bf06669.tar.bz2
volse-hubzilla-afffbb6487d8dc1806767ed2b2728ab56bf06669.zip
go live with wiki mimetypes - you can now choose if a wiki will contain markdown or bb-code markup
Diffstat (limited to 'view/tpl')
-rw-r--r--view/tpl/wiki.tpl41
-rw-r--r--view/tpl/wikilist.tpl3
2 files changed, 38 insertions, 6 deletions
diff --git a/view/tpl/wiki.tpl b/view/tpl/wiki.tpl
index bdce4f4be..726494883 100644
--- a/view/tpl/wiki.tpl
+++ b/view/tpl/wiki.tpl
@@ -42,7 +42,11 @@
</ul>
<div class="tab-content" id="wiki-page-tabs">
<div id="edit-pane" class="tab-pane fade">
+ {{if !$mimeType || $mimeType == 'text/markdown'}}
<div id="ace-editor"></div>
+ {{else}}
+ <textarea id="editor">{{$content}}</textarea>
+ {{/if}}
{{if $showCommitMsg}}
{{if $showPageControls}}
<div>
@@ -50,7 +54,7 @@
<div class="input-group">
<input class="widget-input" name="{{$commitMsg.0}}" id="id_{{$commitMsg.0}}" type="text" value="{{$commitMsg.2}}"{{if $commitMsg.5}} {{$commitMsg.5}}{{/if}}>
<div class="input-group-btn">
- <button id="save-page" type="button" class="btn btn-primary btn-sm disabled">Save</button>
+ <button id="save-page" type="button" class="btn btn-primary btn-sm{{if !$mimeType || $mimeType == 'text/markdown'}} disabled{{/if}}">Save</button>
</div>
</div>
</div>
@@ -98,7 +102,7 @@
<script>
window.wiki_resource_id = '{{$resource_id}}';
window.wiki_page_name = '{{$page}}';
- window.wiki_page_content = {{$content}};
+ window.wiki_page_content = {{if !$mimeType || $mimeType == 'text/markdown'}}{{$content}}{{else}}`{{$content}}`{{/if}};
window.wiki_page_commit = '{{$commit}}';
if (window.wiki_page_name === 'Home') {
@@ -135,6 +139,7 @@
event.preventDefault();
});
+ {{if !$mimeType || $mimeType == 'text/markdown'}}
var editor = ace.edit("ace-editor");
editor.setOptions({
theme: "ace/theme/github",
@@ -153,12 +158,26 @@
{{if !$showPageControls}}
editor.setReadOnly(true); // Disable editing if the viewer lacks edit permission
{{/if}}
+
+
+ {{else}}
+ window.editor = editor = $('#editor');
+ {{/if}}
+
$('#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) {
+ $.post("wiki/{{$channel}}/preview", {
+ {{if !$mimeType || $mimeType == 'text/markdown'}}
+ content: editor.getValue(),
+ {{else}}
+ content: editor.val(),
+ {{/if}}
+ 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"});
@@ -207,7 +226,12 @@
ev.preventDefault();
return false;
}
- var currentContent = editor.getValue();
+ {{if !$mimeType || $mimeType == 'text/markdown'}}
+ var currentContent = editor.getValue();
+ {{else}}
+ var currentContent = editor.val();
+ {{/if}}
+
if (window.wiki_page_content === currentContent) {
window.console.log('No edits to save.');
ev.preventDefault();
@@ -224,8 +248,12 @@
window.console.log('Page saved successfully.');
window.wiki_page_content = currentContent;
$('#id_commitMsg').val(''); // Clear the commit message box
+
+ {{if !$mimeType || $mimeType == 'text/markdown'}}
$('#save-page').addClass('disabled'); // Disable the save button
window.editor.getSession().getUndoManager().markClean(); // Reset the undo history for the editor
+ {{/if}}
+
window.editor.focus(); // Return focus to the editor for continued editing
// $('#wiki-get-history').click();
} else {
@@ -400,6 +428,7 @@
$('#new-wiki-button').hide();
{{/if}}
// using input event instead of change since it's called with some timeout
+ {{if !$mimeType || $mimeType == 'text/markdown'}}
window.editor.on("input", function() {
if(window.editor.getSession().getUndoManager().isClean()) {
$('#save-page').addClass('disabled');
@@ -407,6 +436,10 @@
$('#save-page').removeClass('disabled');
}
});
+ {{else}}
+ window.editor.bbco_autocomplete('bbcode');
+ {{/if}}
+
});
</script>
diff --git a/view/tpl/wikilist.tpl b/view/tpl/wikilist.tpl
index c7cdfaa43..68aa41e7c 100644
--- a/view/tpl/wikilist.tpl
+++ b/view/tpl/wikilist.tpl
@@ -9,8 +9,7 @@
<div id="new-wiki-form-wrapper" class="section-content-tools-wrapper">
<form id="new-wiki-form" action="wiki/{{$channel}}/create/wiki" method="post" class="acl-form" data-form_id="new-wiki-form" data-allow_cid='{{$allow_cid}}' data-allow_gid='{{$allow_gid}}' data-deny_cid='{{$deny_cid}}' data-deny_gid='{{$deny_gid}}'>
{{include file="field_input.tpl" field=$wikiName}}
- {{* include file="field_select.tpl" field=$mimeType *}}
- <input type="hidden" name="mimeType" value="text/markdown">
+ {{include file="field_select.tpl" field=$mimeType}}
{{include file="field_checkbox.tpl" field=$notify}}
<div>
<div class="btn-group pull-right">