mirror of
https://github.com/partitioncloud/partitioncloud-server.git
synced 2025-01-23 17:26:26 +01:00
Add thumbnails
This commit is contained in:
parent
ace8895652
commit
260cef29d4
1
.gitignore
vendored
1
.gitignore
vendored
@ -7,3 +7,4 @@
|
|||||||
# data
|
# data
|
||||||
instance/partitioncloud.sqlite
|
instance/partitioncloud.sqlite
|
||||||
partitioncloud/partitions
|
partitioncloud/partitions
|
||||||
|
partitioncloud/thumbnails
|
||||||
|
@ -5,7 +5,7 @@ Main file
|
|||||||
import os
|
import os
|
||||||
from flask import Flask, render_template, request, send_file, g, redirect
|
from flask import Flask, render_template, request, send_file, g, redirect
|
||||||
|
|
||||||
from . import auth, albums
|
from . import auth, albums, partition
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
@ -18,6 +18,7 @@ app.config.from_mapping(
|
|||||||
|
|
||||||
app.register_blueprint(auth.bp)
|
app.register_blueprint(auth.bp)
|
||||||
app.register_blueprint(albums.bp)
|
app.register_blueprint(albums.bp)
|
||||||
|
app.register_blueprint(partition.bp)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/")
|
@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 %}
|
{% block content %}
|
||||||
{% if not_participant %}
|
{% if not_participant %}
|
||||||
<a href="/albums/{{ album['uuid'] }}/join">
|
<a href="/albums/{{ album['uuid'] }}/join">
|
||||||
<button id="join-album">Rejoindre</button>
|
<button id="join-album">Rejoindre</button>
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if partitions|length != 0 %}
|
{% if partitions|length != 0 %}
|
||||||
{% for partition in partitions %}
|
{% for partition in partitions %}
|
||||||
<a href="{{ album['uuid'] }}/{{ partition['uuid'] }}">
|
<a href="{{ album['uuid'] }}/{{ partition['uuid'] }}">
|
||||||
<div class="partition-cover" id="partition-{{ partition['uuid'] }}">
|
<div class="partition" id="partition-{{ partition['uuid'] }}">
|
||||||
{{ partition["name"] }}
|
<img src="/partition/{{ partition['uuid'] }}/preview">
|
||||||
</div>
|
<div class="partition-name">{{ partition["name"] }}</div>
|
||||||
</a>
|
<div class="partition-author">{{ partition["author"] }}</div>
|
||||||
{% endfor %}
|
</div>
|
||||||
|
</a>
|
||||||
|
{% endfor %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<div>Aucune partition disponible</div>
|
<div>Aucune partition disponible</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
Loading…
Reference in New Issue
Block a user