diff options
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | Makefile | 68 | ||||
-rwxr-xr-x | bin/pagerender | 44 | ||||
-rw-r--r-- | lib/pandoc.rb | 77 | ||||
-rw-r--r-- | lib/template.erb | 51 | ||||
-rw-r--r-- | src/.gitignore | 1 | ||||
-rw-r--r-- | src/header-text.svg | 28 | ||||
-rw-r--r-- | src/index.md | 14 | ||||
m--------- | src/logos | 0 | ||||
-rw-r--r-- | src/safety/.gitignore | 1 | ||||
-rw-r--r-- | src/safety/index.md | 23 | ||||
-rwxr-xr-x | src/safety/reports | 47 | ||||
-rw-r--r-- | src/style.scss | 86 | ||||
-rw-r--r-- | src/trophies.jpg | bin | 0 -> 34759 bytes |
14 files changed, 442 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..621a527 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/out/ +.sass-cache/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e858021 --- /dev/null +++ b/Makefile @@ -0,0 +1,68 @@ +SHELL = bash +RUBYLIB=$(realpath .)/lib +export RUBYLIB + +patsubst-all = $(if $1,$(call patsubst-all,$(wordlist 2,$(words $1),$1),$2,$(patsubst $(firstword $1),$2,$3)),$3) + +html.suffixes = md org html +html.src = $(shell find src -type f \( -false $(foreach s,$(html.suffixes), -o -name '*.$s' -o -name '*.$s.m4' ) \) | grep -v /web/) +html.out = $(call patsubst-all,$(addprefix src/%.,$(html.suffixes)),out/%.html,$(patsubst %.m4,%,$(html.src))) +all: $(html.out) +all: out/style.css +all: out/header-path.svg + +pagerender.deps = bin/pagerender lib/pandoc.rb lib/template.erb + +out/%: src/%.m4 + mkdir -p -- $(@D) + m4 -P < $< > $@ +out/%: out/%.m4 + m4 -P < $< > $@ + +out/%.html: src/%.md $(pagerender.deps) + mkdir -p -- $(@D) + bin/pagerender $< > $@ +out/%.html: out/%.md $(pagerender.deps) + bin/pagerender $< > $@ + +out/%.html: src/%.org $(pagerender.deps) + mkdir -p -- $(@D) + bin/pagerender $< > $@ +out/%.html: out/%.org $(pagerender.deps) + bin/pagerender $< > $@ + +out/%.html: src/%.html $(pagerender.deps) + mkdir -p -- $(@D) + bin/pagerender $< > $@ +out/%.html: out/%.html $(pagerender.deps) + bin/pagerender $< > $@ + +out/%.html: src/%.erb $(pagerender.deps) + mkdir -p -- $(@D) + bin/pagerender $< > $@ +out/%.html: out/%.erb $(pagerender.deps) + bin/pagerender $< > $@ + +var-%: + @printf '%s\n' $(call quote.shell,$($*)) + +out/%.css: src/%.scss + scss -s < $< > $@ + +.DELETE_ON_ERROR: +.SECONDARY: + +outdir=out/logos +srcdir=src/logos +topoutdir=out +topsrcdir=src +include src/logos/Makefile + +define nl + + +endef + +# I put this as the last line in the file because it confuses Emacs syntax +# highlighting and makes the remainder of the file difficult to edit. +quote.shell = $(subst $(nl),'$$'\n'','$(subst ','\'',$1)') diff --git a/bin/pagerender b/bin/pagerender new file mode 100755 index 0000000..a4ce6a1 --- /dev/null +++ b/bin/pagerender @@ -0,0 +1,44 @@ +#!/usr/bin/env ruby +# -*- coding: utf-8 -*- +require 'erb' +require 'date' + +load 'pandoc.rb' +Pandoc::prog='pandoc' + +def erb(file, context=nil) + _erb = ERB.new(File.read(file)) + _erb.filename = file + if context.nil? + return _erb.result() + else + return _erb.result(context) + end +end + +template = 'lib/template.erb' +infile = ARGV.first +input = File.read(infile) + +@title = 'TITLE GOES HERE' + +case File.extname(infile) +when '.md' + doc = Pandoc::load('markdown', input) + @title = doc['title'] || input.split("\n",2).first + @body = doc.to('html5') +when '.org' + doc = Pandoc::load('org', input) + @title = doc['title'] || input.split("\n",2).first + @body = doc.to('html5') +when '.erb' + erb_body = ERB.new(input) + erb_body.filename = infile + @body = erb_body.result() +else + abort +end + +erb = ERB.new(File.read(template)); +erb.filename = template +erb.run() diff --git a/lib/pandoc.rb b/lib/pandoc.rb new file mode 100644 index 0000000..9c12351 --- /dev/null +++ b/lib/pandoc.rb @@ -0,0 +1,77 @@ +require 'open3' +require 'json' + +module Pandoc + def self.prog + @prog ||= 'pandoc' + end + def self.prog=(val) + @prog = val + end + def self.load(fmt, input) + cmd = Pandoc::prog + " -t json" + unless fmt.nil? + cmd += " -f " + fmt + end + str = input + if str.respond_to? :read + str = str.read + end + json = '' + errors = '' + Open3::popen3(cmd) do |stdin, stdout, stderr| + stdin.puts(str) + stdin.close + json = stdout.read + errors = stderr.read + end + unless errors.empty? + raise errors + end + return Pandoc::AST::new(json) + end + + class AST + def initialize(json) + @js = JSON::parse(json) + end + + def [](key) + Pandoc::AST::js2sane(@js[0]["unMeta"][key]) + end + + def to(format) + cmd = Pandoc::prog + " -f json -t " + format.to_s + output = '' + errors = '' + Open3::popen3(cmd) do |stdin, stdout, stderr| + stdin.puts @js.to_json + stdin.close + output = stdout.read + errors = stderr.read + end + unless errors.empty? + raise errors + end + return output + end + + def self.js2sane(js) + if js.nil? + return js + end + case js["t"] + when "MetaList" + js["c"].map{|c| js2sane(c)} + when "MetaInlines" + js["c"].map{|c| js2sane(c)}.join() + when "Space" + " " + when "MetaString" + js["c"] + when "Str" + js["c"] + end + end + end +end diff --git a/lib/template.erb b/lib/template.erb new file mode 100644 index 0000000..19f018f --- /dev/null +++ b/lib/template.erb @@ -0,0 +1,51 @@ +<!DOCTYPE html> +<html lang="en"> + <head> + <meta charset="utf-8"> + <meta http-equiv="X-UA-Compatible" content="IE=edge"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <!-- the meta tags must come first --> + + <title><%= @title %></title> + + <link href="/style.css" rel="stylesheet"> + <%= @head %> + </head> + <body> + <header> + <h1> + <img src="/logos/brass-bull.png"/> + <img src="/header-path.svg" alt="4272 Maverick Boiler Robotics"/> + </h1> + <nav> + <ul> + <li><a href="/">Home</a></li> + <li><a href="javascript:">Collaboration Tools</a> + <ul> + <li><a href="https://git.team4272.com/">Git</a></li> + <li><a href="https://owncloud.team4272.com/">ownCloud</a></li> + <li><a href="https://ethercalc.team4272.com/">EtherCalc</a></li> + </ul> + </li> + <li><a href="/safety">Safety App</a></li> + </ul> + </nav> + </header> + <article> + <%= @body %> + </article> + <footer> + <table> + <tr> + <td> + This is where we would put our sponsors. IF WE HAD ANY! + </td> + <td> + <img style="float:right; max-height: 150px" + src="/trophies.jpg"> + </td> + </tr> + </table> + </footer> + </body> +</html> diff --git a/src/.gitignore b/src/.gitignore new file mode 100644 index 0000000..c037bd6 --- /dev/null +++ b/src/.gitignore @@ -0,0 +1 @@ +/releases/
\ No newline at end of file diff --git a/src/header-text.svg b/src/header-text.svg new file mode 100644 index 0000000..47b21a0 --- /dev/null +++ b/src/header-text.svg @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg xmlns="http://www.w3.org/2000/svg" version="1.1" + width="245.16283" + height="89.061935" + viewBox="0 0 245.16283 89.061935"> + <text + style="font-size:97.46086884px;font-family:'Eras Bold ITC';fill:#000000;stroke:none" + id="text4272" + x="-3.6167119" + y="66.195343"> + <tspan + id="tspan10" + y="66.195343" + x="-3.6167119 59.830311 123.27733 186.72438" + style="fill:#000000">4272</tspan> + </text> + <text + style="font-size:16.36325073px;font-family:'Orator Std';fill:#000000;stroke:none" + id="textMBR" + x="5.1302819" + y="88.849213"> + <tspan + id="tspan13" + y="88.849213" + x="5.1302819 14.94823 24.766176 34.584126 44.402088 54.22002 64.037979 73.855942 83.673874 93.491837 103.30977 113.12773 122.94566 132.76363 142.58159 152.39952 162.21748 172.03545 181.85338 191.67131 201.48927 211.30724 221.12517 230.94313" + style="fill:#000000">MAVERICK BOILER ROBOTICS</tspan> + </text> +</svg> diff --git a/src/index.md b/src/index.md new file mode 100644 index 0000000..8e9d523 --- /dev/null +++ b/src/index.md @@ -0,0 +1,14 @@ +--- +title: "FRC Team 4272: Maverick Boiler Robitics" +--- + +Lior make old site go bye-bye. Luke put off making new site all +summer. + +Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do +eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad +minim veniam, quis nostrud exercitation ullamco laboris nisi ut +aliquip ex ea commodo consequat. Duis aute irure dolor in +reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla +pariatur. Excepteur sint occaecat cupidatat non proident, sunt in +culpa qui officia deserunt mollit anim id est laborum. diff --git a/src/logos b/src/logos new file mode 160000 +Subproject e33bf28ae4ebc0a74e28b37c9535324e391deb1 diff --git a/src/safety/.gitignore b/src/safety/.gitignore new file mode 100644 index 0000000..63ea916 --- /dev/null +++ b/src/safety/.gitignore @@ -0,0 +1 @@ +/*/ diff --git a/src/safety/index.md b/src/safety/index.md new file mode 100644 index 0000000..15dd619 --- /dev/null +++ b/src/safety/index.md @@ -0,0 +1,23 @@ +FRC Team 4272 SafetyApp +======================= + +The app currently supports Android, and running as a Web application. +iOS support is written, but Apple's App-Store approval takes time. + +- [Download for Android](../releases/SafetyApp-latest.apk) — Requires + enabling installing apps from unknown sources; since I'm not sucking + up to Google to get it in the Play store. To do this, go to Settings + → Applications, then check "Unknown Sources" +- [Web application](./web/) — Should work pretty much anywhere. Taking + photos when reporting an injury may or may not work, depending on + your browser (verified to work in Firefox on Desktop and Android). + +The layout of the Android application will be extra-ugly on old versions +of Android, but if you have a version of android from the last 3 years, +you should be in good shape. If you do happen to be locked to an old +version of Android, you may want to try installing a recent version of +Firefox Mobile, and using the web app. + +Also, the [source code](https://git.team4272.com/2016/safetyapp.git) +because [Free Software](https://www.gnu.org/philosophy/free-sw) legal +and ethical reasons. diff --git a/src/safety/reports b/src/safety/reports new file mode 100755 index 0000000..e9dd9fa --- /dev/null +++ b/src/safety/reports @@ -0,0 +1,47 @@ +#!/bin/bash + +render_redirect() { + declare -i i=$1 + cat <<EOF +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>Redirect</title> +</head> +<body> + <script> + window.history.go(-$i); + </script> +</body> +</html> +EOF +} + +post() { + local dir="$(dirname -- "$0")" + file="$(mktemp -- "$dir/reports.d/$(date +%Y-%m-%dT%H:%M:%S)-XXXXXXXXXX")" + cat > "$file" + printf -- '%s\r\n' \ + 'Status: 201 Created' \ + 'Content-Type: text/html; charset=utf-8' \ + "Location: ${SCRIPT_NAME}/redirect" \ + '' + render_redirect 2 +} + +main() { + pwd + if [[ "$REQUEST_METHOD" == POST ]]; then + post + elif [[ "$REQUEST_METHOD" == GET ]] && [[ "$PATH_INFO" = */redirect ]]; then + render_redirect 2 + else + printf -- '%s\r\n' \ + 'Status: 403 Forbidden' \ + '' + render_redirect 1 + fi +} + +main "$@" diff --git a/src/style.scss b/src/style.scss new file mode 100644 index 0000000..bfe7fc0 --- /dev/null +++ b/src/style.scss @@ -0,0 +1,86 @@ +$maroon: #8a181a; +$gold: #e5b217; + +$main-radius: 1.5em; + +body { + background-color: #111111; +} + +body > * { + box-sizing: border-box; + max-width: 8in; + margin-left: auto; + margin-right: auto; + display: block; + padding: $main-radius; + overflow: hidden; +} + +body > header { + text-align: center; + vertical-align: middle; + background: $maroon; + border-radius: $main-radius $main-radius 0 0 ; + padding: 0; + padding-top: $main-radius; + & > h1 img { + height: 89px; + } + & > nav { + /* single-level drop downs */ + line-height: 1; + ul { + padding: 0; + margin: 0; + list-style: none; + } + li { + float: left; + } + a { + display: block; + } + li ul { + position: absolute; + display: none; + left: auto; + } + :hover > ul, + :focus + ul { + display: block; + } + + /* pretty */ + & { + height: 3em; + background-color: #333333; + } + li ul, li li { + width: 10em; + } + a { + display: block; + padding: 1em; + color: white; + background-color: #333333; + text-decoration: none; + + &:hover, + &:focus { + background-color: $gold; + } + } + } +} + +body > article { + background: white; +} + +body > footer { + background: #333333; + color: #ffffff; + vertical-align: top; + border-radius: 0 0 $main-radius $main-radius; +} diff --git a/src/trophies.jpg b/src/trophies.jpg Binary files differnew file mode 100644 index 0000000..00001da --- /dev/null +++ b/src/trophies.jpg |