Compare commits
8 Commits
393b73aacb
...
master
Author | SHA1 | Date | |
---|---|---|---|
e490bf002e | |||
31dee4654f | |||
4c74f96579 | |||
de5a0ba39f | |||
00e3ef6987 | |||
a1eb445bff | |||
2b54284d2d | |||
36778e0e5b |
@ -3,21 +3,21 @@
|
|||||||
font-family: roboto;
|
font-family: roboto;
|
||||||
src: url(/fonts/Roboto-Regular.ttf)
|
src: url(/fonts/Roboto-Regular.ttf)
|
||||||
}
|
}
|
||||||
|
|
||||||
@font-face {
|
@font-face {
|
||||||
font-family: overpass;
|
font-family: overpass;
|
||||||
src: url(/fonts/Overpass-Regular.ttf)
|
src: url(/fonts/Overpass-Regular.ttf)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Element styling */
|
/* Consistent background and text color */
|
||||||
html {
|
html {
|
||||||
background-color: #212121;
|
background-color: #212121;
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
font-family: Overpass;
|
font-family: Overpass;
|
||||||
}
|
}
|
||||||
|
|
||||||
footer {
|
/* Keep the paddings consistent */
|
||||||
width: 100%;
|
body {
|
||||||
|
padding: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1, h2, h3 {
|
h1, h2, h3 {
|
||||||
@ -29,55 +29,38 @@ a {
|
|||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
.page-title {
|
/* General fixes */
|
||||||
color: #9b59b6;
|
|
||||||
}
|
|
||||||
|
|
||||||
ul {
|
|
||||||
margin-top: 2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Layouting */
|
|
||||||
* {
|
* {
|
||||||
/* To fix sizing issues */
|
/* To fix sizing issues */
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
.container {
|
/* Horizontal flow using flexbox */
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.horizontal {
|
.horizontal {
|
||||||
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Horizontally centered using flexbox */
|
||||||
.horizontal-center {
|
.horizontal-center {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
width: 100%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Vertical flow using flexbox */
|
||||||
.vertical {
|
.vertical {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
width: 100% !important;
|
/*width: 100% !important;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
.subbar-link {
|
/* Vertically center using flexbox */
|
||||||
padding: 5px;
|
.vertical-center {
|
||||||
}
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
|
||||||
.title-sub {
|
height: 100%;
|
||||||
margin-top: 0px;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
.title-sub-subbar {
|
|
||||||
margin-top: -20px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Text styling */
|
/* Text styling */
|
||||||
@ -86,6 +69,7 @@ ul {
|
|||||||
padding: 4px;
|
padding: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Show a white border at the left side to indicate a quote */
|
||||||
.quote {
|
.quote {
|
||||||
border-left: 2px;
|
border-left: 2px;
|
||||||
border-left-style: solid;
|
border-left-style: solid;
|
||||||
@ -93,6 +77,7 @@ ul {
|
|||||||
padding-left: 4px;
|
padding-left: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Useful for warning the user of something */
|
||||||
.warning {
|
.warning {
|
||||||
border-left: 2px;
|
border-left: 2px;
|
||||||
border-left-style: solid;
|
border-left-style: solid;
|
||||||
@ -101,3 +86,63 @@ ul {
|
|||||||
|
|
||||||
color: #f1c40f;
|
color: #f1c40f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Useful for the footer shown at the bottom of the page */
|
||||||
|
.footer {
|
||||||
|
width: 100%;
|
||||||
|
margin-top: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Used a big <img /> showing my avatar */
|
||||||
|
.avatar {
|
||||||
|
width: 200px;
|
||||||
|
height: 200px;
|
||||||
|
border-radius: 10px;
|
||||||
|
margin-right: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Keep entire site at a reasonable width on wide displays
|
||||||
|
* but let it stretch all the way on small displays (See media query).
|
||||||
|
*/
|
||||||
|
.header {
|
||||||
|
width: 42%;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Display the links below the header in a row instead of below each other. */
|
||||||
|
#header-links ul {
|
||||||
|
list-style: none;
|
||||||
|
padding-left: 0px;
|
||||||
|
margin-bottom: 0px;
|
||||||
|
margin-top: 0px;
|
||||||
|
}
|
||||||
|
#header-links li {
|
||||||
|
display: inline;
|
||||||
|
|
||||||
|
font-size: large;
|
||||||
|
margin-left: 20px;
|
||||||
|
}
|
||||||
|
#header-links li:first-child {
|
||||||
|
margin-left: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Title font for the page */
|
||||||
|
.name-title {
|
||||||
|
font-size: xxx-large;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Small screen adjustments */
|
||||||
|
@media screen and (max-width: 720px) {
|
||||||
|
.header {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.name-title {
|
||||||
|
font-size: x-large;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avatar {
|
||||||
|
width: 100px;
|
||||||
|
height: 100px;
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BIN
assets/img/avatar.jpg
Normal file
BIN
assets/img/avatar.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 137 KiB |
27
flake.lock
Normal file
27
flake.lock
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1638239011,
|
||||||
|
"narHash": "sha256-AjhmbT4UBlJWqxY0ea8a6GU2C2HdKUREkG43oRr3TZg=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "a7ecde854aee5c4c7cd6177f54a99d2c1ff28a31",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "21.11",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
21
flake.nix
Normal file
21
flake.nix
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
description = "The website hosted at https://polynom.me";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/21.11";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = {
|
||||||
|
self,
|
||||||
|
nixpkgs
|
||||||
|
}: let
|
||||||
|
supportedSystems = [ "x86_64-linux" ];
|
||||||
|
forAllSystems = nixpkgs.lib.attrsets.genAttrs supportedSystems;
|
||||||
|
in {
|
||||||
|
packages = forAllSystems (system: let
|
||||||
|
pkgs = import nixpkgs { inherit system; };
|
||||||
|
in {
|
||||||
|
default = pkgs.callPackage ./pkgs/shared-assets.nix {};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
42
makesite.py
42
makesite.py
@ -124,8 +124,40 @@ def read_content(filename):
|
|||||||
|
|
||||||
def render(template, **params):
|
def render(template, **params):
|
||||||
"""Replace placeholders in template with values from params."""
|
"""Replace placeholders in template with values from params."""
|
||||||
return re.sub(r'{{\s*([^}\s]+)\s*}}',
|
def handle_variable(match):
|
||||||
lambda match: str(params.get(match.group(1), match.group(0))),
|
var = match.group(1).strip()
|
||||||
|
if match.group(1).startswith("template "):
|
||||||
|
import_name = var[7:]
|
||||||
|
import_ = fread(import_name)
|
||||||
|
return render(import_, **params)
|
||||||
|
elif var.startswith("for_each "):
|
||||||
|
args = var.split(" ")[1:]
|
||||||
|
attribute_name = args[0]
|
||||||
|
template_name = args[1]
|
||||||
|
|
||||||
|
template_ = fread(template_name)
|
||||||
|
templates = []
|
||||||
|
for val in params.get(attribute_name, []):
|
||||||
|
templates.append(render(template_, **params, item=val))
|
||||||
|
return "\n".join(templates)
|
||||||
|
elif var.startswith("item."):
|
||||||
|
return str(params["item"].get(var[5:], match.group(0)))
|
||||||
|
elif var.startswith("template_if_empty "):
|
||||||
|
# {{ template_if_empty <param> <template if param is empty> <otherwise> }}
|
||||||
|
args = var[17:].split(" ")[1:]
|
||||||
|
value = params["item"].get(args[0][5:], "") if args[0].startswith("item.") else params.get(args[0], "")
|
||||||
|
template_name = args[1] if value == "" else args[2]
|
||||||
|
template_ = fread(template_name)
|
||||||
|
return render(template_, **params)
|
||||||
|
else:
|
||||||
|
if not var in params:
|
||||||
|
print("Did not find variable '%s'!" % var)
|
||||||
|
return match.group(0)
|
||||||
|
|
||||||
|
return params[var]
|
||||||
|
|
||||||
|
return re.sub(r'{{\s*([^}]+)\s*}}',
|
||||||
|
handle_variable,
|
||||||
template)
|
template)
|
||||||
|
|
||||||
|
|
||||||
@ -141,6 +173,8 @@ def make_pages(src, dst, layout, **params):
|
|||||||
if 'params' in content:
|
if 'params' in content:
|
||||||
page_params.update(**json.loads(open(content['params'], 'r').read()))
|
page_params.update(**json.loads(open(content['params'], 'r').read()))
|
||||||
|
|
||||||
|
page_params['file_name'] = os.path.basename(src_path)
|
||||||
|
|
||||||
# Populate placeholders in content if content-rendering is enabled.
|
# Populate placeholders in content if content-rendering is enabled.
|
||||||
if page_params.get('render') == 'yes':
|
if page_params.get('render') == 'yes':
|
||||||
rendered_content = render(page_params['content'], **page_params)
|
rendered_content = render(page_params['content'], **page_params)
|
||||||
@ -236,7 +270,7 @@ def main():
|
|||||||
if os.path.isfile(params_file):
|
if os.path.isfile(params_file):
|
||||||
params.update(**json.loads(fread(params_file)))
|
params.update(**json.loads(fread(params_file)))
|
||||||
|
|
||||||
for variable in options.variables:
|
for variable in (options.variables or []):
|
||||||
key, val = variable.split('=')
|
key, val = variable.split('=')
|
||||||
params[key] = val
|
params[key] = val
|
||||||
|
|
||||||
@ -267,7 +301,7 @@ def main():
|
|||||||
|
|
||||||
# Create blog list pages.
|
# Create blog list pages.
|
||||||
make_list(blog_posts, '_site/index.html',
|
make_list(blog_posts, '_site/index.html',
|
||||||
list_layout, item_layout, blog='blog', **params)
|
list_layout, item_layout, blog='blog', title=params["blog_title"], description=params["blog_description"], **params)
|
||||||
|
|
||||||
if options.rss:
|
if options.rss:
|
||||||
feed_xml = fread('layout/feed.xml')
|
feed_xml = fread('layout/feed.xml')
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
|
28
pkgs/shared-assets.nix
Normal file
28
pkgs/shared-assets.nix
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
lib, stdenv
|
||||||
|
, python3 # for makesite.py and pgp-sign.py
|
||||||
|
}:
|
||||||
|
|
||||||
|
stdenv.mkDerivation {
|
||||||
|
pname = "shared-assets";
|
||||||
|
version = "202205120-01";
|
||||||
|
|
||||||
|
src = ../.;
|
||||||
|
|
||||||
|
propagatedBuildInputs = [ python3 python3.pkgs.markdown ];
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out/bin
|
||||||
|
cp -v makesite.py pgp-sign.py $out/bin
|
||||||
|
cp -vr assets/ $out/
|
||||||
|
'';
|
||||||
|
|
||||||
|
doCheck = false;
|
||||||
|
|
||||||
|
meta = with lib; {
|
||||||
|
description = "Shared assets for polynom.me web pages";
|
||||||
|
homepage = "https://git.polynom.me/polynom.me/shared-assets";
|
||||||
|
maintainers = [];
|
||||||
|
license = licenses.gpl3;
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user