From 47f16f0e30b9735a40dbb746550318a0e44c25a7 Mon Sep 17 00:00:00 2001 From: "Elf M. Sternberg" Date: Fri, 29 Apr 2022 11:03:21 -0700 Subject: [PATCH] Making much progress. --- README.md | 21 +++++- TODO.org | 7 ++ content/docs/git/_index.md | 90 +++++++++++++++++++++++ content/docs/zola-cookbook/_index.md | 67 +++++++++++++++++ content/docs/zola/_index.md | 2 + content/docs/zola/predicates.json | 40 ++++++++++ content/docs/zola/predicates.yaml | 52 +++++++++++++ templates/macros/definition_body.html | 9 +++ templates/shortcodes/definition_list.html | 5 ++ 9 files changed, 292 insertions(+), 1 deletion(-) create mode 100644 TODO.org create mode 100644 content/docs/git/_index.md create mode 100644 content/docs/zola-cookbook/_index.md create mode 100644 content/docs/zola/predicates.json create mode 100644 content/docs/zola/predicates.yaml create mode 100644 templates/macros/definition_body.html create mode 100644 templates/shortcodes/definition_list.html diff --git a/README.md b/README.md index 18247fd..1db2c3e 100644 --- a/README.md +++ b/README.md @@ -25,33 +25,50 @@ Zola itself. Eventually, though, I'm going to add whatever scraps I have lying around for some, perhaps most, of the following topics, since I've worked in all of them: +- .NET compilation chain +- Aloq - Apache Configuration +- Assembly +- Audio & Music production - Bash - Bash Customization - C - C++ - CMake - Clojure +- Cobol - Django - ESlint - Emacs - F# - Git & Pre-Commit - Go +- Graphic design +- HAML - HTML & CSS +- Handbrake Cookbook - Haskell +- ID3V2 +- Imagemagick - Javascript +- Kanren +- Kubernetes - Linux Administration - Linux Software Development - Lisp - Lit-HTML +- Machine learning - Makefiles - Markdown +- Mate / Gnome customization - Nginx Configuration -- Org-mode +- Org mode +- PHP +- PNM Suite - Perl - Podman - Prettier +- Prolog - Python - Rails - React @@ -61,8 +78,10 @@ of them: - SQL - Sass - Scheme +- Snobol - Typescript - Vite +- Wasm - Web Components - X86 Assembly - XCB / X11 Systems Programming diff --git a/TODO.org b/TODO.org new file mode 100644 index 0000000..026eaa4 --- /dev/null +++ b/TODO.org @@ -0,0 +1,7 @@ +* Organization +** TODO Figure out weight/taxonomy scheme for home page. +** TODO Implement multiple cards +** TODO Sidebar - what navigation should be in sidebar? +** TODO Menu - Megamenu on other pages, but always link back to home +*** Check out Asana's nifty morph in their mobile transition; looks like pure CSS + diff --git a/content/docs/git/_index.md b/content/docs/git/_index.md new file mode 100644 index 0000000..66eb2ae --- /dev/null +++ b/content/docs/git/_index.md @@ -0,0 +1,90 @@ ++++ +title = "Git Notes" +description = "Basic documentation of Git" +date = 2022-04-27T18:00:00+00:00 +updated = 2022-04-27T18:00:00+00:00 +template = "docs/section.html" +sort_by = "weight" +weight = 6 +draft = false +[taxonomies] +documentation=["Reference"] +categories=["Git", "Version Control", "VCS"] ++++ + +[Git](https://git-scm.com/) is the most widely used version control system (or +source configuration management) tool. Pretty much everything I do uses Git. +This is where I keep my notes on how to do things. + +## Starting a project + +Git is project and folder-centered, and to start using git go to the root folder +of a project you want to place under source control and initialize it: + +```shell +$ mkdir a-new-project +$ git init +``` + +This creates a new folder, `.git`, where Git will store your commit history and +some configuration details. + +## Putting files into git + +To put files under source control, you must add them. To update the entire +folder, switch to the root of the project and add _all_ of it: + +```shell +$ git add . +$ git commit +``` + +An editor will pop-up, asking you what this commit is about. It's generally +polite, especially if you're working in a team, to explain your commit in some +detail-- and to generally keep the commit small, in order to ensure that you +don't have to explain too much! + +If your commit message could be a single line, you can add it directly from the +command line: + +```shell +$ git add . +$ git commit -m "Updated the widget to widgetize." +``` + +... and you can even combine both commands, but be careful: this command will +not add any files that are new. It will only commit existing files that have +been modified, and will delete any files that you have deleted, from the +repository. (Deleted files still exist in the history and can always be +recovered.) + +```shell +$ git commit -am "Updated the widget to widgetize." +``` + +## Git Configuration + +You can have a global Git configuration file, `$HOME/\.gitconfig`, in which you +keep your personal information and command aliases, which is one of three ways +you can add your own commands to Git. + +```shell +[user] + name = Elf M. Sternberg + email = someguy@example.com + +[alias] + unstage = reset -q HEAD -- + nevermind = !git reset --hard HEAD && git clean -d -f + wip = for-each-ref --sort='authordate:iso8601' --format='%(color:green)%(authordate:relative)%09%(color:white)%(refname:short)' refs/heads + stem = "!f() { git checkout -b $1 master; }; f" + start = !git init && git commit --allow-empty -m \"Initial commit\" +``` + +I'll explain each of these eventually, but for now, just know that if you want +your commits to be attributed to the right person, you must have the `[user]` +block, and + + + + diff --git a/content/docs/zola-cookbook/_index.md b/content/docs/zola-cookbook/_index.md new file mode 100644 index 0000000..2177a31 --- /dev/null +++ b/content/docs/zola-cookbook/_index.md @@ -0,0 +1,67 @@ ++++ +title = "Zola Cookbook" +description = "Snippets I've developed that I want to keep" +date = 2022-04-27T18:00:00+00:00 +updated = 2022-04-27T18:00:00+00:00 +template = "docs/section.html" +sort_by = "weight" +weight = 5 +draft = false +[taxonomies] +documentation=["Reference"] +categories=["Web Development", "Static Site Generation", "Zola"] ++++ + +[Zola](../zola) is the static site generator I use for most of my websites that +don't require much dynamic functionality. + +## Generating Nested Lists from Data + +Example data: + +```html +{ + "definitions": [ + { "dt": "undefined", "dd": " the thing is undefined." }, + { "dt": "defined", "dd": " the thing is defined.", definitions: [ + { "dt": "truthy", "dd": "the defined thing is truthy" }, + { "dt": "falsy", "dd": "the defined thing is falsy" } + ]} + ] +} +``` + +Tera macro to render a nested list: + +``` +{% macro definition_body(source) %} +
+ {% for entry in source %} +
{{ entry.dt | safe }}
+
+ {{ entry.dd | safe }} + {% if entry.definitions %} + {{ self::definition_body(source=entry.definitions) }} + {% endif %} +
+ {% endfor %} +
+{% endmacro %} +``` + +Zola shortcode to import the macro template into Markdown and start the render: + +``` +{%- import 'macros/definition_body.html' as renderer -%} +
+ {% set content = load_data(path=source) %} + {{ renderer::definition_body(source=content.definitions) }} +
+``` + +Invocation in Markdown file, providing the data source: + +``` +{‎{ definition_list(source="@/docs/zola/definitions.json") }} +``` + diff --git a/content/docs/zola/_index.md b/content/docs/zola/_index.md index 393db8f..5b9596a 100644 --- a/content/docs/zola/_index.md +++ b/content/docs/zola/_index.md @@ -107,6 +107,8 @@ Conditional statements are managed with `if/is ... else ... endif` The list of `is` tests that are shipped with Zola are: +{{ definition_list(source="@/docs/zola/predicates.yaml") }} + - `defined`: the given variable is defined. - `undefined`: the given variable is undefined. - `odd`: the given variable is an odd number. diff --git a/content/docs/zola/predicates.json b/content/docs/zola/predicates.json new file mode 100644 index 0000000..48ef20d --- /dev/null +++ b/content/docs/zola/predicates.json @@ -0,0 +1,40 @@ +{ + "definitions": [ + { "dt": "defined", "dd": " the given variable is defined." }, + { "dt": "undefined", "dd": " the given variable is undefined." }, + { "dt": "odd", "dd": " the given variable is an odd number." }, + { "dt": "even", "dd": " the given variable is an even number." }, + { "dt": "string", "dd": " the given variable is a string." }, + { "dt": "number", "dd": " the given variable is a number." }, + { "dt": "divisibleby", "dd": " the given expression is divisible by the arg given." }, + { + "dt": "iterable", + "dd": " Returns true if the given variable can be iterated over in Tera (i.e. is an array/tuple or an object)." + }, + { + "dt": "object", + "dd": " Returns true if the given variable is an object (i.e. can be iterated over key, value)." + }, + { + "dt": "starting_with(string)", + "dd": " Returns true if the given variable is a string and starts with the arg given." + }, + { + "dt": "ending_with(string)", + "dd": " Returns true if the given variable is a string and ends with the arg given." + }, + { + "dt": "containing(val)", + "dd": " Returns true if the given variable contains the arg given.", + "definitions": [ + { "dt": "strings", "dd": " is the arg a substring?" }, + { "dt": "arrays", "dd": " is the arg one of the members of the array?" }, + { "dt": "maps", "dd": " is the arg a key of the map?" } + ] + }, + { + "dt": "matching(regexp)", + "dd": " Returns true if the given variable is a string and matches the regex in the argument." + } + ] +} diff --git a/content/docs/zola/predicates.yaml b/content/docs/zola/predicates.yaml new file mode 100644 index 0000000..922d01d --- /dev/null +++ b/content/docs/zola/predicates.yaml @@ -0,0 +1,52 @@ +--- + definitions: + - + dt: "defined" + dd: " the given variable is defined." + - + dt: "undefined" + dd: " the given variable is undefined." + - + dt: "odd" + dd: " the given variable is an odd number." + - + dt: "even" + dd: " the given variable is an even number." + - + dt: "string" + dd: " the given variable is a string." + - + dt: "number" + dd: " the given variable is a number." + - + dt: "divisibleby" + dd: " the given expression is divisible by the arg given." + - + dt: "iterable" + dd: " Returns true if the given variable can be iterated over in Tera (i.e. is an array/tuple or an object)." + - + dt: "object" + dd: " Returns true if the given variable is an object (i.e. can be iterated over key, value)." + - + dt: "starting_with(string)" + dd: " Returns true if the given variable is a string and starts with the arg given." + - + dt: "ending_with(string)" + dd: " Returns true if the given variable is a string and ends with the arg given." + - + dt: "containing(val)" + dd: " Returns true if the given variable contains the arg given." + definitions: + - + dt: "strings" + dd: " is the arg a substring?" + - + dt: "arrays" + dd: " is the arg one of the members of the array?" + - + dt: "maps" + dd: " is the arg a key of the map?" + - + dt: "matching(regexp)" + dd: " Returns true if the given variable is a string and matches the regex in the argument." + diff --git a/templates/macros/definition_body.html b/templates/macros/definition_body.html new file mode 100644 index 0000000..a8ef1f0 --- /dev/null +++ b/templates/macros/definition_body.html @@ -0,0 +1,9 @@ +{% macro definition_body(source) %} +
+{% for entry in source %} +
{{ entry.dt | safe }}
+
{{ entry.dd | safe }}
+{% if entry.definitions %}{{ self::definition_body(source=entry.definitions) }}{% endif %} +{% endfor %} +
+{% endmacro %} diff --git a/templates/shortcodes/definition_list.html b/templates/shortcodes/definition_list.html new file mode 100644 index 0000000..ff9b7a2 --- /dev/null +++ b/templates/shortcodes/definition_list.html @@ -0,0 +1,5 @@ +{%- import 'macros/definition_body.html' as renderer -%} +
+{% set content = load_data(path=source) %} +{{ renderer::definition_body(source=content.definitions) }} +