Merge pull request 'added homepage' (#1) from TussockyJoker/timtabla:master into master

Reviewed-on: Ugric/cov-to-ics#1
This commit is contained in:
Ugric committed 2026-04-25 00:27:33 +01:00
commit 1889835e02
4 files changed
+81 -17

No files matched your search

+5 -16
View File
@@ -9,10 +9,6 @@ from requests_ntlm import HttpNtlmAuth
import urllib
import html
# ------------------------------------------------------------
# Config
# ------------------------------------------------------------
LOCAL_TZ = pytz.timezone("Europe/London")
URL = "https://webapp.coventry.ac.uk/Timetable-main/Timetable/Current"
@@ -53,7 +49,6 @@ def parse_events(events_data):
return parsed_data
def get_events_data(page_data):
soup = BeautifulSoup(page_data, features="html.parser")
@@ -66,16 +61,13 @@ def get_events_data(page_data):
return source.split("events:")[1].split("]")[0] + "]"
def ics_time(dt):
return dt.astimezone(timezone.utc).strftime("%Y%m%dT%H%M%SZ")
def make_uid(event):
key = f"{event['moduleDesc']}|{event['title']}|{event['start'].isoformat()}"
return hashlib.sha1(key.encode()).hexdigest() + "@timetable"
def create_ics_event(event):
return {
"uid": make_uid(event),
@@ -85,7 +77,6 @@ def create_ics_event(event):
"end": event["end"],
}
def load_existing_uids(path):
uids = set()
return uids
@@ -111,7 +102,6 @@ def load_existing_uids(path):
return uids
def fetch_timetable(username, password):
session = requests.Session()
session.auth = HttpNtlmAuth(username, password)
@@ -123,7 +113,6 @@ def fetch_timetable(username, password):
session.close()
return r.text
def build_calendar(page_data):
events_js = get_events_data(page_data)
parsed_events = parse_events(events_js)
@@ -187,14 +176,14 @@ def build_calendar(page_data):
return data, start_year, start_month, end_year, end_month
# ------------------------------------------------------------
# Flask
# ------------------------------------------------------------
@app.route("/")
def home():
return render_template("home.jinja")
@app.route("/login")
def index():
return render_template("login.jinja")
@app.route("/login-and-download", methods=["POST"])
def login_and_download():
data = request.form
@@ -212,4 +201,4 @@ def login_and_download():
if __name__ == "__main__":
app.run(debug=True, host="0.0.0.0")
app.run(debug=True, host="0.0.0.0", port=3000)
+60
View File
@@ -41,6 +41,17 @@ body::before {
}
}
.title {
display: flex;
justify-content: center;
font-size: 80px;
font-weight: bold;
text-shadow:
0 20px 40px rgba(0, 0, 0, 0.2),
0 80px 200px rgba(255, 255, 255, 0.15);
}
.login-box {
position: absolute;
inset: 0px;
@@ -59,6 +70,28 @@ body::before {
align-items: center;
}
.text-box {
font-size: 20px;
position: absolute;
inset: 0px;
max-width: 90%;
max-width: 800px;
height: fit-content;
max-height: 100dvh;
margin: auto;
background: var(--background);
padding: 30px;
border-radius: 8px;
text-align: center;
border: solid 1px var(--accent);
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
display: flex;
flex-direction: column;
align-items: center;
}
.text-box .b
input {
width: 100%;
padding: 8px;
@@ -81,6 +114,33 @@ button {
cursor: pointer;
}
.button {
margin-top: 1rem;
width: fit-content;
min-width: 7.5rem;
padding: 10px;
background: var(--accent);
color: var(--background);
font-size: large;
font-weight: bold;
border: none;
cursor: pointer;
text-decoration: none;
}
.div-image {
background-size: cover;
background-position: center;
max-width: 80%;
max-height: 80%;
aspect-ratio: 1/1;
object-fit: scale-down;
display: block;
margin: 0 auto;
border-radius: 10px;
}
button:hover {
background: var(--primary);
color: var(--background);
+16
View File
@@ -0,0 +1,16 @@
{%set page_title = "Home"%}
{% extends "base.jinja" %}
{% block body %}
<p class="title">Timtabla</p>
<div class="text-box">
<p> Timtabla is a third-party website for Coventry University students to convert their timetable to an <code style="font-size: 17px;">.ics</code> file which can be imported into any modern calendar app.</p>
<b> Please be aware we do not store your username or password on our server, just pass them on to the university server to retrieve your timetable.</b>
<p> This website is based on open-source code developed by Coventry University students, you can find this code at <a href="https://git.wbell.dev/Ugric/cov-to-ics">git.wbell.dev</a> </p>
<a href="https://git.wbell.dev/Ugric/cov-to-ics">
<img src="https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/png/gitea.png" alt="Gitea Logo" height="48" />
</a>
<a href="/login" class="button"> Convert timetable </a>
</div>
{% endblock %}
-1
View File
@@ -10,7 +10,6 @@
<button type="submit">Login & Download</button>
<!-- Optional: server can re-render this with an error message -->
{% if error|trim %}<div class="error">{{error}}</div>{% endif %}
</form>
{% endblock %}