From 2b7574a5588b9830cbe1c02e3bd74e5f0ef861e7 Mon Sep 17 00:00:00 2001 From: yanyongyu Date: Fri, 14 May 2021 18:27:09 +0800 Subject: [PATCH] :construction: add html template --- .prettierrc | 6 ++ src/libs/github/models/issue.py | 5 +- src/libs/github/models/timeline.py | 4 +- src/plugins/github/libs/issue/issue.html | 128 +++++++++++++++++++++++ src/plugins/github/libs/issue/render.py | 28 +++++ 5 files changed, 166 insertions(+), 5 deletions(-) create mode 100644 .prettierrc create mode 100644 src/plugins/github/libs/issue/issue.html create mode 100644 src/plugins/github/libs/issue/render.py diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..8daf154 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,6 @@ +{ + "tabWidth": 2, + "useTabs": false, + "endOfLine": "lf", + "singleQuote": false +} diff --git a/src/libs/github/models/issue.py b/src/libs/github/models/issue.py index 4a97283..049d660 100644 --- a/src/libs/github/models/issue.py +++ b/src/libs/github/models/issue.py @@ -4,7 +4,7 @@ @Author : yanyongyu @Date : 2021-03-11 16:57:04 @LastEditors : yanyongyu -@LastEditTime : 2021-05-14 01:45:44 +@LastEditTime : 2021-05-14 18:13:34 @Description : None @GitHub : https://github.com/yanyongyu """ @@ -40,6 +40,7 @@ class Issue(BaseModel): labels_url: str comments_url: str events_url: str + timeline_url: str html_url: str number: int state: str @@ -93,5 +94,5 @@ class Issue(BaseModel): TimelineEventReviewed, TimelineEventRenamed], self.requester, "GET", - f"{self.url}/timeline", + self.timeline_url, headers=headers) diff --git a/src/libs/github/models/timeline.py b/src/libs/github/models/timeline.py index d17c13e..93bf1fd 100644 --- a/src/libs/github/models/timeline.py +++ b/src/libs/github/models/timeline.py @@ -4,7 +4,7 @@ @Author : yanyongyu @Date : 2021-05-14 00:57:33 @LastEditors : yanyongyu -@LastEditTime : 2021-05-14 02:18:47 +@LastEditTime : 2021-05-14 18:13:03 @Description : None @GitHub : https://github.com/yanyongyu """ @@ -73,7 +73,6 @@ class TimelineEventCommented(TimelineEvent): body: str body_text: Optional[str] body_html: Optional[str] - performed_via_github_app: bool actor: User @@ -117,4 +116,3 @@ class TimelineEventRenamed(TimelineEvent): commit_url: Optional[str] created_at: datetime rename: TimelineEventRenamedDetail - performed_via_github_app: Optional[bool] diff --git a/src/plugins/github/libs/issue/issue.html b/src/plugins/github/libs/issue/issue.html new file mode 100644 index 0000000..4e2b9a8 --- /dev/null +++ b/src/plugins/github/libs/issue/issue.html @@ -0,0 +1,128 @@ + + + + + + + + + + + + +
+
+
+

+ + + + + {owner} + + / + + + {repo_name} + + +

+
+
+
+
+ +
+
+
+
+
+ + diff --git a/src/plugins/github/libs/issue/render.py b/src/plugins/github/libs/issue/render.py new file mode 100644 index 0000000..ed87378 --- /dev/null +++ b/src/plugins/github/libs/issue/render.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +@Author : yanyongyu +@Date : 2021-05-14 17:09:12 +@LastEditors : yanyongyu +@LastEditTime : 2021-05-14 18:26:47 +@Description : None +@GitHub : https://github.com/yanyongyu +""" +__author__ = "yanyongyu" + +from html import escape +from pathlib import Path + +from src.libs.github.models import Issue + +with (Path(__file__).parent / "issue.html").open("r") as f: + HTML = f.read() + + +def issue_to_html(owner: str, repo_name: str, issue: Issue): + return HTML.format(owner=escape(owner), + repo_name=escape(repo_name), + title=escape(issue.title), + number=issue.number, + status=escape(issue.state), + comments=issue.comments)