initial code commit

This commit is contained in:
Cadey Ratio 2018-04-07 18:56:43 +00:00
parent 6d29aef3e7
commit 5ae88aa728
5 changed files with 156 additions and 0 deletions

1
.gitignore vendored
View File

@ -24,3 +24,4 @@ _testmain.go
*.test *.test
*.prof *.prof
*.db

7
env.tcl Normal file
View File

@ -0,0 +1,7 @@
proc wapp-page-env {} {
wapp-allow-xorigin-params
wapp-trim {
<h1>Wapp Environment</h1>
<pre>%html([wapp-debug-env])</pre>
}
}

23
mkdb.tcl Normal file
View File

@ -0,0 +1,23 @@
#/bin/env wapptclsh
sqlite3 db register.db
# This prevents machines from the same public IP from submitting data twice in
# the same 24 hour period. To prevent spookiness, the server will run on GMT and
# clients will submit at 9 AM their time.
db eval {CREATE TABLE hits
( ip_address_hash TEXT NOT NULL
, date TEXT NOT NULL
)}
db eval {CREATE UNIQUE INDEX hits_unique_daily ON hits(ip_address_hash, date)}
# Keep track of the packages installed by date. This will end up being a big
# table, but databases have indexes for a reason.
db eval {CREATE TABLE package_installs
( package_name TEXT NOT NULL
, date TEXT NOT NULL
)}
db eval {CREATE INDEX package_installs_name ON package_installs(package_name)}

19
site.tcl Normal file
View File

@ -0,0 +1,19 @@
source env.tcl
source wing.tcl
package require wapp
proc wapp-default {} {
set B [wapp-param BASE_URL]
wingcss
wapp-trim {
<section class="container">
<h1>Hello, World!</h1>
<p>See the <a href='%html($B)/env'>Wapp
Environment</a></p>
</section>
}
}
wapp-start $::argv

106
wing.tcl Normal file
View File

@ -0,0 +1,106 @@
proc wingcss {} {
wapp-trim {
<link rel="stylesheet" href="/wing.css" />
}
}
proc wapp-page-wing.css {} {
wapp-mimetype text/css
wapp-cache-control max-age=3600
wapp-unsafe [binary decode base64 {
LyoNCiogV2luZyAxLjAuMC1iZXRhDQoqIENvcHlyaWdodCAyMDE2LCBLYWJpciBTaGFoDQoqIGh0
dHA6Ly91c2V3aW5nLm1sLw0KKiBGcmVlIHRvIHVzZSB1bmRlciB0aGUgTUlUIGxpY2Vuc2UuDQ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