mirror of
https://github.com/MathiasDPX/grainParisArt.git
synced 2025-01-08 00:06: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/
|
||||
.idea
|
||||
|
||||
# Python
|
||||
__pycache__/
|
||||
.venv
|
59
app.py
59
app.py
|
@ -1,36 +1,19 @@
|
|||
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 *
|
||||
|
||||
cinemas = {
|
||||
"C0071": "Écoles Cinéma Club",
|
||||
"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 = [Theater(data["node"]) for data in
|
||||
requests.get("https://www.allocine.fr/_/localization_city/Brest").json()["values"]["theaters"]]
|
||||
|
||||
theaters: list[Theater] = []
|
||||
for id, name in cinemas.items():
|
||||
theaters.append(Theater({
|
||||
"name": name,
|
||||
"internalId": id,
|
||||
"location": None
|
||||
}))
|
||||
|
||||
def getShowtimes(date):
|
||||
showtimes:list[Showtime] = []
|
||||
showtimes: list[Showtime] = []
|
||||
|
||||
for theater in theaters:
|
||||
showtimes.extend(theater.getShowtimes(date))
|
||||
|
@ -56,7 +39,6 @@ def getShowtimes(date):
|
|||
"seances": {}
|
||||
}
|
||||
|
||||
|
||||
if theater.name not in data[movie.title]["seances"].keys():
|
||||
data[movie.title]["seances"][theater.name] = []
|
||||
|
||||
|
@ -68,13 +50,13 @@ def getShowtimes(date):
|
|||
|
||||
return data
|
||||
|
||||
|
||||
showtimes = []
|
||||
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)
|
||||
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):
|
||||
match num:
|
||||
|
@ -92,6 +74,7 @@ def translateMonth(num: int):
|
|||
case 12: return "déc"
|
||||
case _: return "???"
|
||||
|
||||
|
||||
def translateDay(weekday: int):
|
||||
match weekday:
|
||||
case 0: return "lun"
|
||||
|
@ -103,6 +86,9 @@ def translateDay(weekday: int):
|
|||
case 6: return "dim"
|
||||
case _: return "???"
|
||||
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.route('/')
|
||||
def home():
|
||||
delta = request.args.get("delta", default=0, type=int)
|
||||
|
@ -112,17 +98,20 @@ def home():
|
|||
|
||||
dates = []
|
||||
|
||||
for i in range(0,7):
|
||||
day = datetime.today()+timedelta(i)
|
||||
for i in range(0, 7):
|
||||
day = datetime.today() + timedelta(i)
|
||||
dates.append({
|
||||
"jour": translateDay(day.weekday()),
|
||||
"chiffre": day.day,
|
||||
"mois": translateMonth(day.month),
|
||||
"choisi": i==delta,
|
||||
"choisi": i == delta,
|
||||
"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__':
|
||||
app.run()
|
||||
app.run()
|
|
@ -1,2 +1,3 @@
|
|||
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 name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<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' />
|
||||
<script src='https://api.mapbox.com/mapbox-gl-js/v2.8.1/mapbox-gl.js'></script>
|
||||
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css"
|
||||
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"/>
|
||||
<title>grainParisArt</title>
|
||||
<title>CinéBrest</title>
|
||||
{% block head %} {% endblock %}
|
||||
</head>
|
||||
|
||||
<header id="headerTop">
|
||||
<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>
|
||||
</div>
|
||||
</header>
|
||||
<body>
|
||||
{% block body %} {% endblock %}
|
||||
</body>
|
||||
</body>
|
||||
|
||||
<footer>
|
||||
<div class="container_footer">
|
||||
<p>Fait avec amour par Solène Derniaux</p>
|
||||
<p>©Tous droits réservés</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<br><a href="https://github.com/MathiasDPX/grainParisArt/tree/brest">Disponible sur GitHub</a></p>
|
||||
</div>
|
||||
</footer>
|
||||
</html>
|
|
@ -86,47 +86,32 @@
|
|||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
mapboxgl.accessToken = '###';
|
||||
var map = L.map('map').setView([48.396205, -4.477066], 13);
|
||||
|
||||
var map = new mapboxgl.Map({
|
||||
container: 'map',
|
||||
style: 'mapbox://styles/mapbox/streets-v11',
|
||||
center: [2.3522, 48.8566],
|
||||
zoom: 12
|
||||
});
|
||||
var myicon = L.icon({
|
||||
iconUrl: "static/images/point.png",
|
||||
iconSize: [16,16]
|
||||
})
|
||||
|
||||
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 = [
|
||||
{ coordinates: [2.348973, 48.848363], description: "Écoles Cinéma club" },
|
||||
{ coordinates: [2.546596, 48.840113], description: "UGC Ciné Cité Noisy-le-Grand" },
|
||||
{ coordinates: [2.343014, 48.849777], description: "UGC Ciné Cité les Halles" },
|
||||
{ coordinates: [2.342790, 48.849510], description: "Reflet Medicis" },
|
||||
{ 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" }
|
||||
{ coordinates: [48.390699, -4.487733], description: "Multiplexe Liberté" },
|
||||
{ coordinates: [48.397915, -4.473528], description: "CGR Brest Le Celtic" },
|
||||
{ coordinates: [48.396205, -4.477066], description: "Les Studios" },
|
||||
{ coordinates: [48.389640, -4.498724], description: "Pathé Capucins" },
|
||||
];
|
||||
|
||||
locations.forEach(function (location) {
|
||||
var el = document.createElement('div');
|
||||
el.className = 'custom-marker';
|
||||
|
||||
var popup = new mapboxgl.Popup({ offset: 25 }).setText(location.description);
|
||||
|
||||
new mapboxgl.Marker(el)
|
||||
.setLngLat(location.coordinates)
|
||||
.setPopup(popup)
|
||||
.addTo(map);
|
||||
new L.Marker(location.coordinates, {icon: myicon})
|
||||
.addTo(map)
|
||||
.bindPopup(location.description);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
|
Loading…
Reference in a new issue