Move jekyll back out of matrix-doc again

Having the jekyll assets here is a mistake, because they need to be versioned
separately to the spec: we keep old versions of the spec, but they sometimes
need to be restyled to match the latest website.
This commit is contained in:
Richard van der Hoff 2017-08-03 15:49:17 +01:00
parent 8a66b1a68b
commit b0ea6038c6
32 changed files with 23 additions and 1453 deletions

View file

@ -1,71 +0,0 @@
#!/usr/bin/perl
use strict;
use warnings;
use File::Slurp qw/read_file/;
if (scalar(@ARGV) < 1) {
die "Usage: $0 include_dir file_to_replace...";
}
my $include_dir = $ARGV[0];
if (! -d $include_dir) {
die "'$include_dir' is not a directory";
}
my $header = read_file("${include_dir}/head.html");
my $nav = read_file("${include_dir}/nav.html");
my $footer = read_file("${include_dir}/footer.html");
$header .= "<link rel=\"stylesheet\" href=\"/docs/guides/css/docs_overrides.css\">\n";
$nav = <<EOT;
<div id="page-wrapper">
<div class="page-content" id="page-container">
$nav
<div id="main-content">
<div class="wrapper" id="wrapper">
<div class="document_foo" id="document">
EOT
$footer = <<EOT;
</div>
</div>
<div class="push">
</div>
</div>
</div>
$footer
</div>
</div>
EOT
my $oldargv;
while(<>) {
if (!$oldargv || $ARGV ne $oldargv) {
# new file: open output file
unlink($ARGV);
open(ARGVOUT, ">", $ARGV);
select(ARGVOUT);
$oldargv = $ARGV;
}
s/<head>/$&$header/;
if (/<body.*?>/) {
my $match = $&;
my $classes = "blog et_fixed_nav et_cover_background et_right_sidebar";
if ($match =~ / class=/) {
$match =~ s/ class="([^"]*)"/ class="$1 $classes"/;
} else {
$match =~ s/>/ class=\"$classes\">/;
}
s/<body.*?>/$match$nav/;
}
s#</body>#$footer$&#;
print;
}

View file

@ -1,28 +0,0 @@
#!/usr/bin/env python
#
# adds anchors before any <h1/h2/h3/h4/h5> tags with an id="..." - this is used
# for things like the FAQ where we want to have anchored links to every
# question (and this way you don't have to manually maintain it in the source
# doc).
from sys import argv
import re
filename = argv[1]
regex = r'(<h\d id="(.*?)">)'
regex2 = r'(<div class="section" id="(.*?)">)'
replacement = r'<p><a class="anchor" id="\2"></a></p>\n\1'
with open(filename, "r") as f:
lines = list(f)
# check for <hX id="..." (used in the FAQ) and add anchors - and then check
# for <div class="section" id="..." and add anchors (used in the spec)
with open(filename, "w") as f:
for line in lines:
line = re.sub(regex, replacement, line)
line = re.sub(regex2, replacement, line)
f.write(line)

View file

@ -0,0 +1,18 @@
#!/bin/sh
#
# generate a tarball of assets suitable for the matrix.org site
cd `dirname $0`/..
mkdir -p assets
# generate the spec docs
./scripts/gendoc.py -d assets/spec
# also need the supporting-docs, which become the jekyll posts.
cp -rT supporting-docs assets/jekyll-posts
# create a tarball of the assets. Exclude the spec index for now, as
# we want to leave it pointing at the release versions of the specs.
# (XXX: how to maintain this?)
tar -czf assets.tar.gz --exclude="assets/spec/index.html" assets

View file

@ -1,30 +0,0 @@
#!/bin/bash
#
# This script builds part of the matrix.org site, under '_site'.
#
# jekyll requires the `docutils` and `pygments` python packages, so install
# them or run from a virtualenv which includes them.
set -ex
# tell jekyll to parse things as utf-8
export LANG="en_GB.UTF-8"
cd `dirname $0`/..
mkdir -p _site
# generate the jekyll bits
jekyll build -s jekyll
# add some anchors to some generated jekyll bits
./scripts/add_anchors.py _site/guides/faq.html
./scripts/add_anchors.py _site/projects/try-matrix-now.html
# generate the latest spec
./scripts/gendoc.py -d _site/spec
# apply the matrix.org styling to the spec
find _site/spec -name '*.html' |
xargs ./scripts/add-matrix-org-stylings.pl jekyll/_includes