diff --git a/app.py b/app.py index bb679a2..aa3e46b 100644 --- a/app.py +++ b/app.py @@ -1,6 +1,7 @@ from flask import Flask, render_template, Response import requests from bs4 import BeautifulSoup +from datetime import datetime class WikiApp(Flask): @@ -22,7 +23,7 @@ class WikiApp(Flask): 'titles': all_pages_string, 'format': 'json', 'prop': 'pageimages', - 'pithumbsize': 700 + 'pithumbsize': 700, }) thumb_data = thumb_resp.json() pages_thumb_data = thumb_data.get('query', {}).get('pages', {}) @@ -32,20 +33,32 @@ class WikiApp(Flask): pageid = value.get('pageid') source = value.get('thumbnail', {}).get('source') for category, pages in category_page_list.items(): + # print(category, pages) if title in pages: - - category_page_list[category][pages.index(title)] = {'title': title, 'pageid': pageid, 'source': source} + for index, page_title in enumerate(category_page_list[category]): + if title == page_title: + category_page_list[category][page_title].update({'pageid':pageid, 'title': title, 'source': source }) + return category_page_list + def fetch_all_pages(self, categories): category_page_list = {} for category in categories: - response = requests.get(self.MEDIAWIKI_BASE_URL + self.BASE_API, params={'action': 'ask', 'query': '[[Concept:'+category+']]', 'format': 'json', 'formatversion': '2'}) + response = requests.get(self.MEDIAWIKI_BASE_URL + self.BASE_API, params={'action': 'ask', 'query': '[[Concept:'+category+']]|?Article:Date', 'format': 'json', 'formatversion': '2'}) data = response.json() - page_titles = [page['fulltext'] for page in data['query']['results'].values()] - category_page_list[category] = page_titles + page_title_timestamps = {} + for page_title, page_data in data['query']['results'].items(): + if 'printouts' in page_data and 'Article:Date' in page_data['printouts']: + raw_timestamp = page_data['printouts']['Article:Date'][0]['raw'] + raw_timestamp = raw_timestamp[2:] + lol = datetime.strptime(raw_timestamp, "%Y/%m/%d") + formatted_date = lol.strftime("%d.%m.%Y") + page_title_timestamps[page_title] = {'date': formatted_date} + + category_page_list[category] = page_title_timestamps return category_page_list @@ -53,11 +66,9 @@ class WikiApp(Flask): # Fetch pages for articles, projects, and newsletters categories = ['Articles', 'Projects', 'Newsletters', 'MainNavigation'] category_page_list = self.fetch_all_pages(categories) - print(category_page_list) updated_cat_list = self.fetch_pages_cat(category_page_list) - print(updated_cat_list) - articles = updated_cat_list.get('Articles', []) + print(articles) projects = updated_cat_list.get('Projects', []) newsletters = updated_cat_list.get('Newsletters', []) nav_elements = updated_cat_list.get('MainNavigation', []) diff --git a/static/assets/styles.css b/static/assets/styles.css index 1680268..ab3924d 100644 --- a/static/assets/styles.css +++ b/static/assets/styles.css @@ -31,6 +31,7 @@ body { display: flex; flex-direction: column; width: 100%; + height: 120px; gap: 5px; } @@ -57,6 +58,8 @@ body { background-color: white; width: 100%; height: 1px; + padding: 0; + margin: 0; } .spinning-star { @@ -65,15 +68,14 @@ body { } .section-cont { - width: 100%; - height: 100%; - min-height: 750px; + width: 100% ; + height: 75vh; display: flex; flex-direction: row; justify-content: space-between; margin-top: 10px; background-color: rgb(54, 54, 255); /* Background color for demonstration */ - border-radius: 30% 70% 70% 30% / 46% 30% 70% 54% + border-radius: 30% 70% 70% 30% / 46% 30% 70% 54% ; } .section { @@ -82,14 +84,32 @@ body { flex-direction: column; gap: 10px; height: 100%; + margin-left: 60px; + overflow: hidden; } -.section-title { +.section::-webkit-scrollbar { + display: none; + } + +.section-group::-webkit-scrollbar { + display: none; +} +.section-group { + overflow: scroll; + overflow-x: hidden; + -ms-overflow-style: none; /* IE and Edge */ + scrollbar-width: none; /* Firefox */ + display: flex; + flex-direction: column; + gap: 10px; } .section-element { - text-transform: lowercase; + text-transform: uppercase; + font-size: 20px; + padding-left: 20px; } .section-element a { @@ -97,6 +117,22 @@ body { color: white; } +.section-img img{ + max-width: 100%; + border-radius: 10px; +} + +.section-img { + width: 50%; + height: auto; + padding-left: 20px; + margin-bottom: 20px; +} + +.section-date { + padding-left: 20px; +} + /* Keyframes for the spin animation */ @keyframes spin { diff --git a/templates/homepage.html b/templates/homepage.html index e55c9c4..bd0a443 100644 --- a/templates/homepage.html +++ b/templates/homepage.html @@ -17,7 +17,7 @@ @@ -26,21 +26,33 @@
articles 
+
{% for article in articles %} - + + +
{% endfor %} +
newsletters
- {% for newsletter in articles %} - - {% endfor %} +
+ {% for newsletter in newsletters %} + + +
+ {% endfor %} +
projects
- {% for project in articles %} - - {% endfor %} +
+ {% for project in projects %} + + +
+ {% endfor %} +