summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Benjamin Barenblat <benjamin@barenblat.name>2016-08-16 17:10:06 -0400
committerGravatar Benjamin Barenblat <benjamin@barenblat.name>2016-08-16 17:10:06 -0400
commiteb4c69f4606bcae608abe661375b5e90fb8b1be3 (patch)
tree4e324995ac53c2739fcdc20d9205bb81d514e72c
parent5bdb7576c4bfd0ec032f30650308626daf9ad4b1 (diff)
Use a database
Enable future development with queries by switch to a SQLite database for next actions.
-rw-r--r--.gitignore2
-rw-r--r--Makefile15
-rw-r--r--main.ur16
-rw-r--r--prepopulate.sql20
-rw-r--r--ugtd.urp4
5 files changed, 43 insertions, 14 deletions
diff --git a/.gitignore b/.gitignore
index 93f87fe..c0813ec 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,6 +9,8 @@ mdl/lib.urp
mdl/mdl.ur
# Ur/Web
+*.db
+initialize.sql
ugtd
diff --git a/Makefile b/Makefile
index 36bd738..7b78731 100644
--- a/Makefile
+++ b/Makefile
@@ -14,8 +14,16 @@
MDL = mdl/lib.urp mdl/mdl.ur
-ugtd: ugtd.urp $(MDL) main.urs main.ur
- urweb -ccompiler build_scripts/clang -output $@ ugtd
+.PHONY: all
+all: ugtd ugtd.db
+
+ugtd initialize.sql: ugtd.urp $(MDL) main.urs main.ur
+ urweb -ccompiler build_scripts/clang -output ugtd ugtd
+
+ugtd.db: initialize.sql prepopulate.sql
+ printf "" >$@
+ sqlite3 $@ <initialize.sql
+ sqlite3 $@ <prepopulate.sql
.PHONY: mdl
mdl: $(MDL)
@@ -25,4 +33,5 @@ $(MDL): mdl/classes
.PHONY: clean
clean:
$(RM) $(MDL)
- $(RM) ugtd
+ $(RM) ugtd.db
+ $(RM) ugtd initialize.sql
diff --git a/main.ur b/main.ur
index fa8cf7e..bab2cac 100644
--- a/main.ur
+++ b/main.ur
@@ -14,14 +14,9 @@ specific language governing permissions and limitations under the License. *)
open Mdl
-type nextAction = string
-
-val actionsForTesting =
- Cons ("Print cover for TPS report",
- Cons ("Collect information for TPS report",
- Cons ("Generate charts for TPS report",
- Cons ("Lorem ipsum dolor sit amet",
- Nil))))
+table nextAction : {
+ Nam : string,
+}
(* Forces JavaScript to be enabled on the given page, so as to pull in external
scripts specified in the .urp file. *)
@@ -31,13 +26,14 @@ fun renderNextAction action =
<xml>
<li class="mdl-list__item">
<span class="mdl-list__item-primary-content">
- {[action]}
+ {[action.Nam]}
</span>
</li>
</xml>
val main =
+ actionItems <- queryX1 (SELECT * FROM nextAction) renderNextAction;
setHeader (blessResponseHeader "X-UA-Compatible") "IE=edge";
return <xml>
<head>
@@ -68,7 +64,7 @@ val main =
</div>
<div class="mdl-layout__content">
<ul class="mdl-list">
- {List.mapX renderNextAction actionsForTesting}
+ {actionItems}
</ul>
</div>
</div>
diff --git a/prepopulate.sql b/prepopulate.sql
new file mode 100644
index 0000000..4d3437b
--- /dev/null
+++ b/prepopulate.sql
@@ -0,0 +1,20 @@
+-- Copyright 2016 Benjamin Barenblat
+--
+-- Licensed under the Apache License, Version 2.0 (the “License”); you may not
+-- use this file except in compliance with the License. You may obtain a copy
+-- of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an “AS IS” BASIS, WITHOUT
+-- WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+-- License for the specific language governing permissions and limitations under
+-- the License.
+
+INSERT INTO uw_Main_nextAction (uw_nam)
+VALUES
+ ("Print cover for TPS report"),
+ ("Collect information for TPS report"),
+ ("Generate charts for TPS report"),
+ ("Lorem ipsum dolor sit amet");
diff --git a/ugtd.urp b/ugtd.urp
index 32f5e0e..e7cfe83 100644
--- a/ugtd.urp
+++ b/ugtd.urp
@@ -4,9 +4,11 @@ allow meta viewport
allow responseHeader X-UA-Compatible
allow url https://fonts.googleapis.com/*
allow url https://code.getmdl.io/*
+database dbname=ugtd.db
+dbms sqlite
library mdl
script https://storage.googleapis.com/code.getmdl.io/1.1.3/material.min.js
+sql initialize.sql
rewrite url Main/main
-$/list
main