Skip to content

Commit

Permalink
FINALLY moved repo data polling from client js to server
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreaTerenz committed Feb 21, 2024
1 parent 768411f commit 6eb2210
Show file tree
Hide file tree
Showing 19 changed files with 259 additions and 278 deletions.
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ name = "pypi"

[packages]
flask = "*"
requests = "*"

[dev-packages]

Expand Down
140 changes: 131 additions & 9 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# AndreaTerenz.github.io

<p align="center">
<img src="static/icons/new/favicon-base.png" alt="site favicon"/>
<img src="static/icons/favicon-base.png" alt="site favicon"/>
</p>

Welcome to my personal portfolio website.
Expand Down
76 changes: 48 additions & 28 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,59 @@
from dataclasses import dataclass
from datetime import date

import requests
import flask
from flask import Flask, send_from_directory, request
from flask import Flask, request

app = Flask(__name__)
def get_request(url):
r = requests.get(url)

@dataclass
class ShareSocial:
name: str
link: str
assert r.status_code == 200, f"Status: {r.status_code} - URL: {url}"
return r.json()

GH_LANG_COLORS = get_request("https://raw.githubusercontent.com/ozh/github-colors/master/colors.json")
GH_LANG_COLORS = { lang : GH_LANG_COLORS[lang]["color"] for lang in GH_LANG_COLORS }

@dataclass
class Repo:
display_name : str
description : str
gh_name : str
display_name : str = ""
description : str = ""
data : dict = None

def __post_init__(self):
self.reload()

#FIXME: DO THIS EVERY 60 MINS (otherwise the data may be stale)
def reload(self):
self.data = get_request(f"https://api.github.com/repos/AndreaTerenz/{self.gh_name}")

if self.description != "":
self.data["description"] = self.description

self.data["name"] = self.display_name if self.display_name != "" else self.gh_name

lang = self.data.get("language", "")
self.data["lang_color"] = GH_LANG_COLORS[lang] if lang else ""

print("Loading repos data...", end="")
repos = [
Repo("Nameless", display_name="Nameless",
description="FPS prototype game made with Godot"),
Repo("Advent-of-Code-2020", display_name="AoC 2020",
description="Some of my solutions for the 2020 Advent of Code challenges"),
Repo("p5-pong", display_name="p5 Pong",
description="Pong clone made with p5.js and Node.js"),
Repo("GodotMaze", display_name="GodotMaze",
description="A demonstration of some maze generation algorithms made with Godot"),
Repo("Portfolio", display_name="This very website",
description="This portfolio website, made with Bootstrap 5 and Less"),
]
print("done")

@dataclass
class ShareSocial:
name: str
link: str

@dataclass
class Contact:
Expand All @@ -31,17 +69,7 @@ def calculateAge(birthDate):

return age

@app.route("/static/icons/new/<path:filename>")
def newicons(filename):
return send_from_directory(app.static_folder, f"icons/new/{filename}")

@app.route("/static/scripts/<path:filename>")
def scripts(filename):
return send_from_directory(app.static_folder, f"scripts/{filename}")

@app.route("/static/styles/<path:filename>")
def styles(filename):
return send_from_directory(app.static_folder, f"styles/{filename}")
app = Flask(__name__)

@app.route('/')
def index():
Expand All @@ -58,14 +86,6 @@ def index():
"1/18/ISO_C%2B%2B_Logo.svg",
]

repos = [
Repo("Nameless", "FPS prototype game made with Godot", "Nameless"),
Repo("AoC 2020", "Some of my solutions for the 2020 Advent of Code challenges", "Advent-of-Code-2020"),
Repo("p5 Pong", "Pong clone made with p5.js and Node.js", "p5-pong"),
Repo("GodotMaze", "A demonstration of some maze generation algorithms made with Godot", "GodotMaze"),
Repo("This very website", "This portfolio website, made with Bootstrap 5 and Less", "Portfolio"),
]

contacts = [
Contact("mailto:contact.me@terenz.dev", "Email", icon="envelope", social="google"),
Contact("https://www.linkedin.com/in/andrea-terenz/", "Linkedin"),
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
43 changes: 0 additions & 43 deletions static/icons/favicon.svg

This file was deleted.

Loading

0 comments on commit 6eb2210

Please sign in to comment.