]> git.ipfire.org Git - ipfire.org.git/blame - src/templates/wiki/edit.html
wiki: Add editor elements to insert headlines
[ipfire.org.git] / src / templates / wiki / edit.html
CommitLineData
d398ca08
MT
1{% extends "base.html" %}
2
3{% block title %}{% if page %}{{ _("Edit %s") % page.title }}{% else %}{{ _("Create A New Page") }}{% end %}{% end block %}
4
6c13ca2d
MT
5{% block sidebar %}
6 {% set help = backend.wiki.get_page("/wiki/edit") %}
7
8 {% if help %}
9 {% raw help.html %}
10 {% end %}
11{% end block %}
12
d398ca08 13{% block main %}
2901b734 14 <div class="card mb-4">
d398ca08
MT
15 <div class="card-body">
16 <h4 class="card-title">
17 {% if page %}{{ _("Edit %s") % page.title }}{% else %}{{ _("Create A New Page") }}{% end %}
18 </h4>
19
40cb87a4 20 <form action="" method="POST">
d398ca08
MT
21 {% raw xsrf_form_html() %}
22
feeace6e
MT
23 <div class="form-group editor">
24 <div class="btn-toolbar mb-3" role="toolbar">
a563f064 25 <div class="btn-group btn-group-sm mr-2" role="group">
feeace6e
MT
26 <button type="button" class="btn btn-secondary" id="bold">
27 <i class="fas fa-bold"></i>
28 </button>
29 <button type="button" class="btn btn-secondary" id="italic">
30 <i class="fas fa-italic"></i>
31 </button>
32 </div>
a563f064 33
18c36357
MT
34 <div class="btn-group btn-group-sm mr-2" role="group">
35 <button type="button" class="btn btn-secondary" id="headline-up">
36 <i class="fas fa-chevron-left"></i>
37 </button>
38 <button type="button" class="btn btn-secondary" id="headline">
39 <i class="fas fa-heading"></i>
40 </button>
41 <button type="button" class="btn btn-secondary" id="headline-down">
42 <i class="fas fa-chevron-right"></i>
43 </button>
44 </div>
45
a563f064
MT
46 <a class="btn btn-sm btn-secondary" href="{{ path }}/_files" target="_blank">
47 <i class="fas fa-images"></i>
48 </a>
feeace6e
MT
49 </div>
50
2901b734 51 <textarea class="form-control" rows="16" name="content" id="content" placeholder="{{ _("Text") }}"
d398ca08
MT
52 >{% if page and page.markdown %}{{ page.markdown }}{% end %}</textarea>
53 </div>
54
55 <div class="form-group row">
db82550d
MT
56 <label class="col-sm-4 col-form-label">{{ _("What has changed?") }}</label>
57 <div class="col-sm-8">
d398ca08
MT
58 <input type="text" class="form-control" name="changes" required>
59 </div>
60 </div>
61
f2e25ded 62 {% if page and not page.is_watched_by(current_user) %}
917d9cfa 63 <div class="form-group form-check">
47a206ca
MT
64 <div class="custom-control custom-checkbox">
65 <input type="checkbox" class="custom-control-input" name="watch" id="watch" checked>
66 <label class="custom-control-label" for="watch">{{ _("Watch this page") }}</label>
67 </div>
bfb776cd 68
47a206ca 69 <small class="form-text text-muted">
bfb776cd 70 {{ _("Get notified when this page is changed") }}
47a206ca 71 </small>
917d9cfa
MT
72 </div>
73 {% end %}
d64a1e35 74
d398ca08
MT
75 <button type="submit" class="btn btn-primary btn-block">
76 {% if page %}{{ _("Save Page") }}{% else %}{{ _("Create Page") }}{% end %}
77 </button>
78 </form>
79 </div>
80 </div>
2901b734
MT
81
82 <div id="preview" class="fade show">
83 <div class="d-flex align-items-center mb-4">
84 <h4 class="mb-0">{{ _("Preview") }}</h4>
85 <div id="spinner" class="spinner-border ml-auto" role="status" aria-hidden="true"></div>
86 </div>
87
88 <div class="card">
89 <div class="card-body mb-0">
90 <div id="preview-content" class="wiki-content mb-0">
91 {{ _("Loading...") }}
92 </div>
93 </div>
94 </div>
95 </div>
96{% end block %}
97
98{% block javascript %}
3c8524b4
MT
99 {% import os.path %}
100
feeace6e 101 <script src="{{ static_url("js/editor.js") }}"></script>
2901b734
MT
102 <script type="text/javascript">
103 var update = null;
104
105 $(document).ready(function() {
106 var preview = $("#preview");
107 preview.hide();
108
109 $("#content").on("keyup", function(e) {
110 if (update)
111 clearTimeout(update);
112
113 var content = $(this).val();
114
115 // If the field is all empty, we will hide it
116 if (content)
117 preview.show();
118 else
119 preview.hide();
120
121 // Go into update mode
122 preview.addClass("updating");
123
124 update = setTimeout(function() {
125 var c = $("#preview-content");
126
ec606db5 127 $.post("{{ os.path.join(path, "_render") }}", { content : content },
2901b734
MT
128 function(data) {
129 c.html(data);
130
131 // Update finished
132 preview.removeClass("updating");
133 }
134 );
135 }, 750);
136 });
137 });
138 </script>
d398ca08 139{% end block %}