summary refs log tree commit diff
diff options
context:
space:
mode:
authorRobert Günzler <r@gnzler.io>2020-04-24 12:43:14 +0200
committerRobert Günzler <r@gnzler.io>2020-04-24 12:43:14 +0200
commit4e2d42677a8a15b3c6d058227aeb8b86861bb3dc (patch)
tree3930ea9a6bf87ad0d6c0de4801eb4fafedd8e5e7
parentf9fc57288444b270269ce1d73679a810b65ecc94 (diff)
yamlfs: add more templates
-rw-r--r--.config/yamlfs/.gitattributes1
-rw-r--r--.config/yamlfs/hugo.yml194
-rw-r--r--.config/yamlfs/meson.yml159
3 files changed, 354 insertions, 0 deletions
diff --git a/.config/yamlfs/.gitattributes b/.config/yamlfs/.gitattributes
new file mode 100644
index 0000000..c2e46b3
--- /dev/null
+++ b/.config/yamlfs/.gitattributes
@@ -0,0 +1 @@
+*.yml -whitespace
diff --git a/.config/yamlfs/hugo.yml b/.config/yamlfs/hugo.yml
new file mode 100644
index 0000000..8c08066
--- /dev/null
+++ b/.config/yamlfs/hugo.yml
@@ -0,0 +1,194 @@
+{% exec git init %}
+{% exec hugo new site -f toml %}
+
+Makefile: |-
+  repo ?= {% default "TODO" .repo %}
+  rev ?= $(shell git describe --tags --always --abbrev=7)
+
+  all: clean public/index.html
+
+  public/index.html:
+    DOCKER_BUILDKIT=1 docker build --platform=linux/amd64 \
+      --output=./public \
+      --target=final .
+
+  clean:
+    rm -rf ./public/*
+
+  .PHONY:
+    all clean
+    dev
+    container container-clean push
+
+  dev:
+    docker image inspect hugo:server >/dev/null || \
+      docker build --target=server --tag=hugo:server .
+    docker run --rm -it \
+      --mount type=bind,src=$(PWD),dst=/src,ro \
+      --mount type=tmpfs,dst=/src/public \
+      --publish 1313:1313 \
+      hugo:server
+
+  container:
+    img build --platform=linux/amd64 --tag=$(repo):$(rev) \
+      --target=deploy \
+      --no-console .
+    img tag $(repo):$(rev) $(repo):latest
+
+  container-clean:
+    img rm $(repo):latest || true
+    img rm $(repo):$(rev) || true
+
+  push:
+    img push $(repo):$(rev)
+    img push $(repo):latest
+
+Caddyfile: |-
+  :2015
+  root * /public
+  @index {
+    path_regexp .*/$
+  }
+  uri_replace @index {path} {path}index.html
+  try_files {uri} 404.html /404.html
+  respond /healthz 200
+  respond /readyz 200
+  encode zstd gzip
+  file_server
+
+Dockerfile: |-
+  FROM docker.io/library/alpine AS hugo
+  RUN apk add git hugo
+
+  FROM hugo AS dev
+  WORKDIR /src
+  ENTRYPOINT [ "hugo" ]
+
+  FROM dev AS build
+  COPY . .
+  ARG HUGO_BUILD_ARGS="--cleanDestinationDir"
+  RUN hugo ${HUGO_BUILD_ARGS}
+
+  FROM scratch AS final
+  COPY --from=build /src/public /public
+
+  FROM dev AS server
+  CMD ["server", "--bind=0.0.0.0"]
+
+  FROM scratch AS final
+  COPY --from=build /src/public/* /
+
+  FROM docker.io/robertgzr/caddy:v2.0.0-beta13 AS caddy
+  FROM scratch AS deploy
+  COPY --from=caddy /usr/bin/caddy /caddy
+  COPY --from=build /src/public /public
+  COPY ./Caddyfile /Caddyfile
+  WORKDIR /public
+  EXPOSE 2015
+  ENTRYPOINT ["/caddy", "run", "--config=/Caddyfile"]
+
+assets:
+  scss:
+    main.scss: |-
+      @import "reset";
+
+      @import "modules/all";
+
+      @import "partials/content";
+      @import "partials/header";
+      @import "partials/footer";
+      @import "partials/typo";
+
+    _reset.scss: |-
+      html {
+        font-size: $fs-normal;
+      }
+
+      * {
+        box-sizing: border-box;
+        text-rendering: geometricPrecision;
+      }
+
+      body {
+        font-size: $fs-normal;
+        line-height: 1.5rem;
+        margin: 0;
+        font-family: serif;
+        word-wrap: break-word;
+      }
+
+      h1, h2, h3, h4, h5, h6 {
+        line-height: 1.3em;
+      }
+
+      fieldset {
+        border: none;
+        padding: 0;
+        margin: 0;
+      }
+
+      pre {
+        padding: 2rem;
+        margin: 1.75rem 0;
+        background-color: white;
+        border: 1px solid #ccc;
+        overflow: auto;
+      }
+
+      pre code,
+      code[class*="language-"], pre[class*="language-"] {
+        font-weight: 100;
+        text-shadow: none;
+        margin: 1.75rem 0;
+      }
+
+      a {
+        cursor: pointer;
+        text-decoration: none;
+      }
+
+    modules:
+      _all.scss: |-
+        // mixins go here
+
+        @mixin invert() {
+          filter: hue-rotate(180deg) contrast(100%) invert(100%);
+          -webkit-filter: hue-rotate(180deg) contrast(100%) invert(100%);
+        }
+        @mixin invert_img() {
+          filter: invert(100%) hue-rotate(180deg) brightness(105%) contrast(85%);
+          -webkit-filter: invert(100%) hue-rotate(180deg) brightness(105%) contrast(85%);
+        }
+
+    partials:
+      _content.scss: |-
+        // TODO content style
+      _header.scss: |-
+        // TODO header style
+      _footer.scss: |-
+        // TODO footer style
+      _typo.scss: |-
+        // TODO typography style
+
+layouts/humans.txt: |-
+  User-agent: *
+  {{ if (getenv "HUGO_ENV") "production" }}
+  Disallow:
+  {{ else }}
+  Disallow: /
+  {{ end }}
+
+static/humans.txt: |-
+  /* WHAT IS THIS? */
+      https://humanstxt.org
+
+  /* AUTHOR */
+      Standard: TODO
+      Email: TODO
+
+  /* SITE */
+      Last update:{% printf "%s" time.Now().Format("2006/01/02") %}
+      Language: English
+      Doctype:HTML5
+      IDE: vim, alacritty
+      Technologies: hugo, scss, yamlfs, docker
diff --git a/.config/yamlfs/meson.yml b/.config/yamlfs/meson.yml
new file mode 100644
index 0000000..378afb1
--- /dev/null
+++ b/.config/yamlfs/meson.yml
@@ -0,0 +1,159 @@
+meson.build: |-
+  project(
+      '{% .name %}',
+      'c',
+      version: '0.0.0+unknown',
+      license: 'MIT',
+      default_options: [
+        'c_std=c99' \
+        'warning_level=2' \
+        'werror=true' \
+      ],
+  )
+
+  cc = meson.get_compiler('c')
+  add_project_arguments(cc.get_supported_arguments([
+    '-D_POSIX_C_SOURCE=200809L',
+
+    '-Wundef',
+    '-Wlogical-op',
+    '-Wmissing-include-dirs',
+    '-Wold-style-definition',
+    '-Wpointer-arith',
+    '-Winit-self',
+    '-Wfloat-equal',
+    '-Wstrict-prototypes',
+    '-Wredundant-decls',
+    '-Wimplicit-fallthrough=2',
+    '-Wendif-labels',
+    '-Wstrict-aliasing=2',
+    '-Woverflow',
+    '-Wformat=2',
+  
+    '-Wno-missing-braces',
+    '-Wno-missing-field-initializers',
+    '-Wno-unused-parameter',
+  ]), language: 'c')
+
+  executable(
+    meson.project_name(),
+    files(
+      'src/main.c',
+    ),
+    include_directories: include_directories('include'),
+    dependencies: [],
+    install: true,
+  )
+
+  {%- if .doc %}
+  scdoc = dependency(
+    'scdoc',
+    version: '>=1.9.2',
+    native: true,
+    required: get_option('man-pages'),
+  )
+  if scdoc.found()
+    scdoc_prog = find_program(scdoc.get_pkgconfig_variable('scdoc'), native: true)
+    sh = find_program('sh', native: true)
+    mandir = get_option('mandir')
+    man_files = [
+      '{% .name %}.1.scd',
+    ]
+    foreach fn : man_files
+      topic = fn.split('.')[-3].split('/')[-1]
+      section = fn.split('.')[-2]
+      output = '@0@.@1@'.format(topic, section)
+
+      custom_target(
+        output,
+        input: fn,
+        output: output,
+        command: [
+          sh, '-c', '@0@ < @INPUT@ > @1@'.format(scdoc_prog.path(), output)
+        ],
+        install: true,
+        install_dir: '@0@/man@1@'.format(mandir, section),
+    )
+    endforeach
+  endif
+  {%- end %}
+
+  version = '"@0@ (" __DATE__ ")"'.format(meson.project_version())
+  # embed version sourced from git ref
+  git = find_program('git', native: true, required: false)
+  if git.found()
+      git_commit_hash = run_command([
+        git, 'describe', '--always', '--tags'
+      ])
+      git_branch = run_command([
+        git, 'rev-parse', '--abbrev-ref', 'HEAD'
+      ])
+      if git_commit_hash.returncode() == 0 and git_branch.returncode() == 0
+        version = '"@0@ (" __DATE__ ", branch \'@1@\')"'.format(
+          git_commit_hash.stdout().strip(),
+          git_branch.stdout().strip(),
+        )
+      endif
+  endif
+  add_project_arguments('-DVERSION=@0@'.format(version), language: 'c')
+
+src:
+  main.c: |-
+    #define _POSIX_C_SOURCE 200809L
+    #include <stdlib.h>
+    #include <stdio.h>
+
+    #include "{% .name %}.h"
+
+    int main(int argc, char **argv) {
+        printf("%s version %s\n\n", *argv, VERSION);
+
+        printf("args (len: %d)", argc-1);
+        for (int i=1; i < argc; ++i) {
+            printf(" '%s'", argv[i]);
+        }
+        printf("\n");
+
+        return 0;
+    }
+
+include:
+  {% .name | lower %}: |-
+    #ifndef {% .name | upper %}_H
+    #define {% .name | upper %}_H
+
+    #ifndef VERSION
+    #define VERSION "0.0.0+unknown"
+    #endif
+
+    /* TODO */
+
+    #endif
+
+.editorconfig: |-
+  ; http://editorconfig.org/
+
+  root = true
+
+  [*]
+  charset = utf-8
+  end_of_line = lf
+  indent_style = space
+
+  [*.{c,h,cmake,txt}]
+  indent_style = tab
+  indent_size = 4
+
+  [*.md]
+  trim_trailing_whitespace = false
+
+  [meson.build]
+  indent_size = 2
+
+  [Dockerfile]
+  indent_size = 4
+
+README.md: |-
+  # {% .name %}
+
+  TODO