diff --git a/edit_script/edit_entry.ipynb b/edit_script/edit_entry.ipynb index 72115ff..47aa384 100644 --- a/edit_script/edit_entry.ipynb +++ b/edit_script/edit_entry.ipynb @@ -2,118 +2,107 @@ "cells": [ { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "id": "090c7992", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - " im still struggling:\n", - "

\n", - "

sudo pacman -S archlinux-keyring

\n", - "

melange:

\n", - " \n", - "\n", - "Post 3 updated successfully.\n" - ] - } - ], + "outputs": [], "source": [ - "import datetime\n", - "\n", + "# git entry and print\n", "def get_entry(file_path, id):\n", - "\n", " # 1. Import the current list to get the latest ID\n", - "\n", - " # We use a namespace to avoid path issues\n", - "\n", + " # use a namespace to avoid path issues\n", " namespace = {}\n", "\n", - " with open(file_path, 'r') as f:\n", - "\n", + " with open(file_path, \"r\") as f:\n", " exec(f.read(), namespace)\n", "\n", - " posts = namespace.get('BLOG_POSTS', [])\n", + " posts = namespace.get(\"BLOG_POSTS\", [])\n", "\n", " for items in posts:\n", - "\n", " if items.get(\"id\") == id:\n", - "\n", - " content = items.get('content')\n", - "\n", + " content = items.get(\"content\")\n", " print(content)\n", - "\n", - " return items \n", - "\n", + " return items\n", "\n", "\n", "def update_entry(file_path, post_id, new_content):\n", " # 1. Load the existing data into memory\n", " namespace = {}\n", - " with open(file_path, 'r') as f:\n", + " with open(file_path, \"r\") as f:\n", " exec(f.read(), namespace)\n", - " \n", - " posts = namespace.get('BLOG_POSTS', [])\n", - " \n", + "\n", + " posts = namespace.get(\"BLOG_POSTS\", [])\n", + "\n", " # 2. Find and update the specific post\n", " found = False\n", " for post in posts:\n", " if post.get(\"id\") == post_id:\n", - " post['content'] = new_content\n", + " post[\"content\"] = new_content\n", " # Optional: Update the date or add an \"updated\" field\n", - " # post['subtitle'] += \" (Updated)\" \n", + " # post['subtitle'] += \" (Updated)\"\n", " found = True\n", " break\n", - " \n", + "\n", " if not found:\n", " print(f\"Error: Post {post_id} not found.\")\n", " return\n", "\n", " # 3. Write the entire list back to the file\n", " # Using repr() or a loop to format it cleanly\n", - " with open(file_path, 'w') as f:\n", + " with open(file_path, \"w\") as f:\n", " f.write(\"BLOG_POSTS = [\\n\")\n", " for p in posts:\n", - " # Use .get() to provide a default value if the key is missing\n", - " display_val = p.get('displayall', False) \n", - " data_val = p.get('date', \"?\") \n", - " subtitle_val = p.get('subtitle', \"\") \n", - " \n", - " entry = f\"\"\" {{\n", - " 'id': {p['id']},\n", - " 'title': \"{p['title']}\",\n", + " # Use .get() to provide a default value if the key is missing\n", + " display_val = p.get(\"displayall\", False)\n", + " data_val = p.get(\"date\", \"?\")\n", + " subtitle_val = p.get(\"subtitle\", \"\")\n", + "\n", + " entry = f\"\"\" {{\n", + " 'id': {p[\"id\"]},\n", + " 'title': \"{p[\"title\"]}\",\n", " 'subtitle': \"{subtitle_val}\",\n", " 'date': \"{data_val}\",\n", - " 'content': \\\"\\\"\\\"{p['content']}\\\"\\\"\\\",\n", + " 'content': \\\"\\\"\\\"{p[\"content\"]}\\\"\\\"\\\",\n", " \"displayall\": {display_val}\n", " }},\\n\"\"\"\n", - " f.write(entry)\n", + " f.write(entry)\n", " f.write(\"]\\n\")\n", - " \n", + "\n", " print(f\"Post {post_id} updated successfully.\")\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "7c80d17a", + "metadata": {}, + "outputs": [], + "source": [ + "FIEL_PATH = \"../content/posts.py\"\n", + "get_entry(FIEL_PATH, 0)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e2048547", + "metadata": {}, + "outputs": [], + "source": [ "\n", "# --- Usage Example ---\n", "if __name__ == \"__main__\":\n", - " file = '../content/posts.py'\n", + " file = \"../content/posts.py\"\n", " target_id = 3\n", - " \n", + "\n", " # Get the old one first to see it\n", " old_post = get_entry(file, target_id)\n", - " \n", + "\n", " if old_post:\n", " pass\n", "\n", - " new_text=\"\"\"\n", + " new_text = \"\"\"\n", "

sudo pacman -S archlinux-keyring

\n", "

sudo pacman -Sc

\n", "

melange:

\n", @@ -128,15 +117,14 @@ "\n", "\n", " \"\"\"\n", - " \n", - " \n", - " update_entry(file, target_id, new_text)\n" + "\n", + " update_entry(file, target_id, new_text)" ] } ], "metadata": { "kernelspec": { - "display_name": "base", + "display_name": "graphx", "language": "python", "name": "python3" }, @@ -150,7 +138,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.7" + "version": "3.11.11" } }, "nbformat": 4, diff --git a/templates/components/timeline.html b/templates/components/timeline.html new file mode 100644 index 0000000..4003780 --- /dev/null +++ b/templates/components/timeline.html @@ -0,0 +1,16 @@ +
+
    + {% for item in timeline %} +
  1. + + + +

    {{ item.title }}

    + +

    {{ item.description }}

    +
  2. + {% endfor %} +
+
diff --git a/templates/posts/post_5.html b/templates/posts/post_5.html new file mode 100644 index 0000000..3c0360b --- /dev/null +++ b/templates/posts/post_5.html @@ -0,0 +1,3 @@ +

Project Timeline

+ +{% include "components/timeline.html" %}