diff --git a/data/dk.db b/data/dk.db index d03eaf4..d782d4a 100644 Binary files a/data/dk.db and b/data/dk.db differ diff --git a/libs/install.lua b/libs/install.lua new file mode 100644 index 0000000..f2cc79a --- /dev/null +++ b/libs/install.lua @@ -0,0 +1,11 @@ +local m = {} + +function m.is_installed() + if fs.exists(".installed") then + return true + else + return false + end +end + +return m \ No newline at end of file diff --git a/moonshark b/moonshark index 9dbee03..442cb73 100755 Binary files a/moonshark and b/moonshark differ diff --git a/routes/install/first/get.lua b/routes/install/first/get.lua new file mode 100644 index 0000000..13b05e7 --- /dev/null +++ b/routes/install/first/get.lua @@ -0,0 +1,16 @@ +local i = require("install") +if i.is_installed() then http.redirect("/") end + +return send.html([[ + + + Dragon Knight Installation + + + +

Dragon Knight Installation

+

Installation for Dragon Knight is a simple two-step process: set up the database tables, then create the admin user. After that, you're done.

+ + + +]]) diff --git a/routes/install/get.lua b/routes/install/get.lua index d1bdc4e..4fe3247 100644 --- a/routes/install/get.lua +++ b/routes/install/get.lua @@ -1,14 +1,2 @@ -http.set_content_type("text/html") -return [[ - - - Dragon Knight Installation - - - -

Dragon Knight Installation

-

Installation for Dragon Knight is a simple two-step process: set up the database tables, then create the admin user. After that, you're done.

- - - -]] +local i = require("install") +if i.is_installed() then http.redirect("/") else http.redirect("/install/first") end \ No newline at end of file diff --git a/routes/install/second/get.lua b/routes/install/second/get.lua index a9e500d..cf46ed0 100644 --- a/routes/install/second/get.lua +++ b/routes/install/second/get.lua @@ -1,3 +1,6 @@ +local i = require("install") +if i.is_installed() then http.redirect("/") end + local start = microtime(true) local db = sqlite("dk") @@ -429,16 +432,15 @@ db:commit() local time = math.roundto(microtime(true) - start, 4) -http.set_content_type("text/html") -return [[ +return send.html(iparse([[ Dragon Knight Installation

Dragon Knight Installation

-

Database setup complete in ]]..time..[[ seconds.

+

Database setup complete in seconds.

-]] +]], {time})) diff --git a/routes/install/third/get.lua b/routes/install/third/get.lua new file mode 100644 index 0000000..317732f --- /dev/null +++ b/routes/install/third/get.lua @@ -0,0 +1,2 @@ +local i = require("install") +if i.is_installed() then http.redirect("/") end \ No newline at end of file