diff options
author | 2021-03-23 17:17:22 +0800 | |
---|---|---|
committer | 2021-03-23 18:35:19 +0800 | |
commit | 7de2959402a048652bf6d4ec8e3bec1172bb11e8 (patch) | |
tree | fb4c7397ef262ca60e6aa90315dc1ec9371398fe /pydis_site/apps/content/utils.py | |
parent | Style <pre> tag backgrounds same as <code>. (diff) |
Remove Github metadata feature.
This feature is still under implementation debate, so it will be further
discussed in another issue and implemeneted in a future PR.
Diffstat (limited to 'pydis_site/apps/content/utils.py')
-rw-r--r-- | pydis_site/apps/content/utils.py | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/pydis_site/apps/content/utils.py b/pydis_site/apps/content/utils.py index a89db83c..305d26b5 100644 --- a/pydis_site/apps/content/utils.py +++ b/pydis_site/apps/content/utils.py @@ -1,16 +1,11 @@ import os from typing import Dict, List, Optional, Union -import requests import yaml -from dateutil import parser from django.conf import settings from django.http import Http404 from markdown2 import markdown -COMMITS_URL = "https://api.github.com/repos/{owner}/{name}/commits?path={path}&sha={branch}" -BASE_ARTICLES_LOCATION = "pydis_site/apps/content/resources/content/" - def get_category(path: List[str]) -> Dict[str, str]: """Load category information by name from _info.yml.""" @@ -77,36 +72,3 @@ def get_article(path: List[str]) -> Dict[str, Union[str, Dict]]: ) return {"article": str(html), "metadata": html.metadata} - - -def get_github_information( - path: List[str] -) -> Dict[str, Union[List[str], str]]: - """Get article last modified date and contributors from GitHub.""" - result = requests.get( - COMMITS_URL.format( - owner=settings.SITE_REPOSITORY_OWNER, - name=settings.SITE_REPOSITORY_NAME, - branch=settings.SITE_REPOSITORY_BRANCH, - path=( - f"{BASE_ARTICLES_LOCATION}{'/'.join(path[:-1])}" - f"{'/' if len(path) > 1 else ''}{path[-1]}.md" - ) - ) - ) - - if result.status_code == 200 and len(result.json()): - data = result.json() - return { - "last_modified": parser.isoparse( - data[0]["commit"]["committer"]["date"] - ).strftime("%dth %B %Y"), - "contributors": { - c["commit"]["committer"]["name"]: c["committer"]["html_url"] for c in data - } - } - else: - return { - "last_modified": "N/A", - "contributors": {} - } |