mirror of
https://github.com/MathiasDPX/grainParisArt.git
synced 2025-01-09 00:26:38 +00:00
Rebrand for Brest
This commit is contained in:
parent
0e8b3523b8
commit
c515b51a1a
9 changed files with 63 additions and 109 deletions
1
.env.example
Normal file
1
.env.example
Normal file
|
@ -0,0 +1 @@
|
||||||
|
JAWG_API_KEY="Votre clé d'API jawg.io"
|
8
.gitignore
vendored
8
.gitignore
vendored
|
@ -1,3 +1,9 @@
|
||||||
__pycache__/
|
.env
|
||||||
|
|
||||||
|
# IDE
|
||||||
.vscode/
|
.vscode/
|
||||||
|
.idea
|
||||||
|
|
||||||
|
# Python
|
||||||
|
__pycache__/
|
||||||
.venv
|
.venv
|
59
app.py
59
app.py
|
@ -1,36 +1,19 @@
|
||||||
from flask import Flask, render_template, request
|
from flask import Flask, render_template, request
|
||||||
from datetime import datetime, timedelta
|
from datetime import timedelta
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
from os import getenv
|
||||||
|
|
||||||
# IMPORT DES MODULES
|
load_dotenv()
|
||||||
|
|
||||||
|
# IMPORT DES MODULES
|
||||||
from modules.Classes import *
|
from modules.Classes import *
|
||||||
|
|
||||||
cinemas = {
|
theaters = [Theater(data["node"]) for data in
|
||||||
"C0071": "Écoles Cinéma Club",
|
requests.get("https://www.allocine.fr/_/localization_city/Brest").json()["values"]["theaters"]]
|
||||||
"C2954": "MK2 Bibliothèque",
|
|
||||||
"C0050": "MK2 Beaubourg",
|
|
||||||
"W7504": "Épée de bois",
|
|
||||||
"C0076": "Cinéma du Panthéon",
|
|
||||||
"C0089": "Max Linder Panorama",
|
|
||||||
"C0013": "Luminor Hotel de Ville",
|
|
||||||
"C0072": "Le Grand Action",
|
|
||||||
"C0099": "MK2 Parnasse",
|
|
||||||
"C0073": "Le Champo",
|
|
||||||
"C0020": "Filmothèque du Quartier Latin",
|
|
||||||
"C0074": "Reflet Medicis",
|
|
||||||
"C0159": "UGC Ciné Cité Les Halles",
|
|
||||||
"C0026": "UGC Ciné Cité Bercy"
|
|
||||||
}
|
|
||||||
|
|
||||||
theaters: list[Theater] = []
|
|
||||||
for id, name in cinemas.items():
|
|
||||||
theaters.append(Theater({
|
|
||||||
"name": name,
|
|
||||||
"internalId": id,
|
|
||||||
"location": None
|
|
||||||
}))
|
|
||||||
|
|
||||||
def getShowtimes(date):
|
def getShowtimes(date):
|
||||||
showtimes:list[Showtime] = []
|
showtimes: list[Showtime] = []
|
||||||
|
|
||||||
for theater in theaters:
|
for theater in theaters:
|
||||||
showtimes.extend(theater.getShowtimes(date))
|
showtimes.extend(theater.getShowtimes(date))
|
||||||
|
@ -56,7 +39,6 @@ def getShowtimes(date):
|
||||||
"seances": {}
|
"seances": {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if theater.name not in data[movie.title]["seances"].keys():
|
if theater.name not in data[movie.title]["seances"].keys():
|
||||||
data[movie.title]["seances"][theater.name] = []
|
data[movie.title]["seances"][theater.name] = []
|
||||||
|
|
||||||
|
@ -68,13 +50,13 @@ def getShowtimes(date):
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
showtimes = []
|
showtimes = []
|
||||||
for i in range(0, 7):
|
for i in range(0, 7):
|
||||||
day_showtimes = getShowtimes(datetime.today()+timedelta(days=i))
|
day_showtimes = getShowtimes(datetime.today() + timedelta(days=i))
|
||||||
showtimes.append(day_showtimes)
|
showtimes.append(day_showtimes)
|
||||||
print(f"{len(day_showtimes)} séances récupéré {i+1}/7!")
|
print(f"{len(day_showtimes)} séances récupéré {i + 1}/7!")
|
||||||
|
|
||||||
app = Flask(__name__)
|
|
||||||
|
|
||||||
def translateMonth(num: int):
|
def translateMonth(num: int):
|
||||||
match num:
|
match num:
|
||||||
|
@ -92,6 +74,7 @@ def translateMonth(num: int):
|
||||||
case 12: return "déc"
|
case 12: return "déc"
|
||||||
case _: return "???"
|
case _: return "???"
|
||||||
|
|
||||||
|
|
||||||
def translateDay(weekday: int):
|
def translateDay(weekday: int):
|
||||||
match weekday:
|
match weekday:
|
||||||
case 0: return "lun"
|
case 0: return "lun"
|
||||||
|
@ -103,6 +86,9 @@ def translateDay(weekday: int):
|
||||||
case 6: return "dim"
|
case 6: return "dim"
|
||||||
case _: return "???"
|
case _: return "???"
|
||||||
|
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def home():
|
def home():
|
||||||
delta = request.args.get("delta", default=0, type=int)
|
delta = request.args.get("delta", default=0, type=int)
|
||||||
|
@ -112,17 +98,20 @@ def home():
|
||||||
|
|
||||||
dates = []
|
dates = []
|
||||||
|
|
||||||
for i in range(0,7):
|
for i in range(0, 7):
|
||||||
day = datetime.today()+timedelta(i)
|
day = datetime.today() + timedelta(i)
|
||||||
dates.append({
|
dates.append({
|
||||||
"jour": translateDay(day.weekday()),
|
"jour": translateDay(day.weekday()),
|
||||||
"chiffre": day.day,
|
"chiffre": day.day,
|
||||||
"mois": translateMonth(day.month),
|
"mois": translateMonth(day.month),
|
||||||
"choisi": i==delta,
|
"choisi": i == delta,
|
||||||
"index": i
|
"index": i
|
||||||
})
|
})
|
||||||
|
|
||||||
return render_template('index.html', page_actuelle='home', films=showtimes[delta], dates=dates)
|
return render_template('index.html',
|
||||||
|
films=showtimes[delta],
|
||||||
|
dates=dates,
|
||||||
|
JAWG_API_KEY=getenv("JAWG_API_KEY"))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run()
|
app.run()
|
|
@ -1,2 +1,3 @@
|
||||||
Flask
|
Flask
|
||||||
requests
|
requests
|
||||||
|
python-dotenv
|
Binary file not shown.
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
BIN
static/images/point.png
Normal file
BIN
static/images/point.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
|
@ -1,32 +0,0 @@
|
||||||
var isLoading = false;
|
|
||||||
var page = 1;
|
|
||||||
|
|
||||||
function fetchCinemaSessions() {
|
|
||||||
if (isLoading) return;
|
|
||||||
|
|
||||||
isLoading = true;
|
|
||||||
var loadingContainer = document.getElementById('loading-container');
|
|
||||||
loadingContainer.innerHTML = '<img src="{{ url_for("static", filename="loading.gif") }}" alt="Loading...">';
|
|
||||||
|
|
||||||
fetch('/?page=' + page)
|
|
||||||
.then(function(response) {
|
|
||||||
return response.text();
|
|
||||||
})
|
|
||||||
.then(function(html) {
|
|
||||||
var cinemaContainer = document.getElementById('cinema-container');
|
|
||||||
cinemaContainer.insertAdjacentHTML('beforeend', html);
|
|
||||||
isLoading = false;
|
|
||||||
page += 1;
|
|
||||||
})
|
|
||||||
.catch(function() {
|
|
||||||
isLoading = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
window.addEventListener('scroll', function() {
|
|
||||||
if (window.innerHeight + window.scrollY >= document.body.offsetHeight - 100 && !isLoading) {
|
|
||||||
fetchCinemaSessions();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
fetchCinemaSessions();
|
|
|
@ -4,27 +4,31 @@
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<link rel="stylesheet" href="{{url_for('static', filename='css/main.css')}}">
|
<link rel="stylesheet" href="{{url_for('static', filename='css/main.css')}}">
|
||||||
<link href='https://api.mapbox.com/mapbox-gl-js/v2.8.1/mapbox-gl.css' rel='stylesheet' />
|
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css"
|
||||||
<script src='https://api.mapbox.com/mapbox-gl-js/v2.8.1/mapbox-gl.js'></script>
|
integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY="
|
||||||
|
crossorigin=""/>
|
||||||
|
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"
|
||||||
|
integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo="
|
||||||
|
crossorigin=""></script>
|
||||||
<link rel="shortcut icon" type="image/png" href="static/images/favicon.png"/>
|
<link rel="shortcut icon" type="image/png" href="static/images/favicon.png"/>
|
||||||
<title>grainParisArt</title>
|
<title>CinéBrest</title>
|
||||||
{% block head %} {% endblock %}
|
{% block head %} {% endblock %}
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<header id="headerTop">
|
<header id="headerTop">
|
||||||
<div class="divHeader">
|
<div class="divHeader">
|
||||||
<h1 class="textLogo_header">GrainParisArt</h1>
|
<h1 class="textLogo_header">CinéBrest</h1>
|
||||||
<p>Quand ça va pas, y aura toujours le cinéma</p>
|
<p>Quand ça va pas, y aura toujours le cinéma</p>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<body>
|
<body>
|
||||||
{% block body %} {% endblock %}
|
{% block body %} {% endblock %}
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
<footer>
|
<footer>
|
||||||
<div class="container_footer">
|
<div class="container_footer">
|
||||||
<p>Fait avec amour par Solène Derniaux</p>
|
<a>Fait avec amour par <a href="https://www.solenederniaux.fr/">Solène Derniaux</a><br><a href="https://coolcraft.ovh">Adapté pour Brest par MathiasDPX</a></p>
|
||||||
<p>©Tous droits réservés</p>
|
<p>©Tous droits réservés<br><a href="https://github.com/MathiasDPX/grainParisArt/tree/brest">Disponible sur GitHub</a></p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
</html>
|
</html>
|
|
@ -86,47 +86,32 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
mapboxgl.accessToken = '###';
|
var map = L.map('map').setView([48.396205, -4.477066], 13);
|
||||||
|
|
||||||
var map = new mapboxgl.Map({
|
var myicon = L.icon({
|
||||||
container: 'map',
|
iconUrl: "static/images/point.png",
|
||||||
style: 'mapbox://styles/mapbox/streets-v11',
|
iconSize: [16,16]
|
||||||
center: [2.3522, 48.8566],
|
})
|
||||||
zoom: 12
|
|
||||||
});
|
|
||||||
|
|
||||||
map.addControl(new mapboxgl.NavigationControl());
|
L.tileLayer('https://tile.jawg.io/jawg-lagoon/{z}/{x}/{y}{r}.png?access-token={accessToken}', {
|
||||||
|
attribution: '<a href="https://jawg.io" title="Tiles Courtesy of Jawg Maps" target="_blank">© <b>Jawg</b>Maps</a> © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
|
||||||
|
minZoom: 0,
|
||||||
|
maxZoom: 22,
|
||||||
|
accessToken: '{{ JAWG_API_KEY }}'
|
||||||
|
}).addTo(map);
|
||||||
|
|
||||||
var locations = [
|
var locations = [
|
||||||
{ coordinates: [2.348973, 48.848363], description: "Écoles Cinéma club" },
|
{ coordinates: [48.390699, -4.487733], description: "Multiplexe Liberté" },
|
||||||
{ coordinates: [2.546596, 48.840113], description: "UGC Ciné Cité Noisy-le-Grand" },
|
{ coordinates: [48.397915, -4.473528], description: "CGR Brest Le Celtic" },
|
||||||
{ coordinates: [2.343014, 48.849777], description: "UGC Ciné Cité les Halles" },
|
{ coordinates: [48.396205, -4.477066], description: "Les Studios" },
|
||||||
{ coordinates: [2.342790, 48.849510], description: "Reflet Medicis" },
|
{ coordinates: [48.389640, -4.498724], description: "Pathé Capucins" },
|
||||||
{ coordinates: [2.342790, 48.849510], description: "Fimothèque du quartier Latin" },
|
|
||||||
{ coordinates: [2.343223, 48.849980], description: "Le Champo" },
|
|
||||||
{ coordinates: [2.330526, 48.842813], description: "MK2 Parnasse" },
|
|
||||||
{ coordinates: [2.352129, 48.847530], description: "Le Grand Action" },
|
|
||||||
{ coordinates: [2.353602, 48.858676], description: "Luminor Hotel de Ville" },
|
|
||||||
{ coordinates: [2.344856, 48.871370], description: "Max Linder Panorama" },
|
|
||||||
{ coordinates: [2.342385, 48.847488], description: "Cinéma du Panthéon" },
|
|
||||||
{ coordinates: [2.349555, 48.841300], description: "Épée de bois" },
|
|
||||||
{ coordinates: [2.375488, 48.832448], description: "MK2 Bibliothèque" },
|
|
||||||
{ coordinates: [2.352312, 48.861584], description: "MK2 Beaubourg" }
|
|
||||||
];
|
];
|
||||||
|
|
||||||
locations.forEach(function (location) {
|
locations.forEach(function (location) {
|
||||||
var el = document.createElement('div');
|
new L.Marker(location.coordinates, {icon: myicon})
|
||||||
el.className = 'custom-marker';
|
.addTo(map)
|
||||||
|
.bindPopup(location.description);
|
||||||
var popup = new mapboxgl.Popup({ offset: 25 }).setText(location.description);
|
|
||||||
|
|
||||||
new mapboxgl.Marker(el)
|
|
||||||
.setLngLat(location.coordinates)
|
|
||||||
.setPopup(popup)
|
|
||||||
.addTo(map);
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue