summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: d9cfa4e929da5002cd9bd24b5f8367232e665ec5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Maintainer: Index Dev Team <indexdevteam@gmail.com>

# shellcheck disable=SC2034
_distro=dogelonindex
_pkgbase="${_distro}-website"
pkgname="${_pkgbase}-git"
pkgver=v0.1+150+g238a074
pkgrel=1
pkgdesc='Dogelon Index Website'
arch=('any')
license=('GPL3')
_url="https://github.com/indexdevteam/dogelonindex-website"
url="https://www.dogelonindex.org"
_marker_tag="2020.04.04"
makedepends=('git'
	     'marker'
	     'pandoc'
             'python-fastjsonschema')
checkdepends=()
provides=("${_pkgbase}")
conflicts=("${_pkgbase}")
optdepends=("apache"
	    "lighttpd"
            "nginx")
source=("${_pkgbase}::git+${_url}")
sha256sums=('SKIP')

pkgver() {
  cd "${_pkgbase}" || exit
  git describe --tags | sed 's/-/+/g'
}

# shellcheck disable=SC2154
build() {
  local _styles="/usr/share/com.github.fabiocolacio.marker/styles"
  cp -r "${_styles}" "${srcdir}"
}

# shellcheck disable=SC2154
package() {
  local _pages="${srcdir}/${_pkgbase}"
  local dest="${pkgdir}/srv/http"
  local _styles="${srcdir}/styles"
  local _tl_src="${_pages}/tokenlist.json"
  local _tl_schema="${_pages}/tokenlist.schema.json"
  local _dest name page
  install -dm750 "${dest}"
  chown -R 0:33 "${dest}"

  cd "${_pages}" || exit
  for page in "${_pages}"/*md; do
    name="${page%%.md}"
    pandoc -s --verbose \
	      --css="${_styles}/markdown.css" \
              --css="${_styles}/swiss.css" \
	      --self-contained \
              -f markdown \
              -t html \
              --output "${name}.html" \
              "${page}"
    _dest="${dest}"
    install -dm750 "${_dest}/resources"
    chown -R 0:33 "${_dest}"
    if [ "$(basename "${name}")" != "index" ]; then
      _dest="${dest}/$(basename "${name}")"
      install -dm750 "${_dest}"
      chown -R 0:33 "${_dest}"
      _dest="${_dest}/index.html"
    fi
    install -Dm 644 "${name}.html" "${_dest}"
    rm "${name}.html"
  done
  install -Dm 644 "${_pages}/sitemap.xml" "${dest}"
  jsonschema -i "${_tl_src}" "${_tl_schema}"
  install -Dm644 "${_tl_src}" "${dest}/resources"
}