Browse Source

fixed structure and changed styling (color, font)

main
Cailean Finn 8 months ago
parent
commit
ff1091a093
  1. 59
      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

59
app.py

@ -12,11 +12,48 @@ class WikiApp(Flask):
super().__init__(*args, **kwargs)
# 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('/favicon.ico')(self.favicon)
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):
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={
@ -42,14 +79,11 @@ class WikiApp(Flask):
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+']]|?Article:Date', 'format': 'json', 'formatversion': '2'})
data = response.json()
print(data)
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']:
@ -62,7 +96,6 @@ class WikiApp(Flask):
category_page_list[category] = page_title_timestamps
return category_page_list
def homepage(self):
# Fetch pages for articles, projects, and newsletters
categories = ['Articles', 'Projects', 'Newsletters']
@ -85,13 +118,25 @@ class WikiApp(Flask):
page_content = self.fix_html(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):
response = requests.get(self.MEDIAWIKI_BASE_URL + self.BASE_API, params={'action': 'ask', 'query': '[[Concept:MainNavigation]]', 'format': 'json', 'formatversion': '2'})
data = response.json()
main_navigation_elements = {}
for page_title, page_data in data['query']['results'].items():
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):
soup = BeautifulSoup(page_content, 'html.parser')
@ -110,7 +155,7 @@ class WikiApp(Flask):
for link in links:
# Add _blank to href
link['target'] = '_blank'
link.string = link.string.strip() + " "
link.string = link.string.strip() + " "
# Find all a tags with href containing 'index.php'
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 */
body {
font-family: Arial, sans-serif;
background-color: black;
color: white;
background-color: white;
color: black;
margin: auto;
padding: 0px;
font-family: "Space Mono", monospace;
@ -21,7 +21,7 @@ body {
.header-title {
font-size: 40px;
display: flex;
background-color: black;
background-color: white;
width: fit-content;
padding: 10px;
padding-left: 20px;
@ -31,7 +31,7 @@ body {
.header-title a {
text-decoration: none;
color: white;
color: black;
}
.header-summary {
@ -54,28 +54,28 @@ body {
.nav-element-cont {
display: flex;
flex-direction: row;
gap: 10px;
gap: 20px;
text-transform: lowercase;
font-size: 25px;
width: 100%;
background-color: white;
background-color: black;
padding:20px;
align-items: center;
}
.nav-element-cont a{
text-decoration: none;
color: black;
color: white;
}
.nav-element {
display: flex;
flex-direction: row;
gap: 10px;
gap: 20px;
}
.line {
background-color: white;
background-color: black;
width: 100%;
height: 1px;
padding: 0;
@ -133,9 +133,9 @@ body {
}
.content-cont .article-cont a {
color: black;
color: white;
text-decoration: none;
background-color: white;
background-color: black;
font-style: oblique;
padding-left: 5px;
padding-right: 5px;
@ -155,7 +155,7 @@ body {
height: 100%;
width: auto;
max-width: 900px;
border: white;
border: black;
border-style: dashed;
transition: transform 0.3s ease-in-out;
}
@ -178,7 +178,7 @@ body {
height: 100vh;
display: flex;
flex-direction: row;
justify-content: space-between;
justify-content: space-around;
}
.collection-cont {
@ -196,7 +196,7 @@ body {
border: 2px;
border-radius: 20px;
border-style: solid;
border-color: white;
border-color: black;
padding: 10px;
}
@ -214,7 +214,7 @@ body {
.content-cont .collection-cont a {
text-decoration: underline;
color: white;
color: black;
}
.collection-cont .section-img{
@ -229,7 +229,7 @@ body {
max-width: 200px;
object-fit: contain;
border-radius: 0px;
border: white;
border: black;
border-style: dashed;
transition: transform 0.3s ease-in-out;
}
@ -264,7 +264,7 @@ body {
.section-element a {
text-decoration: underline;
color: white;
color: black;
}
.section-img img{
@ -272,7 +272,7 @@ body {
height: 200px;
object-fit: cover;
border-radius: 0px;
border: white;
border: black;
border-style: dashed;
transition: transform 0.3s ease-in-out;
}

4
templates/base.html

@ -13,10 +13,8 @@
</div>
<div class='nav-element-cont'>
{% 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 %}
<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>

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