Skip to content

Commit

Permalink
Fixing redirection (#3)
Browse files Browse the repository at this point in the history
* checking redirection

* redirecting to latest page

* Removing personal fork

* Setting logic for automatic redirecting
  • Loading branch information
KasukabeDefenceForce authored Apr 10, 2024
1 parent 4aa9355 commit a7c15ec
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 398 deletions.
50 changes: 33 additions & 17 deletions create_html.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -20,7 +20,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -34,7 +34,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -44,27 +44,43 @@
"start_date_datetime = datetime.strptime(start_date, \"%Y/%m/%d\")\n",
"end_date_datetime = datetime.strptime(end_date, \"%Y/%m/%d\")\n",
"event_year = end_date_datetime.year\n",
"html_page_name_list = [f\"{event_year}.html\", \"index.html\"]"
"html_page_name = f\"{event_year}.html\""
]
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
"page_template = environment.get_template(\"landingpage.html\")\n",
"template_level = html_page_name.count(\"/\")\n",
"page_html_path = html_page_name\n",
"page_content = page_template.render(\n",
" TEMPLATE_LEVEL=template_level,\n",
" start_date=start_date_datetime,\n",
" end_date=end_date_datetime,\n",
" event_year=event_year,\n",
")\n",
"with open(page_html_path, mode=\"w\", encoding=\"utf-8\") as page:\n",
" page.write(page_content)"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
"for html_page_name in html_page_name_list:\n",
" page_template = environment.get_template(\"landingpage.html\")\n",
" template_level = html_page_name.count(\"/\")\n",
" page_html_path = html_page_name\n",
" page_content = page_template.render(\n",
" TEMPLATE_LEVEL=template_level,\n",
" start_date=start_date_datetime,\n",
" end_date=end_date_datetime,\n",
" event_year=event_year,\n",
" )\n",
" with open(page_html_path, mode=\"w\", encoding=\"utf-8\") as page:\n",
" page.write(page_content)"
"page_template = environment.get_template(\"index_template.html\")\n",
"template_level = html_page_name.count(\"/\")\n",
"index_html_path = \"index.html\"\n",
"index_page_content = page_template.render(\n",
" TEMPLATE_LEVEL=template_level,\n",
" current_year=event_year\n",
")\n",
"with open(index_html_path, mode=\"w\", encoding=\"utf-8\") as index_page:\n",
" index_page.write(index_page_content)"
]
}
],
Expand Down
Loading

0 comments on commit a7c15ec

Please sign in to comment.