import model
import database
+# Path to the Sqlite3 database
+fun tnitter_db_path: String do return "tnitter.db"
+
redef class Session
# User logged in
var user: nullable String = null
class Tnitter
super Action
- var db_path = "tnitter.db"
- var db = new DB.open(db_path)
-
# Header on pages served by this `Action`
#
# Keywords to `Text::replace`:
# Error to display on page as a dismissable panel
var error = null
+ var db = new DB.open(tnitter_db_path)
+
# Login/logout
if turi == "/login" and request.post_args.keys.has("user") and
request.post_args.keys.has("pass") then
# Post a Tnit!
var text = request.post_args["text"]
db.post(user, text)
+ db.close
# Redirect the user to avoid double posting
var response = new HttpResponse(303)
# Load the last 16 Tnits
var posts = db.latest_posts(16)
+ db.close
var html_posts = new Array[String]
for post in posts do