|
@@ -4,6 +4,8 @@ import os
|
|
|
import json
|
|
|
from typing import List
|
|
|
import markdown as md
|
|
|
+from dataclasses import dataclass
|
|
|
+from dataclasses_json import dataclass_json
|
|
|
|
|
|
app = Flask(__name__)
|
|
|
assets = Environment(app)
|
|
@@ -18,48 +20,29 @@ assets.config['PYSCSS_ASSETS_ROOT'] = assets.directory
|
|
|
assets.register('scss_all', scss)
|
|
|
|
|
|
|
|
|
+@dataclass
|
|
|
+@dataclass_json
|
|
|
class ArtifactItem:
|
|
|
file: str
|
|
|
description: str
|
|
|
width: int = 0
|
|
|
|
|
|
- def __init__(self, file, description):
|
|
|
- self.file = file
|
|
|
- self.description = description
|
|
|
-
|
|
|
|
|
|
+@dataclass
|
|
|
+@dataclass_json
|
|
|
class Artifact:
|
|
|
id: str
|
|
|
date: str
|
|
|
changelog: str
|
|
|
artifacts: List[ArtifactItem]
|
|
|
-
|
|
|
- def __init__(self, id, date, changelog, artifacts):
|
|
|
- self.id = id
|
|
|
- self.date = date.strip()
|
|
|
- self.changelog = changelog
|
|
|
- self.artifacts = [ArtifactItem(**item)
|
|
|
- for item in artifacts]
|
|
|
- maxwidth = max((len(a.file) for a in self.artifacts), default=0)
|
|
|
- for a in self.artifacts:
|
|
|
- a.width = maxwidth
|
|
|
-
|
|
|
- @classmethod
|
|
|
- def from_json(cls, json_str):
|
|
|
- json_dict = json.loads(json_str)
|
|
|
- return cls(**json_dict)
|
|
|
+ hash: str = None
|
|
|
|
|
|
|
|
|
+@dataclass
|
|
|
+@dataclass_json
|
|
|
class ProjectInfo:
|
|
|
name: str
|
|
|
-
|
|
|
- def __init__(self, name):
|
|
|
- self.name = name
|
|
|
-
|
|
|
- @classmethod
|
|
|
- def from_json(cls, json_str):
|
|
|
- json_dict = json.loads(json_str)
|
|
|
- return cls(**json_dict)
|
|
|
+ commit_url: str
|
|
|
|
|
|
|
|
|
class Project:
|
|
@@ -79,6 +62,12 @@ class Project:
|
|
|
try:
|
|
|
with open(info_file_path, "r", encoding="utf-8") as f:
|
|
|
artifact = Artifact.from_json(f.read())
|
|
|
+ artifact.date = artifact.date.strip()
|
|
|
+ maxwidth = max((len(a.file)
|
|
|
+ for a in artifact.artifacts), default=0)
|
|
|
+ for a in artifact.artifacts:
|
|
|
+ a.width = maxwidth
|
|
|
+
|
|
|
result.append(artifact)
|
|
|
except:
|
|
|
continue
|
|
@@ -140,5 +129,6 @@ def index():
|
|
|
projects = get_projects()
|
|
|
return render_template("main.html", projects=projects)
|
|
|
|
|
|
+
|
|
|
if __name__ == "__main__":
|
|
|
app.run(host='0.0.0.0')
|