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='up.css') }}" rel="stylesheet">
 | 
				
			||||||
    <link href="{{ url_for('static', filename='cover.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='simplemde.min.css') }}" rel="stylesheet">
 | 
				
			||||||
 | 
					    <link href="{{ url_for('static', filename='glightbox.min.css') }}" rel="stylesheet">
 | 
				
			||||||
 
 | 
					 
 | 
				
			||||||
</head>
 | 
					</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 %} >
 | 
					            <li{% if section == "Files" %} class="active" {% endif %} >
 | 
				
			||||||
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
 | 
					                    <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">
 | 
					                    <ul class="dropdown-menu" role="menu">
 | 
				
			||||||
                        <li><a href="/view/"> <span class="glyphicon glyphicon-cloud-download" aria-hidden="true"></span>
 | 
					                        <li><a href="/view/"> <span class="glyphicon glyphicon-cloud-download" aria-hidden="true"></span>
 | 
				
			||||||
			    Fichiers envoyés </a></li>
 | 
								    Mes Fichiers </a></li>
 | 
				
			||||||
                        <li><a href="/filesupload/"><span class="glyphicon glyphicon-cloud-upload" aria-hidden="true"></span>
 | 
								<li><a href="/gallery/">
 | 
				
			||||||
                            Envoyer des fichiers</a></li>
 | 
								    <span class="glyphicon glyphicon-cog" aria-hidden="true"></span>
 | 
				
			||||||
                        <li><a href="/gallery/"><span class="glyphicon glyphicon-cog" aria-hidden="true"></span>
 | 
					                            Ma Gallerie d'images
 | 
				
			||||||
                            Gallerie d'images
 | 
					 | 
				
			||||||
                        </a></li>
 | 
					                        </a></li>
 | 
				
			||||||
 | 
								<li><a href="/filesupload/">
 | 
				
			||||||
 | 
								    <span class="glyphicon glyphicon-cloud-upload" aria-hidden="true"></span>
 | 
				
			||||||
 | 
					                            Envoyer des fichiers</a></li>
 | 
				
			||||||
                    </ul>
 | 
					                    </ul>
 | 
				
			||||||
	    </li>
 | 
						    </li>
 | 
				
			||||||
            <li{% if section == "mailbox" %} class="active" {% endif %} >
 | 
					            <li{% if section == "mailbox" %} class="active" {% endif %} >
 | 
				
			||||||
 | 
				
			|||||||
@ -3,24 +3,31 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
{% block main %}
 | 
					{% block main %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<div class="container theme-showcase" role="main">
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<br />
 | 
					<br />
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<div id="gallery center" style= "margin-top:10vw;">
 | 
				
			||||||
{% if fichiers %}
 | 
					{% 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 %}
 | 
					    {% endfor %}
 | 
				
			||||||
       
 | 
					       
 | 
				
			||||||
    </div>
 | 
					{% else %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					       <h2> Il n'y a aucunes images dans votre gallerie </h2>
 | 
				
			||||||
 | 
					       
 | 
				
			||||||
 | 
					   
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
{% endif %}
 | 
					{% endif %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
</div>
 | 
					 </div>
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
{% endblock %}
 | 
					{% endblock %}
 | 
				
			||||||
 | 
				
			|||||||
@ -13,11 +13,13 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
<div class="container theme-showcase" role="main">
 | 
					<div class="container theme-showcase" role="main">
 | 
				
			||||||
    {% block main %}{% endblock %}
 | 
					    {% block main %}{% endblock %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
</div>
 | 
					</div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
{% include '_flash_msgs.html' %}
 | 
					{% include '_flash_msgs.html' %}
 | 
				
			||||||
{% include '_footer.html' %}
 | 
					{% include '_footer.html' %}
 | 
				
			||||||
{% include '_js.html' %}
 | 
					{% include '_js-core.html' %}
 | 
				
			||||||
 | 
					{% include '_js-gallery.html' %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
</body>
 | 
					</body>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -10,3 +10,7 @@ def getFileSizeKo(filename): # Prend un nom de fichier en arguments renvoie la t
 | 
				
			|||||||
    tmp = os.path.getsize(filename)
 | 
					    tmp = os.path.getsize(filename)
 | 
				
			||||||
    size = floor(tmp / 1024)
 | 
					    size = floor(tmp / 1024)
 | 
				
			||||||
    return size
 | 
					    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 sqlite3
 | 
				
			||||||
import os
 | 
					import os
 | 
				
			||||||
from shutil import move
 | 
					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')
 | 
					filesupload = Blueprint('filesupload', __name__, template_folder='templates')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -35,6 +35,8 @@ def uploadfiles():
 | 
				
			|||||||
           files = request.files.getlist('fic')
 | 
					           files = request.files.getlist('fic')
 | 
				
			||||||
           for f in files :
 | 
					           for f in files :
 | 
				
			||||||
               nom = secure_filename(f.filename)
 | 
					               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):
 | 
					               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')
 | 
					                   flash(u'Un fichier avec le même nom existe déjà, merci de spécifier un autre nom de fichier', 'error')
 | 
				
			||||||
               else:
 | 
					               else:
 | 
				
			||||||
@ -76,12 +78,17 @@ def uploadfiles():
 | 
				
			|||||||
@filesupload.route('/view/')
 | 
					@filesupload.route('/view/')
 | 
				
			||||||
def list():
 | 
					def list():
 | 
				
			||||||
    if 'username' in session :
 | 
					    if 'username' in session :
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
        user = '%s'% escape(session['username'])
 | 
					        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/')
 | 
					        files_private = os.listdir(DOSSIER_PERSO + user + '/files/')
 | 
				
			||||||
        listFilesPublic = []
 | 
					        listFilesPublic = []
 | 
				
			||||||
        listFilesPrivate = []
 | 
					        listFilesPrivate = []
 | 
				
			||||||
        nb_pv = 0
 | 
					        nb_pv = 0
 | 
				
			||||||
 | 
					        size=0
 | 
				
			||||||
        if files_private:
 | 
					        if files_private:
 | 
				
			||||||
            for fich in files_private:
 | 
					            for fich in files_private:
 | 
				
			||||||
                nb_pv += 1
 | 
					                nb_pv += 1
 | 
				
			||||||
@ -119,7 +126,11 @@ def myfiles(username, filename):
 | 
				
			|||||||
@filesupload.route('/make_public/<filename>')
 | 
					@filesupload.route('/make_public/<filename>')
 | 
				
			||||||
def move_public(filename):
 | 
					def move_public(filename):
 | 
				
			||||||
    if 'username' in session:
 | 
					    if 'username' in session:
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
        user = '%s' % escape(session['username'])
 | 
					        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)
 | 
					        src = os.path.join(DOSSIER_PERSO, user, 'files', filename)
 | 
				
			||||||
        dst = os.path.join(DOSSIER_PUBLIC, user, 'files/')
 | 
					        dst = os.path.join(DOSSIER_PUBLIC, user, 'files/')
 | 
				
			||||||
        move (src, dst)
 | 
					        move (src, dst)
 | 
				
			||||||
@ -131,6 +142,8 @@ def move_public(filename):
 | 
				
			|||||||
def move_private(filename):
 | 
					def move_private(filename):
 | 
				
			||||||
    if 'username' in session:
 | 
					    if 'username' in session:
 | 
				
			||||||
        user = '%s' % escape(session['username'])
 | 
					        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)
 | 
					        src = os.path.join(DOSSIER_PUBLIC, user, 'files', filename)
 | 
				
			||||||
        dst = os.path.join(DOSSIER_PERSO, user, 'files/')
 | 
					        dst = os.path.join(DOSSIER_PERSO, user, 'files/')
 | 
				
			||||||
        move (src, dst)
 | 
					        move (src, dst)
 | 
				
			||||||
 | 
				
			|||||||
@ -7,7 +7,7 @@ from PIL import Image
 | 
				
			|||||||
import time
 | 
					import time
 | 
				
			||||||
import sqlite3
 | 
					import sqlite3
 | 
				
			||||||
import os
 | 
					import os
 | 
				
			||||||
 | 
					from tools.filesutils import check_and_create
 | 
				
			||||||
 | 
					
 | 
				
			||||||
mygallery = Blueprint('mygallery', __name__, template_folder='templates')
 | 
					mygallery = Blueprint('mygallery', __name__, template_folder='templates')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -18,7 +18,7 @@ app.config.from_pyfile('config.py')
 | 
				
			|||||||
#### Variables ####################################################################################
 | 
					#### Variables ####################################################################################
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DOSSIER_PERSO= app.config['DOSSIER_APP']
 | 
					DOSSIER_PERSO= app.config['DOSSIER_APP']
 | 
				
			||||||
 | 
					DOSSIER_PUBLIC= app.config['DOSSIER_PUBLIC']+'/'
 | 
				
			||||||
extensionimg = app.config['EXT_IMG']
 | 
					extensionimg = app.config['EXT_IMG']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DATABASE = app.config['DATABASE']
 | 
					DATABASE = app.config['DATABASE']
 | 
				
			||||||
@ -27,8 +27,12 @@ DATABASE = app.config['DATABASE']
 | 
				
			|||||||
@mygallery.route( '/gallery/')
 | 
					@mygallery.route( '/gallery/')
 | 
				
			||||||
def gallery():
 | 
					def gallery():
 | 
				
			||||||
    if 'username' in session :
 | 
					    if 'username' in session :
 | 
				
			||||||
        UTILISATEUR='%s' % escape(session['username'])
 | 
					        user ='%s' % escape(session['username'])
 | 
				
			||||||
        THUMBNAILS=DOSSIER_PERSO + UTILISATEUR + '/images/thumbnails/'
 | 
					        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)]
 | 
					        fichiers = [fich for fich in os.listdir(THUMBNAILS)]
 | 
				
			||||||
        return render_template('gallery.html',
 | 
					        return render_template('gallery.html',
 | 
				
			||||||
                               section='Gallery',
 | 
					                               section='Gallery',
 | 
				
			||||||
 | 
				
			|||||||
@ -116,21 +116,6 @@ def signin(token) :
 | 
				
			|||||||
                            if res != 0:
 | 
					                            if res != 0:
 | 
				
			||||||
                                flash(u'Il y a eu un problème pour la création du compte XMPP !', 'error')
 | 
					                                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.
 | 
					                        # Une fois que tout c'est bien passé pour l'inscription on détruit le jeton.
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user