Skip to content

Commit

Permalink
New content model
Browse files Browse the repository at this point in the history
  • Loading branch information
fadado committed Aug 28, 2016
1 parent 1a377d4 commit c23d157
Show file tree
Hide file tree
Showing 40 changed files with 209 additions and 187 deletions.
28 changes: 12 additions & 16 deletions bin/jqt
Original file line number Diff line number Diff line change
Expand Up @@ -401,18 +401,17 @@ $endif$
# Merge document and all data
########################################################################

declare DOCUMENT_METADATA_NAME='front' # front matter
declare DOCUMENT_CONTENT_NAME='body' # body matter
declare DOCUMENT_METADATA_NAME='page' # front matter and etc.

declare -A JSON_DATA=() YAML_DATA=() YAML_SNIPPETS=()
declare -A JSON_DATA_DOT=() YAML_DATA_DOT=()

# Global objects available in jq scripts:
# .body
# .front ...
# .front._highlight
# .front._id
# .front._toc
# .page ...
# .page._content
# .page._highlight
# .page._id
# .page._toc

# < stdin > stdout
function merge
Expand All @@ -423,10 +422,9 @@ function merge

{ # split .
echo '(. / "<!--JQT-->") as [$body, $toc, $css] |'
# front and body
echo "{ $DOCUMENT_CONTENT_NAME: "'$body'
echo ", $DOCUMENT_METADATA_NAME: ("; yaml2json < $FRONT_MATTER
echo "+ { _id: \"${DOCUMENT_ID}\","' _toc: $toc, _highlight: $css })}'
# page
echo "{ $DOCUMENT_METADATA_NAME: ("; yaml2json < $FRONT_MATTER
echo "+ { _id: \"${DOCUMENT_ID}\","' _content: $body, _toc: $toc, _highlight: $css })}'
# additional data
for key in "${!YAML_DATA[@]}"; do
echo "+{ $key:"
Expand Down Expand Up @@ -591,7 +589,7 @@ declare expand=''

declare opt key filename

while getopts :hVD:I:P:L:i:j:45d:eprtf:n:m:M:T:CHS-: opt; do
while getopts :hVD:I:P:L:i:j:45d:eprtn:m:M:T:CHS-: opt; do
case $opt in
# Generic options
h) help
Expand Down Expand Up @@ -638,10 +636,6 @@ while getopts :hVD:I:P:L:i:j:45d:eprtf:n:m:M:T:CHS-: opt; do
t) front_matter=1
;;
# Data options
f) DOCUMENT_METADATA_NAME=$OPTARG
;;
n) DOCUMENT_CONTENT_NAME=$OPTARG
;;
m|M)[[ $OPTARG == *:* ]] || usage "Bad format in data specification; expected 'key:filename'"
key=${OPTARG%:*} filename=${OPTARG#*:}
[[ -e $filename ]] || usage "File '$filename' does not exists"
Expand All @@ -661,6 +655,8 @@ while getopts :hVD:I:P:L:i:j:45d:eprtf:n:m:M:T:CHS-: opt; do
fi
fi
;;
n) DOCUMENT_METADATA_NAME=$OPTARG
;;
T) if [[ -z $OPTARG ]]; then
snippets=1
elif [[ $OPTARG == '--' ]]; then
Expand Down
10 changes: 5 additions & 5 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Common := \
$(Structure)/default.html \
$(Structure)/head.html \
$(Structure)/footer.html \
$(Content)/LINKS.MD \
$(Content)/LINKS.txt \
filters.jq \
macros.m \

Expand Down Expand Up @@ -131,8 +131,8 @@ $(Destination)/index.html: $(Content)/home.md $(Common) \
$(info ==> $@)
$(JQT) -d $< $(Structure)/default.html > $@

$(foreach p,$(Pages),$(Destination)/$(p).html): $(Content)/FLOW.MD $(Content)/opt/*.md
$(Destination)/index.html $(Destination)/structure.html: $(Content)/EXAMPLE.MD
$(foreach p,$(Pages),$(Destination)/$(p).html): $(Content)/FLOW.txt $(Content)/opt/*.txt
$(Destination)/index.html $(Destination)/structure.html: $(Content)/EXAMPLE.txt

define Target
$(Destination)/$(1).html: $(Content)/$(1).md $(Structure)/$(2).html $(Common) \
Expand All @@ -148,14 +148,14 @@ $(Destination)/jqt.css: $(Presentation)/jqt.css $(Presentation)/github.css
jqt -P CSS-min -I$(Presentation) $< > $@

# Man page
$(ManPage): $(Content)/jqt.1.md
$(ManPage): $(Content)/jqt.1.markdown
$(info ==> $@)
jqt -P MarkDown -I$(Content) $< \
| pandoc --standalone --from markdown --to man \
| gzip > $@

# Help text
/tmp/help: $(Content)/help.txt
/tmp/help: $(Content)/help.markdown
jqt -P MarkDown -I$(Content) $< \
| pandoc --from markdown --to plain - \
| sed '1,7b;/^$$/d;s/_\([A-Z]\+\)_/\1/g;/^[^A-Z]/s/^/ /' \
Expand Down
12 changes: 6 additions & 6 deletions docs/content/EXAMPLE.MD → docs/content/EXAMPLE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
#>

```html
<html lang='{{.front.lang}}'>
<html lang='{{.page.lang//.site.lang}}'>
<head>
<title>{{.front.title | gsub("<[^>]*>"; "")}}</title>
<title>{{.page.title | gsub("<[^>]*>"; "")}}</title>
{# include files in preprocessing stage #}
<%include "head.html">
<meta name="generator" content="jqt v<%include "../VERSION">"/>
{# optional line #}
<meta name='dcterms.modified' content='{{.front.updated//empty}}' />
<meta name='dcterms.modified' content='{{.page.updated//empty}}' />
{# implicit loop for all authors #}
{% .front.author | sort[] %}<meta name='author' content='{{.}}' />
{% .page.author | sort[] %}<meta name='author' content='{{.}}' />
</head>
<body>
<h1>{{.front.title}}</h1>
<h1>{{.page.title}}</h1>
<div id="CONTENT">
{{.body}}
{{.page._content}}
</div>
<%partial analytics 'UA-82432866-1'>
</body>
Expand Down
File renamed without changes.
File renamed without changes.
26 changes: 26 additions & 0 deletions docs/content/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
File extension conventions
==========================

* Web site pages
- content.md
- data.md
- engine.md
- home.md
- structure.md

* Partial MarkDown to be included
- EXAMPLE.txt
- FLOW.txt
- LINKS.txt
- opt/*.txt

* MarkDown snippets
- snippets.yaml

* Other unrelated MarkDown files
- help.markdown
- jqt.1.markdown

<!--
vim:ts=4:sw=4:ai:et:fileencoding=utf8:syntax=markdown
-->
28 changes: 13 additions & 15 deletions docs/content/content.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
<%include "config.yaml">
title: Document content
updated: "2016-08-17T10:34:16Z"
updated: "2016-08-28T10:27:09Z"
---
<%include "macros.m">&
<%include "LINKS.MD">&
<%include "LINKS.txt">&

## General operation

Expand All @@ -13,16 +12,15 @@ but before [GPP][GPP] is used to preprocess them. Pandoc's output
is then merged with the [YAML][YAML] front matter metadata and other input data before be sended
to the render stage. This is described on the middle of this diagram:

<%include "FLOW.MD">
<%include "FLOW.txt">

When invoking `jqt` you can use the following options to influence document
conversion:

<%include "opt/4.md">
<%include "opt/D.md">
<%include "opt/d.md">
<%include "opt/I.md">
<%include "opt/n.md">
<%include "opt/4.txt">
<%include "opt/D.txt">
<%include "opt/d.txt">
<%include "opt/I.txt">

## File structure

Expand All @@ -32,15 +30,15 @@ Document files contain MarkDown text preceded by an optional YAML front matter.

Pandoc accepts YAML metadata intermixed with MarkDown content. _jqt_
extracts the YAML front matter, located at the very beginning of the file,
and injects it into the render stage under a global JSON object named `.front`.
and injects it into the render stage under a global JSON object named `.page`.

### Body

Pandoc will convert the document body to HTML,
and _jqt_ will inject it into the render stage under a global JSON scalar named
`.body`. If the document contains fenced code blocks specifying the language of
the code block, the highlight code will be in the scalar `.front._css`. Also, the
table of contents will be in the scalar `.front._toc`.
and _jqt_ will inject it into the render stage under the global JSON scalar
`.page._content`. If the document contains fenced code blocks specifying the language of
the code block, the highlight code will be in the scalar `.page._css`. Also, the
table of contents will be in the scalar `.page._toc`.

## Document syntax

Expand Down Expand Up @@ -89,7 +87,7 @@ Inside macro definitions argument references are prefixed by a dollar (`$1`, `$2
Predefined macros and user define macros have the same call sequence:

```
<%include "LINKS.MD">
<%include "LINKS.txt">
<%sc 'A title in small caps'>
```

Expand Down
25 changes: 12 additions & 13 deletions docs/content/data.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
<%include "config.yaml">
title: Data model
updated: "2016-08-13T07:48:26Z"
updated: "2016-08-28T10:27:09Z"
---
<%include "macros.m">&
<%include "LINKS.MD">&
<%include "LINKS.txt">&

## General operation

Expand All @@ -16,17 +15,17 @@ rendering the template. Also, `jqt` accepts additional data files in the command
in [YAML][YAML] or [JSON][JSON] format to be merged with
the document front matter. This is described on the bottom of this diagram:

<%include "FLOW.MD">
<%include "FLOW.txt">

When invoking `jqt` you can use the following options to define the additional input
data and influence JSON preprocessing:

<%include "opt/D.md">
<%include "opt/f.md">
<%include "opt/I.md">
<%include "opt/M.md">
<%include "opt/m.md">
<%include "opt/T.md">
<%include "opt/D.txt">
<%include "opt/I.txt">
<%include "opt/M.txt">
<%include "opt/m.txt">
<%include "opt/n.txt">
<%include "opt/T.txt">

## Data formats

Expand Down Expand Up @@ -165,9 +164,9 @@ Read the output of `yq --help` and `cq --help` for more information.
When invoking `jqt` you can use the following options to extract, remove or
test the presence of front matter data in the input document:

<%include "opt/e.md">
<%include "opt/r.md">
<%include "opt/t.md">
<%include "opt/e.txt">
<%include "opt/r.txt">
<%include "opt/t.txt">

<#
vim:ts=4:sw=4:ai:et:fileencoding=utf8:syntax=markdown
Expand Down
54 changes: 26 additions & 28 deletions docs/content/engine.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
<%include "config.yaml">
title: Operating the engine
updated: "2016-08-17T09:50:11Z"
updated: "2016-08-28T10:27:09Z"
---
<%include "macros.m">&
<%include "LINKS.MD">&
<%include "LINKS.txt">&

## General operation

Expand All @@ -14,7 +13,7 @@ where HTML is mixed with [_jq_][JQ] snippets to implement the transformation log
This diagram shows how document, template and data inputs (on the left) are combined by
_jqt_ to produce the final HTML output:

<%include "FLOW.MD">
<%include "FLOW.txt">

The command `jqt` is a shell script executed by `bash`.
The external shell commands called by `jqt` are `cat`, `gpp`, `jq`, `mkdir`,
Expand Down Expand Up @@ -72,28 +71,27 @@ arguments. The usage possibilities are:

### Options

<%include "opt/4.md">
<%include "opt/C.md">
<%include "opt/D.md">
<%include "opt/d.md">
<%include "opt/e.md">
<%include "opt/f.md">
<%include "opt/H.md">
<%include "opt/h.md">
<%include "opt/I.md">
<%include "opt/i.md">
<%include "opt/j.md">
<%include "opt/L.md">
<%include "opt/M.md">
<%include "opt/m.md">
<%include "opt/n.md">
<%include "opt/P.md">
<%include "opt/p.md">
<%include "opt/r.md">
<%include "opt/S.md">
<%include "opt/T.md">
<%include "opt/t.md">
<%include "opt/V.md">
<%include "opt/4.txt">
<%include "opt/C.txt">
<%include "opt/D.txt">
<%include "opt/d.txt">
<%include "opt/e.txt">
<%include "opt/H.txt">
<%include "opt/h.txt">
<%include "opt/I.txt">
<%include "opt/i.txt">
<%include "opt/j.txt">
<%include "opt/L.txt">
<%include "opt/M.txt">
<%include "opt/m.txt">
<%include "opt/n.txt">
<%include "opt/P.txt">
<%include "opt/p.txt">
<%include "opt/r.txt">
<%include "opt/S.txt">
<%include "opt/T.txt">
<%include "opt/t.txt">
<%include "opt/V.txt">

## Preprocessing

Expand All @@ -112,7 +110,7 @@ detail their usage of the preprocessor.
A different transformation can also be be considered a kind of preprocessing. The option
`-T` allows the use of YAML files for collections of MarkDown snippets:

<%include "opt/T.md">
<%include "opt/T.txt">

### CSS preprocessing

Expand All @@ -121,7 +119,7 @@ section because it is outside the _jqt_ normal processing work flow.

To enable CSS preprocessing the `-P` option must be used with the `css` or `css-min` options:

<%include "opt/P.md">
<%include "opt/P.txt">

You can minify the CSS style sheet choosing the `css-min` option.
The CSS minimization is not extremely aggressive, but is safe and sufficient.
Expand Down
Loading

0 comments on commit c23d157

Please sign in to comment.