ksr-express
This commit is contained in:
4
projects/ksr-express/.gitignore
vendored
Normal file
4
projects/ksr-express/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
node_modules/
|
||||||
|
.haxelib/
|
||||||
|
libs/
|
||||||
|
index.js
|
||||||
8
projects/ksr-express/build.hxml
Normal file
8
projects/ksr-express/build.hxml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
-lib kiss
|
||||||
|
-lib express
|
||||||
|
-lib kiss-express
|
||||||
|
-lib kiss-spaced-rep
|
||||||
|
-cp src
|
||||||
|
--main kiss_spaced_rep.Main
|
||||||
|
--js index.js
|
||||||
|
--cmd node index.js
|
||||||
1196
projects/ksr-express/package-lock.json
generated
Normal file
1196
projects/ksr-express/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
17
projects/ksr-express/package.json
Normal file
17
projects/ksr-express/package.json
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"main": "index.js",
|
||||||
|
"name": "ksr_express",
|
||||||
|
"description": "An ExpressJS website made with Kisslang",
|
||||||
|
"title": "ksr-express",
|
||||||
|
"dependencies": {
|
||||||
|
"express": "^4.18.1",
|
||||||
|
"@types/express": "^4.17.13"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"dts2hx": "^0.19.0"
|
||||||
|
},
|
||||||
|
"version": "0.0.0",
|
||||||
|
"scripts": {
|
||||||
|
"postinstall": "dts2hx --all"
|
||||||
|
}
|
||||||
|
}
|
||||||
47
projects/ksr-express/src/ksr_express/Engine.kiss
Normal file
47
projects/ksr-express/src/ksr_express/Engine.kiss
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
(import kiss_spaced_rep.StudyEngine)
|
||||||
|
(implements StudyEngine)
|
||||||
|
|
||||||
|
(prop &mut :String content "")
|
||||||
|
|
||||||
|
(defNew []
|
||||||
|
[&mut :String image ""
|
||||||
|
&mut :Continuation cc null
|
||||||
|
&mut :String->Void resolve null]
|
||||||
|
(let [app (Express.call)
|
||||||
|
port 3000]
|
||||||
|
(app.use (Express.static_.call (Sys.getCwd)))
|
||||||
|
(app.get "/" ->[req :Dynamic res next]
|
||||||
|
(res.send content))
|
||||||
|
(app.get "/image/:path" ->[:Dynamic req :Dynamic res next]
|
||||||
|
(res.sendFile req.params.path (object root (Sys.getCwd))))
|
||||||
|
(app.get "/continue" ->[req res next] {
|
||||||
|
(whenLet [_cc cc] (set cc null) (_cc))
|
||||||
|
(res.redirect "/")
|
||||||
|
})
|
||||||
|
(app.get "/submit" ->[:Dynamic req :Dynamic res next] {
|
||||||
|
(whenLet [_resolve resolve] (set resolve null) (_resolve req.query.value))
|
||||||
|
(res.redirect "/")
|
||||||
|
})
|
||||||
|
(#unless test
|
||||||
|
(app.listen port ->(print "kiss-express listening at http://localhost:$port")))))
|
||||||
|
|
||||||
|
(method :Void clear []
|
||||||
|
(set content ""))
|
||||||
|
|
||||||
|
(method :Void print [text]
|
||||||
|
(+= content text))
|
||||||
|
|
||||||
|
(method :Void println [text]
|
||||||
|
(+= content text "<br />"))
|
||||||
|
|
||||||
|
(method :Void showImage [path]
|
||||||
|
(+= content "<img src=\"/image/${path}\" /><br />"))
|
||||||
|
|
||||||
|
(method :Void delayForUserInput [cc]
|
||||||
|
(set this.cc cc)
|
||||||
|
(+= content "<br /><a href=\"/continue\">Next</a><br />"))
|
||||||
|
|
||||||
|
(method :Void getUserInput [resolve]
|
||||||
|
(set this.resolve resolve)
|
||||||
|
(+= content "<br /><input type=\"text\" id=\"value\"><br /><a href=\"#\" onclick=\"window.open('/submit?value=' + document.getElementById('value').value);\">Submit</a><br />"))
|
||||||
|
|
||||||
7
projects/ksr-express/test.sh
Normal file
7
projects/ksr-express/test.sh
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
if [ ! -d node_modules ]; then
|
||||||
|
$(haxelib libpath kiss)/build-scripts/dts2hx-externs/regenerate.sh
|
||||||
|
fi
|
||||||
|
|
||||||
|
haxe -D cards="$(pwd)/$1" -D engine="ksr_express.Engine" build.hxml
|
||||||
Reference in New Issue
Block a user