From 0d2af3e2181165298efa5661301861b2e889b36f Mon Sep 17 00:00:00 2001 From: Lynne Date: Wed, 4 Mar 2020 00:14:16 +1000 Subject: [PATCH] added recipe difficulty tag --- README.md | 4 ++++ _includes/difficulty_stars.html | 22 ++++++++++++++++++++++ _layouts/recipe.html | 3 ++- assets/fonts/stars.woff | Bin 0 -> 3088 bytes assets/fonts/stars.woff2 | Bin 0 -> 2436 bytes assets/style.css | 9 +++++++++ 6 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 _includes/difficulty_stars.html create mode 100644 assets/fonts/stars.woff create mode 100644 assets/fonts/stars.woff2 diff --git a/README.md b/README.md index dad0915..fce10ec 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ Here's an example recipe, which could be saved to `_recipes/chocolate_cake.md`: --- name: Chocolate cake author: Jane Crocker +difficulty: 2 ingredients: - [1, egg, null] @@ -47,6 +48,7 @@ time: 240 ``` - `name` (string) - The displayed name of the recipe. Does not appear in the URL. - `author` (string, optional) - The author of the recipe. +- `difficulty` (float, optional) - The difficulty of the recipe on a scale of 1 to 5. Will be displayed as a star rating. Half stars (e.g. "2.5") are allowed. - `ingredients` (list) - Each entry in `ingredients` is an array consisting of up to four items: - amount (number or array) - The amount of this item to add, e.g. `2` for 2 cups of flour. - If this is `0`, the output will be e.g. "jalepeño chillis to taste" rather than "0 jalepeño chillis". @@ -94,6 +96,8 @@ The entries in `parents` refer to the filenames of the parent recipes - `chocola If a subrecipe does not have at least one valid `parents` entry, it will not appear anywhere on the website. ## Licensing +This software makes use of a subset of Font Awesome v4.7.0, which is licensed under the [SIL](https://scripts.sil.org/OFL_web). + This software is licensed under the [Apache 2.0 license](https://choosealicense.com/licenses/apache-2.0/). Copyright 2020 Lynnesbian diff --git a/_includes/difficulty_stars.html b/_includes/difficulty_stars.html new file mode 100644 index 0000000..6de745f --- /dev/null +++ b/_includes/difficulty_stars.html @@ -0,0 +1,22 @@ +{%- if page.difficulty < 6 and page.difficulty > 0 -%} + {%- comment -%} note: these characters are invalid unicode. they will only render properly on the webpage using the bundled "stars" font. {%- endcomment -%} + {%- assign empty_star ="" -%} + {%- assign full_star = "" -%} + {%- assign half_star = "" -%} + + {%- comment -%} build a string of empty stars {%- endcomment -%} + {%- assign difficulty = "" -%} + {%- for i in (1..5) -%} + {%- assign difficulty = difficulty | append: empty_star -%} + {%- endfor -%} + {%- comment -%} replace the first page.difficulty stars will filled stars {%- endcomment -%} + {%- assign page_difficulty_rounded = page.difficulty | floor -%} + {%- for i in (1..page_difficulty_rounded) -%} + {%- assign difficulty = difficulty | replace_first: empty_star, full_star -%} + {%- endfor -%} + {%- if page.difficulty != page_difficulty_rounded -%} + {%- comment -%} difficulty ends in .5 (or .1, or .9, or whatever) {%- endcomment -%} + {%- assign difficulty = difficulty | replace_first: empty_star, half_star -%} + {%- endif -%} + {{ difficulty }} +{%- endif -%} diff --git a/_layouts/recipe.html b/_layouts/recipe.html index dab63da..485530a 100644 --- a/_layouts/recipe.html +++ b/_layouts/recipe.html @@ -29,7 +29,8 @@ layout: default {%- assign time = page.time %} {%- endif -%} {%- endif -%} -

{{ page.method.size }} steps - Estimated cooking time: {{ time | default: "Not provided" }} {% if page.author %} - By {{ page.author }} {% endif %}

+ +

{% if page.difficulty %}Difficulty: {% include difficulty_stars.html %} - {% endif %}{{ page.method.size }} steps - Estimated cooking time: {{ time | default: "Not provided" }} {% if page.author %} - By {{ page.author }} {% endif %}

{%- if applicable_subrecipes %}

Subrecipes

{% for subrecipe in site.subrecipes -%} diff --git a/assets/fonts/stars.woff b/assets/fonts/stars.woff new file mode 100644 index 0000000000000000000000000000000000000000..c79c54a195af94dea9f821b8f64ef75f7262405d GIT binary patch literal 3088 zcmY*bc{o&W8$M&kSY|9)$C6|h!;q{=_BA^ZnaxaO?7JpQ_N6Q#ge(<`qLqpaku_vZ zMD`IOTS@tj-|zeW_}=Tf&w20r+1|5U*Ykv085sc(09;5;faCDa%kwWk-2eYFwsX(} z0EiQ)YJsp9O_hwWvQtz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|7= zf~5@R)j1lzWIDHZ$rmsi3*<<_D~yXgI_BAKDq&GasPfS%`}c7#aW} C&YJT8 literal 0 HcmV?d00001 diff --git a/assets/style.css b/assets/style.css index f0464c6..4d32097 100644 --- a/assets/style.css +++ b/assets/style.css @@ -46,6 +46,10 @@ h4 { margin: 0.75em 0; } +.stars { + font-family: 'stars'; +} + .ingredients li.optional::before { content: "(Optional) "; font-style: italic; @@ -169,3 +173,8 @@ footer, .subtle { color: grey; font-style: italic; } + +@font-face { + font-family: 'stars'; + src: url("/assets/fonts/stars.woff") format("woff"), url("/assets/fonts/stars.woff2") format("woff2"); +}