aboutsummaryrefslogtreecommitdiff
path: root/dev_status
diff options
context:
space:
mode:
Diffstat (limited to 'dev_status')
-rw-r--r--dev_status/__init__.py0
-rw-r--r--dev_status/admin.py3
-rw-r--r--dev_status/apps.py6
-rw-r--r--dev_status/migrations/__init__.py0
-rw-r--r--dev_status/models.py3
-rw-r--r--dev_status/tests.py3
-rw-r--r--dev_status/urls.py11
-rw-r--r--dev_status/views.py52
8 files changed, 78 insertions, 0 deletions
diff --git a/dev_status/__init__.py b/dev_status/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/dev_status/__init__.py
diff --git a/dev_status/admin.py b/dev_status/admin.py
new file mode 100644
index 00000000..8c38f3f3
--- /dev/null
+++ b/dev_status/admin.py
@@ -0,0 +1,3 @@
+from django.contrib import admin
+
+# Register your models here.
diff --git a/dev_status/apps.py b/dev_status/apps.py
new file mode 100644
index 00000000..132122b0
--- /dev/null
+++ b/dev_status/apps.py
@@ -0,0 +1,6 @@
+from django.apps import AppConfig
+
+
+class DevStatusConfig(AppConfig):
+ default_auto_field = 'django.db.models.BigAutoField'
+ name = 'dev_status'
diff --git a/dev_status/migrations/__init__.py b/dev_status/migrations/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/dev_status/migrations/__init__.py
diff --git a/dev_status/models.py b/dev_status/models.py
new file mode 100644
index 00000000..71a83623
--- /dev/null
+++ b/dev_status/models.py
@@ -0,0 +1,3 @@
+from django.db import models
+
+# Create your models here.
diff --git a/dev_status/tests.py b/dev_status/tests.py
new file mode 100644
index 00000000..7ce503c2
--- /dev/null
+++ b/dev_status/tests.py
@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.
diff --git a/dev_status/urls.py b/dev_status/urls.py
new file mode 100644
index 00000000..c9bcf35a
--- /dev/null
+++ b/dev_status/urls.py
@@ -0,0 +1,11 @@
+from django.urls import path
+from django.views.generic import RedirectView
+from . import views
+
+app_name = 'dev_status'
+urlpatterns = [
+ path('', views.home, name='home'),
+ path('tree/', views.tree, name='roottree'),
+ path('tree/<path:path>', views.tree, name='tree'),
+ path('raw/<path:path>', views.raw, name='raw'),
+]
diff --git a/dev_status/views.py b/dev_status/views.py
new file mode 100644
index 00000000..1d511293
--- /dev/null
+++ b/dev_status/views.py
@@ -0,0 +1,52 @@
+from django.shortcuts import render
+from github import Github
+from dotenv import load_dotenv
+import os
+
+load_dotenv()
+
+# Create your views here.
+
+def home(request):
+ g = Github(os.getenv('GH_TOKEN'))
+ repo = g.get_repo('luciferreeves/thatcomputerscientist')
+ contents = repo.get_contents('')
+ files = []
+ while contents:
+ file_content = contents.pop(0)
+ files.append(file_content)
+ context = {
+ 'title': 'Source Code',
+ 'files': files,
+ }
+ return render(request, 'dev_status/home.html', context)
+
+def tree(request, path=None):
+ g = Github(os.getenv('GH_TOKEN'))
+ repo = g.get_repo('luciferreeves/thatcomputerscientist')
+ path = '' if not path else path
+ parent = '' if len(path.split('/')) == 1 else '/'.join(path.split('/')[:-1])
+ contents = repo.get_contents(path)
+ files = []
+ while contents:
+ file_content = contents.pop(0)
+ files.append(file_content)
+ context = {
+ 'title': 'Tree - {}'.format(path),
+ 'files': files,
+ 'parent': parent,
+ }
+ return render(request, 'dev_status/home.html', context)
+
+def raw(request, path):
+ g = Github(os.getenv('GH_TOKEN'))
+ repo = g.get_repo('luciferreeves/thatcomputerscientist')
+ path = '' if not path else path
+ parent = '' if len(path.split('/')) == 1 else '/'.join(path.split('/')[:-1])
+ contents = repo.get_contents(path)
+ context = {
+ 'title': 'File - {}'.format(path),
+ 'file': contents.html_url,
+ 'parent': parent,
+ }
+ return render(request, 'dev_status/home.html', context) \ No newline at end of file