SVG favicons

Image and colour preview for links
This commit is contained in:
Michał Gdula 2023-03-15 16:19:42 +00:00
parent 3008a55899
commit f9aeb0955d
5 changed files with 164 additions and 4 deletions

View file

@ -1,6 +1,6 @@
"""
Onlylegs - API endpoints
Used intermally by the frontend and possibly by other applications
Used internally by the frontend and possibly by other applications
"""
from uuid import uuid4
import os
@ -32,7 +32,7 @@ db_session = db_session()
def get_file(file_name):
"""
Returns a file from the uploads folder
t is the type of file (thumb, etc)
t is the type of file (thumb, etc.)
w and h are the width and height of the image for resizing
f is whether to apply filters to the image, such as blurring NSFW images
b is whether to force blur the image, even if it's not NSFW
@ -44,6 +44,15 @@ def get_file(file_name):
filtered = request.args.get('f', default=False, type=bool) # Whether to apply filters
blur = request.args.get('b', default=False, type=bool) # Whether to force blur
# Idea: instead if specifying the height and width, pass in a string like "200x200" or "200x" or "x200"
# This would remove the need for the if statements below and would be possible to pass in a string
# like 'thumb' to get the thumbnail size instead of having to specify the width and height
# This would also allow for more flexibility in the future if I wanted to add more sizes
# Another idea is to pass in a list of filters to apply to the image
# such as "blur,grayscale" or "blur,grayscale,sepia". But this would require a lot more work to implement
# and would be a lot more complicated to use, would also implement the risk of the server being overloaded
# with requests to apply a lot of filters to a lot of images at once
file_name = secure_filename(file_name) # Sanitize file name
# If type is thumb(nail), return from database instead of file system

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 7.9 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 8.1 KiB

View file

@ -1,5 +1,10 @@
{% extends 'layout.html' %}
{% block head %}
<meta property="og:image" content="/api/file/{{ image.file_name }}"/>
<meta name="theme-color" content="#{{ image.image_colours.0.0 }}{{ image.image_colours.0.1 }}{{ image.image_colours.0.2 }}"/>
{% endblock %}
{% block wrapper_class %}image-wrapper{% endblock %}
{% block content %}

View file

@ -3,13 +3,37 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Gallery</title>
<link rel="icon" href="{{url_for('static', filename='images/icon.png')}}">
<title>{{ config.WEBSITE.name }}</title>
<meta name="description" content="{{ config.WEBSITE.motto }}"/>
<meta name="author" content="{{ config.WEBSITE.author }}"/>
<meta property="og:title" content="{{ config.WEBSITE.name }}"/>
<meta property="og:description" content="{{ config.WEBSITE.motto }}"/>
<meta property="og:type" content="website"/>
<meta name="twitter:title" content="{{ config.WEBSITE.name }}"/>
<meta name="twitter:description" content="{{ config.WEBSITE.motto }}"/>
<meta name="twitter:card" content="summary_large_image">
<link
href="{{url_for('static', filename='images/logo-black.svg')}}"
rel="icon"
type="image/svg+xml"
media="(prefers-color-scheme: light)"/>
<link
href="{{url_for('static', filename='images/logo-white.svg')}}"
rel="icon"
type="image/svg+xml"
media="(prefers-color-scheme: dark)"/>
<link rel="stylesheet" href="{{url_for('static', filename='theme/style.css')}}" defer>
{% assets "js_all" %}
<script type="text/javascript" src="{{ ASSET_URL }}"></script>
{% endassets %}
{% block head %}{% endblock %}
</head>
<body>
<div class="notifications"></div>