diff options
author | Benjamin Barenblat <benjamin@barenblat.name> | 2016-08-16 17:10:06 -0400 |
---|---|---|
committer | Benjamin Barenblat <benjamin@barenblat.name> | 2016-08-16 17:10:06 -0400 |
commit | eb4c69f4606bcae608abe661375b5e90fb8b1be3 (patch) | |
tree | 4e324995ac53c2739fcdc20d9205bb81d514e72c | |
parent | 5bdb7576c4bfd0ec032f30650308626daf9ad4b1 (diff) |
Use a database
Enable future development with queries by switch to a SQLite database
for next actions.
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | Makefile | 15 | ||||
-rw-r--r-- | main.ur | 16 | ||||
-rw-r--r-- | prepopulate.sql | 20 | ||||
-rw-r--r-- | ugtd.urp | 4 |
5 files changed, 43 insertions, 14 deletions
@@ -9,6 +9,8 @@ mdl/lib.urp mdl/mdl.ur # Ur/Web +*.db +initialize.sql ugtd @@ -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 @@ -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"); @@ -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 |