Adds ability to specify scripts in config to be added to HTML.

This commit is contained in:
Dominik Picheta 2018-05-22 22:15:42 +01:00
commit b895bf3d75
3 changed files with 5 additions and 1 deletions

View file

@ -17,5 +17,6 @@
<div id="ROOT" /> <div id="ROOT" />
<script type="text/javascript" src="/js/forum.js?t=$timestamp"></script> <script type="text/javascript" src="/js/forum.js?t=$timestamp"></script>
$scripts
</body> </body>
</html> </html>

View file

@ -266,7 +266,8 @@ proc initialise() =
karaxHtml = readFile("public/karax.html") % karaxHtml = readFile("public/karax.html") %
{ {
"title": config.title, "title": config.title,
"timestamp": encodeUrl(CompileDate & CompileTime) "timestamp": encodeUrl(CompileDate & CompileTime),
"scripts": config.scripts
}.newStringTable() }.newStringTable()

View file

@ -28,6 +28,7 @@ type
dbPath*: string dbPath*: string
hostname*: string hostname*: string
name*, title*: string name*, title*: string
scripts*: string
ForumError* = object of Exception ForumError* = object of Exception
data*: PostError data*: PostError
@ -64,6 +65,7 @@ proc loadConfig*(filename = getCurrentDir() / "forum.json"): Config =
result.hostname = root["hostname"].getStr() result.hostname = root["hostname"].getStr()
result.name = root["name"].getStr() result.name = root["name"].getStr()
result.title = root["title"].getStr() result.title = root["title"].getStr()
result.scripts = root{"scripts"}.getStr()
proc processGT(n: XmlNode, tag: string): (int, XmlNode, string) = proc processGT(n: XmlNode, tag: string): (int, XmlNode, string) =
result = (0, newElement(tag), tag) result = (0, newElement(tag), tag)