|
@@ -3,11 +3,13 @@ from flask_assets import Environment, Bundle
|
|
|
import os
|
|
|
import json
|
|
|
from typing import List
|
|
|
+import markdown as md
|
|
|
|
|
|
app = Flask(__name__)
|
|
|
assets = Environment(app)
|
|
|
assets.url = app.static_url_path
|
|
|
-scss = Bundle('style/main.scss', filters='libsass', output='all.css', depends='**/*.scss')
|
|
|
+scss = Bundle('style/main.scss', filters='libsass',
|
|
|
+ output='all.css', depends='**/*.scss')
|
|
|
assets.config['PYSCSS_LOAD_PATHS'] = assets.load_path
|
|
|
assets.config['PYSCSS_STATIC_URL'] = assets.url
|
|
|
assets.config['PYSCSS_STATIC_ROOT'] = assets.directory
|
|
@@ -15,9 +17,10 @@ assets.config['PYSCSS_ASSETS_URL'] = assets.url
|
|
|
assets.config['PYSCSS_ASSETS_ROOT'] = assets.directory
|
|
|
assets.register('scss_all', scss)
|
|
|
|
|
|
+
|
|
|
class ProjectInfo:
|
|
|
name: str
|
|
|
-
|
|
|
+
|
|
|
def __init__(self, name):
|
|
|
self.name = name
|
|
|
|
|
@@ -31,6 +34,7 @@ class Project:
|
|
|
id: str
|
|
|
info: ProjectInfo
|
|
|
|
|
|
+
|
|
|
def get_projects() -> List[Project]:
|
|
|
result = []
|
|
|
projects = [f.path for f in os.scandir("../builds") if f.is_dir()]
|
|
@@ -48,18 +52,34 @@ def get_projects() -> List[Project]:
|
|
|
continue
|
|
|
return result
|
|
|
|
|
|
+
|
|
|
@app.route("/projects/<string:project_id>")
|
|
|
def display_project(project_id):
|
|
|
projects = get_projects()
|
|
|
- selected_project = next((project for project in projects if project.id == project_id), None)
|
|
|
+
|
|
|
+ selected_project = next(
|
|
|
+ (project for project in projects if project.id == project_id), None)
|
|
|
if not selected_project:
|
|
|
return abort(404)
|
|
|
- return render_template("main.html", projects=projects, selected_project=selected_project.id)
|
|
|
+
|
|
|
+ info_path = os.path.join("../builds", selected_project.id, "info.md")
|
|
|
+
|
|
|
+ readme = None
|
|
|
+ try:
|
|
|
+ if os.path.exists(info_path):
|
|
|
+ with open(info_path, "r", encoding="utf-8") as f:
|
|
|
+ readme = md.markdown(f.read())
|
|
|
+ except:
|
|
|
+ readme = None
|
|
|
+
|
|
|
+ return render_template("project_view.html", projects=projects, selected_project=selected_project, readme=readme)
|
|
|
+
|
|
|
|
|
|
@app.route("/")
|
|
|
def test():
|
|
|
projects = get_projects()
|
|
|
return render_template("main.html", projects=projects)
|
|
|
|
|
|
+
|
|
|
if __name__ == "__main__":
|
|
|
- app.run(host='0.0.0.0')
|
|
|
+ app.run(host='0.0.0.0')
|