diff options
| author | Michael Foster <savetheinternet@tinyboard.org> | 2013-08-01 17:18:10 -0400 |
|---|---|---|
| committer | Michael Foster <savetheinternet@tinyboard.org> | 2013-08-01 17:18:10 -0400 |
| commit | 5a44c50811ba9a927add4d54604307692492df8a (patch) | |
| tree | 603b32aae4513b06a48fab63a1d9462abaf7e295 /templates/mod | |
| parent | 157dcf9fb13f83d3d7ec8e2ab6cd566e92efea97 (diff) | |
Simple file editor replacement for ?/config (optional). Issue #127
Diffstat (limited to 'templates/mod')
| -rw-r--r-- | templates/mod/config-editor-php.html | 45 | ||||
| -rw-r--r-- | templates/mod/dashboard.html | 2 | ||||
| -rw-r--r-- | templates/mod/edit_post_form.html | 2 |
3 files changed, 47 insertions, 2 deletions
diff --git a/templates/mod/config-editor-php.html b/templates/mod/config-editor-php.html new file mode 100644 index 00000000..54c398e4 --- /dev/null +++ b/templates/mod/config-editor-php.html @@ -0,0 +1,45 @@ +{% if readonly %} + <p style="text-align:center;max-width:800px;margin:20px auto">Tinyboard does not have the required permissions to edit <strong>inc/instance-config.php</strong>. To make changes, you will need to change the file's permissions first or manually edit the code.</p> +{% endif %} + + +{% if not readonly %}<form method="post" action="">{% endif %} + <textarea name="code" id="code" style="display:block; margin:auto;width:100%;max-width:800px;height:500px{% if readonly %};background:#eee" readonly{% else %}"{% endif %}> + {{ php }} + </textarea> + + <ul style="padding:0;text-align:center;list-style:none"> + <li><input name="save" type="submit" value="{% trans 'Save changes' %}"{% if readonly %} disabled{% endif %}></li> + </ul> +{% if not readonly %}</form>{% endif %} + +<script type="text/javascript"> +var observe; +if (window.attachEvent) { + observe = function (element, event, handler) { + element.attachEvent('on'+event, handler); + }; +} +else { + observe = function (element, event, handler) { + element.addEventListener(event, handler, false); + }; +} + +var text = document.getElementById('code'); +function resize () { + text.style.height = 'auto'; + text.style.height = text.scrollHeight+'px'; +} +/* 0-timeout to get the already changed text */ +function delayedResize () { + window.setTimeout(resize, 0); +} +observe(text, 'change', resize); +observe(text, 'cut', delayedResize); +observe(text, 'paste', delayedResize); +observe(text, 'drop', delayedResize); +observe(text, 'keydown', delayedResize); + +resize(); +</script>
\ No newline at end of file diff --git a/templates/mod/dashboard.html b/templates/mod/dashboard.html index 5f6585fc..e9fb7c9c 100644 --- a/templates/mod/dashboard.html +++ b/templates/mod/dashboard.html @@ -94,7 +94,7 @@ {% if mod|hasPermission(config.mod.rebuild) %} <li><a href="?/rebuild">{% trans 'Rebuild' %}</a></li> {% endif %} - {% if mod|hasPermission(config.mod.show_config) %} + {% if mod|hasPermission(config.mod.edit_config) %} <li><a href="?/config">{% trans 'Configuration' %}</a></li> {% endif %} diff --git a/templates/mod/edit_post_form.html b/templates/mod/edit_post_form.html index b9359c68..a2980d35 100644 --- a/templates/mod/edit_post_form.html +++ b/templates/mod/edit_post_form.html @@ -32,7 +32,7 @@ {% trans %}Comment{% endtrans %} </th> <td> - <textarea name="body" id="body" rows="8" cols="35">{% if raw %}{{ post.body|e }}{% else %}{{ post.body_nomarkup|e }}{% endif %}</textarea> + <textarea name="body" id="body" rows="8" cols="35">{% if raw %}{{ post.body }}{% else %}{{ post.body_nomarkup }}{% endif %}</textarea> </td> </tr> </table> |
