Skip to content

Instantly share code, notes, and snippets.

@Heartmender
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Heartmender/59250eddb8e20252541c to your computer and use it in GitHub Desktop.
Save Heartmender/59250eddb8e20252541c to your computer and use it in GitHub Desktop.
web.nim(22, 3) Hint: 'robotoregwoff2' is declared but not used [XDeclaredButNotUsed]
web.nim(24, 3) Hint: 'robotoregttf' is declared but not used [XDeclaredButNotUsed]
web.nim(23, 3) Hint: 'robotoregwoff' is declared but not used [XDeclaredButNotUsed]
web.nim(21, 3) Hint: 'jqueryJS' is declared but not used [XDeclaredButNotUsed]
web.nim(25, 3) Hint: 'robotstxt' is declared but not used [XDeclaredButNotUsed]
web.nim(20, 3) Hint: 'materializeJS' is declared but not used [XDeclaredButNotUsed]
web.nim(31, 10) Hint: 'cachedFile' is declared but not used [XDeclaredButNotUsed]
web.nim(19, 3) Hint: 'materializeCSS' is declared but not used [XDeclaredButNotUsed]
import jester, asyncdispatch, htmlgen, parsetoml, db_mysql, times, strutils
var t = parsetoml.parseFile("../sobot.toml")
include "./templates/main.tmpl"
include "./templates/error.tmpl"
include "./templates/logs.tmpl"
var
dbhost = t.getString("database.host")
dbuser = t.getString("database.username")
dbpass = t.getString("database.password")
dbname = t.getString("database.database")
db = db_mysql.open(dbhost, dbuser, dbpass, dbname)
query = sql"SELECT id, mytime, nick, line FROM Chatlines WHERE target = ?"
const
materializeCSS = staticRead "public/css/materialize.min.css"
materializeJS = staticRead "public/js/materialize.min.js"
jqueryJS = staticRead "public/js/jquery-2.1.1.min.js"
robotoregwoff2 = staticRead "public/font/roboto/Roboto-Regular.woff2"
robotoregwoff = staticRead "public/font/roboto/Roboto-Regular.woff"
robotoregttf = staticRead "public/font/roboto/Roboto-Regular.ttf"
robotstxt = staticRead "robots.txt"
settings:
port = 5000.Port
bindAddr = "0.0.0.0"
template cachedFile(path, contents, mimetype: string) =
get path:
headers["Cache-Control"] = "public, mapath-age=31536000"
resp contents, mimetype
routes:
cachedFile "/static/css/materialize.min.css", materializeCSS, "text/css"
cachedFile "/static/js/materialize.min.js", materializeJS, "text/javascript"
cachedFile "/static/js/jquery-2.1.1.min.js", jqueryJS, "text/javascript"
cachedFile "/static/font/roboto/Roboto-Regular.woff2", robotoregwoff2, "application/font-woff2"
cachedFile "/static/font/roboto/Roboto-Regular.woff", robotoregwoff, "application/font-woff"
cachedFile "/static/font/roboto/Roboto-Regular.ttf", robotoregttf, "application/octet-stream"
cachedFile "/robots.txt", robotstxt, "text/plain"
get "/":
resp "No logs selected".errorPage.baseTemplate
get "/logs/?@channel?":
var
channel = @"channel"
if channel == "":
channel = t.getString("bot.channel")
else:
channel = "#" & channel
try:
var rows = db.getAllRows(query, channel)
if rows.len() == 0:
resp baseTemplate(errorPage("No logs available"))
else:
resp baseTemplate(showLogs(channel, rows), channel)
except:
resp baseTemplate(errorPage(getCurrentExceptionMsg()))
runForever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment