From 8cefd9fabc30a4c881172b68f64d52285a8f97f7 Mon Sep 17 00:00:00 2001 From: Niklas Fasching Date: Tue, 11 Dec 2018 14:45:57 +0100 Subject: [PATCH] Set up github pages --- .gitignore | 2 + .travis.yml | 12 +++++ Makefile | 6 ++- etc/generate-gh-pages | 48 ++++++++++++++++++++ etc/style.css | 102 ++++++++++++++++++++++++++++++++++++++++++ main.go | 2 +- 6 files changed, 170 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100755 etc/generate-gh-pages create mode 100644 etc/style.css diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2f5ebc1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +gh-pages/ +/go-org diff --git a/.travis.yml b/.travis.yml index 4f2ee4d..804f24a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1 +1,13 @@ language: go +script: + - make test + - make generate-gh-pages +deploy: + provider: pages + github-token: $GITHUB_TOKEN # From travis-ci.org repository settings + local-dir: gh-pages + target-branch: gh-pages + skip-cleanup: true + verbose: true + on: + branch: master diff --git a/Makefile b/Makefile index 85ea291..b91089d 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ install: .PHONY: build build: install - go build main.go + go build . .PHONY: test test: install @@ -21,3 +21,7 @@ case=example .PHONY: render render: go run main.go org/testdata/$(case).org html | html2text + +.PHONY: generate-gh-pages +generate-gh-pages: build + ./etc/generate-gh-pages diff --git a/etc/generate-gh-pages b/etc/generate-gh-pages new file mode 100755 index 0000000..4f33ff3 --- /dev/null +++ b/etc/generate-gh-pages @@ -0,0 +1,48 @@ +#!/bin/bash + +org_files=org/testdata/*.org +content=" +

Sections

+ +
" + +for org_file in $org_files; do + echo generating content for $org_file + name=$(basename $org_file) + content+=" +

${name}

+
+
$(cat $org_file)
+
$(./go-org $org_file html-chroma)
+
" +done + +html=" + + + + + $content +" + +mkdir -p gh-pages +echo "$html" > gh-pages/index.html diff --git a/etc/style.css b/etc/style.css new file mode 100644 index 0000000..163c26c --- /dev/null +++ b/etc/style.css @@ -0,0 +1,102 @@ +* { + box-sizing: border-box; + margin: 0; + padding: 0; } + +html { + font: 100%/1.5 sans-serif; + word-wrap: break-word; + padding: 1.5em; } + +@media (min-width: 768px) { + html { font-size: 125%; } } + +h1, h2, h3, h4 { + margin: 2.5rem 0 1.5rem 0; + line-height: 1.25; } + +.title { + font-size: 2.5em; } + +.subtitle { + font-weight: normal; + font-size: 0.75em; + color: #666; } + +a { + color: #fa6432; + text-decoration: none; } +a:hover, a:focus, a:active { + text-decoration: underline; } + +p { + margin: 1em 0; } +p code { + background-color: #eee; + padding: 0.05em 0.2em; + border: 1px solid #ccc; } + +ol, ul { + margin: 1em; } +ol li ol, ol li ul, ul li ol, ul li ul { + margin: 0 2em; } +ol li p, ul li p { + margin: 0; } + +img { + max-width: 100%; + display: block; + margin: 0 auto; + padding: 0.5em; } + +blockquote { + padding-left: 1em; + font-style: italic; + border-left: solid 1px #fa6432; } + +table { + font-family: monospace; + font-size: 1rem; + text-align: left; + caption-side: bottom; + margin-bottom: 2em; } +table * { + border: none; } +table thead, table tr { + display: table; + table-layout: fixed; + width: 100%; } +table tr:nth-child(even) { + background-color: #ccc; } +table tbody { + display: block; + max-height: 70vh; + overflow-y: auto; } +table td, table th { + padding: 0.25em; } + +table, .highlight > pre, pre.example { + max-height: 70vh; + margin: 1em 0; + padding: 1em; + overflow: auto; + font-size: 0.85rem; + border: 1px solid rgba(250, 100, 50, 0.5); } + +.caption { + font-family: monospace; + font-size: 0.75em; + text-align: center; + color: grey; + margin-top: 0; } + +.footnote-definition sup { + float: left; } + +.footnote-definition .footnote-body { + margin: 1em 0; + padding: 0 1em; + border: 1px solid rgba(250, 100, 50, 0.3); + background-color: #ccc; } +.footnote-definition .footnote-body p:only-child { + margin: 0.2em 0; } diff --git a/main.go b/main.go index fe7d3ba..751dadb 100644 --- a/main.go +++ b/main.go @@ -50,5 +50,5 @@ func highlightCodeBlock(source, lang string) string { l = chroma.Coalesce(l) it, _ := l.Tokenise(nil, source) _ = html.New().Format(&w, styles.Get("friendly"), it) - return w.String() + return `
` + w.String() + `
` }