Fix bugs in section files
This commit is contained in:
parent
f9b1b53c9f
commit
c405d0109c
1
static/glightbox.min.css
vendored
Normal file
1
static/glightbox.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
1
static/glightbox.min.js
vendored
Normal file
1
static/glightbox.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -15,5 +15,6 @@
|
||||
<link href="{{ url_for('static', filename='up.css') }}" rel="stylesheet">
|
||||
<link href="{{ url_for('static', filename='cover.css') }}" rel="stylesheet">
|
||||
<link href="{{ url_for('static', filename='simplemde.min.css') }}" rel="stylesheet">
|
||||
<link href="{{ url_for('static', filename='glightbox.min.css') }}" rel="stylesheet">
|
||||
|
||||
</head>
|
||||
|
@ -1 +1,45 @@
|
||||
<script src="{{ url_for('static', filename='docs.min.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='glightbox.min.js') }}"></script>
|
||||
<script>
|
||||
var lightbox = GLightbox();
|
||||
lightbox.on('open', (target) => {
|
||||
console.log('lightbox opened');
|
||||
});
|
||||
var lightboxDescription = GLightbox({
|
||||
selector: '.glightbox2'
|
||||
});
|
||||
var lightboxVideo = GLightbox({
|
||||
selector: '.glightbox3'
|
||||
});
|
||||
lightboxVideo.on('slide_changed', ({ prev, current }) => {
|
||||
console.log('Prev slide', prev);
|
||||
console.log('Current slide', current);
|
||||
|
||||
const { slideIndex, slideNode, slideConfig, player } = current;
|
||||
|
||||
if (player) {
|
||||
if (!player.ready) {
|
||||
// If player is not ready
|
||||
player.on('ready', (event) => {
|
||||
// Do something when video is ready
|
||||
});
|
||||
}
|
||||
|
||||
player.on('play', (event) => {
|
||||
console.log('Started play');
|
||||
});
|
||||
|
||||
player.on('volumechange', (event) => {
|
||||
console.log('Volume change');
|
||||
});
|
||||
|
||||
player.on('ended', (event) => {
|
||||
console.log('Video ended');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
var lightboxInlineIframe = GLightbox({
|
||||
selector: '.glightbox4'
|
||||
});
|
||||
|
||||
</script>
|
||||
|
@ -41,16 +41,17 @@
|
||||
|
||||
<li{% if section == "Files" %} class="active" {% endif %} >
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||
<span class="glyphicon glyphicon-folder-open" aria-hidden="true"></span> Mes Fichiers</a>
|
||||
<span class="glyphicon glyphicon-folder-open" aria-hidden="true"></span> Fichiers </a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li><a href="/view/"> <span class="glyphicon glyphicon-cloud-download" aria-hidden="true"></span>
|
||||
Fichiers envoyés </a></li>
|
||||
<li><a href="/filesupload/"><span class="glyphicon glyphicon-cloud-upload" aria-hidden="true"></span>
|
||||
Envoyer des fichiers</a></li>
|
||||
<li><a href="/gallery/"><span class="glyphicon glyphicon-cog" aria-hidden="true"></span>
|
||||
Gallerie d'images
|
||||
Mes Fichiers </a></li>
|
||||
<li><a href="/gallery/">
|
||||
<span class="glyphicon glyphicon-cog" aria-hidden="true"></span>
|
||||
Ma Gallerie d'images
|
||||
</a></li>
|
||||
|
||||
<li><a href="/filesupload/">
|
||||
<span class="glyphicon glyphicon-cloud-upload" aria-hidden="true"></span>
|
||||
Envoyer des fichiers</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li{% if section == "mailbox" %} class="active" {% endif %} >
|
||||
|
@ -3,24 +3,31 @@
|
||||
|
||||
{% block main %}
|
||||
|
||||
<div class="container theme-showcase" role="main">
|
||||
|
||||
|
||||
<br />
|
||||
|
||||
<div id="gallery center" style= "margin-top:10vw;">
|
||||
{% if fichiers %}
|
||||
|
||||
|
||||
<div id="gallery">
|
||||
{% for image in fichiers %}
|
||||
|
||||
<img src="/myfiles/images/thumbnails/{{ image }}" class="img-rounded" alt=""/>
|
||||
|
||||
{% for image in fichiers %}
|
||||
<a href="/myfiles/images/{{ image }}" class="glightbox">
|
||||
<img src="/myfiles/images/thumbnails/{{ image }}" class="img-rounded gallery" alt=""/>
|
||||
</a>
|
||||
{% endfor %}
|
||||
|
||||
</div>
|
||||
{% else %}
|
||||
|
||||
<h2> Il n'y a aucunes images dans votre gallerie </h2>
|
||||
|
||||
|
||||
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
@ -13,11 +13,13 @@
|
||||
|
||||
<div class="container theme-showcase" role="main">
|
||||
{% block main %}{% endblock %}
|
||||
|
||||
</div>
|
||||
|
||||
{% include '_flash_msgs.html' %}
|
||||
{% include '_footer.html' %}
|
||||
{% include '_js.html' %}
|
||||
{% include '_js-core.html' %}
|
||||
{% include '_js-gallery.html' %}
|
||||
|
||||
</body>
|
||||
|
||||
|
@ -10,3 +10,7 @@ def getFileSizeKo(filename): # Prend un nom de fichier en arguments renvoie la t
|
||||
tmp = os.path.getsize(filename)
|
||||
size = floor(tmp / 1024)
|
||||
return size
|
||||
|
||||
def check_and_create(folder):
|
||||
if not os.path.exists(folder):
|
||||
os.makedirs(folder)
|
||||
|
@ -8,7 +8,7 @@ import time
|
||||
import sqlite3
|
||||
import os
|
||||
from shutil import move
|
||||
from tools.filesutils import getFileSizeMo
|
||||
from tools.filesutils import getFileSizeMo, getFileSizeKo, check_and_create
|
||||
|
||||
filesupload = Blueprint('filesupload', __name__, template_folder='templates')
|
||||
|
||||
@ -35,6 +35,8 @@ def uploadfiles():
|
||||
files = request.files.getlist('fic')
|
||||
for f in files :
|
||||
nom = secure_filename(f.filename)
|
||||
check_and_create(DOSSIER_PERSO+ user + 'files')
|
||||
check_and_create(DOSSIER_PERSO+ user + 'images')
|
||||
if os.path.isfile(DOSSIER_PERSO + user + '/files/' + nom) or os.path.isfile(DOSSIER_PERSO + user + '/images/' + nom):
|
||||
flash(u'Un fichier avec le même nom existe déjà, merci de spécifier un autre nom de fichier', 'error')
|
||||
else:
|
||||
@ -76,12 +78,17 @@ def uploadfiles():
|
||||
@filesupload.route('/view/')
|
||||
def list():
|
||||
if 'username' in session :
|
||||
|
||||
user = '%s'% escape(session['username'])
|
||||
files_public = os.listdir(DOSSIER_PUBLIC + user + '/files')
|
||||
|
||||
check_and_create(DOSSIER_PUBLIC + user + '/files/')
|
||||
check_and_create(DOSSIER_PERSO + user + '/files/')
|
||||
files_public = os.listdir(DOSSIER_PUBLIC + user + '/files/')
|
||||
files_private = os.listdir(DOSSIER_PERSO + user + '/files/')
|
||||
listFilesPublic = []
|
||||
listFilesPrivate = []
|
||||
nb_pv = 0
|
||||
size=0
|
||||
if files_private:
|
||||
for fich in files_private:
|
||||
nb_pv += 1
|
||||
@ -119,7 +126,11 @@ def myfiles(username, filename):
|
||||
@filesupload.route('/make_public/<filename>')
|
||||
def move_public(filename):
|
||||
if 'username' in session:
|
||||
|
||||
user = '%s' % escape(session['username'])
|
||||
check_and_create(DOSSIER_PUBLIC + user + '/files/')
|
||||
check_and_create(DOSSIER_PERSO + user + '/files/')
|
||||
|
||||
src = os.path.join(DOSSIER_PERSO, user, 'files', filename)
|
||||
dst = os.path.join(DOSSIER_PUBLIC, user, 'files/')
|
||||
move (src, dst)
|
||||
@ -131,6 +142,8 @@ def move_public(filename):
|
||||
def move_private(filename):
|
||||
if 'username' in session:
|
||||
user = '%s' % escape(session['username'])
|
||||
check_and_create(DOSSIER_PUBLIC + user + '/files/')
|
||||
check_and_create(DOSSIER_PERSO + user + '/files/')
|
||||
src = os.path.join(DOSSIER_PUBLIC, user, 'files', filename)
|
||||
dst = os.path.join(DOSSIER_PERSO, user, 'files/')
|
||||
move (src, dst)
|
||||
|
@ -7,7 +7,7 @@ from PIL import Image
|
||||
import time
|
||||
import sqlite3
|
||||
import os
|
||||
|
||||
from tools.filesutils import check_and_create
|
||||
|
||||
mygallery = Blueprint('mygallery', __name__, template_folder='templates')
|
||||
|
||||
@ -18,7 +18,7 @@ app.config.from_pyfile('config.py')
|
||||
#### Variables ####################################################################################
|
||||
|
||||
DOSSIER_PERSO= app.config['DOSSIER_APP']
|
||||
|
||||
DOSSIER_PUBLIC= app.config['DOSSIER_PUBLIC']+'/'
|
||||
extensionimg = app.config['EXT_IMG']
|
||||
|
||||
DATABASE = app.config['DATABASE']
|
||||
@ -27,8 +27,12 @@ DATABASE = app.config['DATABASE']
|
||||
@mygallery.route( '/gallery/')
|
||||
def gallery():
|
||||
if 'username' in session :
|
||||
UTILISATEUR='%s' % escape(session['username'])
|
||||
THUMBNAILS=DOSSIER_PERSO + UTILISATEUR + '/images/thumbnails/'
|
||||
user ='%s' % escape(session['username'])
|
||||
check_and_create(DOSSIER_PUBLIC + user + '/images/')
|
||||
check_and_create(DOSSIER_PUBLIC + user + '/images/thumbnails/')
|
||||
check_and_create(DOSSIER_PERSO + user + '/images/')
|
||||
check_and_create(DOSSIER_PERSO + user + '/images/thumbnails/')
|
||||
THUMBNAILS=DOSSIER_PERSO + user + '/images/thumbnails/'
|
||||
fichiers = [fich for fich in os.listdir(THUMBNAILS)]
|
||||
return render_template('gallery.html',
|
||||
section='Gallery',
|
||||
|
@ -116,21 +116,6 @@ def signin(token) :
|
||||
if res != 0:
|
||||
flash(u'Il y a eu un problème pour la création du compte XMPP !', 'error')
|
||||
|
||||
# on créé les dossier de l'utilisateur
|
||||
userracine = DATAS_USER + user
|
||||
userfiles = userracine + '/files'
|
||||
userimages = userracine + '/images'
|
||||
userthumbnails = userracine + '/images/thumbnails'
|
||||
userprofile = userracine + '/profile'
|
||||
userlog = userracine + '/log.txt'
|
||||
if not os.path.exists(userracine):
|
||||
os.makedirs(userracine)
|
||||
os.makedirs(userfiles)
|
||||
os.makedirs(userimages)
|
||||
os.makedirs(userthumbnails)
|
||||
os.makedirs(userprofile)
|
||||
fp = open(userlog, 'x')
|
||||
fp.close()
|
||||
|
||||
|
||||
# Une fois que tout c'est bien passé pour l'inscription on détruit le jeton.
|
||||
|
Loading…
Reference in New Issue
Block a user