Browse Source

dynamically edit website info: locations, texts, dates using contentful

2025
Cailean Finn 4 weeks ago
parent
commit
11af659bb4
  1. 47
      ContentfulService.py
  2. BIN
      __pycache__/ContentfulService.cpython-310.pyc
  3. 19
      app.py
  4. 2
      public/css/styles.css
  5. 48
      public/js/locations.js
  6. 6
      templates/_nav.html
  7. 12
      templates/base.html
  8. 13
      templates/index.html
  9. 21
      templates/list.html
  10. 53
      templates/locations.html

47
ContentfulService.py

@ -0,0 +1,47 @@
import contentful
import markdown
import os
class ContentfulService:
def __init__(self, space_id, access_token):
self.client = contentful.Client(space_id, access_token)
def get_general_info(self):
entries = self.client.entries({'content_type': 'general'})
if not entries:
return None
entry = entries[0]
general_date = entry.fields().get('general_date')
general_end_date = entry.fields().get('general_end_date')
general_text = entry.fields().get('general_text')
general_text_event = entry.fields().get('general_event_text')
general_text_conference = entry.fields().get('general_conference_text')
formatted_date = general_date.strftime('%#d %b %Y') if general_date else None
formatted_end_date = general_end_date.strftime('%#d %b %Y') if general_end_date else None
info = {
'startDate': formatted_date,
'endDate': formatted_end_date,
'text': markdown.markdown(general_text) if general_text else '',
'textConference': markdown.markdown(general_text_conference) if general_text_conference else '',
'textEvent':markdown.markdown(general_text_event) if general_text_event else ''
}
return info
def get_location_info(self):
entries = self.client.entries({'content_type': 'locations'})
location_list = []
for e in entries:
name = getattr(e, 'name')
directions = getattr(e, 'directions')
url = getattr(e, 'url')
image_asset = getattr(e, 'image')
image_url = image_asset.url() if image_asset else ''
content = {
'name': name,
'directions' : directions,
'url' : url,
'image' : image_url
}
location_list.append(content)
return location_list

BIN
__pycache__/ContentfulService.cpython-310.pyc

Binary file not shown.

19
app.py

@ -3,6 +3,7 @@ import contentful
from dotenv import load_dotenv
import os
import markdown
from ContentfulService import ContentfulService
load_dotenv()
@ -13,6 +14,18 @@ SPACE_ID = os.getenv('SPACE_ID')
ACCESS_TOKEN = os.getenv('ACCESS_TOKEN')
client = contentful.Client(SPACE_ID, ACCESS_TOKEN)
contentful_service = ContentfulService(SPACE_ID, ACCESS_TOKEN)
# Simple in-memory cahce - this is to store information that will be used on all pages, so I don't have to make
# request's over and over again.
global festival_general_info_cache
with app.app_context():
festival_general_info_cache = contentful_service.get_general_info()
@app.context_processor
def inject_general_info():
return dict(festival_general_info=festival_general_info_cache)
@app.route('/')
def index():
@ -60,10 +73,12 @@ def event_articles(type, title, ex_type):
@app.route('/locations')
def locations():
return render_template('locations.html', title='Locations')
location_info = contentful_service.get_location_info()
print(location_info)
return render_template('locations.html', title='Locations', locInfo=location_info)
def get_all_content(type):
entries = client.entries({'content_type': type})
entries = client.entries({'content_type': type, 'fields.beta25': 'true'})
content_list = process_content(entries, type)
return content_list

2
public/css/styles.css

@ -496,7 +496,7 @@ hr {
font-weight: 300;
}
.list-info-text {
#list-info-container p{
padding-bottom: 10px;
}

48
public/js/locations.js

@ -1,38 +1,3 @@
// Example location data
const locationData = {
'digital-hub': {
text: 'The Digital Hub, 10-13 Thomas St, The Liberties, Dublin 8, D08 PX8H',
imageUrl: '/public/images/locations/digital-hub.webp',
direction: 'https://www.google.com/maps/dir//115-117,+The+Coombe,+The+Liberties,+Dublin,+D08+A970/@53.3391179,-6.3569591,12z/data=!4m8!4m7!1m0!1m5!1m1!1s0x48670e89423ed249:0x8aa3669566840ff9!2m2!1d-6.274559!2d53.3391463?entry=ttu'
},
'pallas-projects': {
text: '115-117, The Coombe, The Liberties, Dublin, D08 A970',
imageUrl: 'public/images/locations/pallas.webp',
direction: 'https://www.google.com/maps?gs_lcrp=EgZjaHJvbWUqBggAEEUYOzIGCAAQRRg7MgYIARBFGDkyBggCEEUYOzIGCAMQRRg8MgYIBBAuGEDSAQgxNDA3ajBqOagCALACAQ&um=1&ie=UTF-8&fb=1&gl=ie&sa=X&geocode=KUnSPkKJDmdIMfkPhGaVZqOK&daddr=115-117,+The+Coombe,+The+Liberties,+Dublin,+D08+A970'
},
'fire-station': {
text: '9 - 12 Buckingham Street Lower, Mountjoy, Dublin 1',
imageUrl: 'public/images/locations/fire.webp',
direction: 'https://www.google.com/maps/place//data=!4m2!3m1!1s0x48670e897d6ec3f7:0x2eee044a4b511022?sa=X&ved=1t:8290&ictx=111'
},
'imma': {
text: 'Royal Hospital Kilmainham, Military Rd, Kilmainham, Dublin 8, D08 FW31',
imageUrl: 'public/images/locations/imma.webp',
direction: 'https://www.google.com/maps/place//data=!4m2!3m1!1s0x48670c462efd7fcd:0x3dc9b365e0e6ace?sa=X&ved=1t:8290&ictx=111'
},
'digital-bank': {
text: '85 James St, The Liberties, Dublin 8, D08 C2PR',
imageUrl: '/public/images/locations/bank.webp',
direction: 'https://www.google.com/maps/place//data=!4m2!3m1!1s0x48670d2fc081f95f:0xa5173048f627d0?sa=X&ved=1t:8290&ictx=111'
},
'beckett': {
text: 'Samuel Beckett Theatre, Trinity College, Dublin',
imageUrl: '/public/images/locations/beckett.png',
direction: 'https://maps.app.goo.gl/a1T7HktmKdxNcFWB7'
},
// Add more locations as needed
};
// Function to update the content
function updateLocationContent(locationKey) {
const location = locationData[locationKey];
@ -43,10 +8,15 @@ function updateLocationContent(locationKey) {
}
}
// Add event listeners to buttons
document.querySelectorAll('.location-button').forEach(button => {
button.addEventListener('click', (event) => {
const locationKey = event.currentTarget.getAttribute('data-location');
updateLocationContent(locationKey);
const index = event.currentTarget.getAttribute('data-location');
const locInfo = window.locInfo; // We'll inject this below
const location = locInfo[index];
if (location) {
document.getElementById('location-text').innerText = location.directions;
document.getElementById('location-img').src = location.image;
document.getElementById('location-direction').href = location.url;
}
});
});
});

6
templates/_nav.html

@ -1,7 +1,9 @@
<div id="nav-bar">
<a href="/"><div class="nav-element">BETA FESTIVAL (2024)</div></a>
<a href="/"><div class="nav-element">BETA FESTIVAL (2025)</div></a>
<div class="nav-element nav-element-align">
<div>NOV 1 - 17 | DUBLIN</div>
{% if festival_general_info %}
<div>{{ festival_general_info.startDate }} - {{ festival_general_info.endDate }} | DUBLIN</div>
{% endif %}
</div>
</div>
<hr>

12
templates/base.html

@ -3,15 +3,15 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="og:description" content="The Beta Festival 2024 catalogue showcasing and archiving all exhibitions, events, and conferences which will be on as part of this years festival." />
<meta name="description" content="The Beta Festival 2024 catalogue showcasing and archiving all exhibitions, events, and conferences which will be on as part of this years festival." />
<meta content="Beta Festival 2024" property="og:title"/>
<meta content="Beta Festival 2024" property="og:site_name"/>
<meta name="og:description" content="The Beta Festival 2025 catalogue showcasing and archiving all exhibitions, events, and conferences which will be on as part of this years festival." />
<meta name="description" content="The Beta Festival 2025 catalogue showcasing and archiving all exhibitions, events, and conferences which will be on as part of this years festival." />
<meta content="Beta Festival 2025" property="og:title"/>
<meta content="Beta Festival 2025" property="og:site_name"/>
<meta content="website" property="og:type"/>
<meta name="keywords" content="beta festival, 2024, dublin, art and technology, digital art" />
<meta name="keywords" content="beta festival, 2025, dublin, art and technology, digital art" />
<meta name="robots" content="all" />
<meta name="language" content="en-ie" />
<title>Beta Festival 2024 {% block title %}{% endblock %}</title>
<title>Beta Festival 2025 {% block title %}{% endblock %}</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:[email protected]&family=JetBrains+Mono:ital,wght@0,100..800;1,100..800&display=swap" rel="stylesheet">

13
templates/index.html

@ -26,15 +26,10 @@
<div>\Locations</div>
</div></a>
</div>
<p>
Beta is a new festival of art and technology critically engaging with the impact of emerging technologies on society. Taking Ireland’s role as a central node in today's wired world as a starting point, Beta showcases and celebrates Ireland’s research and artistic communities through a combination of creativity, debate and experimentation. Beta allows members of the public to engage playfully and critically with new technologies essentially beta testing ethical issues facing society
</p>
<p>
The 2024 edition of Beta will explore a range of themes relating to AI, Automated Systems, and the politics of resistance in an algorithmic age. Through a programme of exhibitions, workshops and talks, the festival will interrogate what kinds of powers reside in technology.
</p>
<p>
The festival is co-founded by The Digital Hub and supported by Science Week with additional support for the 2024 programme from Screen Ireland, the French Embassy, Institut français, British Council, Smart Dublin, Cultural and Creative Industries Skillsnet, Arts Council Festival Investment Scheme and Creative Europe Desk Ireland.
</p>
{% if festival_general_info %}
{{ festival_general_info.text | safe}}
{% endif %}
<div id="index-socials">
<a href="https://betafestival.ie/" target="_blank"><span>↑ beta-festival</span></a>

21
templates/list.html

@ -8,19 +8,18 @@
{% include '_list-header.html'%}
<div id="main-container">
<div id="list-info-container">
{% if title == 'Conferences'%}
<p class="list-info-text">Exploring the relationship between technology and power, Beta Festival’s 2024 conference explores how digital infrastructures and software have reshaped society, culture, and politics. Spanning two days, the event delves into the ways technology influences institutions, political interests, and economic and cultural practices. Bringing together artists, technologists, and researchers, the conference participants will question the forms of power and control embedded in digital infrastructures and explore strategies for redesigning these systems to meet societal demands for both individual and collective autonomy.</p>
<p class="list-info-text">On the first day, discussions will focus on the ethics of AI development, its impact on democracy, and the manipulation of political systems, as well as how artists are leveraging digital tools to resist surveillance and platform capitalism. The second day will explore the transformation of creative practices by these technologies, with sessions addressing copyright and intellectual property in the age of AI, the preservation of digital cultural memory, counter-archives, and new possibilities for immersive and interactive storytelling.</p>
<p class="list-info-text">Throughout the conference, keynote speakers Abeba Birhane, an accountability expert, and Kay Watson, a specialist in art and technology, will offer insights into how AI is reshaping society and culture, while exploring the limits and possibilities of individual and collective agency in this rapidly evolving digital landscape.</p>
{% endif %}
{% if festival_general_info %}
{% if title == 'Conferences'%}
{{ festival_general_info.textConference | safe }}
{% endif %}
{% if title == 'Events'%}
<p class="list-info-text">Beta Festival will feature a variety of performances, workshops and discussions as part of this year's programme including a number of events with our festival research partner ADAPT Research Centre and collaborations with D.A.T.A., Base, Fire Station Artists Studios, Creative Futures Academy and Creative Sparks Fab Lab.</p>
<p class="list-info-text">We will also present Noire (France) in association with the French Embassy and Institut français, the Cannes award-winning immersive experience directed by Stéphane Foenkinos and Pierre-Alain Giraud, based on the work by Tania de Montaigne, produced by Novaya in partnership with the Centre Pompidou, co-produced with Flash Forward Entertainment.</p>
{% endif %}
{% if title == 'Events'%}
{{ festival_general_info.textEvent | safe }}
{% endif %}
{% if title == 'Exhibitions' %}
{% include '_ex.html' %}
{% if title == 'Exhibitions' %}
{% include '_ex.html' %}
{% endif %}
{% endif %}
</div>

53
templates/locations.html

@ -4,33 +4,32 @@
{% block content %}
<div id="main-wrapper">
{% include '_nav.html' %}
<div id="main-container-locations">
<div id="location-list">
<div id="location-button-list">
<div class="location-button" data-location="digital-hub">Digital Depot at The Digital Hub</div>
<div class="location-button" data-location="digital-bank">The Bank at The Digital Hub</div>
<div class="location-button" data-location="pallas-projects">Pallas Projects/Studios</div>
<div class="location-button" data-location="fire-station">Fire Station Artists Studios</div>
<div class="location-button" data-location="beckett">Samuel Beckett Theatre</div>
</div>
<div id="location-information">
<div id="location-text">
The Digital Hub, 10-13 Thomas St, The Liberties, Dublin 8, D08 PX8H
</div>
<a id="location-direction" target="_blank" href="https://www.google.com/maps/dir//115-117,+The+Coombe,+The+Liberties,+Dublin,+D08+A970/@53.3391179,-6.3569591,12z/data=!4m8!4m7!1m0!1m5!1m1!1s0x48670e89423ed249:0x8aa3669566840ff9!2m2!1d-6.274559!2d53.3391463?entry=ttu">
<div class="location-button">↳ Directions</div>
</a>
</div>
</div>
<div id="location-images">
<div id="location-image">
<img id="location-img" src="{{ url_for('static', filename='images/locations/digital-hub.webp') }}">
</div>
</div>
</div>
{% include '_nav.html' %}
<div id="main-container-locations">
<div id="location-list">
<div id="location-button-list">
{% for loc in locInfo %}
<div class="location-button" data-location="{{ loop.index0 }}">{{ loc.name }}</div>
{% endfor %}
</div>
<div id="location-information">
<div id="location-text">
{{ locInfo[0].directions }}
</div>
<a id="location-direction" target="_blank" href="{{ locInfo[0].url }}">
<div class="location-button">↳ Directions</div>
</a>
</div>
</div>
<div id="location-images">
<div id="location-image">
<img id="location-img" src="{{ locInfo[0].image }}">
</div>
</div>
</div>
</div>
<script type="module" src="{{ url_for('static', filename='js/skybox.js') }}"></script>
<script>
window.locInfo = {{ locInfo|tojson }};
</script>
<script type="module" src="{{ url_for('static', filename='js/locations.js') }}"></script>
{% endblock content %}
Loading…
Cancel
Save