From cd93d79cf2cd961d29a49c8123e660bf6236fd44 Mon Sep 17 00:00:00 2001 From: albertkun Date: Tue, 20 Feb 2024 15:58:55 -0800 Subject: [PATCH] feat: add presentations to resources as a part of the build process --- .scripts/test.ipynb | 172 ++++++++++++++++++ docs/resources/index.md | 2 +- docs/resources/presentations/index.md | 6 + docusaurus.config.js | 12 +- generate-presentations-index.js | 33 ++++ .../current/resources/presentations/index.md | 6 + package.json | 7 +- presentations.csv | 6 +- yarn.lock | 12 ++ 9 files changed, 249 insertions(+), 7 deletions(-) create mode 100644 .scripts/test.ipynb create mode 100644 docs/resources/presentations/index.md create mode 100644 generate-presentations-index.js create mode 100644 i18n/ja/docusaurus-plugin-content-docs/current/resources/presentations/index.md diff --git a/.scripts/test.ipynb b/.scripts/test.ipynb new file mode 100644 index 000000000..47161aefc --- /dev/null +++ b/.scripts/test.ipynb @@ -0,0 +1,172 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 33, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['../docs/events/2023-05-22.md', '../docs/events/2023-05-26.md', '../docs/events/2023-06-16.md', '../docs/events/2023-06-19.md', '../docs/events/2023-07-17.md', '../docs/events/2023-07-21.md', '../docs/events/2023-08-09.md', '../docs/events/2023-08-18.md', '../docs/events/2023-08-20.md', '../docs/events/index.md']\n", + "input_date::: 2023-08-09\n", + "creating file\n", + "input_date::: 2023-08-20\n", + "creating file\n", + "Processed 3 lines.\n" + ] + } + ], + "source": [ + "import os\n", + "import csv\n", + "participation_link = \"https://ucla.zoom.us/meeting/register/tJcoc-mvrTovG920aIcgb-64RaKdVWKTb1Ik\"\n", + "current_markdown_files = []\n", + "\n", + "def process_csv(file):\n", + " with open(file) as csv_file:\n", + " csv_reader = csv.reader(csv_file, delimiter=',')\n", + " line_count = 0\n", + " for row in csv_reader:\n", + " if line_count != 0:\n", + " create_markdown_from_csv(row,\"en\")\n", + " line_count += 1\n", + " print(f'Processed {line_count} lines.')\n", + "\n", + "def get_files_in_folder(folder):\n", + " current_markdown_files = []\n", + " for r, d, f in os.walk(folder):\n", + " for file in f:\n", + " if '.md' in file:\n", + " if file not in current_markdown_files:\n", + " current_markdown_files.append(os.path.join(r, file))\n", + " return current_markdown_files\n", + "\n", + "def check_list_of_presentation_markdown_files(path):\n", + " return get_files_in_folder(path)\n", + "\n", + "def create_markdown_from_csv(input_csv,language):\n", + " input_date = input_csv[1]\n", + "\n", + " print('input_date::: '+str(input_date))\n", + " if input_date not in current_markdown_files:\n", + " print('creating file')\n", + " generate_markdown_file(input_csv,language)\n", + "\n", + "def generate_markdown_file(input_csv,language):\n", + " outfile = None\n", + " outfile_path = \"\"\n", + " \n", + " if language == \"en\":\n", + " outfile_path = \"../docs/events/\"+input_csv[1]+\".md\"\n", + " # outfile = open(\"../docs/events/\"+input_csv[1]+\".md\", \"w\")\n", + " else:\n", + " outfile_path = \"../i18n/\"+language+\"/docusarus-plugin-content-docs/current/\"+input_csv[1]+\".md\"\n", + " # outfile = open(, \"w\")\n", + " if outfile_path is not None:\n", + " append_copy = open(outfile_path, \"r\")\n", + " original_text = append_copy.read()\n", + " append_copy.close()\n", + " append_copy = open(outfile_path, \"w\")\n", + " # outfile.write(original_text)\n", + " # write_markdown_header(outfile,input_csv)\n", + " # outfile.write(old_content.read())\n", + " write_presentation_contents(append_copy,input_csv)\n", + " \n", + "\n", + "def write_presentation_contents(outfile,input_csv):\n", + " outfile.write(\"\\n ## Presentation \\n\"+input_csv[2]+\"\\n\")\n", + " outfile.write(\"\\n View the [recording](\"+input_csv[3]+\") \\n\")\n", + " outfile.write(\" Download the [slides](\"+input_csv[5]+\") \\n\")\n", + "\n", + "def write_markdown_header(outfile,input_csv):\n", + " outfile.write(\"---\\n\")\n", + " outfile.write(\"id: \"+input_csv[1]+\"\\n\")\n", + " outfile.write(\"title: \"+input_csv[0]+\"\\n\")\n", + " outfile.write(\"authors: \"+input_csv[2]+\"\\n\")\n", + " outfile.write(\"sidebar_label: \"+input_csv[0]+\"\\n\")\n", + " outfile.write(\"hide_title: false\\n\")\n", + " outfile.write(\"hide_table_of_contents: false\\n\")\n", + " outfile.write(\"keywords:\\n\")\n", + " outfile.write(\" - \"+input_csv[4]+\"\\n\")\n", + " outfile.write(\"---\\n\")\n", + "\n", + "def write_markdown_body(outfile,input_csv):\n", + " outfile.write(\"\\n # \"+input_csv[0]+\"\\n\")\n", + " outfile.write(\"\\n ## Date \"+input_csv[1]+\"\\n\")\n", + " this_date = input_csv[1]\n", + " this_time = input_csv[2]\n", + " add_padded_zero_for_date(this_date)\n", + " utc_format_the_time(this_time)\n", + " outfile.write(\"\\n Time [\"+input_csv[3]+\" UTC](https://www.timeanddate.com/worldclock/fixedtime.html?msg=\"+input_csv[0]+\"&iso=\"+add_padded_zero_for_date(this_date)+\"T\"+this_time.split(\":\")[0]+\"&p1=1440&ah=1) \\n\")\n", + " outfile.write(\"\\n ## How to join \\n Join via the this [Zoom link](\"+participation_link+\"). \\n\")\n", + "\n", + "\n", + "def add_padded_zero_for_date(this_date):\n", + " this_date = this_date.split(\"-\")\n", + " if len(this_date[1]) == 1:\n", + " this_date[1] = \"0\"+this_date[1]\n", + " if len(this_date[2]) == 1:\n", + " this_date[2] = \"0\"+this_date[2]\n", + " this_date = \"-\".join(this_date)\n", + " return this_date\n", + "\n", + "\n", + "def utc_format_the_time(this_time):\n", + " this_time = this_time.split(\":\")\n", + " if len(this_time[0]) == 1:\n", + " this_time[0] = \"0\"+this_time[0]\n", + " if len(this_time[1]) == 1:\n", + " this_time[1] = \"0\"+this_time[1]\n", + " this_time = \"\".join(this_time)\n", + " return this_time\n", + "\n", + "def __main__():\n", + " current_markdown_files_eng = check_list_of_presentation_markdown_files(\"../docs/events/\")\n", + " \n", + " print(current_markdown_files_eng)\n", + " process_csv(\"../presentations.csv\")\n", + "\n", + "if __name__ == \"__main__\":\n", + " __main__()\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def " + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.7" + }, + "orig_nbformat": 4 + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/docs/resources/index.md b/docs/resources/index.md index 021c92718..42e79515a 100644 --- a/docs/resources/index.md +++ b/docs/resources/index.md @@ -20,4 +20,4 @@ This page is a work in progress. Not everything is what we developed. There are ## Use Cases -[Use Cases](./use-cases/) +[Use Cases](/use-cases/) diff --git a/docs/resources/presentations/index.md b/docs/resources/presentations/index.md new file mode 100644 index 000000000..c567997c9 --- /dev/null +++ b/docs/resources/presentations/index.md @@ -0,0 +1,6 @@ +# Presentations + +| Title | Date |Speaker | Link | Keywords | +| ----- | ---- | ------- | ---- | -------- | +| Documentation Update | 2023-08-20 | Albert Kochaphum | [Link](https://hackmd.io/@MXxudfFtSvSvSonMo4L3qQ/SyT0kFwqn#/1) | documentation, UN Smartmaps | +| UN Smart Maps Quarterly #1 | 2023-08-09 | Hidenori Fujimura and Yuiseki Matsumura | [Link](https://docs.google.com/presentation/d/1OwuZeywXDsbAmpsuYT3m70hp4psQag7O8nfHJZNzvrs/edit?usp=sharing) | UN, Smartmaps, quarterly | diff --git a/docusaurus.config.js b/docusaurus.config.js index 3964aa1b1..883a08c57 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -80,8 +80,18 @@ const config = { { label: "Resources", position: "left", - to: "/resources" + to: "/resources", + items: [ + { + label: 'Presentations', + to: '/resources/presentations', + }, + { + label: 'Use-Cases', + to: '/resources/use-cases', + }] }, + // { to: "/get-involved", label: "Get Involved", position: "left" }, { type: 'dropdown', diff --git a/generate-presentations-index.js b/generate-presentations-index.js new file mode 100644 index 000000000..654a5fc14 --- /dev/null +++ b/generate-presentations-index.js @@ -0,0 +1,33 @@ +const fs = require('fs'); +const csv = require('csv-parser'); + +const presentations = []; + +fs.createReadStream('presentations.csv') + .pipe(csv()) + .on('data', (row) => { + presentations.push(row); + }) + .on('end', () => { + // Sort presentations by date in descending order + presentations.sort((a, b) => new Date(b.date) - new Date(a.date)); + + let markdownEN = '# Presentations\n\n'; + let markdownJP = '# プレゼンテーション\n\n'; // Translated "Presentations" + + markdownEN += '| Title | Date |Speaker | Link | Keywords |\n'; + markdownEN += '| ----- | ---- | ------- | ---- | -------- |\n'; + + markdownJP += '| タイトル | 日付 | スピーカー | リンク | キーワード |\n'; // Translated headers + markdownJP += '| ------ | ---- | -------- | ---- | -------- |\n'; + + presentations.forEach((presentation) => { + markdownEN += `| ${presentation["presentation title"]} | ${presentation.date} | ${presentation.speaker} | [Link](${presentation.link}) | ${presentation.keywords} |\n`; + + markdownJP += `| ${presentation["presentation title"]} | ${presentation.date} | ${presentation.speaker} | [リンク](${presentation.link}) | ${presentation.keywords} |\n`; // Translated "Link" + }); + + fs.writeFileSync('docs/resources/presentations/index.md', markdownEN); + fs.writeFileSync('i18n/ja/docusaurus-plugin-content-docs/current/resources/presentations/index.md', markdownJP); + console.log('Markdown files have been updated successfully! 🎉'); + }); \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/resources/presentations/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/resources/presentations/index.md new file mode 100644 index 000000000..d181c35af --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/resources/presentations/index.md @@ -0,0 +1,6 @@ +# プレゼンテーション + +| タイトル | 日付 | スピーカー | リンク | キーワード | +| ------ | ---- | -------- | ---- | -------- | +| Documentation Update | 2023-08-20 | Albert Kochaphum | [リンク](https://hackmd.io/@MXxudfFtSvSvSonMo4L3qQ/SyT0kFwqn#/1) | documentation, UN Smartmaps | +| UN Smart Maps Quarterly #1 | 2023-08-09 | Hidenori Fujimura and Yuiseki Matsumura | [リンク](https://docs.google.com/presentation/d/1OwuZeywXDsbAmpsuYT3m70hp4psQag7O8nfHJZNzvrs/edit?usp=sharing) | UN, Smartmaps, quarterly | diff --git a/package.json b/package.json index b5039e335..89ea7c808 100644 --- a/package.json +++ b/package.json @@ -4,9 +4,10 @@ "private": true, "license": "GPL-3.0", "scripts": { + "update-presentations": "node generate-presentations-index.js", "docusaurus": "docusaurus", "start": "docusaurus start", - "build": "docusaurus build", + "build": "yarn update-presentations && docusaurus build", "swizzle": "docusaurus swizzle", "deploy": "docusaurus deploy", "clear": "docusaurus clear", @@ -20,10 +21,12 @@ "@docusaurus/theme-mermaid": "^2.4.0", "@mdx-js/react": "^1.6.22", "clsx": "^1.2.1", + "csv-parser": "^3.0.0", "docusaurus-lunr-search": "^2.3.2", "prism-react-renderer": "^1.3.5", "react": "^17.0.2", - "react-dom": "^17.0.2" + "react-dom": "^17.0.2", + "react-table": "^7.8.0" }, "devDependencies": { "@docusaurus/module-type-aliases": "2.4.0" diff --git a/presentations.csv b/presentations.csv index 6fe5b73ec..dc6bfd3af 100644 --- a/presentations.csv +++ b/presentations.csv @@ -1,3 +1,3 @@ -"presentation title",date,speaker,link,keywords -"UN Smart Maps Quarterly #1",2023-08-09,"Hidenori Fujimura and Yuiseki Matsumura ","https://docs.google.com/presentation/d/1OwuZeywXDsbAmpsuYT3m70hp4psQag7O8nfHJZNzvrs/edit?usp=sharing","UN, Smartmaps, quarterly" -"Documentation Update",2023-08-20,"Albert Kochaphum","https://hackmd.io/@MXxudfFtSvSvSonMo4L3qQ/SyT0kFwqn#/1","documentation, UN Smartmaps" \ No newline at end of file +"presentation title",date,time,speaker,link,keywords +"UN Smart Maps Quarterly #1",2023-08-09,16:45,"Hidenori Fujimura and Yuiseki Matsumura ","https://docs.google.com/presentation/d/1OwuZeywXDsbAmpsuYT3m70hp4psQag7O8nfHJZNzvrs/edit?usp=sharing","UN, Smartmaps, quarterly" +"Documentation Update",2023-08-20,03:00,"Albert Kochaphum","https://hackmd.io/@MXxudfFtSvSvSonMo4L3qQ/SyT0kFwqn#/1","documentation, UN Smartmaps" \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index bdda1145e..60d4da709 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3380,6 +3380,13 @@ csstype@^3.0.2: resolved "https://registry.npmjs.org/csstype/-/csstype-3.1.2.tgz" integrity sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ== +csv-parser@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/csv-parser/-/csv-parser-3.0.0.tgz#b88a6256d79e090a97a1b56451f9327b01d710e7" + integrity sha512-s6OYSXAK3IdKqYO33y09jhypG/bSDHPuyCme/IdEHfWpLf/jKcpitVFyOC6UemgGk8v7Q5u2XE0vvwmanxhGlQ== + dependencies: + minimist "^1.2.0" + cytoscape-cose-bilkent@^4.1.0: version "4.1.0" resolved "https://registry.npmjs.org/cytoscape-cose-bilkent/-/cytoscape-cose-bilkent-4.1.0.tgz" @@ -6693,6 +6700,11 @@ react-router@5.3.4, react-router@^5.3.3: tiny-invariant "^1.0.2" tiny-warning "^1.0.0" +react-table@^7.8.0: + version "7.8.0" + resolved "https://registry.yarnpkg.com/react-table/-/react-table-7.8.0.tgz#07858c01c1718c09f7f1aed7034fcfd7bda907d2" + integrity sha512-hNaz4ygkZO4bESeFfnfOft73iBUj8K5oKi1EcSHPAibEydfsX2MyU6Z8KCr3mv3C9Kqqh71U+DhZkFvibbnPbA== + react-textarea-autosize@^8.3.2: version "8.4.1" resolved "https://registry.npmjs.org/react-textarea-autosize/-/react-textarea-autosize-8.4.1.tgz"