From 2b58f2589efb48f7df112a2e175ce28b52f2f8f7 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Wed, 21 Apr 2021 17:12:50 +0200 Subject: Small build script and design improvements --- assets/css/components/_project.scss | 26 +++++++++++++++---- assets/css/layouts/_project-grid.scss | 2 +- scripts/build_content.sh | 6 +---- scripts/metadata_filter.lua | 48 +++++++++++++++++------------------ 4 files changed, 47 insertions(+), 35 deletions(-) diff --git a/assets/css/components/_project.scss b/assets/css/components/_project.scss index 09dc062..62a7118 100644 --- a/assets/css/components/_project.scss +++ b/assets/css/components/_project.scss @@ -21,6 +21,19 @@ background-image: linear-gradient(340deg, rgba(#000, .25) 5em, transparent 18em); } + &:link, + &:visited { + &:hover { + @include element('picture') { + opacity: .75; + } + + @include element('card') { + transform: translateY(-1em); + } + } + } + @include multi('element' 'picture', '&::after') { display: block; position: absolute; @@ -39,18 +52,21 @@ right: 1em; bottom: 1em; min-width: 15em; + max-width: calc(100% - 2em); + transform: translateY(0); + transition: transform .2s; box-shadow: 0 .3em 1em rgba(#000, .25); } + @include element('picture') { + transition: opacity .2s; + opacity: 1; + } + @include media('<=sm') { &::after { background-image: linear-gradient(to top, rgba(#000, .25) 1em, transparent 11em); } - - @include element('card') { - width: calc(100% - 2em); - min-width: 0; - } } } } diff --git a/assets/css/layouts/_project-grid.scss b/assets/css/layouts/_project-grid.scss index 612d857..7c67663 100644 --- a/assets/css/layouts/_project-grid.scss +++ b/assets/css/layouts/_project-grid.scss @@ -1,7 +1,7 @@ @include namespace('project-grid') { @include store(( --dims: ( - --col-width: 26em + --col-width: 20em ) )); diff --git a/scripts/build_content.sh b/scripts/build_content.sh index 154a93f..3e4d512 100755 --- a/scripts/build_content.sh +++ b/scripts/build_content.sh @@ -30,7 +30,6 @@ get_metadata() { -f markdown \ -t plain \ --metadata content_dir="$CONTENT_DIR" \ - --metadata output_dir="$OUTPUT_DIR" \ --metadata file_in="$1" \ --metadata relative_to="$2" \ --metadata-file metadata/metadata.yaml \ @@ -44,7 +43,6 @@ get_content() { -f markdown \ -t markdown \ --metadata content_dir="$CONTENT_DIR" \ - --metadata output_dir="$OUTPUT_DIR" \ --metadata file_in="$1" \ --metadata-file metadata/metadata.yaml \ --no-highlight \ @@ -103,6 +101,7 @@ handle () { if [ "${1#*.}" = "md" ]; then local included_metadata=$(get_metadata "$1") local file_out=$(echo "$included_metadata" | jq -r .file_out) + file_out="$OUTPUT_DIR${file_out#/}" local create_feed=$(echo "$included_metadata" | jq -r .create_feed) mkdir -p $(dirname "$file_out") @@ -127,7 +126,6 @@ handle () { --template "${TEMPLATES_DIR}feed.xml" \ -o "${file_out%.html}.xml" \ --metadata content_dir="$CONTENT_DIR" \ - --metadata output_dir="$OUTPUT_DIR" \ --metadata file_in="$1" \ --metadata page_type=feed \ --metadata-file metadata/metadata.yaml \ @@ -144,7 +142,6 @@ handle () { --template "${TEMPLATES_DIR}base.html" \ -o "$file_out" \ --metadata content_dir="$CONTENT_DIR" \ - --metadata output_dir="$OUTPUT_DIR" \ --metadata file_in="$1" \ --metadata-file metadata/metadata.yaml \ --metadata-file "$meta_file" \ @@ -157,7 +154,6 @@ handle () { # --no-highlight \ # --template scripts/metadata_tpl.json \ # --metadata content_dir="$CONTENT_DIR" \ - # --metadata output_dir="$OUTPUT_DIR" \ # --metadata file_in="$1" \ # --metadata-file metadata/metadata.yaml \ # --metadata-file "$meta_file" \ diff --git a/scripts/metadata_filter.lua b/scripts/metadata_filter.lua index 21698bd..ad2bb83 100644 --- a/scripts/metadata_filter.lua +++ b/scripts/metadata_filter.lua @@ -101,7 +101,7 @@ function apply_path_rewrites(rewrites, str) return str end -function get_file_out(rewrites, content_dir, output_dir, file_in) +function get_file_out(rewrites, content_dir, file_in) local file_out = file_in:gsub("^" .. content_dir, ""):gsub("%.md$", ".html") if file_out:match(".html$") and not file_out:match("/index%.html$") then @@ -110,15 +110,21 @@ function get_file_out(rewrites, content_dir, output_dir, file_in) file_out = apply_path_rewrites(rewrites, file_out) - return pandoc.MetaString(output_dir .. file_out) + return pandoc.MetaString(file_out) end -function resolve_url(site_url, output_dir, ref_file, target_file) +function make_absolute(rel, base) + return + rel:find("^/") ~= nil and rel or base:gsub("^(.*)/.-$", "%1") .. "/" .. + rel +end + +function resolve_url(site_url, ref_file, target_file) + target_file = target_file:gsub("/index%.html$", "/") + local ref_base_dir = ref_file:gsub("^(.*)/.-$", "%1") - local abs = target_file:gsub("^" .. output_dir, ""):gsub("/index%.html$", - "/") - local rel = - relative_to(ref_base_dir, target_file):gsub("/index%.html$", "/") + local abs = target_file + local rel = relative_to(ref_base_dir, abs):gsub("/index%.html$", "/") return pandoc.MetaMap({ abs = pandoc.MetaString(abs), @@ -176,10 +182,10 @@ function prep_main_menu(rewrites, section, main_menu) }) end -function organize_subpages(site_url, output_dir, ref_file, pages) +function organize_subpages(site_url, ref_file, pages) for i = 1, #pages do local page = pages[i] - page.url = resolve_url(site_url, output_dir, ref_file, + page.url = resolve_url(site_url, ref_file, pandoc.utils.stringify(page.file_out)) end @@ -250,7 +256,6 @@ end function Meta(meta) meta.content_dir = meta.content_dir:gsub("/$", "") - meta.output_dir = meta.output_dir:gsub("/$", "") meta.site.url = pandoc.utils.stringify(meta.site.url):gsub("/$", "") meta.rewrites = meta.rewrites or pandoc.MetaMap({path = pandoc.MetaList({})}) @@ -258,19 +263,17 @@ function Meta(meta) meta.layout = resolve_layout(meta.layout) meta.section = resolve_section(meta.content_dir, meta.file_in) - meta.file_out = get_file_out(meta.rewrites, meta.content_dir, - meta.output_dir, meta.file_in) + meta.file_out = get_file_out(meta.rewrites, meta.content_dir, meta.file_in) if meta.relative_to == nil then meta.relative_to = meta.file_in end meta.relative_to_out = get_file_out(meta.rewrites, meta.content_dir, - meta.output_dir, meta.relative_to) + meta.relative_to) - meta.url = resolve_url(meta.site.url, meta.output_dir, meta.relative_to_out, - meta.file_out) + meta.url = resolve_url(meta.site.url, meta.relative_to_out, meta.file_out) if meta.preview ~= nil then - meta.preview = pandoc.utils.stringify(meta.preview) - meta.preview = meta.file_out:gsub("/index%.html$", "/" .. meta.preview) - meta.preview = resolve_url(meta.site.url, meta.output_dir, - meta.relative_to_out, meta.preview) + meta.preview = resolve_url(meta.site.url, meta.relative_to_out, + make_absolute( + pandoc.utils.stringify(meta.preview), + meta.file_out)) end meta.date = format_date(meta.date) @@ -286,16 +289,14 @@ function Meta(meta) if meta.page_type == "feed" then meta.page = pandoc.MetaMap({ - url = resolve_url(meta.site.url, meta.output_dir, - meta.relative_to_out, + url = resolve_url(meta.site.url, meta.relative_to_out, meta.file_out:gsub("%.xml$", ".html")) }) end if meta.create_feed then meta.feed = pandoc.MetaMap({ - url = resolve_url(meta.site.url, meta.output_dir, - meta.relative_to_out, + url = resolve_url(meta.site.url, meta.relative_to_out, meta.file_out:gsub("%.html$", ".xml")) }) end @@ -307,7 +308,6 @@ function Meta(meta) if meta.pages then local pages, categories = organize_subpages(meta.site.url, - meta.output_dir, meta.relative_to_out, meta.pages) meta.pages = pages -- cgit v1.2.3-70-g09d2