From 18c8871e4c2814453a78d320ae3ffef31cdc0f45 Mon Sep 17 00:00:00 2001 From: Damian Myrda Date: Thu, 25 Apr 2024 22:16:21 -0500 Subject: [PATCH] Update and format everything --- .gitignore | 1 + README.md | 10 ++- config.py | 1 + database.json | 14 +++- database.py | 47 ++++++------ main.py | 102 +++++++++++++++++++++++-- models/discussion.py | 55 ++++++++------ models/event.py | 34 +++++---- models/group.py | 45 +++++------ models/member.py | 10 +-- models/project.py | 22 +++--- models/update.py | 15 ++-- projects.py | 28 +++---- schoology.py | 114 +++++++++++++++------------- static/intro.css | 70 ++++++++--------- static/style.css | 19 ++--- templates/discussions.html | 34 +++++---- templates/elements/authors.html | 7 +- templates/elements/datetime.html | 10 +-- templates/elements/discussions.html | 20 ++--- templates/elements/events.html | 55 ++++---------- templates/elements/metadata.html | 10 +-- templates/elements/navigation.html | 20 +++-- templates/elements/projects.html | 77 ++++++++----------- templates/elements/space.html | 38 +++++----- templates/elements/updates.html | 30 ++++---- templates/home.html | 43 +++++------ templates/members.html | 74 +++++++++--------- templates/projects.html | 43 ++++++----- templates/updates.html | 34 +++++---- 30 files changed, 584 insertions(+), 498 deletions(-) diff --git a/.gitignore b/.gitignore index 4f43ac1..6002496 100755 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ lib64 bin/ __pycache__/ pyvenv.cfg +google_auth.json diff --git a/README.md b/README.md index 3d561cd..6f3815d 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,15 @@ # computer_science_club + A website for Computer Science Club. It was made during a mini-hackathon. ## setup -To setup the server environment, run ```python -m venv .``` in the root of the project. Then, execute ```. ./bin/activate``` and you should be in the virtual environment. Next, run ```pip install flask schoolopy``` to install all the dependencies. Now, exit using by running ```exit```. + +To setup the server environment, run `python -m venv .` in the root of the project. Then, execute `. ./bin/activate` and you should be in the virtual environment. Next, run `pip install flask schoolopy` to install all the dependencies. Now, exit using by running `exit`. + +To setup Google OAuth2, goto [get google api clientid](https://developers.google.com/identity/oauth2/web/guides/get-google-api-clientid) and follow the instructions. Copy the json file into `google_auth.json` in the root of the project. In the `config.py` file in the directory of the project, change `REDIRECT_URL` to the url you used when you set up the google project. ## running -To run the server, you need an API key and its companioning secret. In your browser, go to ```schoology.(PUT DOMAIN HERE).org/api```. There, you can manage your API credentials. Get the key and secret and return. -Now, you can execute ```SCHOOLOGY_API_KEY="PUT KEY HERE" SCHOOLOGY_API_SECRET="PUT SECRET HERE" ./run.sh```. +To run the server, you need an API key and its companioning secret. In your browser, go to `schoology.(PUT DOMAIN HERE).org/api`. There, you can manage your API credentials. Get the key and secret and return. +Now, you can execute `SCHOOLOGY_API_KEY="PUT KEY HERE" SCHOOLOGY_API_SECRET="PUT SECRET HERE" ./run.sh`. diff --git a/config.py b/config.py index 0dbfb30..eca7a57 100644 --- a/config.py +++ b/config.py @@ -1,2 +1,3 @@ DOMAIN = "https://schoology.d214.org" GROUP_ID = 6454678062 +REDIRECT_URL = "127.0.0.1:5000" diff --git a/database.json b/database.json index 3fa2896..e5868d1 100644 --- a/database.json +++ b/database.json @@ -1 +1,13 @@ -{"py/object": "database.Data", "projects": [{"py/object": "project.Project", "name": "Computer Science Club Website", "description": "Made for Computer Science Club's Mini-Hackathon.", "authors": ["Damian Myrda"], "source": "https://github.com/moncheeta/computer_science_club", "images": null}]} +{ + "py/object": "database.Data", + "projects": [ + { + "py/object": "project.Project", + "name": "Computer Science Club Website", + "description": "(this website)", + "authors": ["Damian Myrda"], + "source": "https://github.com/moncheeta/computer_science_club.git", + "images": null + } + ] +} diff --git a/database.py b/database.py index 785a90a..08bd2e2 100644 --- a/database.py +++ b/database.py @@ -1,31 +1,32 @@ import os from jsonpickle import decode, encode + class Data: - projects = [] - - def __init__(self, projects): - self.projects = projects + projects = [] + + def __init__(self, projects): + self.projects = projects + class Database: - def read(self): - if not os.path.isfile("database.json"): - data = Data([]) - self.write(data) - return data - with open("database.json", "r") as file: - return decode(file.read()) - - def write(self, data): - with open("database.json", "w") as file: - file.write(encode(data)) + def read(self): + if not os.path.isfile("database.json"): + return Data([]) + with open("database.json", "r") as file: + return decode(file.read()) + + def write(self, data): + with open("database.json", "w") as file: + file.write(encode(data)) + class ProjectDatabase: - def read(self): - projects = [] - for project in Database().read().projects: - projects.append(project) - return projects - - def write(self, projects): - Database().write(Data(projects)) + def read(self): + projects = [] + for project in Database().read().projects: + projects.append(project) + return projects + + def write(self, projects): + Database().write(Data(projects)) diff --git a/main.py b/main.py index cc0f10e..21718fd 100644 --- a/main.py +++ b/main.py @@ -1,34 +1,120 @@ import os, sys, pathlib + PROJECT_DIR = os.path.join(pathlib.Path(__file__).parent) sys.path.append(os.path.join(PROJECT_DIR, "config.py")) sys.path.append(os.path.join(PROJECT_DIR, "models")) sys.path.append(os.path.join(PROJECT_DIR, "projects.py")) sys.path.append(os.path.join(PROJECT_DIR, "schoology.py")) +from config import REDIRECT_URL +from models import Project +from database import ProjectDatabase from schoology import group -from flask import Flask, render_template +from flask import Flask, request, redirect, abort, render_template, session +from cachecontrol import CacheControl app = Flask(__name__) app.secret_key = "https://computer-science-club.moncheeto.repl.co" + @app.route("/") def index(): - return render_template("home.html", group=group) + return render_template("home.html", group=group, account=session.get("name")) + @app.route("/updates") def updates(): - return render_template("updates.html", group=group) + return render_template("updates.html", group=group, account=session.get("name")) + @app.route("/discussions") def discussions(): - return render_template("discussions.html", group=group) + return render_template("discussions.html", group=group, account=session.get("name")) + -@app.route("/projects", methods = ["GET", "POST"]) +@app.route("/projects", methods=["GET", "POST"]) def projects(): - return render_template("projects.html", group=group) + return render_template( + "projects.html", group=group, create=False, account=session.get("name") + ) + + +@app.route("/projects/add", methods=["GET", "POST"]) +def add_project(): + if request.method == "POST": + if not session.get("name"): + return abort(401) + name = request.form["name"].rstrip() + description = request.form["description"].rstrip() + authors = request.form["authors"] + for author in authors: + author = author.rstrip() + source = request.form["source"].rstrip() + if source == "": + source = None + images = request.files.get("images") + group.projects.append(Project(name, description, [authors], source, images)) + ProjectDatabase().write(group.projects) + return redirect("/projects") + return render_template( + "projects.html", group=group, create=True, account=session.get("name") + ) + @app.route("/members") def members(): - return render_template("members.html", group=group) + return render_template("members.html", group=group, account=session.get("name")) + + +import requests +import google.auth.transport.requests +from google_auth_oauthlib.flow import Flow +from google.oauth2 import id_token + +GOOGLE_CLIENT_ID = ( + "861597772911-7k5ipk33tj84ubts3oulmqt6jp053hnr.apps.googleusercontent.com" +) +GOOGLE_CLIENT_SECRETS_FILE = os.path.join(PROJECT_DIR, "google_auth.json") +GOOGLE_AUTH_SCOPES = [ + "https://www.googleapis.com/auth/userinfo.profile", + "https://www.googleapis.com/auth/userinfo.email", + "openid", +] +os.environ["OAUTHLIB_INSECURE_TRANSPORT"] = "1" +flow = Flow.from_client_secrets_file( + client_secrets_file=GOOGLE_CLIENT_SECRETS_FILE, + scopes=GOOGLE_AUTH_SCOPES, + redirect_uri="http://" + REDIRECT_URL + "/login/callback", +) + + +@app.route("/login") +def login(): + auth_url, state = flow.authorization_url() + session["state"] = state + return redirect(auth_url) + + +@app.route("/login/callback") +def login_callback(): + flow.fetch_token(authorization_response=request.url) + if not session["state"] == request.args["state"]: + abort(500) + credentials = flow.credentials + request_session = requests.session() + cached_session = CacheControl(request_session) + token_request = google.auth.transport.requests.Request(session=cached_session) + id_info = id_token.verify_oauth2_token( + id_token=credentials._id_token, request=token_request, audience=GOOGLE_CLIENT_ID + ) + session["name"] = id_info.get("name") + return redirect("/") + + +@app.route("/logout") +def logout(): + session.clear() + return redirect("/") + if __name__ == "__main__": - app.run(host='0.0.0.0', port=8000) + app.run(host="0.0.0.0") diff --git a/models/discussion.py b/models/discussion.py index 45275f2..dc973b4 100644 --- a/models/discussion.py +++ b/models/discussion.py @@ -1,30 +1,39 @@ from config import DOMAIN + class Discussion: - name = "" - description = "" - link = f"{DOMAIN}/discussion/" - - def __init__(self, id, name, description): - self.link += str(id) - self.name = name - self.description = description + name = "" + description = "" + link = f"{DOMAIN}/discussion/" + + def __init__(self, id, name, description): + self.link += str(id) + self.name = name + self.description = description + + from datetime import datetime from config import DOMAIN + class Event: - name = "" - description = "" - start = datetime.now() - end = None - differentDay = False - link = f"{DOMAIN}/event/" - - def __init__(self, id, name, description, start, end): - self.link += str(id) - self.name = name - self.description = description - self.start = start - self.end = end - if end and self.end.year >= self.start.year and self.end.month >= self.start.month and self.end.day > start.day: - differentDay = True + name = "" + description = "" + start = datetime.now() + end = None + differentDay = False + link = f"{DOMAIN}/event/" + + def __init__(self, id, name, description, start, end): + self.link += str(id) + self.name = name + self.description = description + self.start = start + self.end = end + if ( + end + and self.end.year >= self.start.year + and self.end.month >= self.start.month + and self.end.day > start.day + ): + differentDay = True diff --git a/models/event.py b/models/event.py index e317953..00df198 100644 --- a/models/event.py +++ b/models/event.py @@ -1,19 +1,25 @@ from datetime import datetime from config import DOMAIN + class Event: - name = "" - description = "" - start = datetime.now() - end = None - differentDay = False - link = f"{DOMAIN}/event/" + name = "" + description = "" + start = datetime.now() + end = None + differentDay = False + link = f"{DOMAIN}/event/" - def __init__(self, id, name, description, start, end): - self.link += str(id) - self.name = name - self.description = description - self.start = start - self.end = end - if end and self.end.year >= self.start.year and self.end.month >= self.start.month and self.end.day > start.day: - differentDay = True + def __init__(self, id, name, description, start, end): + self.link += str(id) + self.name = name + self.description = description + self.start = start + self.end = end + if ( + end + and self.end.year >= self.start.year + and self.end.month >= self.start.month + and self.end.day > start.day + ): + differentDay = True diff --git a/models/group.py b/models/group.py index 16e5e39..b830174 100644 --- a/models/group.py +++ b/models/group.py @@ -1,24 +1,25 @@ class Group: - name = "" - description = "" - picture = "https://www.shutterstock.com/image-vector/computer-science-icon-outline-thin-600nw-1613513884.jpg" - leaders = [] - members = [] - events = [] - updates = [] - discussions = [] - projects = [] + name = "" + description = "" + picture = "https://www.shutterstock.com/image-vector/computer-science-icon-outline-thin-600nw-1613513884.jpg" + leaders = [] + members = [] + events = [] + updates = [] + discussions = [] + projects = [] - def __init__(self, name, description, events, updates, discussions, projects, members): - self.name = name - self.description = description - self.events = events - self.updates = updates - self.discussions = discussions - self.projects = projects - for member in members: - if member.leader: - self.leaders.append(member) - continue - self.members.append(member) - \ No newline at end of file + def __init__( + self, name, description, events, updates, discussions, projects, members + ): + self.name = name + self.description = description + self.events = events + self.updates = updates + self.discussions = discussions + self.projects = projects + for member in members: + if member.leader: + self.leaders.append(member) + continue + self.members.append(member) diff --git a/models/member.py b/models/member.py index e00e709..c53b566 100644 --- a/models/member.py +++ b/models/member.py @@ -1,7 +1,7 @@ class Member: - name = "" - leader = False + name = "" + leader = False - def __init__(self, name = "", leader = False): - self.name = name - self.leader = leader + def __init__(self, name="", leader=False): + self.name = name + self.leader = leader diff --git a/models/project.py b/models/project.py index 11f0f17..3484966 100644 --- a/models/project.py +++ b/models/project.py @@ -1,13 +1,13 @@ class Project: - name = "" - description = "" - authors = [] - source = None - images = None + name = "" + description = "" + authors = [] + source = None + images = None - def __init__(self, name, description, authors, source = None, images = None): - self.name = name - self.description = description - self.authors = authors - self.source = source - self.images = images + def __init__(self, name, description, authors, source=None, images=None): + self.name = name + self.description = description + self.authors = authors + self.source = source + self.images = images diff --git a/models/update.py b/models/update.py index 5507110..82b2f77 100644 --- a/models/update.py +++ b/models/update.py @@ -1,12 +1,13 @@ from datetime import datetime from member import Member + class Update: - member = Member() - text = "" - time = datetime.now() + member = Member() + text = "" + time = datetime.now() - def __init__(self, member, text, time): - self.member = member - self.text = text - self.time = time + def __init__(self, member, text, time): + self.member = member + self.text = text + self.time = time diff --git a/projects.py b/projects.py index fb558f6..6074ee9 100644 --- a/projects.py +++ b/projects.py @@ -1,19 +1,19 @@ from models import Project from database import Database, Data + class ProjectDatabase: - def read(self): - projects = [] - for project in Database().read()["projects"]: - name = project.get("name") - description = project.get("description") - authors = project.get("authors") - source = project.get("source") - images = project.get("images") - projects.append(Project(name, description, authors, source, images)) - return projects + def read(self): + projects = [] + for project in Database().read()["projects"]: + name = project.get("name") + description = project.get("description") + authors = project.get("authors") + source = project.get("source") + images = project.get("images") + projects.append(Project(name, description, authors, source, images)) + return projects - def write(self, projects): - with open("database.json", "w") as file: - file.write(encode(Data(projects))) - + def write(self, projects): + with open("database.json", "w") as file: + file.write(encode(Data(projects))) diff --git a/schoology.py b/schoology.py index 7ea51d9..7715362 100644 --- a/schoology.py +++ b/schoology.py @@ -1,71 +1,77 @@ import os from datetime import datetime from config import DOMAIN, GROUP_ID -from models import Group, Event, Update, Discussion, Project, Member +from models import Group, Event, Update, Discussion, Member +from database import ProjectDatabase from schoolopy import Schoology, Auth + class SchoologyAPI: - api = None - auth = Auth(os.environ["SCHOOLOGY_API_KEY"], os.environ["SCHOOLOGY_API_SECRET"], domain = DOMAIN) + api = None + auth = Auth( + os.environ["SCHOOLOGY_API_KEY"], + os.environ["SCHOOLOGY_API_SECRET"], + domain=DOMAIN, + ) + + def __init__(self): + self.api = Schoology(self.auth) + self.api.limit = 64 - def __init__(self): - self.api = Schoology(self.auth) - self.api.limit = 64 + def name(self): + return self.api.get_group(GROUP_ID).title - def name(self): - return self.api.get_group(GROUP_ID).title + def description(self): + return self.api.get_group(GROUP_ID).description - def description(self): - return self.api.get_group(GROUP_ID).description + def events(self): + events = [] + for event in self.api.get_group_events(GROUP_ID): + start = datetime.strptime(event.start, "%Y-%m-%d %H:%M:%S") + end = None + if event.has_end: + end = datetime.strptime(event.end, "%Y-%m-%d %H:%M:%S") + event = Event(event.id, event.title, event.description, start, end) + events.append(event) + return events - def events(self): - events = [] - for event in self.api.get_group_events(GROUP_ID): - start = datetime.strptime(event.start, "%Y-%m-%d %H:%M:%S") - end = None - differentDay = False - if event.has_end: - end = datetime.strptime(event.end, "%Y-%m-%d %H:%M:%S") - event = Event(event.id, event.title, event.description, start, end) - events.append(event) - return events + def updates(self): + updates = [] + for update in self.api.get_group_updates(GROUP_ID): + user = self.api.get_user(update.uid) + member = Member(user.name_display) + # time = datetime.utcfromtimestamp(int(update.created)) + time = datetime.utcfromtimestamp(int(update.last_updated)) + updates.append(Update(member, update.body, time)) + return updates - def updates(self): - updates = [] - for update in self.api.get_group_updates(GROUP_ID): - user = self.api.get_user(update.uid) - member = Member(user.name_display) - #time = datetime.utcfromtimestamp(int(update.created)) - time = datetime.utcfromtimestamp(int(update.last_updated)) - updates.append(Update(member, update.body, time)) - return updates + def discussions(self): + discussions = [] + for discussion in self.api.get_group_discussions(GROUP_ID): + discussions.append( + Discussion(discussion.id, discussion.title, discussion.body) + ) + return discussions - def discussions(self): - discussions = [] - for discussion in self.api.get_group_discussions(GROUP_ID): - discussions.append(Discussion(discussion.id, discussion.title, discussion.body)) - return discussions + def members(self): + members = [] + for enrolled in self.api.get_group_enrollments(GROUP_ID): + member = Member(enrolled.name_display) + if enrolled.admin == 1: + member.leader = True + members.append(member) + return members - def members(self): - members = [] - for enrolled in self.api.get_group_enrollments(GROUP_ID): - member = Member(enrolled.name_display) - if enrolled.admin == 1: - member.leader = True - members.append(member) - return members + def group(self): + name = self.name() + description = self.description() + events = self.events() + updates = self.updates() + discussions = self.discussions() + projects = ProjectDatabase().read() + members = self.members() + return Group(name, description, events, updates, discussions, projects, members) - def group(self): - name = self.name() - description = self.description() - events = self.events() - updates = self.updates() - discussions = self.discussions() - projects = [ - Project("Computer Science Club Website", "(this website)", ["Damian Myrda"], "https://replit.com/@Moncheeto/Computer-Science-Club?v=1") - ] - members = self.members() - return Group(name, description, events, updates, discussions, projects, members) api = SchoologyAPI() group = api.group() diff --git a/static/intro.css b/static/intro.css index 3597bfc..7627388 100644 --- a/static/intro.css +++ b/static/intro.css @@ -1,58 +1,58 @@ * { - color: #FFFF82; - text-align: center; - background-color: black; + color: #ffff82; + text-align: center; + background-color: black; } #board { - font-family: sans-serif; - transform: perspective(300px) rotateX(25deg); - transform-origin: 50% 100%; - text-align: justify; - position: absolute; - margin-left: -9em; - font-weight: bold; - overflow: hidden; - font-size: 350%; - height: 50em; - width: 18em; - bottom: 0; - left: 50%; + font-family: sans-serif; + transform: perspective(300px) rotateX(25deg); + transform-origin: 50% 100%; + text-align: justify; + position: absolute; + margin-left: -9em; + font-weight: bold; + overflow: hidden; + font-size: 350%; + height: 50em; + width: 18em; + bottom: 0; + left: 50%; } #board:after { - position: absolute; - content: ' '; - bottom: 60%; - left: 0; - right: 0; - top: 0; + position: absolute; + content: " "; + bottom: 60%; + left: 0; + right: 0; + top: 0; } #content { - animation: scroll 128s; - position: absolute; - top: 100%; + animation: scroll 128s; + position: absolute; + top: 100%; } @keyframes scroll { - 0% { - top: 100%; - } - 100% { - top: -350%; - } + 0% { + top: 100%; + } + 100% { + top: -350%; + } } #back { - color: white; + color: white; } #back.hidden { - opacity: 0; + opacity: 0; } #back.shown { - opacity: 1; - transition: opacity 2000ms; + opacity: 1; + transition: opacity 2000ms; } diff --git a/static/style.css b/static/style.css index c0f081e..752efab 100644 --- a/static/style.css +++ b/static/style.css @@ -1,19 +1,20 @@ * { - color: white; - font-family: monospace; + color: white; + font-family: monospace; } body { - background-color: black; + background-color: black; } -input, textarea { - color: black; +input, +textarea { + color: black; } center { - top: 50%; - left: 50%; - transform: translate(-50%,-50%); - position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + position: absolute; } diff --git a/templates/discussions.html b/templates/discussions.html index ebfe387..93721f8 100644 --- a/templates/discussions.html +++ b/templates/discussions.html @@ -1,21 +1,23 @@ - - {% import "elements/metadata.html" as metadata %} - {{ metadata.head(group, "Discussions") }} - - + + {% import "elements/metadata.html" as metadata %} {{ metadata.head(group, + "Discussions") }} + + -
- {% import "elements/navigation.html" as navigation %} - {{ navigation.bar() }} -
+
+ {% import "elements/navigation.html" as navigation %} {{ + navigation.bar(account) }} +
- - {% import "elements/space.html" as space %} - {{ space.stars(500) }} + + {% import "elements/space.html" as space %} {{ space.stars(500) }} -

Discussions

- {% import "elements/discussions.html" as discussions %} - {{ discussions.list(group.discussions) }} - +

Discussions

+ {% import "elements/discussions.html" as discussions %} {{ + discussions.list(group.discussions) }} + diff --git a/templates/elements/authors.html b/templates/elements/authors.html index 3a6f82c..f7cb1a2 100644 --- a/templates/elements/authors.html +++ b/templates/elements/authors.html @@ -1,9 +1,8 @@ {% macro view(author) -%} {{ author }} -{%- endmacro %} - -{% macro list(authors) -%} +{%- endmacro %} {% macro list(authors) -%}
- By: {{ view(authors[0]) }}{% for author in authors[1:] %}, {{ author }}{% endfor %} + By: {{ view(authors[0]) }}{% for author in authors[1:] %}, {{ author }}{% + endfor %}
{%- endmacro %} diff --git a/templates/elements/datetime.html b/templates/elements/datetime.html index 5218411..db2e889 100644 --- a/templates/elements/datetime.html +++ b/templates/elements/datetime.html @@ -1,7 +1,3 @@ -{% macro time(time) -%} - {{ time.hour }}:{{ time.minute }} -{%- endmacro %} - -{% macro date(date) -%} - {{ date.year }}.{{ date.month }}.{{ date.day }} -{%- endmacro %} +{% macro time(time) -%} {{ time.hour }}:{{ time.minute }} {%- endmacro %} {% +macro date(date) -%} {{ date.year }}.{{ date.month }}.{{ date.day }} {%- +endmacro %} diff --git a/templates/elements/discussions.html b/templates/elements/discussions.html index b1c563d..d6d5848 100644 --- a/templates/elements/discussions.html +++ b/templates/elements/discussions.html @@ -1,14 +1,8 @@ {% macro view(discussion) -%} - - {{ discussion.name }} - {{ discussion.description }} - -{%- endmacro %} - -{% macro list(discussions) -%} -{% for discussion in discussions %} -
- {{ view(discussion) }} -
-{% endfor %} -{%- endmacro %} + + {{ discussion.name }} {{ discussion.description }} + +{%- endmacro %} {% macro list(discussions) -%} {% for discussion in discussions +%} +
{{ view(discussion) }}
+{% endfor %} {%- endmacro %} diff --git a/templates/elements/events.html b/templates/elements/events.html index 344cb14..948418a 100644 --- a/templates/elements/events.html +++ b/templates/elements/events.html @@ -1,46 +1,17 @@ -{% import "elements/datetime.html" as datetime %} - -{% macro view(event) -%} +{% import "elements/datetime.html" as datetime %} {% macro view(event) -%} - {{ event.name }} - - at {{ datetime.time(event.start) }} - {% if event.end %} - to {{ datetime.time(event.end) }} - {% endif %} - - on {{ datetime.date(event.start) }} - {% if event.end %} - {% if event.differentDay %} - to {{ datetime.date(event.end) }} - {% endif %} - {% endif %} + {{ event.name }} at {{ datetime.time(event.start) }} {% if event.end %} to {{ + datetime.time(event.end) }} {% endif %} on {{ datetime.date(event.start) }} {% + if event.end %} {% if event.differentDay %} to {{ datetime.date(event.end) }} + {% endif %} {% endif %} -{%- endmacro %} - -{% macro next(event) -%} +{%- endmacro %} {% macro next(event) -%} - Upcoming: - {{ event.name }} - - at {{ datetime.time(event.start) }} - {% if event.end %} - to {{ datetime.time(event.end) }} - {% endif %} - - on {{ datetime.date(event.start) }} - {% if event.end %} - {% if event.differentDay %} - to {{ datetime.date(event.end) }} - {% endif %} - {% endif %} + Upcoming: {{ event.name }} at {{ datetime.time(event.start) }} {% if event.end + %} to {{ datetime.time(event.end) }} {% endif %} on {{ + datetime.date(event.start) }} {% if event.end %} {% if event.differentDay %} + to {{ datetime.date(event.end) }} {% endif %} {% endif %} -{%- endmacro %} - -{% macro upcoming(events) -%} -{% for event in events %} -
- view(event) -
-{% endfor %} -{%- endmacro %} +{%- endmacro %} {% macro upcoming(events) -%} {% for event in events %} +
view(event)
+{% endfor %} {%- endmacro %} diff --git a/templates/elements/metadata.html b/templates/elements/metadata.html index 70d9d79..2b9d0a0 100644 --- a/templates/elements/metadata.html +++ b/templates/elements/metadata.html @@ -1,8 +1,6 @@ {% macro head(group, subsection) -%} - {{ group.name }} - {% if subsection %} - - {{ subsection }} - {% endif %} - - + + {{ group.name }} {% if subsection %} - {{ subsection }} {% endif %} + + {%- endmacro %} diff --git a/templates/elements/navigation.html b/templates/elements/navigation.html index 61d3e72..d38b1bf 100644 --- a/templates/elements/navigation.html +++ b/templates/elements/navigation.html @@ -1,9 +1,17 @@ -{% macro bar() -%} +{% macro bar(account) -%} {%- endmacro %} diff --git a/templates/elements/projects.html b/templates/elements/projects.html index b9e3f4a..c86dca6 100644 --- a/templates/elements/projects.html +++ b/templates/elements/projects.html @@ -1,49 +1,38 @@ -{% import "elements/authors.html" as authors %} - -{% macro view(project) -%} -

{{ project.name }}

-

{{ project.description }}

- {% if project.source %} - Source Code -
- {% endif %} - {{ authors.list(project.authors) }} - {% if project.images %} - {% for image in project.images %} - - {% endfor %} - {% endif %} -{%- endmacro %} - -{% macro list(projects) -%} -{% for project in projects %} +{% import "elements/authors.html" as authors %} {% macro view(project) -%} +

{{ project.name }}

+

{{ project.description }}

+{% if project.source %} +Source Code +
+{% endif %} {{ authors.list(project.authors) }} {% if project.images %} {% for +image in project.images %} + +{% endfor %} {% endif %} {%- endmacro %} {% macro list(projects) -%} {% for +project in projects %}
- {{ view(project) }} -
+ {{ view(project) }} +
-{% endfor %} -{%- endmacro %} - -{% macro new() -%} +{% endfor %} {%- endmacro %} {% macro new() -%}
-

Add New Project

-
- - -
- - -
- - -
- - -
- - -
- -
+

Add New Project

+
+ + +
+ + +
+ + +
+ + +
+ + +
+ +
{%- endmacro %} diff --git a/templates/elements/space.html b/templates/elements/space.html index f725d8f..0a3e7e0 100644 --- a/templates/elements/space.html +++ b/templates/elements/space.html @@ -1,26 +1,26 @@ {% macro stars(num) -%} {%- endmacro %} diff --git a/templates/elements/updates.html b/templates/elements/updates.html index f9df6f9..deb347f 100644 --- a/templates/elements/updates.html +++ b/templates/elements/updates.html @@ -1,17 +1,13 @@ -{% import "elements/datetime.html" as datetime %} - -{% macro view(update) -%} -

{{ update.member.name }} on {{ datetime.date(update.time) }} at {{ datetime.time(update.time) }}: {{ update.text }}

-{%- endmacro %} - -{% macro recent(update) -%} -

Annocement from {{ update.member.name }} on {{ datetime.date(update.time) }} at {{ datetime.time(update.time) }}: {{ update.text }}

-{%- endmacro %} - -{% macro list(updates) -%} -{% for update in updates %} -
- {{ view(update) }} -
-{% endfor %} -{%- endmacro %} +{% import "elements/datetime.html" as datetime %} {% macro view(update) -%} +

+ {{ update.member.name }} on {{ datetime.date(update.time) }} at {{ + datetime.time(update.time) }}: {{ update.text }} +

+{%- endmacro %} {% macro recent(update) -%} +

+ Annocement from {{ update.member.name }} on {{ datetime.date(update.time) }} + at {{ datetime.time(update.time) }}: {{ update.text }} +

+{%- endmacro %} {% macro list(updates) -%} {% for update in updates %} +
{{ view(update) }}
+{% endfor %} {%- endmacro %} diff --git a/templates/home.html b/templates/home.html index 6d478b4..bfea052 100644 --- a/templates/home.html +++ b/templates/home.html @@ -1,27 +1,26 @@ - - {% import "elements/metadata.html" as metadata %} - {{ metadata.head(group)}} - - + + {% import "elements/metadata.html" as metadata %} {{ metadata.head(group)}} + + -
- {% import "elements/navigation.html" as navigation %} - {{ navigation.bar() }} -
+
+ {% import "elements/navigation.html" as navigation %} {{ + navigation.bar(account) }} +
- - {% import "elements/space.html" as space %} - {{ space.stars(500) }} -
-

{{ group.name }}

-

{{ group.description }}

+ + {% import "elements/space.html" as space %} {{ space.stars(500) }} +
+

{{ group.name }}

+

{{ group.description }}

- {% import "elements/events.html" as events %} - {{ events.next(group.events[0]) }} - - {% import "elements/updates.html" as updates %} - {{ updates.recent(group.updates[0]) }} -
- + {% import "elements/events.html" as events %} {{ + events.next(group.events[0]) }} {% import "elements/updates.html" as + updates %} {{ updates.recent(group.updates[0]) }} +
+ diff --git a/templates/members.html b/templates/members.html index 5fd07b9..903f15b 100644 --- a/templates/members.html +++ b/templates/members.html @@ -1,39 +1,41 @@ - - {% import "elements/metadata.html" as metadata %} - {{ metadata.head(group, "Members") }} - - + + {% import "elements/metadata.html" as metadata %} {{ metadata.head(group, + "Members") }} + + - - {% import "elements/space.html" as space %} - {{ space.stars(200) }} -
-
-
-

COMPUTER

-

SCIENCE

-

CLUB

-

LEADERS

- {% for leader in group.leaders %} -

{{ leader.name }}

- {% endfor %} -
-

MEMBERS

- {% for member in group.members %} -

{{ member.name }}

- {% endfor %} -
-

CREATED BY

-

Damian Myrda

-
-
-
- - - + + {% import "elements/space.html" as space %} {{ space.stars(200) }} +
+
+
+

COMPUTER

+

SCIENCE

+

CLUB

+

LEADERS

+ {% for leader in group.leaders %} +

{{ leader.name }}

+ {% endfor %} +
+

MEMBERS

+ {% for member in group.members %} +

{{ member.name }}

+ {% endfor %} +
+

CREATED BY

+

Damian Myrda

+
+
+
+ + + diff --git a/templates/projects.html b/templates/projects.html index dadbca5..edd3d6b 100644 --- a/templates/projects.html +++ b/templates/projects.html @@ -1,25 +1,26 @@ - - {% import "elements/metadata.html" as metadata %} - {% if create %} - {{ metadata.head(group, "New Project") }} - {% else %} - {{ metadata.head(group, "Projects") }} - {% endif %} - - + + {% import "elements/metadata.html" as metadata %} {% if create %} {{ + metadata.head(group, "New Project") }} {% else %} {{ metadata.head(group, + "Projects") }} {% endif %} + + -
- {% import "elements/navigation.html" as navigation %} - {{ navigation.bar() }} -
+
+ {% import "elements/navigation.html" as navigation %} {{ + navigation.bar(account) }} +
- - {% import "elements/space.html" as space %} - {{ space.stars(500) }} - - {% import "elements/projects.html" as projects %} -

Projects

- {{ projects.list(group.projects) }} - + + {% import "elements/space.html" as space %} {{ space.stars(500) }} {% import + "elements/projects.html" as projects %} {% if create %} {{ projects.new() }} + {% else %} +

Projects

+ {{ projects.list(group.projects) }} {% if account %} + Add a Project + {% endif %} {% endif %} + diff --git a/templates/updates.html b/templates/updates.html index dfc3477..970f71b 100644 --- a/templates/updates.html +++ b/templates/updates.html @@ -1,21 +1,23 @@ - - {% import "elements/metadata.html" as metadata %} - {{ metadata.head(group, "Updates") }} - - + + {% import "elements/metadata.html" as metadata %} {{ metadata.head(group, + "Updates") }} + + -
- {% import "elements/navigation.html" as navigation %} - {{ navigation.bar() }} -
+
+ {% import "elements/navigation.html" as navigation %} {{ + navigation.bar(account) }} +
- - {% import "elements/space.html" as space %} - {{ space.stars(500) }} + + {% import "elements/space.html" as space %} {{ space.stars(500) }} -

Updates

- {% import "elements/updates.html" as updates %} - {{ updates.list(group.updates) }} - +

Updates

+ {% import "elements/updates.html" as updates %} {{ + updates.list(group.updates) }} + -- 2.43.4