]> prime8.dev >> repos - csc.git/commitdiff
Complete remolding
authorDamian Myrda <monkey.damianek@gmail.com>
Tue, 17 Sep 2024 23:34:14 +0000 (18:34 -0500)
committerDamian Myrda <monkey.damianek@gmail.com>
Tue, 17 Sep 2024 23:34:14 +0000 (18:34 -0500)
12 files changed:
Dockerfile
config.py
models/discussion.py
models/event.py
models/group.py
schoology.py
static/intro.css
static/main.css
templates/elements/datetime.html
templates/elements/metadata.html
templates/elements/space.html
templates/home.html

index fb0f0028d1fc16912ec9bba93219ba8b8a3d48ca..ecc7d2f037ea260ccd9c88d42a4bbc9a673c0512 100644 (file)
@@ -11,6 +11,7 @@ RUN pip install --no-cache-dir \
   gunicorn \
   flask \
   schoolopy \
+  schedule \
   cachecontrol \
   google-auth \
   google_auth_oauthlib
index 0fed17c6ecc91bee9c5969d4ccf3e8d1f8fe1023..e5ad8b413a72cd1f271184476cc5e59769d0d802 100644 (file)
--- a/config.py
+++ b/config.py
@@ -1,7 +1,8 @@
 import os
 
-DOMAIN = "https://" + os.environ["DOMAIN"]
+DOMAIN = os.environ["DOMAIN"]
 
 GROUP_ID = os.environ["GROUP_ID"]
+SCHOOLOGY_DOMAIN = "https://" + os.environ["SCHOOLOGY_DOMAIN"]
 SCHOOLOGY_API_KEY = os.environ["SCHOOLOGY_API_KEY"]
 SCHOOLOGY_API_SECRET = os.environ["SCHOOLOGY_API_SECRET"]
index cc3e9ffcc3d8d235dbf99f15fee10083ba37065c..d45fbd5e5a1cf703e1d79cc9027ed0360137d2a0 100644 (file)
@@ -1,8 +1,8 @@
-from config import DOMAIN
+from config import SCHOOLOGY_DOMAIN
 
 
 class Discussion:
     def __init__(self, id, name, description):
         self.name = name
         self.description = description
-        self.link = f"{DOMAIN}/discussion/{str(id)}"
+        self.link = f"{SCHOOLOGY_DOMAIN}/discussion/{str(id)}"
index 7140c70c44fce04eedf713dd641920496d5e741e..d9418478486ee4b41e02de16c81632b8e9a8ade7 100644 (file)
@@ -1,11 +1,11 @@
-from config import DOMAIN
+from config import SCHOOLOGY_DOMAIN
 
 
 class Event:
     def __init__(self, id, name, description, start, end=None):
         self.name = name
         self.description = description
-        self.link = f"{DOMAIN}/event/{str(id)}"
+        self.link = f"{SCHOOLOGY_DOMAIN}/event/{str(id)}"
         self.start = start
         self.end = end
         if end and (
index 24a070dc00a442b96fde09b7a71a8373bf83d1c8..59b5e3a16dce2cf1997da140de425ee72f8d70e4 100644 (file)
@@ -2,7 +2,6 @@ class Group:
     def __init__(self, name, description):
         self.name = name
         self.description = description
-        self.picture = "https://www.shutterstock.com/image-vector/computer-science-icon-outline-thin-600nw-1613513884.jpg"
 
         self.events = []
         self.updates = []
index 9525f126541064ae9eb15552f0d4f606442458ff..21de793e5da2d3965c7b5b6b9a7151f64d34f5af 100644 (file)
@@ -1,14 +1,22 @@
-from config import DOMAIN, GROUP_ID, SCHOOLOGY_API_KEY, SCHOOLOGY_API_SECRET
+from config import (
+    GROUP_ID,
+    SCHOOLOGY_DOMAIN,
+    SCHOOLOGY_API_KEY,
+    SCHOOLOGY_API_SECRET,
+)
 from datetime import datetime
 from models import Group, Event, Update, Discussion, Member
 from schoolopy import Schoology, Auth
 from database import database
+import schedule
+import time
+from threading import Thread
 
 
 auth = Auth(
     SCHOOLOGY_API_KEY,
     SCHOOLOGY_API_SECRET,
-    domain=DOMAIN,
+    domain=SCHOOLOGY_DOMAIN,
 )
 api = Schoology(auth)
 api.limit = 64
@@ -16,6 +24,7 @@ api.limit = 64
 group = Group(
     api.get_group(GROUP_ID).title, api.get_group(GROUP_ID).description
 )
+group.projects = database.read()
 
 
 def get_members():
@@ -27,19 +36,10 @@ def get_members():
             group.members.append(member)
 
 
-def find_member(name):
-    for member in group.members:
-        if member.name == name:
-            return member
-    return None
-
-
 def get_updates():
     for update in api.get_group_updates(GROUP_ID):
         user = api.get_user(update.uid)
-        member = find_member(user.name_display)
-        if not member:
-            continue
+        member = Member(user.name_display)
         created = datetime.utcfromtimestamp(int(update.created))
         group.updates.append(Update(member, update.body, created))
 
@@ -66,7 +66,17 @@ def update():
     get_updates()
     get_events()
     get_discussions()
-    group.projects = database.read()
 
 
 update()
+schedule.every().hour.do(update)
+
+
+def run():
+    while True:
+        schedule.run_pending()
+        time.sleep(1 * 60)
+
+
+scheduler = Thread(target=run, daemon=True)
+scheduler.start()
index 8cbd128d7b78e9e75ee21417c76a8f0e6a54bd95..6774b31f791378a904b1ca2596976c4d6553ec57 100644 (file)
@@ -1,6 +1,6 @@
 * {
   color: #ffff82;
-  background-color: black;
+  background-color: transparent;
   text-align: center;
 }
 
@@ -8,7 +8,10 @@ html, body {
   width: 100%;
   height: 100%;
   margin: 0;
-  padding: 0;
+}
+
+body {
+  background-color: black;
 }
 
 #board {
@@ -53,6 +56,8 @@ html, body {
 
 #back {
   color: white;
+  position: absolute;
+  padding-top: 8px;
 }
 
 #back.hidden {
index 828e370dec02e9659aec62d3a7a07b42d3aee5cd..388220cd65ab4a5c2e5f3e266af5458ce6919f0b 100644 (file)
@@ -1,7 +1,8 @@
 * {
   color: white;
-  background-color: black;
+  background-color: transparent;
   font-family: monospace;
+  font-size: 18px;
 }
 
 html, body {
@@ -11,11 +12,7 @@ html, body {
 }
 
 body {
-  padding: 8px;
-}
-
-input, textarea {
-  color: black;
+  background-color: black;
 }
 
 center {
@@ -24,3 +21,12 @@ center {
   transform: translate(-50%, -50%);
   position: absolute;
 }
+
+#title {
+  font-size: 32px;
+}
+
+input, textarea {
+  color: black;
+}
+
index a913bcd2f9f412ec2d62e4dcf3310a68e1ce9c9d..66a42e74779e8886e4c283f628b4e85a91493f3d 100644 (file)
@@ -1,7 +1,7 @@
 {% macro time(time) -%}
-{{ time.hour }}:{{ time.minute }}
+{{ "{:02}:{:02}".format(time.hour, time.minute) }}
 {%- endmacro %}
 
 {% macro date(date) -%}
-{{ date.year }}.{{ date.month }}.{{ date.day }}
+{{ "{:04}.{:02}.{:02}".format(date.year, date.month, date.day) }}
 {%-endmacro %}
index 2b9d0a07dc25f1d7413af5982e883b96508ee108..5a1292eae5094c9f8035c216bba9ac420461f84b 100644 (file)
@@ -1,6 +1,5 @@
 {% macro head(group, subsection) -%}
 <title>
-  {{ group.name }} {% if subsection %} - {{ subsection }} {% endif %}
+  CSC {% if subsection %} - {{ subsection }} {% endif %}
 </title>
-<link rel="icon" type="image/x-icon" href="{{ group.picture }}" />
 {%- endmacro %}
index 83deaf0f605c797d3081796935e98a14eb5e54f8..900ceb9899ac07a45445a4bacf76ed5583c59731 100644 (file)
@@ -1,6 +1,6 @@
 {% macro stars(num) -%}
 <style>
-  #star {
+  .star {
     position: absolute;
     background-color: white !important;
     width: 1px;
        return [rw, rh];
   }
 
-  for (let i = 0; i < {{ num }}; i++) {
-       let star = document.createElement("div");
-       star.id = "star";
-       var [w, h] = randomPosition();
-       star.style.top = h + "px";
-       star.style.left = w + "px";
-       document.body.append(star);
+  function createStars() {
+    document.querySelectorAll(".star").forEach(element => element.remove());
+    for (let i = 0; i < {{ num }}; i++) {
+      let star = document.createElement("div");
+      star.className = "star";
+      var [w, h] = randomPosition();
+      star.style.top = h + "px";
+      star.style.left = w + "px";
+      document.body.append(star);
+    }
   }
+  createStars();
+  window.onresize = createStars;
 </script>
 {%- endmacro %}
index 2ea0465818b81bfa0389e3cf6e6797348042c776..029bc72eed6cf7904b6349805de27b643a7d5dd7 100644 (file)
@@ -18,7 +18,7 @@
     {% import "elements/space.html" as space %}
     {{ space.stars(500) }}
     <center>
-      <h1>{{ group.name }}</h1>
+      <h1 id="title">{{ group.name }}</h1>
       <p>{{ group.description }}</p>
 
       {% import "elements/events.html" as events %}