Skip to content

Commit

Permalink
change the url of manuals
Browse files Browse the repository at this point in the history
* add redirects from old urls
* old manuals are now served as stable
* and unstable manuals were added
* <link rel="cannonical" url=".." /> was added not to confuse search
  engines
  • Loading branch information
garbas committed Aug 21, 2020
1 parent 1e059f8 commit a68a4e2
Show file tree
Hide file tree
Showing 10 changed files with 375 additions and 178 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Expand Up @@ -3,11 +3,12 @@

/nixos/manual/
/nixos/nix-pills/

/nixpkgs/manual/

/nix/manual/

/manual/
/guides/

/images/screenshots/nixos-*-small.png

/build/
Expand Down
83 changes: 56 additions & 27 deletions Makefile
Expand Up @@ -14,21 +14,10 @@ HTML = index.html download.html news.html learn.html community.html \
404.html


### Prettify the NixOS manual.

NIXOS_MANUAL_IN ?= /no-such-path
NIXOS_MANUAL_OUT = nixos/manual

all: $(NIXOS_MANUAL_OUT)

$(NIXOS_MANUAL_OUT): $(NIXOS_MANUAL_IN) bootstrapify-docbook.sh bootstrapify-docbook.xsl layout.tt common.tt
bash ./bootstrapify-docbook.sh $(NIXOS_MANUAL_IN)/share/doc/nixos $(NIXOS_MANUAL_OUT) 'NixOS manual' nixos https://github.com/NixOS/nixpkgs/tree/master/nixos/doc/manual


### Prettify the Nix Pills

NIX_PILLS_MANUAL_IN ?= /no-such-path
NIX_PILLS_MANUAL_OUT = nixos/nix-pills
NIX_PILLS_MANUAL_OUT = guides/nix-pills

all: $(NIX_PILLS_MANUAL_OUT)

Expand All @@ -38,26 +27,59 @@ $(NIX_PILLS_MANUAL_OUT): $(NIX_PILLS_MANUAL_IN) bootstrapify-docbook.sh bootstra

### Prettify the Nix manual.

NIX_MANUAL_IN ?= /no-such-path
NIX_MANUAL_OUT = nix/manual
NIX_MANUAL_STABLE_IN ?= /no-such-path
NIX_MANUAL_STABLE_OUT = manual/nix/stable

all: $(NIX_MANUAL_OUT)
all: $(NIX_MANUAL_STABLE_OUT)

$(NIX_MANUAL_OUT): $(call rwildcard, $(NIX_MANUAL_IN), *) bootstrapify-docbook.sh bootstrapify-docbook.xsl layout.tt common.tt
bash ./bootstrapify-docbook.sh $(NIX_MANUAL_IN) $(NIX_MANUAL_OUT) 'Nix manual' nix https://github.com/NixOS/nix/tree/master/doc/manual
ln -sfn manual.html $(NIX_MANUAL_OUT)/index.html
$(NIX_MANUAL_STABLE_OUT): $(call rwildcard, $(NIX_MANUAL_STABLE_IN), *) bootstrapify-docbook.sh bootstrapify-docbook.xsl layout.tt common.tt
bash ./bootstrapify-docbook.sh $(NIX_MANUAL_STABLE_IN) $(NIX_MANUAL_STABLE_OUT) 'Nix $(NIX_STABLE_VERSION) manual' nix https://github.com/NixOS/nix/tree/master/doc/manual

NIX_MANUAL_UNSTABLE_IN ?= /no-such-path
NIX_MANUAL_UNSTABLE_OUT = manual/nix/unstable

all: $(NIX_MANUAL_UNSTABLE_OUT)

$(NIX_MANUAL_UNSTABLE_OUT): $(call rwildcard, $(NIX_MANUAL_UNSTABLE_IN), *) bootstrapify-docbook.sh bootstrapify-docbook.xsl layout.tt common.tt
bash ./bootstrapify-docbook.sh $(NIX_MANUAL_UNSTABLE_IN) $(NIX_MANUAL_UNSTABLE_OUT) 'Nix $(NIX_UNSTABLE_VERSION) manual' nix https://github.com/NixOS/nix/tree/master/doc/manual


### Prettify the Nixpkgs manual.

NIXPKGS_MANUAL_IN ?= /no-such-path
NIXPKGS_MANUAL_OUT = nixpkgs/manual
NIXPKGS_MANUAL_STABLE_IN ?= /no-such-path
NIXPKGS_MANUAL_STABLE_OUT = manual/nixpkgs/stable

all: $(NIXPKGS_MANUAL_STABLE_OUT)

$(NIXPKGS_MANUAL_STABLE_OUT): $(NIXPKGS_MANUAL_STABLE_IN) bootstrapify-docbook.sh bootstrapify-docbook.xsl layout.tt common.tt
bash ./bootstrapify-docbook.sh $(NIXPKGS_MANUAL_STABLE_IN)/share/doc/nixpkgs $(NIXPKGS_MANUAL_STABLE_OUT) 'Nixpkgs $(NIXOS_STABLE_SERIES) manual' nixpkgs https://github.com/NixOS/nixpkgs/tree/master/doc

NIXPKGS_MANUAL_UNSTABLE_IN ?= /no-such-path
NIXPKGS_MANUAL_UNSTABLE_OUT = manual/nixpkgs/unstable

all: $(NIXPKGS_MANUAL_OUT)
all: $(NIXPKGS_MANUAL_UNSTABLE_OUT)

$(NIXPKGS_MANUAL_OUT): $(NIXPKGS_MANUAL_IN) bootstrapify-docbook.sh bootstrapify-docbook.xsl layout.tt common.tt
bash ./bootstrapify-docbook.sh $(NIXPKGS_MANUAL_IN)/share/doc/nixpkgs $(NIXPKGS_MANUAL_OUT) 'Nixpkgs manual' nixpkgs https://github.com/NixOS/nixpkgs/tree/master/doc
ln -sfn manual.html $(NIXPKGS_MANUAL_OUT)/index.html
$(NIXPKGS_MANUAL_UNSTABLE_OUT): $(NIXPKGS_MANUAL_UNSTABLE_IN) bootstrapify-docbook.sh bootstrapify-docbook.xsl layout.tt common.tt
bash ./bootstrapify-docbook.sh $(NIXPKGS_MANUAL_UNSTABLE_IN)/share/doc/nixpkgs $(NIXPKGS_MANUAL_UNSTABLE_OUT) 'Nixpkgs $(NIXOS_UNSTABLE_SERIES) manual' nixpkgs https://github.com/NixOS/nixpkgs/tree/master/doc


### Prettify the NixOS manual.

NIXOS_MANUAL_STABLE_IN ?= /no-such-path
NIXOS_MANUAL_STABLE_OUT = manual/nixos/stable

all: $(NIXOS_MANUAL_STABLE_OUT)

$(NIXOS_MANUAL_STABLE_OUT): $(NIXOS_MANUAL_STABLE_IN) bootstrapify-docbook.sh bootstrapify-docbook.xsl layout.tt common.tt
bash ./bootstrapify-docbook.sh $(NIXOS_MANUAL_STABLE_IN)/share/doc/nixos $(NIXOS_MANUAL_STABLE_OUT) 'NixOS $(NIXOS_STABLE_SERIES) manual' nixos https://github.com/NixOS/nixpkgs/tree/master/nixos/doc/manual

NIXOS_MANUAL_UNSTABLE_IN ?= /no-such-path
NIXOS_MANUAL_UNSTABLE_OUT = manual/nixos/unstable

all: $(NIXOS_MANUAL_UNSTABLE_OUT)

$(NIXOS_MANUAL_UNSTABLE_OUT): $(NIXOS_MANUAL_UNSTABLE_IN) bootstrapify-docbook.sh bootstrapify-docbook.xsl layout.tt common.tt
bash ./bootstrapify-docbook.sh $(NIXOS_MANUAL_UNSTABLE_IN)/share/doc/nixos $(NIXOS_MANUAL_UNSTABLE_OUT) 'NixOS $(NIXOS_UNSTABLE_SERIES) manual' nixos https://github.com/NixOS/nixpkgs/tree/master/nixos/doc/manual


all: $(HTML) favicon.png favicon.ico robots.txt $(subst .png,-small.png,$(filter-out %-small.png,$(wildcard images/screenshots/*)))
Expand All @@ -83,8 +105,8 @@ favicon.ico: favicon.png
--define root=$(ROOT) \
--define fileName=$< \
--define nixosAmis=$(NIXOS_AMIS) \
--define latestNixVersion=$(NIX_VERSION) \
--define latestNixOSSeries=$(NIXOS_SERIES) \
--define latestNixVersion=$(NIX_STABLE_VERSION) \
--define latestNixOSSeries=$(NIXOS_STABLE_SERIES) \
--pre_process=common.tt \
$< > $@.tmp
xmllint --nonet --noout $@.tmp
Expand All @@ -93,7 +115,7 @@ favicon.ico: favicon.png
%: %.in common.tt
echo $$PATH
tpage \
--define latestNixVersion=$(NIX_VERSION) \
--define latestNixVersion=$(NIX_STABLE_VERSION) \
--pre_process=common.tt $< > $@.tmp
mv $@.tmp $@

Expand Down Expand Up @@ -131,5 +153,12 @@ endif

all: demo.cast

manuals:
bash ./fix-manual-headers.sh manual/nix stable
bash ./fix-manual-headers.sh manual/nixpkgs stable
bash ./fix-manual-headers.sh manual/nixos stable

all: manuals

demo.cast: demo.py demo.scenario
python demo.py demo.scenario > demo.cast
4 changes: 4 additions & 0 deletions bootstrapify-docbook.sh
Expand Up @@ -39,3 +39,7 @@ done

rm -rf "$outDir" # FIXME: not atomic
mv "$outDirTmp" "$outDir"

if [ -e "$outDir/manual.html" ]; then
mv "$outDir/manual.html" "$outDir/index.html"
fi
10 changes: 5 additions & 5 deletions common.tt
@@ -1,9 +1,9 @@
[%
nixManual = "/nix/manual"
nixpkgsManual = "/nixpkgs/manual"
nixosManual = "/nixos/manual"
nixManual = "/manual/nix/stable"
nixpkgsManual = "/manual/nixpkgs/stable"
nixosManual = "/manual/nixos/stable"
nixopsManual = "https://hydra.nixos.org/job/nixops/master/tarball/latest/download-by-type/doc/manual"
nixPills = "/nixos/nix-pills"
nixPills = "/guides/nix-pills"
latestNixMirror = "https://nixos.org/releases/nix/nix-$latestNixVersion"
latestNixOSBranch = "release-" _ latestNixOSSeries
;
Expand All @@ -17,4 +17,4 @@
</ul>
[% END;

-%]
-%]
35 changes: 35 additions & 0 deletions fix-manual-headers.sh
@@ -0,0 +1,35 @@
#! /usr/bin/env bash

set -e

dir="$1"
cannonical="$2"
baseUrl="https://nixos.org/$dir/$cannonical"

[[ -d $dir ]]

# loop over each channel/version
for path in $dir/*; do
# loop over each html file
(cd $path && find -type f -print) | while read htmlFile; do
if [[ "$htmlFile" == *.html ]]; then
fileName=${htmlFile#"./"}
filePath="$path/$fileName"
echo -n "Patching $filePath ..."
cannonicalFileName="$dir/$cannonical/$fileName"
cannonicalUrl=$baseUrl
if [ -e $cannonicalFileName ]; then
if [ "$fileName" != "index.html" ]; then
cannonicalUrl="$baseUrl/$fileName"
fi
fi
cannonicalTag="<link rel=\"cannonical\" url=\"$cannonicalUrl\" />"
if grep -Fq "$cannonicalTag" $filePath; then
echo " Already patched!"
else
sed -i -e "s|</head>| $cannonicalTag\n</head>|" $filePath
echo " Patched!"
fi
fi
done
done
77 changes: 64 additions & 13 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a68a4e2

Please sign in to comment.