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