From a0846b387a75009d2ccbbb96def56f6874b8a33e Mon Sep 17 00:00:00 2001 From: Yax <1949284+kianby@users.noreply.github.com> Date: Tue, 19 Jul 2022 19:02:25 +0200 Subject: [PATCH] add notes --- README.md | 2 +- content/_index.html | 28 --------- content/about.html | 23 -------- content/contact.html | 21 ------- layout/note.html | 3 + layout/page.html | 1 + makesite.py | 56 ++++++++++++++++++ notes/git.md | 136 +++++++++++++++++++++++++++++++++++++++++++ poetry.lock | 59 +++++++------------ 9 files changed, 219 insertions(+), 110 deletions(-) delete mode 100644 content/_index.html delete mode 100644 content/about.html delete mode 100644 content/contact.html create mode 100644 layout/note.html create mode 100644 notes/git.md diff --git a/README.md b/README.md index 031b2ff..e13562c 100755 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Blog du Yax -This blog is built on excellent work performed by fspaolo with [Makesite.py](https://github.com/fspaolo/makesite). +This blog is built on top of the great work performed by fspaolo on [Makesite.py](https://github.com/fspaolo/makesite). I cut some features and wristed the code to focus on blog posts and support my [commenting system](https://github.com/kianby/stacosys). You should check fspaolo's repository to really understand Makesite.py's philosophy and find technical details. This static blog generator code is under MIT license. diff --git a/content/_index.html b/content/_index.html deleted file mode 100644 index 8cc489a..0000000 --- a/content/_index.html +++ /dev/null @@ -1,28 +0,0 @@ - - -

Lorem Ipsum

-

-Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc nibh -tellus, vehicula ut maximus sed, fringilla a justo. Nunc vitae efficitur -nisl. Ut sapien erat, pretium et commodo nec, rutrum bibendum magna. Sed -ut massa massa. Etiam euismod neque lacus, id tincidunt risus iaculis a. -Aliquam porta venenatis bibendum. Nam id varius nulla. Sed vitae purus -ac odio ornare vestibulum vitae tempor arcu. Nunc non venenatis purus. -Duis a augue at nulla congue egestas. Morbi mattis felis sit amet tortor -euismod, fringilla viverra est elementum. -

-

-Suspendisse vestibulum sed massa eu tincidunt. Pellentesque cursus, nisl -at gravida suscipit, odio quam placerat mi, in iaculis nunc risus eu -sapien. Suspendisse potenti. Nullam fermentum, tellus vel faucibus -dictum, arcu ante rutrum nisi, ut iaculis eros felis a lectus. Etiam vel -maximus nulla, sed mattis lectus. Aliquam commodo est massa, at -vestibulum diam commodo vehicula. Nullam et tristique tortor. Praesent -luctus, leo id mattis mattis, ex dui dapibus dolor, nec ultrices turpis -nibh in sem. In efficitur, velit ut bibendum interdum, libero turpis -mattis odio, non pharetra metus leo nec arcu. Maecenas auctor laoreet -maximus. Donec metus massa, scelerisque a lacinia et, viverra eget -metus. Aenean vitae tellus vehicula, mattis metus in, facilisis purus. -In purus erat, fringilla ut diam et, convallis convallis nunc. Morbi -sagittis interdum ipsum sit amet fringilla. -

diff --git a/content/about.html b/content/about.html deleted file mode 100644 index f51d17d..0000000 --- a/content/about.html +++ /dev/null @@ -1,23 +0,0 @@ - -

About

-

-Quisque quam nisl, egestas nec convallis vitae, fringilla nec mauris. -Sed et cursus lacus, a pharetra ex. Pellentesque rhoncus malesuada elit -at sodales. In ut elit lectus. Phasellus et hendrerit odio, ac hendrerit -ante. Pellentesque habitant morbi tristique senectus et netus et -malesuada fames ac turpis egestas. Quisque sem nibh, auctor vel dictum -eu, pharetra sit amet nunc. Integer suscipit suscipit dapibus. -Suspendisse vulputate sed mauris eget tempus. Etiam rhoncus, leo nec -cursus elementum, massa lorem fermentum nisi, non convallis nisl dolor -vel ipsum. -

-

-Aliquam imperdiet vel purus sed facilisis. Mauris condimentum vel nulla -ac tempor. In non venenatis arcu. Nam in sapien purus. Suspendisse -faucibus, erat et fringilla vestibulum, ligula nisi porta odio, ut -tristique dui ante eu nisi. Mauris vitae vulputate lorem. Proin tortor -nisl, vehicula sed justo sed, volutpat bibendum purus. Phasellus luctus -fringilla augue ac sodales. Aenean ac nisi sit amet neque pulvinar -tincidunt ut nec ipsum. Aliquam purus tellus, dignissim a augue -placerat, aliquet semper turpis. Fusce id lacinia quam, vel porta quam. -

diff --git a/content/contact.html b/content/contact.html deleted file mode 100644 index f868ad9..0000000 --- a/content/contact.html +++ /dev/null @@ -1,21 +0,0 @@ - -

Contact

-

-In hac habitasse platea dictumst. Suspendisse purus leo, laoreet ac -scelerisque vitae, gravida vitae turpis. Etiam lacinia justo in pharetra -tincidunt. Donec id mi in elit euismod feugiat. Fusce eget velit nec -nunc fermentum ultrices ut auctor tellus. Suspendisse convallis lacus a -mollis volutpat. Donec maximus eros lorem, non faucibus sapien tristique -a. Proin ut magna eget nunc sagittis sodales ac suscipit dolor. -Vestibulum sit amet velit nunc. Nam euismod fermentum neque ac -facilisis. Phasellus imperdiet arcu a lorem pulvinar accumsan. Sed -maximus neque tristique, sollicitudin risus sed, interdum enim. -

-

-Curabitur vel augue mattis, blandit libero rhoncus, fringilla augue. -Aenean condimentum ex justo. In hac habitasse platea dictumst. Etiam -ullamcorper finibus enim, nec cursus dui tristique nec. Phasellus et -tortor libero. Vivamus viverra euismod pulvinar. Fusce maximus, ante -quis lobortis facilisis, lectus mi consequat purus, sed vestibulum ipsum -mi sit amet dui. -

diff --git a/layout/note.html b/layout/note.html new file mode 100644 index 0000000..f0b327c --- /dev/null +++ b/layout/note.html @@ -0,0 +1,3 @@ +
+ {{ content }} +
diff --git a/layout/page.html b/layout/page.html index e0218c9..898b559 100644 --- a/layout/page.html +++ b/layout/page.html @@ -51,6 +51,7 @@ diff --git a/makesite.py b/makesite.py index 38f005b..bd2ceaa 100755 --- a/makesite.py +++ b/makesite.py @@ -295,6 +295,41 @@ def make_posts( return sorted(items, key=lambda x: x["date"], reverse=True) +def make_notes( + src, src_pattern, dst, layout, **params +): + """Generate notes from notes directory.""" + items = [] + + for posix_path in Path(src).glob(src_pattern): + src_path = str(posix_path) + content = read_content(src_path) + + # render text / summary for basic fields + content["content"] = render(content["content"], **params) + content["summary"] = render(content["summary"], **params) + + page_params = dict(params, **content) + page_params["header"] = "" + page_params["footer"] = "" + page_params["friendly_date"] = "" + page_params["category_label"] = "" + page_params["post_url"] = "notes/" + page_params["slug"] + "/" + + content["post_url"] = page_params["post_url"] + content["friendly_date"] = page_params["friendly_date"] + content["category_label"] = page_params["category_label"] + items.append(content) + + dst_path = render(dst, **page_params) + output = render(layout, **page_params) + + log("Rendering {} => {} ...", src_path, dst_path) + fwrite(dst_path, output) + + return sorted(items, key=lambda x: x["date"], reverse=True) + + def make_list( posts, dst, list_layout, item_layout, header_layout, footer_layout, **params ): @@ -374,10 +409,12 @@ def main(param_file): rss_item_xml = fread("layout/rss_item.xml") sitemap_xml = fread("layout/sitemap.xml") sitemap_item_xml = fread("layout/sitemap_item.xml") + note_layout = fread("layout/note.html") # Combine layouts to form final layouts. post_layout = render(page_layout, content=post_layout) list_layout = render(page_layout, content=list_layout) + note_layout = render(page_layout, content=note_layout) # Create blogs. blog_posts = make_posts( @@ -503,6 +540,25 @@ def main(param_file): ) + # Create notes. + notes = make_notes( + "notes", + "**/*.md", + "_site/{{ post_url }}/index.html", + note_layout, + **params + ) + + make_list( + notes, + "_site/notes/index.html", + list_layout, + item_nosummary_layout, + archive_title_layout, + None, + **params + ) + # Test parameter to be set temporarily by unit tests. _test = None diff --git a/notes/git.md b/notes/git.md new file mode 100644 index 0000000..ba49c40 --- /dev/null +++ b/notes/git.md @@ -0,0 +1,136 @@ + + +# Git + +Pousser nouvelle branche : + + git push -u origin + +Lier branche locale à branche distante : + + git branch --set-upstream-to=origin/deployment deployment + +Fusion sans fast-forward pour préserver les commits : + + git merge --no-ff + +Créer une nouvelle branche à partir d'un commit : + + git checkout && git branch -b + +Annuler des changements : + + # committer l'annulation d'un commit : + git revert + + # restaurer l'état d'un fichier par rapport au dernier commit + git checkout -- + + # annuler le dernier commit pour un fichier particulier (n° de checkout + ~1 pour reculer d'un commit) + git checkout c5f567~1 -- file1/to/restore + +Retrouver les branches qui contiennent un commit : + + git branch --contains + +Récupérer toutes les branches localement : + + # ne pas récupérer les branches supprimées + git fetch --prune + + # créer toutes les branches + for BRANCH in $(git branch -a | grep remotes | grep -v HEAD); do git branch --track \"${BRANCH#remotes/origin/}\" \"${BRANCH}\"; done + +Rechercher dans toutes les branches : + + git grep "the magic string" `git show-ref --heads` + +La plupart des commandes peuvent être restreintes à un chemin de fichier : + + git stash push -- + git diff -- + +La gestion des stash : + + # voir le contenu d'un stash (0 est le plus récent) + git stash show -p [stash@{}] + # appliquer un stash sans le supprimer + git stash apply [stash@{}] + +Récupérer un fichier d'une autre branche : + + git checkout -- + +Travailler sur plusieurs branches à la fois (pour comparer par exemple) : + + git worktree add ../my-other-awesome-feature my-other-awesome-feature-branch + git worktree remove ../my-other-awesome-feature + +Supprimer une branche distante + + git push origin --delete + +Lister les commits manquants sur la branche release par rapport à develop + + # depuis branche release + git cherry develop + git log release..develop + # la version one-liner + git log --oneline --graph --decorate --abbrev-commit release..develop + +Créer un patch à partir d'une suite de commits consécutifs + + git format-patch cc1dde0dd^..6de6d4b06 --stdout > foo.patch + +Restaurer un fichier pendant une phase de merge + + git checkout -m FILE + +Modifier l'historique des auteurs / e-mails avec git-filter-repo + + git filter-repo --mailmap my-mailmap + + # ficher my-mailmap de la forme : + # Proper Name + +Créer un nouveau dépôt à partir de la ligne de commande + + echo "# test" >> README.md + git init + git add README.md + git commit -m "first commit" + git branch -M main + git remote add origin git@github.com:user/project.git + git push -u origin main + +Pousser un dépôt existant depuis la ligne de commande + + git remote add origin git@github.com:user/projectgit + git branch -M main + git push -u origin main + +Modifier la racine d'un dépôt + +On peut modifier la racine pour un répertoire enfant sans perdre l'historique : + +- déplacer le répertoire .git vers ce répertoire enfant +- ajouter tous les fichiers modifiés (git add) ce qui renomme les fichiers existants +- committer et pousser + +Transformer un id long de commit en id court + + git rev-parse --short d40f13c5886a8f44e7653f68829dd094045a5499 + +# GitHub + +Générer un Personal Access Token pour les accès HTTPS + + git config --global credential.https://github.com.helper cache + + git credential approve <=2.0.0,<2.1.0", markers = "python_version >= \"3\""} -idna = {version = ">=2.5,<4", markers = "python_version >= \"3\""} +charset-normalizer = ">=2,<3" +idna = ">=2.5,<4" urllib3 = ">=1.21.1,<1.27" [package.extras] -socks = ["PySocks (>=1.5.6,!=1.5.7)", "win-inet-pton"] -use_chardet_on_py3 = ["chardet (>=3.0.2,<5)"] +socks = ["PySocks (>=1.5.6,!=1.5.7)"] +use_chardet_on_py3 = ["chardet (>=3.0.2,<6)"] [[package]] name = "urllib3" -version = "1.26.8" +version = "1.26.10" description = "HTTP library with thread-safe connection pooling, file post, and more." category = "main" optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4" +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, <4" [package.extras] -brotli = ["brotlipy (>=0.6.0)"] +brotli = ["brotlicffi (>=0.8.0)", "brotli (>=1.0.9)", "brotlipy (>=0.6.0)"] secure = ["pyOpenSSL (>=0.14)", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "certifi", "ipaddress"] socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"] [metadata] lock-version = "1.1" -python-versions = "^3.9" -content-hash = "b3549c90bfc38d7a2afe0ca851eb4476175964767e68c6d101067b7e0dd3e92c" +python-versions = "^3.8" +content-hash = "77e6f4dcedb219aa6f4d4ab99393659aad46c1a2612778c23a96f665bc027389" [metadata.files] -certifi = [ - {file = "certifi-2021.10.8-py2.py3-none-any.whl", hash = "sha256:d62a0163eb4c2344ac042ab2bdf75399a71a2d8c7d47eac2e2ee91b9d6339569"}, - {file = "certifi-2021.10.8.tar.gz", hash = "sha256:78884e7c1d4b00ce3cea67b44566851c4343c120abd683433ce934a68ea58872"}, -] -charset-normalizer = [ - {file = "charset-normalizer-2.0.12.tar.gz", hash = "sha256:2857e29ff0d34db842cd7ca3230549d1a697f96ee6d3fb071cfa6c7393832597"}, - {file = "charset_normalizer-2.0.12-py3-none-any.whl", hash = "sha256:6881edbebdb17b39b4eaaa821b438bf6eddffb4468cf344f09f89def34a8b1df"}, -] +certifi = [] +charset-normalizer = [] idna = [ {file = "idna-3.3-py3-none-any.whl", hash = "sha256:84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff"}, {file = "idna-3.3.tar.gz", hash = "sha256:9d643ff0a55b762d5cdb124b8eaa99c66322e2157b69160bc32796e824360e6d"}, @@ -94,15 +88,6 @@ mistune = [ {file = "mistune-0.8.4-py2.py3-none-any.whl", hash = "sha256:88a1051873018da288eee8538d476dffe1262495144b33ecb586c4ab266bb8d4"}, {file = "mistune-0.8.4.tar.gz", hash = "sha256:59a3429db53c50b5c6bcc8a07f8848cb00d7dc8bdb431a4ab41920d201d4756e"}, ] -pygments = [ - {file = "Pygments-2.11.2-py3-none-any.whl", hash = "sha256:44238f1b60a76d78fc8ca0528ee429702aae011c265fe6a8dd8b63049ae41c65"}, - {file = "Pygments-2.11.2.tar.gz", hash = "sha256:4e426f72023d88d03b2fa258de560726ce890ff3b630f88c21cbb8b2503b8c6a"}, -] -requests = [ - {file = "requests-2.27.1-py2.py3-none-any.whl", hash = "sha256:f22fa1e554c9ddfd16e6e41ac79759e17be9e492b3587efa038054674760e72d"}, - {file = "requests-2.27.1.tar.gz", hash = "sha256:68d7c56fd5a8999887728ef304a6d12edc7be74f1cfa47714fc8b414525c9a61"}, -] -urllib3 = [ - {file = "urllib3-1.26.8-py2.py3-none-any.whl", hash = "sha256:000ca7f471a233c2251c6c7023ee85305721bfdf18621ebff4fd17a8653427ed"}, - {file = "urllib3-1.26.8.tar.gz", hash = "sha256:0e7c33d9a63e7ddfcb86780aac87befc2fbddf46c58dbb487e0855f7ceec283c"}, -] +pygments = [] +requests = [] +urllib3 = []