Skip to content

Commit

Permalink
Projects loading from git.
Browse files Browse the repository at this point in the history
  • Loading branch information
mootfrost committed Apr 17, 2022
1 parent 594c580 commit e7b393d
Show file tree
Hide file tree
Showing 34 changed files with 189 additions and 12 deletions.
Binary file removed resources/.DS_Store
Binary file not shown.
59 changes: 59 additions & 0 deletions static/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates
from fastapi import Request
import uvicorn
import requests
import time
import asyncio

app = FastAPI()
app.mount("/static", StaticFiles(directory="static"), name="static")
templates = Jinja2Templates(directory="static/templates")


def load_projects():
print("Loading projects...")
try:
repos = requests.get("https://api.github.com/users/Mootfrost777/repos").json()
res = []
for repo in repos:
res.append(Project(repo["name"], repo["description"], repo["html_url"]))
return res
except:
print("Error loading projects. API request failed.")
return Project('Error', 'Error', 'Error')


class Project:
name: str
description: str
url: str

def __init__(self, name, description, url):
self.name = name
self.description = description
self.url = url


@app.get("/api/get_repos")
def get_repos():
return load_projects()


@app.get("/")
def main_page(request: Request):
return templates.TemplateResponse("index.html", {"request": request})


@app.get("/about")
def main_page(request: Request):
return templates.TemplateResponse("about.html", {"request": request})


@app.get("/projects")
def main_page(request: Request):
return templates.TemplateResponse("projects.html", {"request": request})


uvicorn.run(app)
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.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
56 changes: 56 additions & 0 deletions static/resources/styles/projects.style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
@import url(style.css);


.title-div {

}

.projects-container {
box-sizing: border-box;
width: 1320px;
overflow-wrap: anywhere;
font-family: "Tisa Sans Pro";
}

.project-container {
flex-flow: row wrap;
width: 300px;
height: 150px;
background-color: black;
text-align: left;
}

.project-container:hover {
transform: scale(1.1);
}

.projects-contents {
color: white;
text-decoration: none;
font-size: 16px;
font-weight: lighter;
}

.projects-title {
font-size: 21px;
font-weight: bolder;
}

@media (max-width: 1330px) {
.projects-container {
width: 1000px;
}
}


@media (max-width: 1000px) {
.projects-container {
width: 700px;
}
}

@media (max-width: 700px) {
.projects-container {
width: 400px;
}
}
File renamed without changes.
8 changes: 4 additions & 4 deletions about.html → static/templates/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="resources/styles/about.style.css"/>
<link rel="icon" type="image/x-icon" href="resources/images/favicon.png">
<link rel="stylesheet" type="text/css" href="{{ url_for('static', path='/resources/styles/about.style.css') }}"/>
<link rel="icon" type="image/x-icon" href="{{ url_for('static', path='/resources/images/favicon.png') }}">
<title>Mootfrost — About</title>
<meta name="description" content="About mootfrost.">
</head>
Expand All @@ -23,7 +23,7 @@ <h1 class="title unselectable">about:</h1>
<p class="footer-text">v.0.1</a></p>
</footer>

<script src="resources/scripts/plugins/particles/particles.min.js"></script>
<script src="resources/scripts/script.js"></script>
<script src="{{ url_for('static', path='/resources/scripts/plugins/particles/particles.min.js ') }}"></script>
<script src="{{ url_for('static', path='/resources/scripts/script.js') }}"></script>
</body>
</html>
16 changes: 8 additions & 8 deletions index.html → static/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="resources/styles/index.style.css"/>
<link rel="icon" type="image/x-icon" href="resources/images/favicon.png">
<link rel="stylesheet" type="text/css" href="{{ url_for('static', path='/resources/styles/index.style.css') }}"/>
<link rel="icon" type="image/x-icon" href="{{ url_for('static', path='/resources/images/favicon.png') }}">
<title>Mootfrost</title>
<meta name="description" content="mootfrost.">
</head>
Expand All @@ -14,13 +14,13 @@ <h1 class="title unselectable">mootfrost</h1>
</div>
<div class="contents-div">
<div class="horizontal-container socials-container">
<div class="button-div circle-button-div unselectable"><a class="button-image-link" href="https://github.com/Mootfrost777"><img class="button-image" src="resources/images/github.png"></a></div>
<div class="button-div circle-button-div unselectable"><a class="button-image-link" href="https://t.me/Mootfrost777"><img class="button-image" src="resources/images/telegram.png"></a></div>
<div class="button-div circle-button-div unselectable"><a class="button-image-link" href="https://github.com/Mootfrost777"><img class="button-image" src="{{ url_for('static', path='/resources/images/github.png') }}"></a></div>
<div class="button-div circle-button-div unselectable"><a class="button-image-link" href="https://t.me/Mootfrost777"><img class="button-image" src="{{ url_for('static', path='/resources/images/telegram.png') }}"></a></div>
</div>
<div class="centered-container links-container">
<div class="vertical-container">
<a href="about.html"><div class="button-div unselectable">About me</div></a>
<a href="#" target="_blank"><div class="button-div unselectable">Projects</div></a>
<a href="http://127.0.0.1:8000/about"><div class="button-div unselectable">About me</div></a>
<a href="http://127.0.0.1:8000/projects"><div class="button-div unselectable">Projects</div></a>
</div>
</div>
</div>
Expand All @@ -30,7 +30,7 @@ <h1 class="title unselectable">mootfrost</h1>
<p class="footer-text">v.0.1</a></p>
</footer>

<script src="resources/scripts/plugins/particles/particles.min.js"></script>
<script src="resources/scripts/script.js"></script>
<script src="{{ url_for('static', path='/resources/scripts/plugins/particles/particles.min.js ') }}"></script>
<script src="{{ url_for('static', path='/resources/scripts/script.js') }}"></script>
</body>
</html>
62 changes: 62 additions & 0 deletions static/templates/projects.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="{{ url_for('static', path='/resources/styles/projects.style.css') }}"/>
<link rel="icon" type="image/x-icon" href="{{ url_for('static', path='/resources/images/favicon.png') }}">
<title>Mootfrost</title>
<meta name="description" content="mootfrost.">
</head>
<body id="particles-js">
<div class="title-menu top">
<div class="title-div title-container">
<h1 class="title unselectable">projects:</h1>
<div class="contents-div projects-container horizontal-container" id="projects-list">
<!-- <a href="https://google.com" class="projects-contents"><div class="button-div project-container">
<h2 class="projects-title">Name</h2>
<p class="projects-contents">Description</p>
</div></a> -->
</div>
</div>
</div>

<footer>
<p class="footer-text">v.0.1</a></p>
</footer>

<script src="{{ url_for('static', path='/resources/scripts/plugins/particles/particles.min.js ') }}"></script>
<script src="{{ url_for('static', path='/resources/scripts/script.js') }}"></script>
<script>
async function load_projects()
{
let resp = await fetch('/api/get_repos', {
method: 'GET',
},
);
let projects = await resp.json()
console.log(projects)
let proj_list = document.getElementById('projects-list')
for (let i = 0; i < projects.length; i++) {
let project = projects[i]
let h2 = document.createElement('h2')
h2.textContent = project['name']
h2.classList.add('projects-title')
let p = document.createElement('p')
p.classList.add('projects-contents')
p.textContent = project['description']
let div = document.createElement('div')
div.classList.add('button-div')
div.classList.add('project-container')
div.appendChild(h2)
div.appendChild(p)
let a = document.createElement('a')
a.classList.add('projects-contents')
a.href = project['url']
a.appendChild(div)
proj_list.appendChild(a)
}
}
load_projects()
</script>
</body>
</html>

0 comments on commit e7b393d

Please sign in to comment.