summaryrefslogtreecommitdiff
path: root/src/web/app/dev
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2017-02-18 18:03:52 +0900
committersyuilo <syuilotan@yahoo.co.jp>2017-02-18 18:03:52 +0900
commit6cd3c3e9ec8320af3220816f6cf4a896b0ff849b (patch)
tree69cf5e06a8066df8baafcfbefc7972f95e0db249 /src/web/app/dev
parent:v: (diff)
downloadsharkey-6cd3c3e9ec8320af3220816f6cf4a896b0ff849b.tar.gz
sharkey-6cd3c3e9ec8320af3220816f6cf4a896b0ff849b.tar.bz2
sharkey-6cd3c3e9ec8320af3220816f6cf4a896b0ff849b.zip
:v:
Diffstat (limited to 'src/web/app/dev')
-rw-r--r--src/web/app/dev/router.js42
-rw-r--r--src/web/app/dev/router.ls51
-rw-r--r--src/web/app/dev/script.js4
3 files changed, 44 insertions, 53 deletions
diff --git a/src/web/app/dev/router.js b/src/web/app/dev/router.js
new file mode 100644
index 0000000000..71c098463b
--- /dev/null
+++ b/src/web/app/dev/router.js
@@ -0,0 +1,42 @@
+const route = require('page');
+let page = null;
+
+module.exports = me => {
+ route('/', index);
+ route('/apps', apps);
+ route('/app/new', newApp);
+ route('/app/:app', app);
+ route('*', notFound);
+
+ function index() {
+ mount(document.createElement('mk-index'));
+ }
+
+ function apps() {
+ mount(document.createElement('mk-apps-page'));
+ }
+
+ function newApp() {
+ mount(document.createElement('mk-new-app-page'));
+ }
+
+ function app(ctx) {
+ const el = document.createElement('mk-app-page');
+ el.setAttribute('app', ctx.params.app);
+ mount(el);
+ }
+
+ function notFound() {
+ mount(document.createElement('mk-not-found'));
+ }
+
+ // EXEC
+ route();
+};
+
+const riot = require('riot');
+function mount(content) {
+ if (page) page.unmount();
+ const body = document.getElementById('app');
+ page = riot.mount(body.appendChild(content))[0];
+}
diff --git a/src/web/app/dev/router.ls b/src/web/app/dev/router.ls
deleted file mode 100644
index ac408b36ed..0000000000
--- a/src/web/app/dev/router.ls
+++ /dev/null
@@ -1,51 +0,0 @@
-# Router
-#================================
-
-route = require \page
-page = null
-
-module.exports = (me) ~>
-
- # Routing
- #--------------------------------
-
- route \/ index
- route \/apps apps
- route \/app/new new-app
- route \/app/:app app
- route \* not-found
-
- # Handlers
- #--------------------------------
-
- function index
- mount document.create-element \mk-index
-
- function apps
- mount document.create-element \mk-apps-page
-
- function new-app
- mount document.create-element \mk-new-app-page
-
- function app ctx
- document.create-element \mk-app-page
- ..set-attribute \app ctx.params.app
- .. |> mount
-
- function not-found
- mount document.create-element \mk-not-found
-
- # Exec
- #--------------------------------
-
- route!
-
-# Mount
-#================================
-
-riot = require \riot
-
-function mount content
- if page? then page.unmount!
- body = document.get-element-by-id \app
- page := riot.mount body.append-child content .0
diff --git a/src/web/app/dev/script.js b/src/web/app/dev/script.js
index c9c5ee51e5..e0644c263b 100644
--- a/src/web/app/dev/script.js
+++ b/src/web/app/dev/script.js
@@ -3,8 +3,8 @@
*/
require('./tags');
-const boot = require('../boot.js');
-const route = require('./router.ls');
+const boot = require('../boot');
+const route = require('./router');
/**
* Boot