Update templates
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
{% extends "skeleton.html" %}
|
||||
{% block body %}
|
||||
{% block content %}
|
||||
|
||||
<h3 class="text-danger">{{ error_code }}: {{ error_message }}</h3>
|
||||
<hr />
|
||||
|
||||
37
myapp/templates/inc/editor.js
Normal file
37
myapp/templates/inc/editor.js
Normal file
@@ -0,0 +1,37 @@
|
||||
{% macro plugin(type="tinymce") -%}
|
||||
{% if type=="tinymce" %}
|
||||
<script type="text/javascript" src="/static/tinymce/tinymce.min.js"></script>
|
||||
{% elif type=="ckeditor" %}
|
||||
<script type="text/javascript" src="/static/ckeditor/ckeditor.js"></script>
|
||||
{% endif %}
|
||||
{%- endmacro %}
|
||||
|
||||
{% macro ckeditor(name) -%}
|
||||
CKEDITOR.replace( '{{ name }}', {
|
||||
customConfig: '/static/js/ckeditor-conf.js'
|
||||
} );
|
||||
{%- endmacro %}
|
||||
|
||||
{% macro tinymce(name) -%}
|
||||
tinymce.init({
|
||||
selector: 'textarea#{{ name }}',
|
||||
height: 400,
|
||||
language: 'ru',
|
||||
plugins: "code link image table",
|
||||
toolbar: "table tabledelete | tableprops tablerowprops tablecellprops | tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol"
|
||||
});
|
||||
{%- endmacro %}
|
||||
|
||||
{% macro getValue(name, param, type="tinymce") -%}
|
||||
{% if type=="tinymce" %}
|
||||
let value = tinymce.get("{{ name }}").getContent();
|
||||
if (value != {{ param }}) {
|
||||
{{ param }} = value;
|
||||
}
|
||||
{% elif type=="ckeditor" %}
|
||||
var value = CKEDITOR.instances["{{ name }}"].getData();
|
||||
if (value != {{ param }}) {
|
||||
{{ param }} = value;
|
||||
}
|
||||
{% endif %}
|
||||
{%- endmacro %}
|
||||
@@ -1,5 +1,5 @@
|
||||
{% extends "skeleton.html" %}
|
||||
{% block body %}
|
||||
{% block content %}
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
@@ -1,19 +1,13 @@
|
||||
<div class="row">
|
||||
<div class="col py-2">
|
||||
|
||||
{% if session.logged_in %}
|
||||
<div class="btn-group float-right">
|
||||
<a class="btn btn-outline-secondary border-0" href="/profile"><i class="fa fa-user"></i></a>
|
||||
<a class="btn btn-outline-danger border-0" href="/logout"><i class="fa fa-sign-out"></i></a>
|
||||
</div>
|
||||
{% else %}
|
||||
<a class="btn btn-outline-success border-0 float-right" href="/login"><i class="fa fa-sign-in"></i></a>
|
||||
{% endif %}
|
||||
|
||||
<a class="btn btn-outline-secondary border-0" href="/"><i class="fa fa-home"></i></a>
|
||||
<a class="btn btn-outline-secondary border-0" href="/page">Статья</a>
|
||||
<a class="btn btn-outline-secondary border-0" href="/pages">Статьи</a>
|
||||
<a class="btn btn-outline-secondary border-0" href="/tags">Метки</a>
|
||||
<a class="btn btn-outline-secondary border-0" href="/users">Пользователи</a>
|
||||
<a class="btn btn-outline-secondary border-0" href="/api/browse">API JSON-RPC</a>
|
||||
|
||||
<a class="btn btn-outline-success border-0 float-right" href="/login"><i class="fa fa-sign-in"></i></a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,112 +0,0 @@
|
||||
{% extends "skeleton.html" %}
|
||||
{% block body %}
|
||||
|
||||
{% raw %}
|
||||
<h3>
|
||||
<div class="btn btn-outline-secondary float-right" v-on:click="showPanel(panels.edit)"><i class="fa fa-edit"></i></div>
|
||||
{{ page.title }}</h3>
|
||||
<hr />
|
||||
|
||||
<div class="row" v-if="panels.edit.visible">
|
||||
<div class="col">
|
||||
|
||||
<div class="form-group">
|
||||
<label for="title">Заголовок</label>
|
||||
<input id="title" name="title" type="text" value="Заголовок страницы" class="form-control" v-model="newPage.title">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="text">Текст</label>
|
||||
<textarea class="form-control" id="text" name="text" v-model="newPage.text"></textarea>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<button class="btn btn-outline-success float-right" v-on:click="send"><i class="fa fa-save-o"></i> Сохранить</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mt-3" v-if="error">
|
||||
<div class="col bg-danger text-white" v-html="error">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<span v-html="page.text" v-else></span>
|
||||
|
||||
{% endraw %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block breadcrumb %}
|
||||
<ol class="breadcrumb mt-3">
|
||||
<li class="breadcrumb-item"><a href="/"><i class="fa fa-home"></i></a></li>
|
||||
<li class="breadcrumb-item active">Редактирование страницы</li>
|
||||
</ol>
|
||||
{% endblock %}
|
||||
|
||||
{% block script %}
|
||||
<script type="text/javascript" src="/static/ckeditor/ckeditor.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
var app = new Vue({
|
||||
el: '#app',
|
||||
data: {
|
||||
page: {{ pagedata['page']|tojson|safe }},
|
||||
newPage: {{ pagedata['page']|tojson|safe }},
|
||||
panels: {
|
||||
edit: {
|
||||
visible: false
|
||||
}
|
||||
},
|
||||
error: null
|
||||
},
|
||||
methods: {
|
||||
showPanel: function(panel) {
|
||||
/* Показать/скрыть панель */
|
||||
panel.visible = !panel.visible;
|
||||
},
|
||||
send: function() {
|
||||
let vm = this;
|
||||
var value = CKEDITOR.instances["text"].getData();
|
||||
if (value != vm.newPage.text) {
|
||||
vm.newPage.text = value;
|
||||
}
|
||||
axios.post(
|
||||
'/api',
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"method": 'page.update',
|
||||
"params": {
|
||||
"title": vm.newPage.title,
|
||||
"text": vm.newPage.text
|
||||
},
|
||||
"id": 1
|
||||
}
|
||||
).then(
|
||||
function(response) {
|
||||
if ('result' in response.data) {
|
||||
vm.page = response.data['result'];
|
||||
vm.newPage = vm.page;
|
||||
vm.error = null;
|
||||
} else if ('error' in response.data) {
|
||||
vm.error = response.data['error'].message;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
updated: function() {
|
||||
let vm = this;
|
||||
for(var instanceName in CKEDITOR.instances) {
|
||||
CKEDITOR.instances[instanceName].destroy(true);
|
||||
}
|
||||
if (vm.panels.edit.visible) {
|
||||
CKEDITOR.replace( "text", {
|
||||
customConfig: '/static/js/ckeditor-conf.js'
|
||||
} );
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -7,8 +7,8 @@
|
||||
<div class="container">
|
||||
{% include 'navbar.html' %}
|
||||
|
||||
{% block body %}
|
||||
{% endblock body %}
|
||||
{% block content %}
|
||||
{% endblock content %}
|
||||
|
||||
{% block breadcrumb %}
|
||||
{% endblock %}
|
||||
|
||||
16
myapp/templates/user/navbar.html
Normal file
16
myapp/templates/user/navbar.html
Normal file
@@ -0,0 +1,16 @@
|
||||
<div class="row">
|
||||
<div class="col py-2">
|
||||
|
||||
<a class="btn btn-outline-secondary border-0" href="/"><i class="fa fa-home"></i></a>
|
||||
<a class="btn btn-outline-secondary border-0" href="/pages">Статьи</a>
|
||||
<a class="btn btn-outline-secondary border-0" href="/tags">Метки</a>
|
||||
<a class="btn btn-outline-secondary border-0" href="/users">Пользователи</a>
|
||||
<a class="btn btn-outline-secondary border-0" href="/api/browse">API JSON-RPC</a>
|
||||
|
||||
<div class="btn-group float-right">
|
||||
<a class="btn btn-outline-secondary border-0" href="/profile"><i class="fa fa-user"></i></a>
|
||||
<a class="btn btn-outline-danger border-0" href="/logout"><i class="fa fa-sign-out"></i></a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
33
myapp/templates/user/skeleton.html
Normal file
33
myapp/templates/user/skeleton.html
Normal file
@@ -0,0 +1,33 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
{% include 'header.html' %}
|
||||
<body>
|
||||
<section id="app">
|
||||
|
||||
<div class="container">
|
||||
{% include 'user/navbar.html' %}
|
||||
|
||||
{% block content %}
|
||||
{% endblock content %}
|
||||
|
||||
{% block breadcrumb %}
|
||||
{% endblock %}
|
||||
|
||||
{% include 'footer.html' %}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{% block script %}
|
||||
<script type="text/javascript">
|
||||
var app = new Vue({
|
||||
el: '#app',
|
||||
data: {
|
||||
},
|
||||
methods: {
|
||||
}
|
||||
})
|
||||
</script>
|
||||
{% endblock script %}
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user