Permalink
Browse files

Update website building scripts

- Instead of screenshots, now links to a timestamp in video
- Build various pages from a single template
  • Loading branch information...
anjakefala committed Oct 1, 2017
1 parent 47ddde1 commit 33fce79b153be5c162109d3eff4c02a31bed2736
Showing with 551 additions and 99 deletions.
  1. +17 −6 mkwww.sh
  2. +14 −0 strformat.py
  3. +0 −31 www/demo/demo.thtml
  4. +21 −12 www/demo/mkdemo.py
  5. +20 −0 www/demo/mkindex.py
  6. +6 −0 www/demo/pivot.yaml
  7. +0 −50 www/demo/pivot/index.html
  8. +447 −0 www/normalize.css
  9. +26 −0 www/template.html
View
@@ -1,6 +1,7 @@
#!/bin/sh
#!/bin/zsh
# Stops the execution of a script if there is an error
set -x
set -e
VD=~/git/visidata
@@ -12,20 +13,30 @@ MAN=$VD/docs/man
mkdir -p $WWW/man/vd
mkdir -p $WWW/demo
MAN_KEEP_FORMATTING=1 COLUMNS=100 man $MAN/vd.1 | ul | aha > $WWW/man/vd/index.html
$VD/build.sh
MAN_KEEP_FORMATTING=1 COLUMNS=100 man $MAN/vd.1 | ul | aha --no-header > $BUILD/vd-man-inc.html
$VD/strformat.py body=$BUILD/vd-man-inc.html title="VisiData Quick Reference" head="" < $VD/www/template.html > $WWW/man/vd/index.html
### build front page from README
markdown $VD/README.md > $WWW/index.html
# Builds tours
for tpath in `find $DEMO -name '*.yaml'`; do
tname=${tpath##$DEMO/}
tfolder=${tname%.yaml}
$DEMO/mkdemo.py $DEMO/demo.thtml $DEMO/$tname > $DEMO/$tfolder/index.html
$DEMO/mkindex.py $DEMO/*.yaml > $BUILD/demo-index-body.html
# Which main css file is it referencing?
$VD/strformat.py body=$BUILD/demo-index-body.html title="Tutorials Index" head='' < $VD/www/template.html > $WWW/demo/index.html
for tpath in `find $DEMO -name 'pivot.yaml'`; do
tyaml=${tpath##$DEMO/}
tfolder=${tyaml%.yaml}
mkdir -p $WWW/demo/$tfolder
$VD/strformat.py body=<($DEMO/mkdemo.py $DEMO/$tyaml) title="VisiData tutorial: $tfolder" head=$DEMO/demo-head-inc.html < $VD/www/template.html > $WWW/demo/$tfolder/index.html
cp $VD/www/* $WWW
cp $DEMO/$tfolder/* $WWW/demo/$tfolder
cp $DEMO/asciinema-player.* $WWW/demo
cp $DEMO/*.css $WWW/demo
done
#### At the end
View
@@ -0,0 +1,14 @@
#!/usr/bin/env python3
import sys
import os.path
kwargs = {}
for arg in sys.argv[1:]:
k, v = arg.split('=', maxsplit=1)
if os.path.exists(v):
v = open(v).read()
kwargs[k] = v
sys.stdout.write(sys.stdin.read().format(**kwargs))
View

This file was deleted.

Oops, something went wrong.
View
@@ -7,36 +7,45 @@
def htmlize(s):
return s.replace('\\n', '<br>')
# step?, command, [additional] input, result
def breakdown(rows):
ret = '<table class="vd">\n'
def body(rows, meta):
ret = '<h2>{question}</h2>\n'.format(question=meta['question'])
# Add asciinema video
ret += '<asciinema-player id="player" {preview} src="{name}-asciicast.json"></asciinema-player>\n'.format(preview=meta['preview'], name=meta['name'])
ret += '<script type="text/javascript" src="../asciinema-player.js"></script>\n'
ret += '<hr/>\n'
# Add screenshot tutorial
ret += '<table class="vd">\n'
ret += ' <tr>\n'
ret += ' <th>#</th>'
ret += ' <th>step</th>'
ret += ' <th>command</th>'
ret += ' <th>input</th>'
ret += ' <th>result</th>'
ret += ' </tr>\n'
for i, row in enumerate(rows[1:]):
colname = '<span class="code">%s</span> column' % row[1]
ret += ' <tr>\n'
ret += ' <td class="num">%s</td>' % (i+1)
ret += ' <td class="timestamp"><a id="step{stepnum}" title="Click to jump to this timestamp in the video" href="#" onclick="setTime({timestamp});return false;">{stepnum}</a></td>\n'.format(stepnum=i+1, timestamp=meta['timestamps'][i])
ret += ' <td class="step">%s</td>' % (htmlize(row[5]).replace("current column", colname))
ret += ' <td class="command">%s</td>' % htmlize(row[3])
ret += ' <td class="input">%s</td>' % htmlize(row[4])
ret += ' <td class="screenshot"><img src="%s.png" alt=""/></td>\n' % (i+1)
ret += ' </tr>\n'
#ret += ' <td class="screenshot"><img src="%s.png" alt=""/></td>\n' % (i+1)
ret += '</table>'
ret += ' </tr>\n'
ret += '</table>\n'
ret += '<hr/>\n'
return ret
def main(thtml, yamlfn):
custom = yaml.load(open(yamlfn).read())
rows = list(row[:-1].split('\t') for row in open(custom['vd']))
print(open(thtml).read().format(breakdown=breakdown(rows), **custom))
def main(yamlfn):
meta = yaml.load(open(yamlfn).read())
rows = list(row[:-1].split('\t') for row in open(meta['vd']))
print(body(rows, meta))
main(*sys.argv[1:])
View
@@ -0,0 +1,20 @@
#!/usr/bin/env python3
# Usage: $0 <*.yaml>
import sys
import yaml
def body():
index = '<div id="index_container">\n'
index += '<ul class="index_list">\n'
# <li><a href='tour_url'>Tour Name</a></li>\n
for fnyaml in sys.argv[1:]:
tour = yaml.load(open(fnyaml).read())
index += '<li><a href="{tour_url}">{tour_title}</a></li>\n'.format(tour_url=tour['name'], tour_title=tour['name'])
index += '</ul>\n'
index += '</div>\n'
return index
print(body())
View
@@ -2,3 +2,9 @@ name: pivot
vd: tests/pivot.vd
preview: poster="npt:0:09"
question: Using sample.tsv, how many of each item has been sold by each representative?
timestamps:
- 0.5
- 3.5
- 5.5
- 7.5
- 9.5
View

This file was deleted.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 33fce79

Please sign in to comment.