1
0
mirror of https://github.com/aquatix/digimarks.git synced 2025-12-06 23:05:10 +01:00

More refactoring

This commit is contained in:
2023-12-12 22:46:19 +01:00
parent 65af6b5762
commit a3cdccdb8a

View File

@@ -70,7 +70,6 @@ app.add_middleware(
allow_headers=['*'],
)
# Temporary
all_tags = {}
usersettings = {}
@@ -306,26 +305,29 @@ class Bookmark(Base):
domain = u.netloc
if os.path.isfile(os.path.join(settings.media_dir, 'favicons/', domain + '.png')):
# If file exists, don't re-download it
self.favicon = domain + '.png'
self.favicon = f'{domain}.png'
return
if os.path.isfile(os.path.join(settings.media_dir, 'favicons/', domain + '.ico')):
# If file exists, don't re-download it
self.favicon = domain + '.ico'
self.favicon = f'{domain}.ico'
return
# self._set_favicon_with_iconsbetterideaorg(domain)
self._set_favicon_with_realfavicongenerator(domain)
def set_tags(self, newtags):
def set_tags(self, new_tags):
"""Set tags from `tags`, strip and sort them."""
tags_split = newtags.split(',')
tags_split = new_tags.split(',')
tags_clean = clean_tags(tags_split)
self.tags = ','.join(tags_clean)
def get_redirect_uri(self):
"""Derive where to redirect to."""
if self.redirect_uri:
return self.redirect_uri
if self.http_status == 301 or self.http_status == 302:
result = requests.head(self.url, allow_redirects=True, headers={'User-Agent': DIGIMARKS_USER_AGENT}, timeout=30)
if self.http_status in (301, 302):
result = requests.head(
self.url, allow_redirects=True, headers={'User-Agent': DIGIMARKS_USER_AGENT}, timeout=30
)
self.http_status = result.status_code
self.redirect_uri = result.url
return result.url
@@ -1014,7 +1016,6 @@ def findmissingfavicons(systemkey):
else:
raise HTTPException(status_code=404, detail='I can\'t let you do that Dave')
# Initialisation == create the bookmark, user and public tag tables if they do not exist
# TODO: switch to alembic migrations
# Bookmark.create_table(True)