Skip to content

Commit

Permalink
Renamed make modules
Browse files Browse the repository at this point in the history
  • Loading branch information
fadado committed Apr 8, 2017
1 parent 4bff2b1 commit 6c3eed6
Show file tree
Hide file tree
Showing 13 changed files with 320 additions and 202 deletions.
21 changes: 12 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
########################################################################
# jqt management
#
########################################################################

project := jqt
# Parameters:
# prefix
# bindir
# datadir
# mandir

########################################################################
# Parameters (redefine as you like)
########################################################################
PROJECT := jqt

prefix ?= /usr/local
bindir ?= $(prefix)/bin
Expand Down Expand Up @@ -104,18 +107,18 @@ clobber: clean
install:
[[ -e jqt.1.gz ]] || { cd docs && make ../jqt.1.gz; }
test -d $(bindir) || $(SUDO) mkdir --verbose --parents $(bindir)
test -d $(datadir)/$(project) || $(SUDO) mkdir --verbose --parents $(datadir)/$(project)
test -d $(datadir)/$(PROJECT) || $(SUDO) mkdir --verbose --parents $(datadir)/$(PROJECT)
test -d $(mandir)/man1 || $(SUDO) mkdir --verbose --parents $(mandir)/man1
$(SUDO) install --verbose --compare --mode 555 bin/* $(bindir)
$(SUDO) install --verbose --compare --mode 644 share/* $(datadir)/$(project)
$(SUDO) install --verbose --compare --mode 644 share/* $(datadir)/$(PROJECT)
$(SUDO) install --verbose --compare --mode 644 jqt.1.gz $(mandir)/man1
$(SUDO) sed -i -e "s#DATADIR='.*'#DATADIR='$(datadir)'#" $(bindir)/jqt

uninstall:
$(SUDO) rm --verbose --force -- $(addprefix $(prefix)/,$(wildcard bin/*))
$(SUDO) rm --verbose --force -- $(mandir)/man1/jqt.1.gz
test -d $(datadir)/$(project) \
&& $(SUDO) rm --verbose --force --recursive $(datadir)/$(project) \
test -d $(datadir)/$(PROJECT) \
&& $(SUDO) rm --verbose --force --recursive $(datadir)/$(PROJECT) \
|| true

# Show targets
Expand Down
80 changes: 47 additions & 33 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
# jqt documentation management
########################################################################
# Makefile for web site management
#
# Project: jqt
# Author: [email protected] <Joan Josep Ordinas Rosa>
# Published: https://fadado.github.io/jqt/
########################################################################

# Make configuration
include make.d/prelude.make

# jqt/yummy version
Version := $(shell cat ../VERSION)

########################################################################
# Globals and setup
########################################################################

# Metadata directory
Metadata := .yummy

# jqt/yummy version
Version := $(shell cat ../VERSION)

# Load global parameters
# As a side effect config.json and site.json are built
-include $(Metadata)/globals.make

# Defined in globals.make
Expand All @@ -34,22 +40,21 @@ ifneq (clobber,$(MAKECMDGOALS))
# Define targets for basic metadata
include make.d/config.make

# Defined in metadata.make
# ========================
# Defined in config.make
# ======================
# Targets:
# $(Metadata)
# $(Metadata)/config.json
# $(Metadata)/site.json
# $(Metadata)/globals.make
# $(Metadata)/pages/**.json

# Build metadata from introspection
# Build metadata from filesystem introspection
ifdef __globals__
include make.d/introspect.make
include make.d/pathnames.make
endif

# Defined in introspect.make
# ==========================
# Defined in pathnames.make
# =========================
# Variables:
# HomePage
# Pages
Expand All @@ -58,21 +63,32 @@ endif
# NodesJSON
# Targets:
# $(Destination)
# all paths at $(Destination) and $(Metadata)
# each page from his metadata
# all paths starting at $(Destination) and $(Metadata)

# Build metadata from files front-matter
ifdef __globals__
include make.d/front-matter.make
endif

# Defined in front-matter.make
# ============================
# Targets:
# JSON metadata files at $(Metadata)/pages/ and $(Metadata)/nodes/
# Additional dependencies defined:
# each page and node from his metadata

endif # not clobbering

# Warning:
#
# If `__globals__` is not defined because `globals.make` does not exists, after
# this point most of the file is ignored, but `globals.make` is built because a
# rule exists in the file `metadata.make` (only if the target is not `clobber`).
# rule exists in the file `config.make` (only if the target is not `clobber`).
# Then `Makefile` is restarted, `MAKE_RESTARTS` will be equal to 1,
# `globals.make` is loaded and `__globals__` is defined.

########################################################################
# jqt command with options
# Commands
########################################################################

ifdef __globals__
Expand Down Expand Up @@ -144,7 +160,7 @@ other_pages := $(filter-out $(HomePage),$(Pages))
$(other_pages): \
$(Content)/FLOW.txt \
$(Content)/opt/*.txt \
$(Layouts)/page.html \
$(Layouts)/default.html \

$(HomePage) \
$(Destination)/structure.html: \
Expand Down Expand Up @@ -184,11 +200,11 @@ $(Destination)/$(1).html: $(Content)/$(1).md $(Layouts)/$(2).html \
@$(JQT) -d $$< $(Layouts)/$(2).html | $(DETAILS) > $$@
endef

# TODO: instrospect
Home := index
Other := content data engine structure
$(eval $(call Target,$(Home),page))
$(foreach p,$(Other),$(eval $(call Target,$(p),page-toc)))
# TODO: introspect
home := index
other := content data engine structure
$(eval $(call Target,$(home),page))
$(foreach p,$(other),$(eval $(call Target,$(p),page-toc)))

# CSS stylesheet
$(Destination)/styles.css: $(Styles)/page.css
Expand Down Expand Up @@ -220,32 +236,30 @@ endif # __globals__

ifndef __globals__

clobber: ;
# If clobbering a not initialized project do nothing
clobber: ;@:

else

# Delete generated publications
clean:
@rm -rf $(Destination)/* $(ManPage)

# Delete all generated files and directories
clobber:
@rm -rf $(Destination) $(ManPage) $(Metadata)

# Build again all documents
build: clean all

endif # __globals__

########################################################################
# External utilities
########################################################################

ifdef __globals__
# Build again all documents and metadata
xbuild:
@touch config.yaml
@$(MAKE) -s all

# help and other targets
include make.d/tools.make

# HTML 5 validation
include make.d/vnu.make

endif # __globals__

# vim:ai:sw=8:ts=8:noet:fileencoding=utf8:syntax=make
40 changes: 40 additions & 0 deletions docs/blocks/default.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<# Top-level page markup #>&
<!DOCTYPE html>
<!-- this document uses polyglot markup (well formed XHTML5) -->
<html id="{{.page._id}}" xmlns="http://www.w3.org/1999/xhtml" lang="{{.page.lang//.site.lang}}" xml:lang="{{.page.lang//.site.lang}}">
<head>
<#
# Meta elements
#>
<meta charset="utf-8" />
<# Document title and related metadata #>
<title>jqt · {{.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<%include ../VERSION>" />
<meta name='dcterms.date' content='{{.page.updated//empty}}' />
<# Presentation #>
<link rel="shortcut icon" href="favicon.ico"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<link rel="stylesheet" type="text/css" href="styles.css"/>
{{.page._highlight}}
</head>
<#
# Document body
#>
<body class="#container">
<%include blocks/header/markup.html>&
<%ifndef BODY_BLOCK>&
<%error Descendent layout must define BODY_BLOCK macro>
<%else>&
<%call BODY_BLOCK>
<%endif>&
<%include blocks/footer/markup.html>&
<%partial analytics 'UA-82432866-1'>&
</body>
</html>
<#
vim:ts=2:sw=2:ai:et:fileencoding=utf8:syntax=html
#>
14 changes: 14 additions & 0 deletions docs/blocks/node.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<# Default node #>&
<#
# Main page block for content
#>&
<%define BODY_BLOCK
<%include blocks/body/markup.html>
>&
<#
# Inherit default layout
#>&
<%include blocks/default.html>&
<#
vim:ts=2:sw=2:ai:et:fileencoding=utf8:syntax=perl
#>&
2 changes: 1 addition & 1 deletion docs/blocks/page-toc.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<#
# Inherit default layout
#>&
<%include blocks/page.html>&
<%include blocks/default.html>&
<#
vim:ts=2:sw=2:ai:et:fileencoding=utf8:syntax=perl
#>&
48 changes: 11 additions & 37 deletions docs/blocks/page.html
Original file line number Diff line number Diff line change
@@ -1,40 +1,14 @@
<# Top-level page markup #>&
<!DOCTYPE html>
<!-- this document uses polyglot markup (well formed XHTML5) -->
<html id="{{.page._id}}" xmlns="http://www.w3.org/1999/xhtml" lang="{{.page.lang//.site.lang}}" xml:lang="{{.page.lang//.site.lang}}">
<head>
<# Default page #>&
<#
# Meta elements
#>
<meta charset="utf-8" />
<# Document title and related metadata #>
<title>jqt · {{.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<%include ../VERSION>" />
<meta name='dcterms.date' content='{{.page.updated//empty}}' />
<# Presentation #>
<link rel="shortcut icon" href="favicon.ico"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<link rel="stylesheet" type="text/css" href="styles.css"/>
{{.page._highlight}}
</head>
# Main page block for content
#>&
<%define BODY_BLOCK
<%include blocks/body/markup.html>
>&
<#
# Document body
#>
<body class="#container">
<%include blocks/header/markup.html>&
<%ifndef BODY_BLOCK>&
<%include blocks/body/markup.html>&
<%else>&
<%call BODY_BLOCK>
<%endif>&
<%include blocks/footer/markup.html>&
<%partial analytics 'UA-82432866-1'>&
</body>
</html>
# Inherit default layout
#>&
<%include blocks/default.html>&
<#
vim:ts=2:sw=2:ai:et:fileencoding=utf8:syntax=html
#>
vim:ts=2:sw=2:ai:et:fileencoding=utf8:syntax=perl
#>&
2 changes: 2 additions & 0 deletions docs/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Layouts: ./blocks # shared space
# Site parameters
#

baseurl: https://fadado.github.io/jqt

title: jqt, the jq template engine
baseURL: https://fadado.github.com/jqt/
lang: &lang en
Expand Down
14 changes: 7 additions & 7 deletions docs/make.d/config.make
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
########################################################################
# Configuration
# Build files derived from user defined configuration
########################################################################

# Imported variables:
Expand All @@ -18,9 +18,9 @@ $(Metadata):
$(info ==> $@)
@mkdir --parents $@ >/dev/null 2>&1 || true

#
########################################################################
# Target files
#
########################################################################

# Create $(Metadata)/config.json
# Input is user defined config.yaml or config.json.
Expand All @@ -45,7 +45,7 @@ $(error Configuration file not found)
endif

# Globals definition to mix with config.json
define m_SITE_JSON :=
define m_SITE_JSON.jq :=
del(.defaults) \
| . + { \
Destination: (.Destination // "./_site"), \
Expand All @@ -61,10 +61,10 @@ endef

$(Metadata)/site.json: $(Metadata)/config.json
$(info ==> $@)
@jq --sort-keys '$(m_SITE_JSON)' < $< > $@
@jq --sort-keys '$(m_SITE_JSON.jq)' < $< > $@

# Variables to define in globals.make
define m_GLOBALS_MAKE :=
define m_GLOBALS_MAKE.jq :=
"__globals__ := 1", \
"Assets := " + .Assets, \
"Blocks := " + .Blocks, \
Expand All @@ -79,6 +79,6 @@ endef
# Create globals.make
$(Metadata)/globals.make: $(Metadata)/site.json
$(info ==> $@)
@jq --raw-output '$(m_GLOBALS_MAKE)' < $< > $@
@jq --raw-output '$(m_GLOBALS_MAKE.jq)' < $< > $@

# vim:ai:sw=8:ts=8:noet:fileencoding=utf8:syntax=make
Loading

0 comments on commit 6c3eed6

Please sign in to comment.