]> git.ipfire.org Git - ipfire.org.git/blame - src/templates/wiki/edit.html
wiki: Add link to files page
[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
MT
33
34 <a class="btn btn-sm btn-secondary" href="{{ path }}/_files" target="_blank">
35 <i class="fas fa-images"></i>
36 </a>
feeace6e
MT
37 </div>
38
2901b734 39 <textarea class="form-control" rows="16" name="content" id="content" placeholder="{{ _("Text") }}"
d398ca08
MT
40 >{% if page and page.markdown %}{{ page.markdown }}{% end %}</textarea>
41 </div>
42
43 <div class="form-group row">
db82550d
MT
44 <label class="col-sm-4 col-form-label">{{ _("What has changed?") }}</label>
45 <div class="col-sm-8">
d398ca08
MT
46 <input type="text" class="form-control" name="changes" required>
47 </div>
48 </div>
49
f2e25ded 50 {% if page and not page.is_watched_by(current_user) %}
917d9cfa 51 <div class="form-group form-check">
47a206ca
MT
52 <div class="custom-control custom-checkbox">
53 <input type="checkbox" class="custom-control-input" name="watch" id="watch" checked>
54 <label class="custom-control-label" for="watch">{{ _("Watch this page") }}</label>
55 </div>
bfb776cd 56
47a206ca 57 <small class="form-text text-muted">
bfb776cd 58 {{ _("Get notified when this page is changed") }}
47a206ca 59 </small>
917d9cfa
MT
60 </div>
61 {% end %}
d64a1e35 62
d398ca08
MT
63 <button type="submit" class="btn btn-primary btn-block">
64 {% if page %}{{ _("Save Page") }}{% else %}{{ _("Create Page") }}{% end %}
65 </button>
66 </form>
67 </div>
68 </div>
2901b734
MT
69
70 <div id="preview" class="fade show">
71 <div class="d-flex align-items-center mb-4">
72 <h4 class="mb-0">{{ _("Preview") }}</h4>
73 <div id="spinner" class="spinner-border ml-auto" role="status" aria-hidden="true"></div>
74 </div>
75
76 <div class="card">
77 <div class="card-body mb-0">
78 <div id="preview-content" class="wiki-content mb-0">
79 {{ _("Loading...") }}
80 </div>
81 </div>
82 </div>
83 </div>
84{% end block %}
85
86{% block javascript %}
3c8524b4
MT
87 {% import os.path %}
88
feeace6e 89 <script src="{{ static_url("js/editor.js") }}"></script>
2901b734
MT
90 <script type="text/javascript">
91 var update = null;
92
93 $(document).ready(function() {
94 var preview = $("#preview");
95 preview.hide();
96
97 $("#content").on("keyup", function(e) {
98 if (update)
99 clearTimeout(update);
100
101 var content = $(this).val();
102
103 // If the field is all empty, we will hide it
104 if (content)
105 preview.show();
106 else
107 preview.hide();
108
109 // Go into update mode
110 preview.addClass("updating");
111
112 update = setTimeout(function() {
113 var c = $("#preview-content");
114
ec606db5 115 $.post("{{ os.path.join(path, "_render") }}", { content : content },
2901b734
MT
116 function(data) {
117 c.html(data);
118
119 // Update finished
120 preview.removeClass("updating");
121 }
122 );
123 }, 750);
124 });
125 });
126 </script>
d398ca08 127{% end block %}