Mercurial Hosting > freedit
view src/private/admin/config.html.luan @ 3:fc3ee39d7764
login
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 19 Jun 2022 20:47:31 -0600 |
parents | fc2383eb48a9 |
children | a17e400ddaa1 |
line wrap: on
line source
local Luan = require "luan:Luan.luan" local error = Luan.error local Html = require "luan:Html.luan" local html_encode = Html.encode or error() local Parsers = require "luan:Parsers.luan" local json_string = Parsers.json_string or error() local Io = require "luan:Io.luan" local Http = require "luan:http/Http.luan" local reset_luan = Http.reset_luan or error() local test_as_init = Http.test_as_init or error() local Run = require "luan:http/tools/Run.luan" local Config = require "site:/lib/Config.luan" local Logging = require "luan:logging/Logging.luan" local logger = Logging.logger "admin/Config.html" return function() Io.stdout = Http.response.text_writer() if Http.request.method == "POST" then local config = Http.request.parameters.config or error() try test_as_init(config,"config") catch e Run.print_error(e,config) return end Config.set(config) reset_luan() %>Updated<% return end %> <!doctype html> <html> <head> <title>FreedIt - Configure Forum</title> <style> @import "/site.css"; textarea { width: 90%; height: 20em; } </style> <script> function restoreDefault() { document.querySelector('textarea').value = <%=json_string(Config.default_text,{compressed=true})%>; } </script> </head> <body> <h1>Configure Forum</h1> <form method=post> <p> Configuration in <a href="http://www.luan.software/">Luan</a> - <a href="javascript:restoreDefault()">restore default</a> </p> <p><textarea name=config autofocus><%= html_encode(Config.text) %></textarea></p> <p><input type=submit><p> </form> </body> </html> <% end