Compare commits
10 Commits
e46216337d
...
a7514e22fc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a7514e22fc | ||
|
|
5d91288992 | ||
|
|
5722f37916 | ||
|
|
b493a93785 | ||
|
|
ffa14550fd | ||
|
|
7cca58f524 | ||
|
|
03b679e152 | ||
|
|
b3f8025dad | ||
|
|
45e70e9854 | ||
|
|
598c0ecf2e |
8
.gitignore
vendored
Executable file
8
.gitignore
vendored
Executable file
@@ -0,0 +1,8 @@
|
||||
*.tar
|
||||
simpleserve
|
||||
*.tar
|
||||
*.sw*
|
||||
**.sw*
|
||||
tmp
|
||||
server
|
||||
uvc
|
||||
3
.gitmodules
vendored
Executable file
3
.gitmodules
vendored
Executable file
@@ -0,0 +1,3 @@
|
||||
[submodule "water.css"]
|
||||
path = water.css
|
||||
url = ./private/water.css
|
||||
36
build.sh
Executable file
36
build.sh
Executable file
@@ -0,0 +1,36 @@
|
||||
#! /bin/bash
|
||||
|
||||
function main() {
|
||||
init
|
||||
server
|
||||
local name="$(gitname)"
|
||||
pack "$name"
|
||||
}
|
||||
|
||||
function init() {
|
||||
set -e
|
||||
cd "$(dirname "$BASH_SOURCE")"
|
||||
}
|
||||
|
||||
function server() {
|
||||
local f="./exec-server"
|
||||
GOOS=linux CGO_ENABLED=0 go build -o "$f" -a -installsuffix cgo >&2
|
||||
echo "$f"
|
||||
}
|
||||
|
||||
function gitname() {
|
||||
local name="$(git describe --tags)"
|
||||
if [ -z "$name" ]; then
|
||||
name="$(git rev-parse --abbrev-ref HEAD)"
|
||||
fi
|
||||
echo "$name"
|
||||
}
|
||||
|
||||
function pack() {
|
||||
tar -czf "$1.tar" "./exec-server" "./public"
|
||||
echo "$1.tar"
|
||||
}
|
||||
|
||||
if [ "$0" == "${BASH_SOURCE[0]}" ]; then
|
||||
main "$@"
|
||||
fi
|
||||
73
main.go
Executable file
73
main.go
Executable file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
Serve is a very simple static file server in go
|
||||
Usage:
|
||||
-p="8100": port to serve on
|
||||
-d=".": the directory of static files to host
|
||||
Navigating to http://localhost:8100 will display the index.html or directory
|
||||
listing file.
|
||||
*/
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io/ioutil"
|
||||
"local/args"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fs := args.NewArgSet()
|
||||
fs.Append(args.STRING, "p", "port to serve", "8100")
|
||||
fs.Append(args.STRING, "d", "static path to serve", "./public")
|
||||
if err := fs.Parse(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
d := fs.Get("d").GetString()
|
||||
p := fs.Get("p").GetString()
|
||||
go serve(d, p)
|
||||
go poll(path.Join(d, "csv"), time.Minute)
|
||||
|
||||
<-context.Background().Done()
|
||||
}
|
||||
|
||||
func serve(directory, port string) {
|
||||
port = strings.TrimPrefix(port, ":")
|
||||
http.Handle("/", http.FileServer(http.Dir(directory)))
|
||||
log.Printf("Serving %s on HTTP port: %s\n", directory, port)
|
||||
log.Fatal(http.ListenAndServe(":"+port, nil))
|
||||
}
|
||||
|
||||
func poll(path string, interval time.Duration) {
|
||||
for {
|
||||
select {
|
||||
case <-context.Background().Done():
|
||||
case <-time.After(interval):
|
||||
if err := refresh(path); err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func refresh(path string) error {
|
||||
url := "https://docs.google.com/spreadsheets/d/14F7zRrwGT6JkCeZqZLPM2r2GScrm9FLFxlPtDINbNWg/gviz/tq?tqx=out:csv"
|
||||
resp, err := http.Get(url)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
b, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := ioutil.WriteFile(path, b, os.ModePerm); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Submodule private/water.css updated: 2f4c5fba5e...4aebad045d
4
public/csv
Executable file
4
public/csv
Executable file
@@ -0,0 +1,4 @@
|
||||
"Link to Ride","Date","Day","Time","Route","Start","Notes"
|
||||
"https://ridewithgps.com/routes/29835879","May 11","Sat","9:00 AM","Hobble Creek R & L Forks 86-Mi","OLD Bike Peddler 24 E Main American Fork","Great way to start the cycling year with good friends! Weather Permitting"
|
||||
"","May 11","Sat","9:45 AM","64-Mile Ride Hobble Creek R & L Forks","Gas Station 1600 E 800 N Orem","Same route as last week."
|
||||
"","May 13","Mon","5:45 AM","Spin Class","VASA Fitness American Fork","High Intensity group workout on new spin bikes"
|
||||
@@ -1,47 +0,0 @@
|
||||
function http(method, remote, callback, body) {
|
||||
var xmlhttp = new XMLHttpRequest();
|
||||
xmlhttp.onreadystatechange = function() {
|
||||
if (xmlhttp.readyState == XMLHttpRequest.DONE) { // XMLHttpRequest.DONE == 4
|
||||
callback(xmlhttp.responseText, xmlhttp.status)
|
||||
}
|
||||
};
|
||||
xmlhttp.open(method, remote, true);
|
||||
if (typeof body == "undefined") {
|
||||
body = null
|
||||
}
|
||||
xmlhttp.send(body);
|
||||
}
|
||||
|
||||
function populate_schedule(csv, status_code) {
|
||||
console.log("status_code", status_code)
|
||||
csv = csv.split("\n")
|
||||
var first = true;
|
||||
var table = "";
|
||||
for (var i in csv) {
|
||||
table += "<tr>\n"
|
||||
i = csv[i].split('","')
|
||||
for (var j in i) {
|
||||
j = i[j]
|
||||
j = j.replace(/(^"|"$)/g, "")
|
||||
table += first ? "<th>" : "<td>"
|
||||
table += j
|
||||
table += first ? "</th>" : "</td>"
|
||||
}
|
||||
table += "</tr>\n"
|
||||
first = false;
|
||||
}
|
||||
document.getElementById("schedule").innerHTML = table
|
||||
}
|
||||
|
||||
var cors_anywhere = "https://cors-anywhere.herokuapp.com"
|
||||
var google_doc_pre = "https://docs.google.com/spreadsheets/d/"
|
||||
var google_doc_id = "14F7zRrwGT6JkCeZqZLPM2r2GScrm9FLFxlPtDINbNWg"
|
||||
var google_doc_post = "/gviz/tq?tqx=out:csv"
|
||||
//"https://www.googleapis.com/drive/v3/files/14F7zRrwGT6JkCeZqZLPM2r2GScrm9FLFxlPtDINbNWg/export?mimeType=text/csv&key=AIzaSyCFIWSe7vBnZ-1KRR9yVMbCPW08oCOHRJI",
|
||||
|
||||
http(
|
||||
"get",
|
||||
`${cors_anywhere}/${google_doc_pre}/${google_doc_id}/${google_doc_post}`,
|
||||
populate_schedule,
|
||||
JSON.stringify({"cc": "cc"}),
|
||||
)
|
||||
84
public/index.html
Normal file → Executable file
84
public/index.html
Normal file → Executable file
@@ -1,18 +1,8 @@
|
||||
<html>
|
||||
<header>
|
||||
<link rel='stylesheet' href='light.css'>
|
||||
<link rel='stylesheet' href='uvc.css'>
|
||||
<script src="home.js"></script>
|
||||
</header>
|
||||
<body>
|
||||
<a href="https://github.com/kognise/water.css">this css</a>
|
||||
<div id="title">
|
||||
<h1>Utah Velo Club</h1>
|
||||
<h4>The club is located in Utah County. Just South of Salt Lake City, Utah!</h4>
|
||||
</div>
|
||||
<table><tr>
|
||||
<td id="nav" style="width:150px; vertical-align: top;">
|
||||
<br><a href="http://www.utahveloclub.com/club_membership_request2017.htm">Request for Club Membership</a>
|
||||
<td id="nav">
|
||||
<a href="http://www.utahveloclub.com/club_membership_request2017.htm">Request for Club Membership</a>
|
||||
<br><a href="http://www.utahveloclub.com/club_assumption_of_risk.htm">Assumption of Risk</a></li>
|
||||
<br><a href="http://utahveloclub.com/id18.htm">About the Club</a>
|
||||
<br><a href="http://bikepeddlerutah.com/blog/">Mountain Biking</a>
|
||||
@@ -29,6 +19,10 @@
|
||||
<br><a href="http://utahveloclub.com/id30.htm">Cycling Links</a>
|
||||
</td>
|
||||
<td id="body">
|
||||
<div id="title">
|
||||
<h1>Utah Velo Club</h1>
|
||||
<h4>The club is located in Utah County. Just South of Salt Lake City, Utah!</h4>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Site last Updated: May 10, 2019</h4>
|
||||
</div>
|
||||
@@ -71,4 +65,70 @@
|
||||
</td>
|
||||
</tr></table>
|
||||
</body>
|
||||
<head>
|
||||
<script>
|
||||
function http(method, remote, callback, body) {
|
||||
var xmlhttp = new XMLHttpRequest();
|
||||
xmlhttp.onreadystatechange = function() {
|
||||
if (xmlhttp.readyState == XMLHttpRequest.DONE) { // XMLHttpRequest.DONE == 4
|
||||
callback(xmlhttp.responseText, xmlhttp.status)
|
||||
}
|
||||
};
|
||||
xmlhttp.open(method, remote, true);
|
||||
if (typeof body == "undefined") {
|
||||
body = null
|
||||
}
|
||||
xmlhttp.send(body);
|
||||
}
|
||||
|
||||
function populate_schedule(csv, status_code) {
|
||||
console.log("status_code", status_code)
|
||||
csv = csv.split("\n")
|
||||
var first = true;
|
||||
var table = "";
|
||||
for (var i in csv) {
|
||||
table += "<tr>\n"
|
||||
i = csv[i].split('","')
|
||||
for (var j in i) {
|
||||
j = i[j]
|
||||
j = j.replace(/(^"|"$)/g, "")
|
||||
table += first ? "<th>" : "<td>"
|
||||
table += j
|
||||
table += first ? "</th>" : "</td>"
|
||||
}
|
||||
table += "</tr>\n"
|
||||
first = false;
|
||||
}
|
||||
document.getElementById("schedule").innerHTML = table
|
||||
}
|
||||
|
||||
var cors_anywhere = "https://cors-anywhere.herokuapp.com"
|
||||
var google_doc_pre = "https://docs.google.com/spreadsheets/d/"
|
||||
var google_doc_id = "14F7zRrwGT6JkCeZqZLPM2r2GScrm9FLFxlPtDINbNWg"
|
||||
var google_doc_post = "/gviz/tq?tqx=out:csv"
|
||||
//`${cors_anywhere}/${google_doc_pre}/${google_doc_id}/${google_doc_post}`,
|
||||
|
||||
http(
|
||||
"get",
|
||||
window.location+"/csv",
|
||||
populate_schedule,
|
||||
JSON.stringify({"cc": "cc"}),
|
||||
)
|
||||
</script>
|
||||
<style>
|
||||
#nav
|
||||
{
|
||||
width: 150px;
|
||||
vertical-align: top;
|
||||
background-color: #990000;
|
||||
color: #fff;
|
||||
height: 100%;
|
||||
}
|
||||
#nav > a
|
||||
{
|
||||
color: #fff;
|
||||
}
|
||||
@charset "UTF-8";body{font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;line-height:1.4;max-width:800px;margin:20px auto;padding:0 10px;color:#363636;background:#fff;text-rendering:optimizeLegibility}button,input,textarea{transition:background-color .1s linear,border-color .1s linear,color .1s linear,box-shadow .1s linear,transform .1s ease}h1{font-size:2.2em;margin-top:0}h1,h2,h3,h4,h5,h6{margin-bottom:12px}h1,h2,h3,h4,h5,h6,strong{color:#000}b,h1,h2,h3,h4,h5,h6,strong,th{font-weight:600}blockquote{border-left:4px solid #700;margin:1.5em 0;padding:.5em 1em;font-style:italic}blockquote>footer{margin-top:10px;font-style:normal}address,blockquote cite{font-style:normal}a[href^=mailto]:before{content:"📧 "}a[href^=tel]:before{content:"📞 "}a[href^=sms]:before{content:"💬 "}button,input[type=button],input[type=checkbox],input[type=submit]{cursor:pointer}input:not([type=checkbox]):not([type=radio]),select{display:block}button,input,select,textarea{color:#000;background-color:#efefef;font-family:inherit;font-size:inherit;margin-right:6px;margin-bottom:6px;padding:10px;border:none;border-radius:6px;outline:none}button,input:not([type=checkbox]):not([type=radio]),select,textarea{-webkit-appearance:none}textarea{margin-right:0;width:100%;box-sizing:border-box;resize:vertical}button,input[type=button],input[type=submit]{padding-right:30px;padding-left:30px}button:hover,input[type=button]:hover,input[type=submit]:hover{background:#ddd}button:focus,input:focus,select:focus,textarea:focus{box-shadow:0 0 0 2px #700}button:active,input[type=button]:active,input[type=checkbox]:active,input[type=radio]:active,input[type=submit]:active{transform:translateY(2px)}button:disabled,input:disabled,select:disabled,textarea:disabled{cursor:not-allowed;opacity:.5}::-webkit-input-placeholder{color:#949494}::-moz-placeholder{color:#949494}:-ms-input-placeholder{color:#949494}::-ms-input-placeholder{color:#949494}::placeholder{color:#949494}a{text-decoration:none;color:#900}a:hover{text-decoration:underline}code,kbd{background:#efefef;color:#000;padding:5px;border-radius:6px}pre>code{padding:10px;display:block;overflow-x:auto}img{max-width:100%;height:auto}hr{border:none;border-top:1px solid #dbdbdb}table{border-collapse:collapse;margin-bottom:10px;width:100%}td,th{padding:6px;text-align:left}th{border-bottom:1px solid #dbdbdb}tbody tr:nth-child(2n){background-color:#efefef}::-webkit-scrollbar{height:10px;width:10px}::-webkit-scrollbar-track{background:#efefef;border-radius:6px}::-webkit-scrollbar-thumb{background:#d5d5d5;border-radius:6px}::-webkit-scrollbar-thumb:hover{background:#c4c4c4}::-moz-selection{background-color:#9e9e9e}::selection{background-color:#9e9e9e}
|
||||
</style>
|
||||
</head>
|
||||
</html>
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
../private/water.css/dist/light.css
|
||||
@@ -1 +0,0 @@
|
||||
../private/water.css/dist/uvc.css
|
||||
Reference in New Issue
Block a user