Skip to content

Commit

Permalink
Merge pull request #89 from UNopenGIS:dev
Browse files Browse the repository at this point in the history
Add presentations to resources as a part of the build process
  • Loading branch information
albertkun authored Feb 21, 2024
2 parents f87f7a4 + 36ae3cc commit 906a5dd
Show file tree
Hide file tree
Showing 9 changed files with 242 additions and 7 deletions.
172 changes: 172 additions & 0 deletions .scripts/test.ipynb
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion docs/resources/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,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/)
6 changes: 6 additions & 0 deletions docs/resources/presentations/index.md
Original file line number Diff line number Diff line change
@@ -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 |
12 changes: 11 additions & 1 deletion docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,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',
Expand Down
33 changes: 33 additions & 0 deletions generate-presentations-index.js
Original file line number Diff line number Diff line change
@@ -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! 🎉');
});
Original file line number Diff line number Diff line change
@@ -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 |
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -21,6 +22,7 @@
"@docusaurus/theme-mermaid": "^2.4.0",
"@mdx-js/react": "^3.0.0",
"clsx": "^1.2.1",
"csv-parser": "^3.0.0",
"docusaurus-lunr-search": "^2.3.2",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
6 changes: 3 additions & 3 deletions presentations.csv
Original file line number Diff line number Diff line change
@@ -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"
"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"
8 changes: 7 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5181,6 +5181,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"
Expand Down Expand Up @@ -9807,7 +9814,6 @@ [email protected], react-router@^5.3.3, react-router@^5.3.4:
react-is "^16.6.0"
tiny-invariant "^1.0.2"
tiny-warning "^1.0.0"

react-textarea-autosize@~8.3.2:
version "8.3.4"
resolved "https://registry.yarnpkg.com/react-textarea-autosize/-/react-textarea-autosize-8.3.4.tgz#270a343de7ad350534141b02c9cb78903e553524"
Expand Down

0 comments on commit 906a5dd

Please sign in to comment.