aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--.ignore1
-rw-r--r--TODOs.org2
-rwxr-xr-xcss.sh11
-rw-r--r--default.nix51
-rw-r--r--docs/env.sh4
-rw-r--r--hakyll/Main.hs125
-rw-r--r--pastebin/skeleton.org7
-rwxr-xr-xpastebin/website-pastebin121
-rw-r--r--slides/base.org3
m---------slides/reveal.js0
-rwxr-xr-xslides/website-slides75
-rwxr-xr-xt/website.bats70
-rwxr-xr-xwebsite98
13 files changed, 4 insertions, 564 deletions
diff --git a/.ignore b/.ignore
deleted file mode 100644
index 6b5747f..0000000
--- a/.ignore
+++ /dev/null
@@ -1 +0,0 @@
-reveal.js \ No newline at end of file
diff --git a/TODOs.org b/TODOs.org
index 1009539..f01e65b 100644
--- a/TODOs.org
+++ b/TODOs.org
@@ -1,3 +1,5 @@
* Tasks
** TODO Translate articles
https://groups.google.com/forum/#!topic/hakyll/KAhCO1GVELA
+** TODO Spelling
+** TODO Pastebin
diff --git a/css.sh b/css.sh
deleted file mode 100755
index 420878b..0000000
--- a/css.sh
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/usr/bin/env bash
-set -Eeuo pipefail
-cd "$(dirname "${BASH_SOURCE[@]}")"
-
-nix-build -A subtasks.docs
-rm -rf tmp/
-mkdir tmp/
-
-cp -R result/* tmp/
-chmod -R +w tmp/
-cp site/css/styles.css tmp/css/
diff --git a/default.nix b/default.nix
index 414e233..9c12498 100644
--- a/default.nix
+++ b/default.nix
@@ -1,24 +1,5 @@
let
- pkgsUnstable = import <nixpkgs> { };
- pkgsPinned = import (pkgsUnstable.fetchzip {
- url = "https://github.com/NixOS/nixpkgs/archive/18.03.zip";
- sha256 = "0hk4y2vkgm1qadpsm4b0q1vxq889jhxzjx3ragybrlwwg54mzp4f";
- }) { };
- pkgs = pkgsUnstable;
-
- # Taken from:
- # http://www.cs.yale.edu/homes/lucas.paul/posts/2017-04-10-hakyll-on-nix.html
- websiteBuilder = pkgs.stdenv.mkDerivation {
- name = "website-builder";
- src = ./hakyll;
- phases = "unpackPhase buildPhase";
- buildInputs =
- [ (pkgsPinned.haskellPackages.ghcWithPackages (p: [ p.hakyll ])) ];
- buildPhase = ''
- mkdir -p $out/bin
- ghc -O2 -dynamic --make Main.hs -o $out/bin/build-site
- '';
- };
+ pkgs = import <nixpkgs> { };
in rec {
utils = import ./utils.nix {
pkgs = pkgs;
@@ -26,32 +7,6 @@ in rec {
baseName = "website";
};
subtasks = rec {
- perlPodCheck = utils.baseTask.overrideAttrs (baseAttrs: {
- name = "${baseAttrs.name}-perl-podcheck";
- buildInputs = baseAttrs.buildInputs ++ [ pkgs.perl ];
- buildPhase = ''
- podchecker website pastebin/website-pastebin slides/website-slides
- touch $out
- '';
- });
- batsTest = utils.baseTask.overrideAttrs (baseAttrs: {
- name = "${baseAttrs.name}-bats-test";
- buildInputs = baseAttrs.buildInputs ++ [ pkgs.bats pkgs.perl ];
- buildPhase = ''
- patchShebangs .
- ./t/website.bats
- touch $out
- '';
- });
- perlInternalTest = utils.baseTask.overrideAttrs (baseAttrs: {
- name = "${baseAttrs.name}-perl-test";
- buildInputs = baseAttrs.buildInputs ++ [ pkgs.perl ];
- buildPhase = ''
- patchShebangs .
- ./website test
- touch $out
- '';
- });
hunspellCheck = utils.baseTask.overrideAttrs (baseAttrs: {
name = "${baseAttrs.name}-hunspell";
buildInputs = baseAttrs.buildInputs
@@ -65,7 +20,7 @@ in rec {
docs = utils.baseTask.overrideAttrs (baseAttrs: {
name = "${baseAttrs.name}-docs";
src = ./site;
- buildInputs = [ websiteBuilder ];
+ buildInputs = [ ];
buildPhase = ''
export LOCALE_ARCHIVE="${pkgs.glibcLocales}/lib/locale/locale-archive";
export LANG=en_US.UTF-8
@@ -87,8 +42,6 @@ in rec {
shell = pkgs.mkShell rec {
name = "website-shell";
buildInputs = [
- websiteBuilder
- (pkgs.haskellPackages.ghcWithPackages (p: with p; [ hakyll ]))
(pkgs.hunspellWithDicts (with pkgs.hunspellDicts; [ en-us ]))
];
};
diff --git a/docs/env.sh b/docs/env.sh
deleted file mode 100644
index d5e8be2..0000000
--- a/docs/env.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/usr/bin/env bash
-
-export SERVER_URL=root@euandre.org
-export DOCS_SERVER_PATH="/home/user-data/www/default/"
diff --git a/hakyll/Main.hs b/hakyll/Main.hs
deleted file mode 100644
index f2ed24e..0000000
--- a/hakyll/Main.hs
+++ /dev/null
@@ -1,125 +0,0 @@
-{-# LANGUAGE OverloadedStrings #-}
-import System.FilePath.Posix
-import Hakyll
-
-
-main :: IO ()
-main = hakyll $ do
- match "favicon.ico" $ do
- route idRoute
- compile copyFileCompiler
- match "css/*" $ do
- route idRoute
- compile compressCssCompiler
- match "images/*" $ do
- route idRoute
- compile copyFileCompiler
- match "static/**/*" $ do
- route idRoute
- compile copyFileCompiler
- match "fonts/*" $ do
- route idRoute
- compile copyFileCompiler
- match "root/*" $ do
- route $ dropPrefix "root/"
- compile copyFileCompiler
-
- match "pastebin/*" $ do
- route $ setExtension "html"
- compile $ pandocCompiler
- >>= loadAndApplyTemplate "templates/pastebin.html" pastebinCtx
- >>= saveSnapshot "content"
- >>= loadAndApplyTemplate "templates/default.html" pastebinCtx
- >>= relativizeUrls
-
- match "posts/*" $ do
- route $ setExtension "html"
- `composeRoutes` dropPrefix "posts/"
- `composeRoutes` dateFolders
- compile $ pandocCompiler
- >>= loadAndApplyTemplate "templates/post.html" postCtx
- >>= saveSnapshot "content"
- >>= loadAndApplyTemplate "templates/default.html" postCtx
- >>= relativizeUrls
-
- match "pages/*" $ do
- route $ setExtension "html"
- `composeRoutes` dropPrefix "pages/"
- compile $ pandocCompiler
- >>= loadAndApplyTemplate "templates/default.html" defaultContext
- >>= relativizeUrls
-
- match "pastebins.html" $ do
- route idRoute
- compile $ do
- pastebins <- recentFirst =<< loadAll "pastebin/*"
- let pastebinCtx =
- listField "pastebins" pastebinCtx (return pastebins) `mappend`
- defaultContext
-
- getResourceBody
- >>= applyAsTemplate pastebinCtx
- >>= loadAndApplyTemplate "templates/default.html" pastebinCtx
- >>= relativizeUrls
-
- match "index.html" $ do
- route idRoute
- compile $ do
- posts <- recentFirst =<< loadAll "posts/*"
- let indexCtx =
- listField "posts" postCtx (return posts) `mappend`
- constField "title" "Home" `mappend`
- defaultContext
-
- getResourceBody
- >>= applyAsTemplate indexCtx
- >>= loadAndApplyTemplate "templates/default.html" indexCtx
- >>= relativizeUrls
-
- create ["atom.xml", "feed.xml", "feed.atom"] $ do
- route idRoute
- compile $ do
- loadAllSnapshots "posts/*" "content"
- >>= recentFirst
- >>= renderAtom feedConfiguration feedCtx
-
- create ["rss.xml"] $ do
- route idRoute
- compile $ do
- let feedCtx = postCtx `mappend`
- constField "description" "This is the post description"
-
- posts <- recentFirst =<< loadAll "posts/*"
- renderRss feedConfiguration feedCtx posts
-
- match "templates/*" $ compile templateBodyCompiler
-
-
-postCtx :: Context String
-postCtx =
- dateField "date" "%B %e, %Y" `mappend`
- defaultContext
-
-pastebinCtx :: Context String
-pastebinCtx = postCtx
-
-feedCtx :: Context String
-feedCtx =
- bodyField "description" `mappend`
- defaultContext
-
-feedConfiguration :: FeedConfiguration
-feedConfiguration = FeedConfiguration
- { feedTitle = "EuAndreh"
- , feedDescription = "EuAndreh's blog"
- , feedAuthorName = "EuAndreh"
- , feedAuthorEmail = "eu@euandre.org"
- , feedRoot = "https://euandre.org"
- }
-
-dropPrefix :: String -> Routes
-dropPrefix prefix = gsubRoute prefix $ const ""
-
-dateFolders :: Routes
-dateFolders =
- gsubRoute "[0-9]{4}-[0-9]{2}-[0-9]{2}-" $ replaceAll "-" (const "/")
diff --git a/pastebin/skeleton.org b/pastebin/skeleton.org
deleted file mode 100644
index d116991..0000000
--- a/pastebin/skeleton.org
+++ /dev/null
@@ -1,7 +0,0 @@
----
-title: $title
-date: $date
----
-#+BEGIN_SRC $lang -n
-FIXME
-#+END_SRC
diff --git a/pastebin/website-pastebin b/pastebin/website-pastebin
deleted file mode 100755
index 9aa4956..0000000
--- a/pastebin/website-pastebin
+++ /dev/null
@@ -1,121 +0,0 @@
-#!/usr/bin/env perl
-
-=head1 NAME
-
-website pastebin - Create new pastebins from the org-mode template.
-
-=head1 SYNOPSIS
-
-website pastebin [options]
-
- Options:
- --help Show the manpage.
- --title Title of the pastebin.
-
-=head1 OPTIONS
-
-=over 4
-
-=item B<-h, --help>
-
-Prints the manual page and exits.
-
-=item B<-t, --title>
-
-The title of the pastebin. This string will be slugified and the output is used to create the pastebin file name. Special characters are simplified or discarded.
-
-=back
-
-=head1 DESCRIPTION
-
-B<website pastebin> creates a pastebin org-mode text files, that are later processed to produce HTML to be deployed statically.
-
-=cut
-
-use strict;
-use warnings;
-use Getopt::Long qw(:config no_ignore_case bundling);
-use Pod::Usage qw(pod2usage);
-use Unicode::Normalize qw(NFKD);
-use File::Basename qw(dirname);
-use Term::ANSIColor;
-
-my $help = 0;
-my $title = '';
-my $lang = '';
-my $test = 0;
-GetOptions(
- 'help|h|?' => \$help,
- 'title|t=s' => \$title,
- 'lang|l=s' => \$lang,
- 'test|?' => \$test
-) or pod2usage(-verbose => 1, -exitval => 2);
-pod2usage(
- -verbose => 2,
- -exitval => 0
-) if $help;
-pod2usage(
- -verbose => 1,
- -exitval => 2,
- -message => colored("Missing required --title argument.", "red")
-) if !$title && !$test;
-pod2usage(
- -verbose =>1,
- -exitval => 2,
- -message => colored("Missing required --lang argument.", "red")
-) if !$lang && !$test;
-
-# Taken from:
-# https://stackoverflow.com/a/4009519
-sub slugify {
- my $input = shift;
- $input = NFKD($input); # Normalize (decompose) the Unicode string
- $input =~ tr/\000-\177//cd; # Strip non-ASCII characters (>127)
- $input =~ s/[^\w\s-]//g; # Remove all characters that are not word characters (includes _), spaces, or hyphens
- $input =~ s/^\s+|\s+$//g; # Trim whitespace from both ends
- $input = lc($input);
- $input =~ s/[-\s]+/-/g; # Replace all occurrences of spaces and hyphens with a single hyphen
- return $input;
-}
-
-if ($test) {
- eval "use Test::More tests => 4"; die $@ if $@;
- is(slugify("My Custom Title String"), "my-custom-title-string");
- is(slugify("String with áccents and sym?bol-s."), "string-with-accents-and-symbol-s");
- is(slugify("unicode-↓æđ-chars"), "unicode-aaa-chars");
- is(slugify(" spaces and line
-break"), "spaces-and-line-break");
- done_testing();
- exit;
-}
-
-our $dirname = dirname(__FILE__);
-our $in = "$dirname/skeleton.org";
-our $out;
-my $date = `date +"%Y-%m-%d"`;
-chomp $date;
-my %ENV = (title => $title, date => $date, lang => $lang);
-
-# Derived from both:
-# https://unix.stackexchange.com/a/294836
-# https://stackoverflow.com/a/47664214
-sub envsubst {
- open(IN, '<'.$in) or die $!;
- open(OUT, '>'.$out) or die $!;
- while(<IN>) {
- $_ =~ s/\$([_a-zA-Z]+)/$ENV{$1}/g;
- print OUT $_;
- }
- close(IN);
- close(OUT);
-}
-
-my $slug = slugify($title);
-$out = `realpath $dirname/../site/pastebin/$slug.org`;
-chomp $out;
-
-envsubst();
-
-`cat $out | vipe | sponge $out`;
-
-print "$out\n";
diff --git a/slides/base.org b/slides/base.org
deleted file mode 100644
index 3a2995b..0000000
--- a/slides/base.org
+++ /dev/null
@@ -1,3 +0,0 @@
-#+REVEAL_ROOT: reveal.js/
-#+OPTIONS: num:nil toc:nil reveal_single_file:t
-* sample
diff --git a/slides/reveal.js b/slides/reveal.js
deleted file mode 160000
-Subproject a82c4333ed8c192e26f83f1815593c3db50ab0f
diff --git a/slides/website-slides b/slides/website-slides
deleted file mode 100755
index 77f1f63..0000000
--- a/slides/website-slides
+++ /dev/null
@@ -1,75 +0,0 @@
-#!/usr/bin/env perl
-
-=head1 NAME
-
-website slides - Create new HTML slide presentations from org-mode template.
-
-=head1 SYNOPSIS
-
-website slides [options]
-
- Options:
- --help Show the manpage.
- --name The name of the folder containing the slideshow.
-
-=head1 OPTIONS
-
-=over 4
-
-=item B<-h, --help>
-
-Prints the manual page and exits.
-
-=item B<-n, --name>
-
-The name of the folder containing the slideshow.
-
-=back
-
-=head1 DESCRIPTION
-
-B<website slides> creates an slideshow org-mode text files, that are later processed to produce HTML to be deployed statically.
-
-=cut
-
-use strict;
-use warnings;
-use Getopt::Long qw(:config no_ignore_case bundling);
-use Pod::Usage qw(pod2usage);
-use File::Basename qw(dirname);
-use File::Path qw(make_path);
-use File::Copy qw(copy);
-use Term::ANSIColor;
-
-my $help = 0;
-my $name = '';
-my $test = 0;
-GetOptions(
- 'help|h|?' => \$help,
- 'name|n=s' => \$name,
- 'test|?' => \$test
-) or pod2usage(-verbose => 1, -exitval => 2);
-pod2usage(-verbose => 2, -exitval => 0) if $help;
-pod2usage(
- -verbose => 1,
- -exitval => 2,
- -message => colored("Missing required --name argument.", "red")
-) if !$name && !$test;
-
-if ($test) {
- exit;
-}
-
-my $dirname = dirname(__FILE__);
-chdir $dirname ;
-make_path "$name/reveal.js/";
-
-chdir "reveal.js/";
-`git --work-tree="../$name/reveal.js" checkout HEAD -- .`;
-`git checkout \$(cat "../$name/reveal.js/VERSION" &> /dev/null || printf ".")`;
-`git rev-parse HEAD > "../$name/VERSION"`;
-chdir "../";
-
-copy("base.org", "$name/index.org") or die "Failed to copy base.org file: $!";
-
-print `realpath $name/index.org`;
diff --git a/t/website.bats b/t/website.bats
deleted file mode 100755
index 5bbfb59..0000000
--- a/t/website.bats
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/usr/bin/env bats
-
-# Go to the directory where ./website is.
-cd "$BATS_TEST_DIRNAME/../"
-
-# exit code 1: error running command
-# exit code 2: couldn't parse the command line argument
-
-@test "Help: show short usage when no subcommand is given, exit code is 2" {
- run ./website
- [[ "$status" -eq 2 ]]
- [[ "${lines[0]}" =~ "Missing subcommand." ]]
- [[ "${lines[1]}" = "Usage:" ]]
-}
-
-@test "Help: show short usage for unknown subcommand, exit code is 2" {
- run ./website bad-subcommand
- [[ "$status" -eq 2 ]]
- [[ "${lines[0]}" =~ "Unknown subcommand: bad-subcommand." ]]
- [[ "${lines[1]}" = "Usage:" ]]
-}
-
-@test "Help: show full toplevel help" {
- run ./website --help
- [[ "$status" -eq 0 ]]
- [[ "${lines[0]}" = "NAME" ]]
- run ./website -h
- [[ "$status" -eq 0 ]]
- [[ "${lines[0]}" = "NAME" ]]
-}
-
-@test "Help: show short subcommand usage when subcommand isn't invoked properly, exit code is 2" {
- run ./website pastebin
- [[ "$status" -eq 2 ]]
- [[ "${lines[0]}" =~ "Missing required --title argument." ]]
- [[ "${lines[1]}" = "Usage:" ]]
- run ./website slides
- [[ "$status" -eq 2 ]]
- [[ "${lines[0]}" =~ "Missing required --name argument." ]]
- [[ "${lines[1]}" = "Usage:" ]]
-}
-
-@test "Help: show subcommand manpage" {
- run ./website pastebin -h
- [[ "$status" -eq 0 ]]
- [[ "${lines[0]}" = "NAME" ]]
- run ./website pastebin --help
- [[ "$status" -eq 0 ]]
- [[ "${lines[0]}" = "NAME" ]]
- run ./website slides -h
- [[ "$status" -eq 0 ]]
- [[ "${lines[0]}" = "NAME" ]]
- run ./website slides --help
- [[ "$status" -eq 0 ]]
- [[ "${lines[0]}" = "NAME" ]]
-}
-
-@test "Pastebin: required input for --title" {
- run ./website pastebin --title
- [[ "$status" = 2 ]]
- [[ "${lines[0]}" = "Option title requires an argument" ]]
- [[ "${lines[1]}" = "Usage:" ]]
-}
-
-@test "Slides: required input for --name" {
- run ./website slides --name
- [[ "$status" = 2 ]]
- [[ "${lines[0]}" = "Option name requires an argument" ]]
- [[ "${lines[1]}" = "Usage:" ]]
-}
diff --git a/website b/website
deleted file mode 100755
index 561cccf..0000000
--- a/website
+++ /dev/null
@@ -1,98 +0,0 @@
-#!/usr/bin/env perl
-
-=head1 NAME
-
-website - Website repository CLI manager.
-
-=head1 SYNOPSIS
-
-website <subcommand> [options]
-
- Subcommands:
- pastebin Create a new pastebin from the org-mode template.
- slides Create a new HTML slideshow from the existing templates.
- test Run internal CLI tests.
-
- Options:
- --help Show the manpage.
-
-=head1 OPTIONS
-
-=over 4
-
-=item B<-h, --help>
-
-Prints the manual page and exits.
-
-=back
-
-=head1 DESCRIPTION
-
-B<website> is the top-level coordinator of subtasks inside the website repo.
-
-=cut
-
-use strict;
-use warnings;
-use Getopt::Long qw(:config no_ignore_case bundling pass_through);
-use Pod::Usage qw(pod2usage);
-use File::Basename qw(dirname);
-use Term::ANSIColor;
-
-my $help = 0;
-my $title = '';
-sub getopts {
- GetOptions(
- 'help|h|?' => \$help
- );
-}
-
-sub escaped_cmd {
- my ($cmd, @args) = @_;
- my $dirname = dirname(__FILE__);
- $cmd = "$dirname/$cmd";
- $cmd = $cmd." \"$_\"", for @args;
- system($cmd);
- exit $? >> 8;
-}
-
-sub dispatch {
- my $action = shift;
- my @args = @_;
- if (!defined $action && $help) {
- pod2usage(
- -verbose => 2,
- -exitval => 0
- );
- } elsif (!defined $action) {
- pod2usage(
- -verbose => 1,
- -exitval => 2,
- -message => colored("Missing subcommand.", "red")
- );
- } elsif ($action eq 'pastebin') {
- my @sub_args = grep { $_ ne $action } @args;
- escaped_cmd("pastebin/website-pastebin", @sub_args);
- } elsif ($action eq 'slides') {
- my @sub_args = grep { $_ ne $action } @args;
- escaped_cmd("slides/website-slides", @sub_args);
- } elsif ($action eq 'test') {
- escaped_cmd("pastebin/website-pastebin", "--test");
- escaped_cmd("slides/website-slides", "--test");
- } else {
- pod2usage(
- -verbose => 1,
- -exitval => 2,
- -message => colored("Unknown subcommand: $action.", "red")
- );
- }
-}
-
-sub main {
- my @orig_args=@ARGV;
- getopts();
- my $action=shift @ARGV;
- dispatch($action, @orig_args);
-}
-
-main();