diff options
| author | Bobby <[email protected]> | 2023-11-10 21:02:05 -0500 |
|---|---|---|
| committer | Bobby <[email protected]> | 2023-11-10 21:02:05 -0500 |
| commit | 9b8c5d31124fd4c328cc6b8285695ed8d874efda (patch) | |
| tree | 269613930dcd8cf524596254b742f9b74385135e | |
| parent | 487db6ce3a67ee9909b879cfc7410e0adafcbe2c (diff) | |
| download | thatcomputerscientist-9b8c5d31124fd4c328cc6b8285695ed8d874efda.tar.xz thatcomputerscientist-9b8c5d31124fd4c328cc6b8285695ed8d874efda.zip | |
Clean up junk
| -rw-r--r-- | README.md | 15 | ||||
| -rw-r--r-- | ignis/urls.py | 1 | ||||
| -rw-r--r-- | ignis/views.py | 70 | ||||
| -rw-r--r-- | requirements.txt | 10 | ||||
| -rw-r--r-- | thatcomputerscientist/urls.py | 5 |
5 files changed, 0 insertions, 101 deletions
@@ -3,21 +3,6 @@ Source Code for my Personal Website. - Visit [shi.foo](https://shi.foo) to take a look at the current build. -- ~~Visit [preview.thatcomputerscientist.com](https://preview.thatcomputerscientist.com) to see a instant live deployment of changes whenever I start changing something on my local machine. (_Availability of this server is not guaranteed as it is only active whenever I am working on the project_. Also, sometimes I keep the project loaded in my code editor, while being idle or doing something else – the link is viewable during this time as well.)~~ - -- `preview.thatcomputerscientist.com` is no longer available. The shell script [`runserver.sh`](runserver.sh) can be used to start a local server that presents two domain options: - - `[*].peek.shi.foo` - - `[*].peek.thatcomputerscientist.com` - -Both these domains point to `127.0.0.1` and its a matter of preference which one to choose. The script also automatically generates SSL certificates for both domains and starts the server with HTTPS enabled. A complete, example command chain now looks like: - - - -## Screenshot - - -> <sub><sup>_Screenshot served live from [shi.foo](https://shi.foo)'s server. For efficiency purposes, the screenshot is taken once per build and is served from the server's cache. The screenshot is updated whenever I push changes to this repository. Screenshots will generally be updated within 20 seconds after all GitHub Actions Workflows have completed._</sup></sub> - ## Specifications - Server: [Nginx](https://www.nginx.com/) - Language: [Python](https://www.python.org/), [HTML](https://www.w3schools.com/html/), [CSS](https://www.w3schools.com/css/), [JavaScript](https://www.javascript.com/) diff --git a/ignis/urls.py b/ignis/urls.py index dbc73a5d..ea09dd9f 100644 --- a/ignis/urls.py +++ b/ignis/urls.py @@ -10,7 +10,6 @@ urlpatterns = [ path('/image/<post_id>/<image_name>', views.get_image, name='get_image'), path('/cover/<str:repository>', views.cover_image, name='cover_image'), path('/captcha/<str:captcha_string>', views.captcha_image, name='captcha_image'), - path('/screenshot', views.get_screenshot, name='screenshot'), path('/socialify', views.socialify, name='socialify'), # def socialify(request, repo, theme, font, pattern, name, description, language_1, language_2, stargazers, forks, issues, pulls): diff --git a/ignis/views.py b/ignis/views.py index 56043499..82457968 100644 --- a/ignis/views.py +++ b/ignis/views.py @@ -1,16 +1,12 @@ import json -import os -import time from io import BytesIO import requests from captcha.image import ImageCaptcha from django.core.files.base import ContentFile from django.http import HttpResponse -from django.views.decorators.cache import never_cache from django.views.decorators.csrf import csrf_exempt from PIL import Image -from selenium import webdriver from blog.models import Post from users.tokens import CaptchaTokenGenerator @@ -173,69 +169,3 @@ def captcha_image(request, captcha_string): return HttpResponse(data, content_type='image/png') -@never_cache -def get_screenshot(request): - # check if screenshot exists - if not os.path.exists('siteshot.png'): - options = webdriver.FirefoxOptions() - options.headless = True - driver = webdriver.Firefox(options=options) - driver.set_window_size(1600, 2560) - - url = 'http://localhost:8000' - - # Wait until the page is loaded - driver.get(url) - time.sleep(5) - - screenshot = driver.get_screenshot_as_png() - screenshot = Image.open(BytesIO(screenshot)) - - # Close the browser - driver.quit() - - # Save as 'siteshot.png' - screenshot.save('siteshot.png', 'PNG') - - - # open file called 'siteshot.png' in the root directory - with open('siteshot.png', 'rb') as f: - image = f.read() - # convert to png - image = Image.open(BytesIO(image)) - output = BytesIO() - image.save(output, format='PNG') - - response = HttpResponse(output.getvalue(), content_type='image/png') - response['Cache-Control'] = 'no-cache, no-store, must-revalidate' - response['Pragma'] = 'no-cache' - response['Expires'] = '0' - return response - -def socialify(request): - repo = request.GET.get('repo') - theme = request.GET.get('theme') - font = request.GET.get('font') - pattern = request.GET.get('pattern') - name = request.GET.get('name') - description = request.GET.get('description') - language_1 = request.GET.get('language_1') - language_2 = request.GET.get('language_2') - stargazers = request.GET.get('stargazers') - forks = request.GET.get('forks') - issues = request.GET.get('issues') - pulls = request.GET.get('pulls') - - url = 'https://socialify.thatcomputerscientist.com/{}/png?description={}&font={}&forks={}&issues={}&language={}&language2={}&name={}&owner=1&pattern={}&pulls={}&stargazers={}&theme={}'.format(repo, description, font, forks, issues, language_1, language_2, name, pattern, pulls, stargazers, theme) - - req = requests.get(url) - image = req.content - status = req.status_code - - if status == 200: - return HttpResponse(image, content_type='image/png') - else: - with open('static/images/site/utgi.gif', 'rb') as f: - image = f.read() - return HttpResponse(image, content_type='image/gif') - diff --git a/requirements.txt b/requirements.txt index a5bd5b26..59e7960d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,19 +4,14 @@ python-dotenv gunicorn whitenoise six -cryptocode captcha PyGithub requests -pillow -pycryptodome pygments bs4 jellyfish fuzzywuzzy -python-Levenshtein selenium -django-haystack channels channels_redis daphne @@ -24,9 +19,4 @@ user_agents numpy scikit-learn akismet -google-cloud-translate -django-hosts apscheduler -django-sslserver -djangorestframework -django-cors-headers diff --git a/thatcomputerscientist/urls.py b/thatcomputerscientist/urls.py index 34a4f76d..32d9a06c 100644 --- a/thatcomputerscientist/urls.py +++ b/thatcomputerscientist/urls.py @@ -43,8 +43,3 @@ urlpatterns = [ ] urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) - -import os - -if os.path.exists('siteshot.png'): - os.remove('siteshot.png') |
