~kungtotte/dtt

bf807c3fe4f7e7a25fd250d0301d6f4a9ac69a66 — Thomas Landin 4 months ago 7f0d562
Correctly set permissions on output files

To be able to host files and make copying them to a webhost easy, the
files need 755 permissions.

Also touched up some templates.
2 files changed, 22 insertions(+), 9 deletions(-)

M src/dtt.nim
M src/tmpl.nim
M src/dtt.nim => src/dtt.nim +11 -3
@@ 16,6 16,8 @@ const
  template_dir = "templates"
  output_dir = "output"
  blog_dirs = ["blog", "blogs", "post", "posts", "articles", "journal", "journals"]
  outFilePerms = {fpUserExec, fpUserWrite, fpUserRead, fpGroupExec,
                  fpGRoupRead, fpOthersExec, fpOthersRead}

let
  version = "0.2.0"


@@ 71,6 73,7 @@ proc initCmd(dir: string, force: bool = false) =
  writeFile(wd / template_dir / "header.mustache", tmpl.header)
  writeFile(wd / template_dir / "footer.mustache", tmpl.footer)
  writeFile(wd / output_dir / css_dir / "style.css", tmpl.style)
  setFilePermissions(wd / output_dir / css_dir / "style.css", outFilePerms)


proc cleanCmd(all: bool = false, force: bool = false) =


@@ 225,10 228,15 @@ proc buildCmd() =
            # Right now it just makes everything into a page and does
            # no automatic linking/indexing.
            discard
          let output  = mcontext.renderTemplate(condir / f, tmpl, tmpldir = tmpldir)
          writeFile(savepath / fname & ".html", output)
          let
            output  = mcontext.renderTemplate(condir / f, tmpl, tmpldir = tmpldir)
            outfile = savepath / fname & ".html"
          writeFile(outfile, output)
          setFilePermissions(outfile, outFilePerms)
        else:
          copyFile(condir / f, savepath / fname & ext)
          let outfile = savepath / fname & ext
          copyFile(condir / f, outfile)
          setFilePermissions(outfile, outFilePerms)
      else:
        stderr.writeLine(fmt"Unknown error occurred: {f} is neither file nor directory")
        quit(ord(DttError.UnknownError))

M src/tmpl.nim => src/tmpl.nim +11 -6
@@ 3,6 3,7 @@ let
[Site]
charset = "UTF-8"
language = "en"
base_url = "http://my.domain"
title = "My Own Webpage"
license = "CC-BY-SA"
license_url = "https://creativecommons.org/licenses/by-sa/2.0/"


@@ 16,7 17,7 @@ email = "your@email.tld"
  <head>
    <meta charset="{{charset}}">
    <title>{{page_title}}</title>
    <link rel="stylesheet" type="text/css" href="css/style.css">
    <link rel="stylesheet" type="text/css" href="{{base_url}}/css/style.css">
  </head>
  <body>
  {{> header}}


@@ 49,13 50,13 @@ email = "your@email.tld"
"""
  style* = """
:root {
  --body-bg: #fbf1c7;
  --header-bg: #928374;
  --body-bg: #fff;
  --header-bg: #83a598;
  --font-color: #282828;
  --link-color: #504945;
  --link-color: #282828;
  --visited-color: #af3a03;
  --quote-color: #928374;
  --hover-color: #a89984;
  --hover-color: #928374;
  --monospace-color: #9d0006;
  --codeblock-color: #076678;
  --codeblock-bg: #ebdbb2


@@ 81,6 82,9 @@ a:visited {
a:hover {
  color: var(--hover-color);
}
h1, h2, h3, h4 {
  color: var(--quote-color);
}
aside {
  display: grid;
  position: fixed;


@@ 144,4 148,5 @@ footer {
  text-align: right;
  line-height: 0.8;
  padding: 0px;
}"""
}
"""