Browse Source

fixed structure and changed styling (color, font)

main
Cailean Finn 8 months ago
parent
commit
ff1091a093
  1. 63
      app.py
  2. 36
      static/assets/styles.css
  3. 4
      templates/base.html
  4. 11
      templates/cn-home.html
  5. 14
      templates/meetups.html
  6. 27
      templates/publications.html

63
app.py

@ -12,11 +12,48 @@ class WikiApp(Flask):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
# Define routes # Define routes
self.route('/', methods=['GET'])(self.homepage) # self.route('/', methods=['GET'])(self.homepage)
self.route('/', methods=['GET'])(self.homepage_new)
self.route('/publications', methods=['GET'])(self.fetch_publications)
self.route('/meetups', methods=['GET'])(self.fetch_meetups)
self.route('/<string:title>', methods=['GET'])(self.page_content) self.route('/<string:title>', methods=['GET'])(self.page_content)
self.route('/favicon.ico')(self.favicon) self.route('/favicon.ico')(self.favicon)
self.route('/archive/<string:collection>', methods=['GET'])(self.get_collection) self.route('/archive/<string:collection>', methods=['GET'])(self.get_collection)
def homepage_new(self):
pages = ['Homepage']
homepage_content = ''
for page in pages:
# Make a request to MediaWiki API to get content of a specific page
response = requests.get(self.MEDIAWIKI_BASE_URL + self.BASE_API, params={'action': 'parse', 'page': page, 'format': 'json'})
data = response.json()
# Extract page title and content
page_content = data['parse']['text']['*']
page_content = self.fix_html(page_content)
homepage_content += page_content
return render_template('cn-home.html', nav_elements=self.get_nav_menu(), content=homepage_content)
def fetch_publications(self):
concepts = ['Newsletters', 'Projects']
publication_page_list = self.fetch_all_pages(concepts)
updated_cat_list = self.fetch_pages_cat(publication_page_list)
projects = updated_cat_list.get('Projects', [])
newsletters = updated_cat_list.get('Newsletters', [])
nav_elements = self.get_nav_menu()
return render_template('publications.html', projects=projects, newsletters=newsletters, nav_elements=nav_elements)
def fetch_meetups(self):
concepts = ['Meetups']
# publication_page_list = self.fetch_all_pages(concepts)
# updated_cat_list = self.fetch_pages_cat(publication_page_list)
# meetups = updated_cat_list.get('Meetups', [])
nav_elements = self.get_nav_menu()
meetup_content = self.fetch_page('Meetups')
return render_template('meetups.html', content=meetup_content, nav_elements=nav_elements)
def fetch_pages_cat(self, category_page_list): def fetch_pages_cat(self, category_page_list):
all_pages_string = '|'.join(page for pages in category_page_list.values() for page in pages) all_pages_string = '|'.join(page for pages in category_page_list.values() for page in pages)
thumb_resp = requests.get(self.MEDIAWIKI_BASE_URL + self.BASE_API, params={ thumb_resp = requests.get(self.MEDIAWIKI_BASE_URL + self.BASE_API, params={
@ -41,15 +78,12 @@ class WikiApp(Flask):
category_page_list[category][page_title].update({'pageid':pageid, 'title': title, 'source': source }) category_page_list[category][page_title].update({'pageid':pageid, 'title': title, 'source': source })
return category_page_list return category_page_list
def fetch_all_pages(self, categories): def fetch_all_pages(self, categories):
category_page_list = {} category_page_list = {}
for category in categories: for category in categories:
response = requests.get(self.MEDIAWIKI_BASE_URL + self.BASE_API, params={'action': 'ask', 'query': '[[Concept:'+category+']]|?Article:Date', '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() data = response.json()
print(data)
page_title_timestamps = {} page_title_timestamps = {}
for page_title, page_data in data['query']['results'].items(): for page_title, page_data in data['query']['results'].items():
if 'printouts' in page_data and 'Article:Date' in page_data['printouts']: if 'printouts' in page_data and 'Article:Date' in page_data['printouts']:
@ -61,8 +95,7 @@ class WikiApp(Flask):
category_page_list[category] = page_title_timestamps category_page_list[category] = page_title_timestamps
return category_page_list return category_page_list
def homepage(self): def homepage(self):
# Fetch pages for articles, projects, and newsletters # Fetch pages for articles, projects, and newsletters
categories = ['Articles', 'Projects', 'Newsletters'] categories = ['Articles', 'Projects', 'Newsletters']
@ -85,13 +118,25 @@ class WikiApp(Flask):
page_content = self.fix_html(page_content) page_content = self.fix_html(page_content)
return render_template('article.html', nav_elements=self.get_nav_menu(), title=page_title, content=page_content) return render_template('article.html', nav_elements=self.get_nav_menu(), title=page_title, content=page_content)
def fetch_page(self, title):
# Make a request to MediaWiki API to get content of a specific page
response = requests.get(self.MEDIAWIKI_BASE_URL + self.BASE_API, params={'action': 'parse', 'page': title, 'format': 'json'})
data = response.json()
# Extract page title and content
page_title = data['parse']['title']
page_content = data['parse']['text']['*']
page_content = self.fix_html(page_content)
return page_content
def get_nav_menu(self): def get_nav_menu(self):
response = requests.get(self.MEDIAWIKI_BASE_URL + self.BASE_API, params={'action': 'ask', 'query': '[[Concept:MainNavigation]]', 'format': 'json', 'formatversion': '2'}) response = requests.get(self.MEDIAWIKI_BASE_URL + self.BASE_API, params={'action': 'ask', 'query': '[[Concept:MainNavigation]]', 'format': 'json', 'formatversion': '2'})
data = response.json() data = response.json()
main_navigation_elements = {} main_navigation_elements = {}
for page_title, page_data in data['query']['results'].items(): for page_title, page_data in data['query']['results'].items():
main_navigation_elements[page_title] = {'title':page_data.get('fulltext', '')} main_navigation_elements[page_title] = {'title':page_data.get('fulltext', '')}
return main_navigation_elements reversed_main_navigation = list(main_navigation_elements.items())[::-1]
reversed_main_navigation = dict(reversed_main_navigation)
return reversed_main_navigation
def fix_html(self, page_content): def fix_html(self, page_content):
soup = BeautifulSoup(page_content, 'html.parser') soup = BeautifulSoup(page_content, 'html.parser')
@ -110,7 +155,7 @@ class WikiApp(Flask):
for link in links: for link in links:
# Add _blank to href # Add _blank to href
link['target'] = '_blank' link['target'] = '_blank'
link.string = link.string.strip() + " " link.string = link.string.strip() + " "
# Find all a tags with href containing 'index.php' # Find all a tags with href containing 'index.php'
links = soup.find_all('a', href=lambda href: href and 'index.php' in href) links = soup.find_all('a', href=lambda href: href and 'index.php' in href)

36
static/assets/styles.css

@ -3,8 +3,8 @@
/* styles.css */ /* styles.css */
body { body {
font-family: Arial, sans-serif; font-family: Arial, sans-serif;
background-color: black; background-color: white;
color: white; color: black;
margin: auto; margin: auto;
padding: 0px; padding: 0px;
font-family: "Space Mono", monospace; font-family: "Space Mono", monospace;
@ -21,7 +21,7 @@ body {
.header-title { .header-title {
font-size: 40px; font-size: 40px;
display: flex; display: flex;
background-color: black; background-color: white;
width: fit-content; width: fit-content;
padding: 10px; padding: 10px;
padding-left: 20px; padding-left: 20px;
@ -31,7 +31,7 @@ body {
.header-title a { .header-title a {
text-decoration: none; text-decoration: none;
color: white; color: black;
} }
.header-summary { .header-summary {
@ -54,28 +54,28 @@ body {
.nav-element-cont { .nav-element-cont {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
gap: 10px; gap: 20px;
text-transform: lowercase; text-transform: lowercase;
font-size: 25px; font-size: 25px;
width: 100%; width: 100%;
background-color: white; background-color: black;
padding:20px; padding:20px;
align-items: center; align-items: center;
} }
.nav-element-cont a{ .nav-element-cont a{
text-decoration: none; text-decoration: none;
color: black; color: white;
} }
.nav-element { .nav-element {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
gap: 10px; gap: 20px;
} }
.line { .line {
background-color: white; background-color: black;
width: 100%; width: 100%;
height: 1px; height: 1px;
padding: 0; padding: 0;
@ -133,9 +133,9 @@ body {
} }
.content-cont .article-cont a { .content-cont .article-cont a {
color: black; color: white;
text-decoration: none; text-decoration: none;
background-color: white; background-color: black;
font-style: oblique; font-style: oblique;
padding-left: 5px; padding-left: 5px;
padding-right: 5px; padding-right: 5px;
@ -155,7 +155,7 @@ body {
height: 100%; height: 100%;
width: auto; width: auto;
max-width: 900px; max-width: 900px;
border: white; border: black;
border-style: dashed; border-style: dashed;
transition: transform 0.3s ease-in-out; transition: transform 0.3s ease-in-out;
} }
@ -178,7 +178,7 @@ body {
height: 100vh; height: 100vh;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
justify-content: space-between; justify-content: space-around;
} }
.collection-cont { .collection-cont {
@ -196,7 +196,7 @@ body {
border: 2px; border: 2px;
border-radius: 20px; border-radius: 20px;
border-style: solid; border-style: solid;
border-color: white; border-color: black;
padding: 10px; padding: 10px;
} }
@ -214,7 +214,7 @@ body {
.content-cont .collection-cont a { .content-cont .collection-cont a {
text-decoration: underline; text-decoration: underline;
color: white; color: black;
} }
.collection-cont .section-img{ .collection-cont .section-img{
@ -229,7 +229,7 @@ body {
max-width: 200px; max-width: 200px;
object-fit: contain; object-fit: contain;
border-radius: 0px; border-radius: 0px;
border: white; border: black;
border-style: dashed; border-style: dashed;
transition: transform 0.3s ease-in-out; transition: transform 0.3s ease-in-out;
} }
@ -264,7 +264,7 @@ body {
.section-element a { .section-element a {
text-decoration: underline; text-decoration: underline;
color: white; color: black;
} }
.section-img img{ .section-img img{
@ -272,7 +272,7 @@ body {
height: 200px; height: 200px;
object-fit: cover; object-fit: cover;
border-radius: 0px; border-radius: 0px;
border: white; border: black;
border-style: dashed; border-style: dashed;
transition: transform 0.3s ease-in-out; transition: transform 0.3s ease-in-out;
} }

4
templates/base.html

@ -13,10 +13,8 @@
</div> </div>
<div class='nav-element-cont'> <div class='nav-element-cont'>
{% for key, element in nav_elements.items() %} {% for key, element in nav_elements.items() %}
<div class='nav-element'><a href="{{ url_for('page_content', title=element.title) }}">{{ element.title }}</a><div class='spinning-star'>🞱</div></div> <div class='nav-element'><a href="{{ url_for('page_content', title=element.title.lower()) }}">{{ element.title }}</a><div class='spinning-star'>🞱</div></div>
{% endfor %} {% endfor %}
<div class='nav-element'><a href="/archive/events">events</a><div class='spinning-star'>🞱</div></div>
<div class='nav-element'><a href="/archive/opportunities">opportunities</a><div class='spinning-star'>🞱</div></div>
</div> </div>
</div> </div>

11
templates/cn-home.html

@ -0,0 +1,11 @@
{% extends "base.html" %}
{% block title %}Ø | CONCEPTNULL {% endblock %}
{% block content %}
<div class='content-cont'>
<br></br>
<div class='article-cont'>
{{ content | safe }}
</div>
<div class='foot'></div>
</div>
{% endblock %}

14
templates/meetups.html

@ -0,0 +1,14 @@
{% extends "base.html" %}
{% block title %} Ø | Meetups {% endblock %}
{% block content %}
<div class='content-cont'>
<h1 class='content-header'>Meetups</h1>
<div class='article-cont'>
{{ content | safe }}
</div>
<div class='foot'></div>
</div>
{% endblock %}

27
templates/publications.html

@ -0,0 +1,27 @@
{% extends "base.html" %}
{% block title %} Ø | Publications{% endblock %}
{% block content %}
<div class='section-cont'>
<div class='section'>
<a class='section-header' href='/archive/newsletters'><div class='section-title'><div style="display: inline-flex; text-align: center; justify-content: center; align-items: center; line-height: 100%; padding: 2.2px; font-size: 25px; font-style: normal; object-fit: contain; font-family: monospace; color: black; width: 100%;">NEWSLETTERS<br><!--<img src="https://i-love-everything.com/buttons/img/34.gif" style="max-height: 32px;">--></div></div></a>
<div class='section-group'>
{% for key, values in newsletters.items() %}
<div class='section-element'><a href="{{ url_for('page_content', title=values.title) }}">↘ {{ values.title }}</a></div>
<div class='section-date'>{{ values.date }}</div>
<div class='section-img'><a href="{{ url_for('page_content', title=values.title) }}"><img src="{{ values.source}}"></a></div>
{% endfor %}
</div>
</div>
<div class='section'>
<a class='section-header' href='/archive/projects'><div class='section-title'><div style="display: inline-flex; text-align: center; justify-content: center; align-items: center; line-height: 100%; padding: 3.3px; font-size: 25px; font-style: normal; object-fit: contain; font-family: monospace; color: black; border: 0px solid black; width: 100%;">PROJECTS<!--<img src="https://i-love-everything.com/buttons/img/26.gif" style="max-height: 32px;">--></div></div></a>
<div class='section-group'>
{% for key, values in projects.items() %}
<div class='section-element'><a href="{{ url_for('page_content', title=values.title) }}">↘ {{ values.title }}</a></div>
<div class='section-date'>{{ values.date }}</div>
<div class='section-img'><a href="{{ url_for('page_content', title=values.title) }}"><img src="{{ values.source }}"></a></div>
{% endfor %}
</div>
</div>
</div>
{% endblock %}
Loading…
Cancel
Save