aboutsummaryrefslogtreecommitdiff
path: root/dev_status/views.py
diff options
context:
space:
mode:
authorBobby <[email protected]>2024-03-27 22:36:48 -0400
committerBobby <[email protected]>2024-03-27 22:36:48 -0400
commit6db0708d10192a24760035e12bb7eee8c2b4e2d7 (patch)
tree5f546437218095256df57f32aadf77c40c7de543 /dev_status/views.py
parent5c0b62ad493b629142f722b2f84c91071153350a (diff)
downloadthatcomputerscientist-6db0708d10192a24760035e12bb7eee8c2b4e2d7.tar.xz
thatcomputerscientist-6db0708d10192a24760035e12bb7eee8c2b4e2d7.zip
Update: View Text Files in Repos
Diffstat (limited to 'dev_status/views.py')
-rw-r--r--dev_status/views.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/dev_status/views.py b/dev_status/views.py
index 678be122..96ad7d42 100644
--- a/dev_status/views.py
+++ b/dev_status/views.py
@@ -6,7 +6,13 @@ import requests
from django.shortcuts import render
from dotenv import load_dotenv
from github import Github
-from dev_status.utils import relative_date
+from dev_status.utils import (
+ relative_date,
+ text_lines,
+ text_loc,
+ size_format,
+ highlight_code,
+)
load_dotenv()
g = Github(os.getenv("GH_TOKEN"))
@@ -172,6 +178,13 @@ def get_repo(request, r=None, p=None):
else:
# if it is a blob, display the file
tree = data["data"]["repository"]["object"]
+ tree["path"] = p
+ tree["name"] = p.split("/")[-1]
+ if not tree["isBinary"]:
+ tree["lines"] = text_lines(tree["text"])
+ tree["loc"] = text_loc(tree["text"])
+ tree["size"] = size_format(tree["byteSize"])
+ tree["text"] = highlight_code(tree["text"], tree["name"])
# get commit information for each file or directory
if viewMode == "tree":