aboutsummaryrefslogtreecommitdiff
path: root/ignis
diff options
context:
space:
mode:
authorBobby <[email protected]>2023-11-10 21:02:05 -0500
committerBobby <[email protected]>2023-11-10 21:02:05 -0500
commit9b8c5d31124fd4c328cc6b8285695ed8d874efda (patch)
tree269613930dcd8cf524596254b742f9b74385135e /ignis
parent487db6ce3a67ee9909b879cfc7410e0adafcbe2c (diff)
downloadthatcomputerscientist-9b8c5d31124fd4c328cc6b8285695ed8d874efda.tar.xz
thatcomputerscientist-9b8c5d31124fd4c328cc6b8285695ed8d874efda.zip
Clean up junk
Diffstat (limited to 'ignis')
-rw-r--r--ignis/urls.py1
-rw-r--r--ignis/views.py70
2 files changed, 0 insertions, 71 deletions
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')
-