mirror of
https://github.com/partitioncloud/partitioncloud-server.git
synced 2025-01-23 09:16:25 +01:00
Add thumbnails
This commit is contained in:
parent
ace8895652
commit
260cef29d4
1
.gitignore
vendored
1
.gitignore
vendored
@ -7,3 +7,4 @@
|
||||
# data
|
||||
instance/partitioncloud.sqlite
|
||||
partitioncloud/partitions
|
||||
partitioncloud/thumbnails
|
||||
|
@ -5,7 +5,7 @@ Main file
|
||||
import os
|
||||
from flask import Flask, render_template, request, send_file, g, redirect
|
||||
|
||||
from . import auth, albums
|
||||
from . import auth, albums, partition
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
@ -18,6 +18,7 @@ app.config.from_mapping(
|
||||
|
||||
app.register_blueprint(auth.bp)
|
||||
app.register_blueprint(albums.bp)
|
||||
app.register_blueprint(partition.bp)
|
||||
|
||||
|
||||
@app.route("/")
|
||||
|
27
partitioncloud/partition.py
Normal file
27
partitioncloud/partition.py
Normal file
@ -0,0 +1,27 @@
|
||||
#!/usr/bin/python3
|
||||
"""
|
||||
Partitions module
|
||||
"""
|
||||
import os
|
||||
|
||||
from flask import (Blueprint, render_template,
|
||||
send_file)
|
||||
|
||||
|
||||
bp = Blueprint("partition", __name__, url_prefix="/partition")
|
||||
|
||||
@bp.route("/<uuid>/preview")
|
||||
def preview(uuid):
|
||||
"""
|
||||
Renvoie la prévisualisation d'un fichier pdf
|
||||
"""
|
||||
if not os.path.exists(f"partitioncloud/thumbnails/{uuid}.jpg"):
|
||||
os.system(
|
||||
f'/usr/bin/convert -thumbnail\
|
||||
"178^>" -background white -alpha \
|
||||
remove -crop 178x178+0+0 \
|
||||
partitioncloud/partitions/{uuid}.pdf[0] \
|
||||
partitioncloud/thumbnails/{uuid}.jpg'
|
||||
)
|
||||
|
||||
return send_file(f"thumbnails/{uuid}.jpg")
|
@ -6,19 +6,21 @@
|
||||
|
||||
{% block content %}
|
||||
{% if not_participant %}
|
||||
<a href="/albums/{{ album['uuid'] }}/join">
|
||||
<button id="join-album">Rejoindre</button>
|
||||
</a>
|
||||
<a href="/albums/{{ album['uuid'] }}/join">
|
||||
<button id="join-album">Rejoindre</button>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if partitions|length != 0 %}
|
||||
{% for partition in partitions %}
|
||||
<a href="{{ album['uuid'] }}/{{ partition['uuid'] }}">
|
||||
<div class="partition-cover" id="partition-{{ partition['uuid'] }}">
|
||||
{{ partition["name"] }}
|
||||
</div>
|
||||
</a>
|
||||
{% endfor %}
|
||||
{% for partition in partitions %}
|
||||
<a href="{{ album['uuid'] }}/{{ partition['uuid'] }}">
|
||||
<div class="partition" id="partition-{{ partition['uuid'] }}">
|
||||
<img src="/partition/{{ partition['uuid'] }}/preview">
|
||||
<div class="partition-name">{{ partition["name"] }}</div>
|
||||
<div class="partition-author">{{ partition["author"] }}</div>
|
||||
</div>
|
||||
</a>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<div>Aucune partition disponible</div>
|
||||
<div>Aucune partition disponible</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
Loading…
Reference in New Issue
Block a user