mini deployment

This commit is contained in:
Christoph J. Scherr 2023-06-06 01:05:29 +02:00
parent 3645e92489
commit 17b0fc8d6f
Signed by: PlexSheep
GPG Key ID: 25B4ACF7D88186CC
49 changed files with 45 additions and 15 deletions

View File

@ -146,8 +146,8 @@ USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.2/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = '/app/static'
STATIC_URL = '/static/'
# something for compiling bootstrap
@ -295,6 +295,6 @@ LOGGING = {
# this is where user uploaded files will go.
# TODO change this for prod
#MEDIA_ROOT = "/home/plex/Documents/code/python/gawa/media"
MEDIA_ROOT = "media/"
MEDIA_URL = "/app/media/"
MEDIA_ROOT = "/app/media"
MEDIA_URL = "/media/"
FILE_UPLOAD_TEMP_DIR = "/tmp/gawa/upload"

View File

@ -32,6 +32,7 @@ urlpatterns += i18n_patterns(
# use my fancy error pages
# better yet, don't let it come to that
handler400 = 'start.views.Error400'
handler404 = 'start.views.Error404'
handler500 = 'start.views.Error500'
# FIXME these break the server. something is wrong with them
#handler400 = 'start.views.Error400'
#handler404 = 'start.views.Error404'
#handler500 = 'start.views.Error500'

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View File

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

View File

@ -0,0 +1,18 @@
# Generated by Django 3.2.19 on 2023-06-05 23:01
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('start', '0008_link_status'),
]
operations = [
migrations.AlterField(
model_name='link',
name='favicon',
field=models.ImageField(blank=True, null=True, upload_to='img/links/favicons'),
),
]

View File

@ -97,7 +97,7 @@ class Link(Searchable):
# the actual link
url = models.URLField(unique=True, null=False, primary_key=True)
favicon_dir: str = "img/links/favicons"
favicon = models.ImageField(blank=True, upload_to=favicon_dir)
favicon = models.ImageField(blank=True, upload_to=favicon_dir, null=True)
status = models.BooleanField(default=False)
def __str__(self):
@ -110,6 +110,8 @@ class Link(Searchable):
Implements the abstract method of Searchable
Searches for a favicon in the urr, if one is found, it will be stored in MEDIA_ROOT
TODO filepathings here suck and are too error prone
"""
logger.info(f"regenerating {self.__class__.__name__} object: {self}")
self.suburl = f"/links#{self.title_en}"
@ -128,15 +130,24 @@ class Link(Searchable):
else:
response = requests.get(icons[0].url, stream=True)
filename: str = f"favicon-{random.randint(0x1000, 0xffff)}.{icons[0].format}"
with open(f"{settings.MEDIA_ROOT}/{self.favicon_dir}/{filename}", 'wb') as image:
try:
with open(f"/tmp/{filename}", 'wb') as image:
for chunk in response.iter_content(1024):
image.write(chunk)
logger.debug(image)
with open(f"{settings.MEDIA_ROOT}/{self.favicon_dir}/{filename}", 'rb') as image:
with open(f"/tmp/{filename}", 'rb') as image:
self.favicon.save(filename, File(image))
logger.info(f"downloaded favicon for {self}")
self.status = True
except FileNotFoundError as fe:
logger.error(f"cant write favicon to file for {self}: {fe}")
self.favicon = None
except Exception as e:
logger.warn(f"Unexpected Exception while downloading {self}: {e.with_traceback(None)}")
self.favicon = None
self.save()
class Meta: