Adds dark mode

Fix compare int-str bug
Fix empty values error
Replace sort by attribute filter with direct order_by
additional make targets
This commit is contained in:
relikd
2020-07-15 15:30:22 +02:00
parent 7a8dd41492
commit 265c865b52
10 changed files with 69 additions and 26 deletions

View File

@@ -1,32 +1,51 @@
PROJDIR := 'src' PROJDIR := src
help: help:
@echo @echo
@echo 'make clean - Removes all temporary server-build files (not ./bin)' @echo ' dev - Switch to development branch'
@echo 'make server - Start lektor server with live change updates' @echo ' dist - Switch to distribution branch'
@echo 'make build - Build deployable website into ./bin' @echo ' clean - Removes all temporary server-build files (not ./bin)'
@echo 'make deploy - Custom rsync command to sync ./bin to remote server' @echo ' plugins - Clean and rebuild plugin cache'
@echo ' clean-all - Rebuild everything (not ./bin)'
@echo @echo
@echo 'make find-links - Search for cross reference between recipes' @echo ' server - Start lektor server with live change updates'
@echo ' build - Build deployable website into ./bin'
@echo ' deploy - Custom rsync command to sync ./bin to remote server'
@echo
@echo
@echo ' find-links - Search for cross reference between recipes'
@echo @echo
# Project build & clean define switch_to
@echo Set source to $(1)
@rm $(PROJDIR)/content/recipes; ln -s $(1) $(PROJDIR)/content/recipes
endef
# Clean
dev:
$(call switch_to, '../../data/development/')
dist:
$(call switch_to, '../../data/distribution/')
clean: clean:
@cd '$(PROJDIR)' && \ @echo 'Cleaning output'
temp_path="$$(lektor project-info --output-path)" && \ @cd '$(PROJDIR)' && lektor clean --yes -v
if [[ -d "$$temp_path" ]]; then \
echo "rm -rf $$temp_path"; rm -rf "$$temp_path"; \ plugins:
fi @echo 'Cleaning plugins'
@cd '$(PROJDIR)' && lektor plugins flush-cache && lektor plugins list
clean-all: clean plugins
# Build
server: server:
@cd '$(PROJDIR)' && \ @cd '$(PROJDIR)' && lektor server
(rm content/recipes; ln -s ../../data/development/ content/recipes) && \
lektor server
build: build:
@cd '$(PROJDIR)' && \ @cd '$(PROJDIR)' && \
(rm content/recipes; ln -s ../../data/distribution/ content/recipes) && \
lektor build --output-path ../bin --buildstate-path ../build-state -f ENABLE_APPCACHE lektor build --output-path ../bin --buildstate-path ../build-state -f ENABLE_APPCACHE
deploy: deploy:

View File

@@ -23,11 +23,11 @@ Install
1. Download [Lektor](https://www.getlektor.com/) and follow the instructions. 1. Download [Lektor](https://www.getlektor.com/) and follow the instructions.
2. Clone this repository and change to the `src` directory. 2. Clone this repository and change to the root directory.
3. Run `make server` to run a local server and preview the page. 3. Run `make dev server` to run a local server and preview the page.
4. For distribution run `make build` and add an [official deploy](https://www.getlektor.com/docs/deployment/). 4. For distribution run `make dist build` and add an [official deploy](https://www.getlektor.com/docs/deployment/).
### Modify ### Modify

View File

@@ -0,0 +1,17 @@
name: test empty values
---
yield:
---
ingredients:
---
directions:
---
date:
---
difficulty:
---
source:
---
tags:
---
time:

View File

@@ -2,6 +2,12 @@
--cBg1: #FAF9F7; --cBg2: #EAE9E7; --cBg3: #9A9997; --cBg1: #FAF9F7; --cBg2: #EAE9E7; --cBg3: #9A9997;
--cRed1: #DC3A59; --cRed2: #AA203A; --cRed3: #EE6A84; --cRed1: #DC3A59; --cRed2: #AA203A; --cRed3: #EE6A84;
} }
@media (prefers-color-scheme: dark) {
:root { --cTxt: #DDD;
--cBg1: #191816; --cBg2: #292725; --cBg3: #373635;
--cRed1: #B31; --cRed2: #F64; --cRed3: #FB9;
}
}
.center { text-align: center } .center { text-align: center }
.small { font-size: 0.8em } .small { font-size: 0.8em }
@@ -69,7 +75,7 @@ footer table { margin: -10px 0 }
*/ */
.tags { display: flex; flex-wrap: wrap; justify-content: center } .tags { display: flex; flex-wrap: wrap; justify-content: center }
.tags > * { .tags > * {
background: #FFF; background: var(--cBg1);
border: 1px solid var(--cRed1); border: 1px solid var(--cRed1);
border-radius: 0.3em; border-radius: 0.3em;
padding: 0.3em 0.5em; padding: 0.3em 0.5em;

View File

@@ -73,7 +73,8 @@ def group_by_time_cluster(dic, arr=[30, 60, 120], reverse=False):
except KeyError: except KeyError:
groups[key] = set() groups[key] = set()
groups[key].update(recipes) groups[key].update(recipes)
return sorted(groups.items(), reverse=bool(reverse)) return sorted(groups.items(), reverse=bool(reverse),
key=lambda x: x[0] if x[0] != '' else 999999999)
class TimeDurationPlugin(Plugin): class TimeDurationPlugin(Plugin):

View File

@@ -33,7 +33,7 @@ CACHE MANIFEST
{%- endfor -%} {%- endfor -%}
{%- endif -%} {%- endif -%}
{% set img = x.attachments.images|sort(attribute='record_label')|first -%} {% set img = x.attachments.images.order_by('record_label').first() -%}
{%- if img -%} {%- if img -%}
{{- _add_(cacheList, img.thumbnail(200, 150, 'crop')) -}} {{- _add_(cacheList, img.thumbnail(200, 150, 'crop')) -}}
{%- endif -%} {%- endif -%}

View File

@@ -2,7 +2,7 @@
<div class="tile-grid"> <div class="tile-grid">
{%- for recipe in recipes -%} {%- for recipe in recipes -%}
{%- if limit == 0 or loop.index <= limit -%} {%- if limit == 0 or loop.index <= limit -%}
{%- set img = recipe.attachments.images|sort(attribute='record_label')|first -%} {%- set img = recipe.attachments.images.order_by('record_label').first() -%}
<a href="{{ recipe|url }}">{#--#} <a href="{{ recipe|url }}">{#--#}
<div class="recipe-tile"> <div class="recipe-tile">

View File

@@ -4,7 +4,7 @@
<article class="recipe"> <article class="recipe">
<!-- date added: {{ this.date }} --> <!-- date added: {{ this.date }} -->
<section id="img-carousel" class="v-scroll center"> <section id="img-carousel" class="v-scroll center">
{%- for img in this.attachments.images|sort(attribute='record_label') %} {%- for img in this.attachments.images.order_by('record_label') %}
<img class="lozad" data-src="{{ img|url }}" height="400"> <img class="lozad" data-src="{{ img|url }}" height="400">
{%- endfor %} {%- endfor %}
</section> </section>

View File

@@ -3,6 +3,6 @@
{% block body %} {% block body %}
<h1>{{ localize(this.alt, 'title.latest') }}</h1> <h1>{{ localize(this.alt, 'title.latest') }}</h1>
<div class="latest"> <div class="latest">
{{ render_recipe_list(site.query('recipes', this.alt) | sort(attribute='date', reverse=True), limit=6) }} {{ render_recipe_list(site.query('recipes', this.alt).order_by('-date', 'name'), limit=6) }}
</div> </div>
{% endblock %} {% endblock %}