From 5074ea783da1971926436f7c670273cf6009df33 Mon Sep 17 00:00:00 2001 From: Bobby Date: Sun, 11 Feb 2024 18:29:09 -0500 Subject: Better homepage for repositories --- dev_status/views.py | 19 ++++++++++++++++--- static/images/site/icons/a-globe.gif | Bin 0 -> 8238 bytes static/images/site/icons/isFork.png | Bin 0 -> 53554 bytes static/images/site/icons/pushbutt.gif | Bin 0 -> 4193 bytes static/images/site/icons/scale.gif | Bin 0 -> 5559 bytes templates/dev_status/home.html | 32 +++++++++++++++++++++++++++++--- 6 files changed, 45 insertions(+), 6 deletions(-) create mode 100644 static/images/site/icons/a-globe.gif create mode 100644 static/images/site/icons/isFork.png create mode 100644 static/images/site/icons/pushbutt.gif create mode 100644 static/images/site/icons/scale.gif diff --git a/dev_status/views.py b/dev_status/views.py index c656d2b2..97a3890c 100644 --- a/dev_status/views.py +++ b/dev_status/views.py @@ -14,7 +14,7 @@ g = Github(os.getenv("GH_TOKEN")) def home(request): page = request.GET.get("page") or 1 items = request.GET.get("items") or 10 - sort = request.GET.get("sort") or "updated" + sort = request.GET.get("sort") or "pushed" direction = request.GET.get("direction") or "desc" search = request.GET.get("search") or "" context = {} @@ -46,6 +46,15 @@ def home(request): node {{ name description + forkCount + homepageUrl + isArchived + isFork + licenseInfo {{ + name + }} + pushedAt + stargazerCount }} }} }} @@ -55,13 +64,17 @@ def home(request): user=user, sort=sort_map[sort], direction=direction_map[direction] ) data = requests.post(url, json={"query": query}, headers=headers).json() - repos = [ - {"name": repo["node"]["name"], "description": repo["node"]["description"]} + {"name": repo["node"]["name"], "description": repo["node"]["description"], "forkCount": repo["node"]["forkCount"], "homepageUrl": repo["node"]["homepageUrl"], "isArchived": repo["node"]["isArchived"], "isFork": repo["node"]["isFork"], "licenseInfo": repo["node"]["licenseInfo"], "pushedAt": repo["node"]["pushedAt"], "stargazerCount": repo["node"]["stargazerCount"]} for repo in data["data"]["user"]["repositories"]["edges"] ] total_count = data["data"]["user"]["repositories"]["totalCount"] + # convert pushedAt to date + for repo in repos: + repo["pushedAt"] = repo["pushedAt"].split("T")[0] + + context["search"] = search if search: context["repos"] = [ diff --git a/static/images/site/icons/a-globe.gif b/static/images/site/icons/a-globe.gif new file mode 100644 index 00000000..e4551a91 Binary files /dev/null and b/static/images/site/icons/a-globe.gif differ diff --git a/static/images/site/icons/isFork.png b/static/images/site/icons/isFork.png new file mode 100644 index 00000000..541cab1f Binary files /dev/null and b/static/images/site/icons/isFork.png differ diff --git a/static/images/site/icons/pushbutt.gif b/static/images/site/icons/pushbutt.gif new file mode 100644 index 00000000..408fabd0 Binary files /dev/null and b/static/images/site/icons/pushbutt.gif differ diff --git a/static/images/site/icons/scale.gif b/static/images/site/icons/scale.gif new file mode 100644 index 00000000..639c4d6c Binary files /dev/null and b/static/images/site/icons/scale.gif differ diff --git a/templates/dev_status/home.html b/templates/dev_status/home.html index 1863434b..18574c0a 100644 --- a/templates/dev_status/home.html +++ b/templates/dev_status/home.html @@ -1,4 +1,5 @@ {% extends 'blog/partials/base.html' %} {% block content %} +{% load replace %}
@@ -57,9 +58,34 @@ {% endfor %} -- cgit v1.2.3
-

{{ repo.name }}

-

{{ repo.description }}

- +

+ {{ repo.name }} + {% if repo.isFork %} + + {% endif %} + {% if repo.isArchived %} + + {% endif %} +

+

{{ repo.description }}

+

+ {% if repo.homepageUrl %} + + {{ repo.homepageUrl|replace:'https://'|replace:'http://' }} + {% endif %} + Last Pushed: {{ repo.pushedAt }} +

+
+

+ {% if repo.licenseInfo %} + + {{ repo.licenseInfo.name }} + {% endif %} + + {{ repo.stargazerCount }} + + {{ repo.forkCount }} +