Skip to content

Commit

Permalink
Defined 404 error page
Browse files Browse the repository at this point in the history
  • Loading branch information
fadado committed Dec 8, 2018
1 parent 1422101 commit 2cf2f55
Show file tree
Hide file tree
Showing 17 changed files with 107 additions and 70 deletions.
3 changes: 2 additions & 1 deletion bin/jqt
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ declare -A JSON_DATA_DOT=() YAML_DATA_DOT=()
# ._source
# ._toc
# ._front_matter
# ._version

# < stdin > stdout
function merge
Expand All @@ -463,7 +464,7 @@ function merge
else
echo '(. / "<!--JQT-->") as [$body, $toc, $css] | { _front_matter: ('
yaml2json < $front_matter
echo ")} + { _source: \"${DOCUMENT}\", "'_content: $body, _toc: $toc, _highlight: $css }'
echo ")} + { _version: \"${VERSION}\", _source: \"${DOCUMENT}\", "'_content: $body, _toc: $toc, _highlight: $css }'
fi

# additional data
Expand Down
65 changes: 45 additions & 20 deletions bin/sake
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,25 @@ declare -xr JQTLIB='/usr/local/share/jqt'
# Check project on current directory
########################################################################

# Sakefile must exist
if test ! -e Sakefile; then
echo 1>&2 "sake: no \`Sakefile\` found."
exit 1
fi

# Configuration file must exist
if test -e config.yaml; then
CONFIGURATION_FILE=config.yaml
elif test -e config.json; then
CONFIGURATION_FILE=config.json
else
echo 1>&2 "sake: no \`config.yaml\` or \`config.json\` file found."
exit 1
fi
declare CONFIGURATION_FILE

check() {
# Sakefile must exist
if test ! -e Sakefile; then
echo 1>&2 "sake: no \`Sakefile\` found."
exit 1
fi

# Configuration file must exist
if test -e config.yaml; then
CONFIGURATION_FILE=config.yaml
elif test -e config.json; then
CONFIGURATION_FILE=config.json
else
echo 1>&2 "sake: no \`config.yaml\` or \`config.json\` file found."
exit 1
fi
}

########################################################################
# Commands
Expand Down Expand Up @@ -71,7 +75,25 @@ dag() {
}

new() {
local name=$1 kind=$2
local name=$1 skel=$2

[[ -d "$name" ]] && {
echo 1>&2 "sake: pathname \`$name\` exists!"
exit 1
}
case $skel in
basic|blog)
;;
*)
echo 1>&2 "sake: unknown skeleton \`$skel\`!"
exit 1
;;
esac

#mkdir -p "$name"
#cd "$name"
#cp -r $JQTLIB/skel-$skel/* .

echo 1>&2 "sake: Target \`new\` not implemented."
}

Expand All @@ -92,6 +114,9 @@ alias _sake='exec make "${makeflags[@]}"'
# Default command: `build`
[[ $# == 0 ]] && set -- build

# Check if != new
[[ $1 == new ]] || check

# Run _sake
case $1 in
help) help; exit 0
Expand All @@ -102,15 +127,15 @@ case $1 in
;;
new)
shift
name=site kind=simple
name=site skel=basic
while (( $# > 0 )); do
case "$1" in
name=?*) eval "$1"; shift ;;
kind=?*) eval "$1"; shift ;;
name=?*) name=${1#name=}; shift ;;
skel=?*) skel=${1#skel=}; shift ;;
*) break 2 ;; # error?
esac
done
new $name $kind
new $name $skel
exit 0
;;
touch)
Expand Down
2 changes: 1 addition & 1 deletion docs/blocks/logo/markup.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<#######################################################################
# Logo
######################################################################>&
<span class="logo"><a href="index.html">{{site.logo}}</a><span class="logo__version">v{{site.version}}</span></span>
<span class="logo"><a title="{{site.title}}" href="index.html">{{site.logo}}</a><span class="logo__version">v<%version></span></span>
<#
vim:ts=2:sw=2:ai:et:fileencoding=utf8:syntax=html
#>&
2 changes: 1 addition & 1 deletion docs/blocks/repository/markup.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<li class="repository__section"><a href="https://github.com/fadado/jqt/issues">issues</a></li>
<li class="repository__section"><a href="https://github.com/fadado/jqt/wiki">wiki</a></li>
<li class="repository__section"><a href="https://github.com/fadado/jqt/releases">releases</a></li>
<li class="repository__section -internal"><a href="#">top</a></li>
<li class="repository__section"><a href="#">top</a></li>
</ol>
<#
vim:ts=2:sw=2:ai:et:fileencoding=utf8:syntax=html
Expand Down
6 changes: 5 additions & 1 deletion docs/blocks/repository/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@
font-weight: bold;
}

&CHM{repository}{section}{internal} > a:focus {
&BEM{repository}{section} > a:focus {
color: &ColorPrimary;
}

&BEM{repository}{section} > a:hover {
color: &ColorSecondary;
}

&BEM{repository}{section}:first-child:before {
content: "❲ ";
color: &ColorSecondary;
Expand Down
2 changes: 1 addition & 1 deletion docs/blocks/toc/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
////////////////////////////////////////////////////////////////////////

&BEM{toc} {
max-width: 20em;
max-width: 22em;
padding: 0 1em;
text-align: center;
font-size: 80%;
Expand Down
6 changes: 2 additions & 4 deletions docs/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ Root: /tmp/jqt
# Site parameters
#

# Site version (same as jqt)
version: 0.5.1

title: jqt, the jq template engine
title_prefix: jqt
title_delimiter: "·"
baseurl: https://fadado.github.com/jqt/
lang: &lang en
logo: "❴❴❏❵❵"
Expand All @@ -48,7 +47,6 @@ menu:
defaults:
- idprefix: "" # all files
properties:
title-prefix: jqt
author: *author
lang: *lang
Layout: page-toc
Expand Down
12 changes: 12 additions & 0 deletions docs/content/404.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
title: 404 error
Layout: page
---

# 404

We couldn't find this page.

<#
vim:ts=4:sw=4:ai:et:fileencoding=utf8:syntax=markdown
#>
4 changes: 2 additions & 2 deletions docs/content/EXAMPLE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<title>{{page.title | gsub("<[^>]*>"; "")}}</title>
{# include files in preprocessing stage: #}
<%include "head.html">
<meta name="generator" content="jqt v{{site.version}}"/>
<meta name="generator" content="JQT v<%version>"/>
{# optional line: #}
<meta name='dcterms.modified' content='{{page.updated//empty}}' />
{# implicit loop for all authors: #}
Expand All @@ -17,7 +17,7 @@
<body>
<h1>{{page.title}}</h1>
<div id="CONTENT">
{{page._content}}
{{$jqt._content}}
</div>
{# macro calls: #}
<%partial analytics 'UA-82432866-1'>
Expand Down
9 changes: 5 additions & 4 deletions docs/content/content.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,11 @@ and the second does the proper conversion to HTML.

### Preprocessing

The MarkDown input content is preprocessed using [GPP][GPP]. All the expected options in a preprocessor are available,
like defining new macros, include other files, etc. For example, a macro call
like `<%include "../VERSION">` will expand to the string <code><%include ../VERSION></code>
as you can see in this paragraph and on the top of these pages.
The MarkDown input content is preprocessed using [GPP][GPP]. All the expected
options in a preprocessor are available, like defining new macros, include
other files, etc. For example, a macro call
like `<%version>` will expand to the <%cite jqt> version (<code><%version></code>)
as you can see in this paragraph.

#### Macro calls

Expand Down
1 change: 1 addition & 0 deletions docs/content/data.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ are provided:
* `._highlight`: CSS styles for highlighted code.
* `._source`: the input document pathname as provided to `jqt`.
* `._toc`: the rendered input document table of contents.
* `._version`: <%cite jqt> installed version.

Additional JSON files can be provided and are merged with front matter metadata
to be the `jq` input in the render stage.
Expand Down
2 changes: 1 addition & 1 deletion docs/content/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Dependencies: [content/EXAMPLE.txt]
<%include content/macros.m>&
<%include content/LINKS.txt>&

# Welcome
# Welcome to <%cite jqt>

<!--
> _Editing is a rewording activity._\
Expand Down
2 changes: 1 addition & 1 deletion docs/content/sake.1.text
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ help
list
: Show the list of commands available.

new
new [name=_path_] [skel=(basic|blog)]
: Create a new static web site.

nuke
Expand Down
20 changes: 11 additions & 9 deletions docs/content/structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ This is described on the top of this diagram:
<details>

<summary>
When invoking `jqt` you can use the `-D`, `-I`, `-i`, `-j` and `-L` options to modify template
rendering:
When invoking `jqt` you can use the `-D`, `-I`, `-i`, `-j` and `-L` options to
modify template rendering:
</summary>

<%include content/opt/D.txt>
Expand All @@ -46,23 +46,25 @@ rendering:

A template is a text file with intermixed snippets of [_jq_][JQ] code. Snippets can be
<%dfn expressions> (delimited by `{{` and `}}`), which get replaced with
values when a template is rendered and <%dfn actions> (delimited by `{%` and `%}`), which control the logic of the
template. Comments (delimited by `{#` and `#}`) are ignored and not copied to the output.
values when a template is rendered and <%dfn actions> (delimited by `{%` and
`%}`), which control the logic of the template. Comments (delimited by `{#`
and `#}`) are ignored and not copied to the output.
This is a complete template example:

<%include content/EXAMPLE.txt>&

### Preprocessing

Templates are preprocessed using [GPP][GPP]. All the expected options in a preprocessor are available,
like defining new macros, include other files, etc. For example, a template fragment
like
Templates are preprocessed using [GPP][GPP]. All the expected options in a
preprocessor are available, like defining new macros, include other files, etc.
For example, a template fragment like

```HTML
<meta name="generator" content="jqt v<%include ../VERSION>"/>
<meta name="generator" content="JQT v<%version>"/>
```

will expand to the string <code>&lt;meta name="generator" content="jqt v<%include ../VERSION>"/&gt;</code>
will expand to the string <code>&lt;meta name="generator" content="JQT v<%version>"/&gt;</code>
(assuming the macro `version` has been defined)
as you can see in the internal code of this page.

#### Macro calls
Expand Down
10 changes: 5 additions & 5 deletions docs/layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
#>
<meta charset="utf-8" />
<# Document title and related metadata #>
<title>jqt · {{page.title}}</title>
<title>{{site.title_prefix}} {{site.title_delimiter}} {{page.title}}</title>
<meta name='description' content='{{page.description//empty}}' />
<meta name='keywords' content='{{page.keywords//empty}}' />
<meta name='author' content='{{[(page.author//site.author)[].name] | sort[]}}' />
<# More metadata #>
<meta name="generator" content="jqt v{{site.version}}" />
<meta name="generator" content="JQT v<%version>" />
<meta name='dcterms.date' content='{{page.updated//empty}}' />
<# Presentation #>
<link rel="shortcut icon" href="{{page.Base}}favicon.ico"/>
Expand All @@ -26,10 +26,10 @@
#>
<body class="#container">
<%include blocks/header/markup.html>&
<%ifndef BODY_BLOCK>&
<%error Descendent layout must define BODY_BLOCK macro>
<%else>&
<%ifdef BODY_BLOCK>&
<%call BODY_BLOCK>
<%else>&
<%error Descendent layout must define BODY_BLOCK macro>
<%endif>&
<%include blocks/footer/markup.html>&
<%partial analytics 'UA-82432866-1'>&
Expand Down
11 changes: 4 additions & 7 deletions share/sake.d/phase2.make
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,19 @@ $(PagesJSON): $(Meta)/config.json $(MDIR)/phase2_page.jq $(THIS) \
| $$(dir $$@)

# Content example for `$(Meta)/phase2.make`:

########################################################################
# __phase_2 := 1
#
# destination_paths := _site/ _site/blog/
# destination_paths := /tmp/jqt/ /tmp/jqt/blog/
# metadata_paths := .meta/pages/ .meta/pages/blog/
#
# data_md := .meta/snippets.json
# data_yaml :=
# data_json :=
# data_csv :=
#
# PagesHTML := _site/content.html _site/data.html _site/index.html _site/engine.html _site/structure.html _site/blog/2017-04-13-hello.html _site/blog/index.html
# PagesJSON := .meta/pages/content.json .meta/pages/data.json .meta/pages/index.json .meta/pages/engine.json .meta/pages/structure.json .meta/pages/blog/2017-04-13-hello.json .meta/pages/blog/index.json
# PagesHTML := /tmp/jqt/content.html /tmp/jqt/data.html /tmp/jqt/index.html /tmp/jqt/engine.html /tmp/jqt/structure.html /tmp/jqt/404.html /tmp/jqt/blog/2017-04-13-hello.html /tmp/jqt/blog/index.html
# PagesJSON := .meta/pages/content.json .meta/pages/data.json .meta/pages/index.json .meta/pages/engine.json .meta/pages/structure.json .meta/pages/404.json .meta/pages/blog/2017-04-13-hello.json .meta/pages/blog/index.json
#
# .meta/pages/content.json: content/content.md
# $(info ==> $@)
Expand All @@ -122,9 +122,6 @@ $(PagesJSON): $(Meta)/config.json $(MDIR)/phase2_page.jq $(THIS) \
# .meta/pages/blog/2017-04-13-hello.json: content/blog/2017-04-13-hello.md
# $(info ==> $@)
# @$(EXTRACT_FRONT_MATTER) < $< | $(BUILD_PAGE_JSON) > $@
# .meta/pages/blog/index.json: content/blog/index.md
# $(info ==> $@)
# @$(EXTRACT_FRONT_MATTER) < $< | $(BUILD_PAGE_JSON) > $@

########################################################################
# Rules for directories.
Expand Down
20 changes: 8 additions & 12 deletions share/sake.d/phase3.make
Original file line number Diff line number Diff line change
Expand Up @@ -83,24 +83,20 @@ $(PagesHTML): $(Meta)/phase3.make \
########################################################################
# __phase_3 := 1
#
# %.html: _site/%.html ;
# blog/%.html: _site/blog/%.html ;
# %.html: /tmp/jqt/%.html ;
# blog/%.html: /tmp/jqt/blog/%.html ;
#
# _site/content.html: content/content.md content/macros.m content/LINKS.txt content/FLOW.txt content/opt/[4DdiT].txt .meta/snippets.json
# /tmp/jqt/content.html: content/content.md content/macros.m content/LINKS.txt content/FLOW.txt content/opt/[4DdiT].txt .meta/snippets.json
# $(info ==> $@)
# @$(JQT) -d $< -msnippets:.meta/snippets.json -mpage:.meta/pages/content.json $(Layouts)/page-toc.html | $(DETAILS) > $@
# ...
# _site/blog/2017-04-13-hello.html: content/blog/2017-04-13-hello.md content/macros.m content/LINKS.txt .meta/snippets.json
# $(JQT) -d $< -jsnippets:snippets.json -jpage:pages/content.json $(Layouts)/page-toc.html | $(DETAILS) > $@
# /tmp/jqt/blog/2017-04-13-hello.html: content/blog/2017-04-13-hello.md content/macros.m content/LINKS.txt .meta/snippets.json
# $(info ==> $@)
# @$(JQT) -d $< -msnippets:.meta/snippets.json -mpage:.meta/pages/blog/2017-04-13-hello.json $(Layouts)/page.html | $(DETAILS) > $@
# _site/blog/index.html: content/blog/index.md content/macros.m content/LINKS.txt .meta/snippets.json
# $(info ==> $@)
# @$(JQT) -d $< -msnippets:.meta/snippets.json -mpage:.meta/pages/blog/index.json $(Layouts)/blog.html | $(DETAILS) > $@
# $(JQT) -d $< -jsnippets:snippets.json -jpage:pages/blog/2017-04-13-hello.json $(Layouts)/page.html | $(DETAILS) > $@

# Content example for `$(Meta)/phase3d.make`:
########################################################################
#_site/content.html: blocks/body/_toc/markup.html blocks/content/markup.html blocks/footer/markup.html blocks/header/markup.html blocks/license/markup.html blocks/logo/markup.html blocks/menu-bar/markup.html blocks/repository/markup.html blocks/toc/markup.html layouts/default.html layouts/page-toc.html
#_site/data.html: blocks/body/_toc/markup.html blocks/content/markup.html blocks/footer/markup.html blocks/header/markup.html blocks/license/markup.html blocks/logo/markup.html blocks/menu-bar/markup.html blocks/repository/markup.html blocks/toc/markup.html layouts/default.html layouts/page-toc.html
# /tmp/jqt/content.html: blocks/body/_toc/markup.html blocks/content/markup.html blocks/footer/markup.html blocks/header/markup.html blocks/license/markup.html blocks/logo/markup.html blocks/menu-bar/markup.html blocks/repository/markup.html blocks/toc/markup.html layouts/default.html layouts/page-toc.html
# /tmp/jqt/data.html: blocks/body/_toc/markup.html blocks/content/markup.html blocks/footer/markup.html blocks/header/markup.html blocks/license/markup.html blocks/logo/markup.html blocks/menu-bar/markup.html blocks/repository/markup.html blocks/toc/markup.html layouts/default.html layouts/page-toc.html

endif # __phase_3

Expand Down

0 comments on commit 2cf2f55

Please sign in to comment.