convert OPT from a dict to a class
This commit is contained in:
146
files.py
146
files.py
@@ -18,6 +18,7 @@ import time
|
||||
import re
|
||||
import json
|
||||
from flask_login import login_required, current_user
|
||||
from options import Options
|
||||
|
||||
################################################################################
|
||||
# Local Class imports
|
||||
@@ -170,85 +171,20 @@ def ClearJM_Message(id):
|
||||
db.session.commit()
|
||||
return
|
||||
|
||||
################################################################################
|
||||
# SetViewingOptions: defines set of default values for viewing (order/size, etc.)
|
||||
# and if a request object (from a POST) is passed in, it returns those instead
|
||||
# it also handles the cwd appropriately
|
||||
################################################################################
|
||||
def SetViewingOptions( request ):
|
||||
OPT={}
|
||||
OPT['noo']="Oldest"
|
||||
OPT['grouping']="None"
|
||||
OPT['how_many']="50"
|
||||
OPT['offset']="0"
|
||||
OPT['size']="128"
|
||||
settings=Settings.query.first()
|
||||
if 'orig_url' in request.form:
|
||||
print("okay, this has come from a viewer.html and needs next/prev how_many, recreate orig critiera...")
|
||||
url = request.form['orig_url']
|
||||
else:
|
||||
url = request.path
|
||||
if 'files_sp' in url:
|
||||
OPT['noo']="A to Z"
|
||||
OPT['folders']=True
|
||||
OPT['path_type'] = 'Storage'
|
||||
OPT['cwd']='static/Storage'
|
||||
OPT['paths'] = settings.storage_path.split("#")
|
||||
elif 'files_rbp' in url:
|
||||
OPT['folders']=True
|
||||
OPT['path_type'] = 'Bin'
|
||||
OPT['cwd']='static/Bin'
|
||||
OPT['paths'] = settings.recycle_bin_path.split("#")
|
||||
else:
|
||||
OPT['folders']=False
|
||||
OPT['path_type'] = 'Import'
|
||||
OPT['cwd']='static/Import'
|
||||
OPT['paths'] = settings.import_path.split("#")
|
||||
OPT['root']=OPT['cwd']
|
||||
|
||||
# the above are defaults, if we are here, then we have current values, use them instead
|
||||
if request.method=="POST":
|
||||
OPT['noo']=request.form['noo']
|
||||
OPT['how_many']=request.form['how_many']
|
||||
OPT['offset']=int(request.form['offset'])
|
||||
OPT['grouping']=request.form['grouping']
|
||||
OPT['size'] = request.form['size']
|
||||
# seems html cant do boolean, but uses strings so convert
|
||||
if request.form['folders'] == "False":
|
||||
OPT['folders']=False
|
||||
if request.form['folders'] == "True":
|
||||
OPT['folders']=True
|
||||
# have to force grouping to None if we flick to folders from a flat
|
||||
# view with grouping (otherwise we print out group headings for
|
||||
# child content that is not in the CWD)
|
||||
OPT['grouping']=None
|
||||
|
||||
OPT['cwd'] = request.form['cwd']
|
||||
if 'fullscreen' in request.form:
|
||||
OPT['fullscreen']=request.form['fullscreen']
|
||||
if 'prev' in request.form:
|
||||
OPT['offset'] -= int(OPT['how_many'])
|
||||
if OPT['offset'] < 0:
|
||||
OPT['offset']=0
|
||||
if 'next' in request.form:
|
||||
OPT['offset'] += int(OPT['how_many'])
|
||||
|
||||
return OPT
|
||||
|
||||
################################################################################
|
||||
# GetEntriesInFlatView: func. to retrieve DB entries appropriate for flat view
|
||||
################################################################################
|
||||
def GetEntriesInFlatView( OPT, prefix ):
|
||||
entries=[]
|
||||
|
||||
if OPT['noo'] == "Oldest":
|
||||
entries+=Entry.query.join(File).join(EntryDirLink).join(Dir).join(PathDirLink).join(Path).filter(Path.path_prefix==prefix).order_by(File.year,File.month,File.day,Entry.name).offset(OPT['offset']).limit(OPT['how_many']).all()
|
||||
elif OPT['noo'] == "Newest":
|
||||
entries+=Entry.query.join(File).join(EntryDirLink).join(Dir).join(PathDirLink).join(Path).filter(Path.path_prefix==prefix).order_by(File.year.desc(),File.month.desc(),File.day.desc(),Entry.name).offset(OPT['offset']).limit(OPT['how_many']).all()
|
||||
elif OPT['noo'] == "Z to A":
|
||||
entries+=Entry.query.join(File).join(EntryDirLink).join(Dir).join(PathDirLink).join(Path).filter(Path.path_prefix==prefix).order_by(Entry.name.desc()).offset(OPT['offset']).limit(OPT['how_many']).all()
|
||||
if OPT.noo == "Oldest":
|
||||
entries+=Entry.query.join(File).join(EntryDirLink).join(Dir).join(PathDirLink).join(Path).filter(Path.path_prefix==prefix).order_by(File.year,File.month,File.day,Entry.name).offset(OPT.offset).limit(OPT.how_many).all()
|
||||
elif OPT.noo == "Newest":
|
||||
entries+=Entry.query.join(File).join(EntryDirLink).join(Dir).join(PathDirLink).join(Path).filter(Path.path_prefix==prefix).order_by(File.year.desc(),File.month.desc(),File.day.desc(),Entry.name).offset(OPT.offset).limit(OPT.how_many).all()
|
||||
elif OPT.noo == "Z to A":
|
||||
entries+=Entry.query.join(File).join(EntryDirLink).join(Dir).join(PathDirLink).join(Path).filter(Path.path_prefix==prefix).order_by(Entry.name.desc()).offset(OPT.offset).limit(OPT.how_many).all()
|
||||
else:
|
||||
entries+=Entry.query.join(File).join(EntryDirLink).join(Dir).join(PathDirLink).join(Path).filter(Path.path_prefix==prefix).order_by(Entry.name).offset(OPT['offset']).limit(OPT['how_many']).all()
|
||||
entries+=Entry.query.join(File).join(EntryDirLink).join(Dir).join(PathDirLink).join(Path).filter(Path.path_prefix==prefix).order_by(Entry.name).offset(OPT.offset).limit(OPT.how_many).all()
|
||||
return entries
|
||||
|
||||
################################################################################
|
||||
@@ -258,7 +194,7 @@ def GetEntriesInFlatView( OPT, prefix ):
|
||||
def GetEntriesInFolderView( OPT, prefix ):
|
||||
entries=[]
|
||||
# okay the root cwd is fake, so treat it specially - its Dir can be found by path with dir.rel_path=''
|
||||
if os.path.dirname(OPT['cwd']) == 'static':
|
||||
if os.path.dirname(OPT.cwd) == 'static':
|
||||
dir=Entry.query.join(Dir).join(PathDirLink).join(Path).filter(Dir.rel_path=='').filter(Path.path_prefix==prefix).order_by(Entry.name).first()
|
||||
# this can occur if the path in settings does not exist as it wont be in # the DB
|
||||
if not dir:
|
||||
@@ -266,7 +202,7 @@ def GetEntriesInFolderView( OPT, prefix ):
|
||||
# although this is 1 entry, needs to come back via all() to be iterable
|
||||
entries+= Entry.query.filter(Entry.id==dir.id).all()
|
||||
else:
|
||||
rp = OPT['cwd'].replace( prefix, '' )
|
||||
rp = OPT.cwd.replace( prefix, '' )
|
||||
# when in subdirs, replacing prefix will leave the first char as /, get rid of it
|
||||
if len(rp) and rp[0] == '/':
|
||||
rp=rp[1:]
|
||||
@@ -274,22 +210,22 @@ def GetEntriesInFolderView( OPT, prefix ):
|
||||
# this can occur if the path in settings does not exist as it wont be in # the DB
|
||||
if not dir:
|
||||
return entries
|
||||
if OPT['noo'] == "Z to A" or "Newest":
|
||||
if OPT.noo == "Z to A" or "Newest":
|
||||
entries+= Entry.query.join(EntryDirLink).join(FileType).filter(EntryDirLink.dir_eid==dir.id).filter(FileType.name=='Directory').order_by(Entry.name.desc()).all()
|
||||
# just do A to Z / Oldest by default or if no valid option
|
||||
else:
|
||||
entries+= Entry.query.join(EntryDirLink).join(FileType).filter(EntryDirLink.dir_eid==dir.id).filter(FileType.name=='Directory').order_by(Entry.name).all()
|
||||
|
||||
# add any files at the current CWD (based on dir_eid in DB)
|
||||
if OPT['noo'] == "Oldest":
|
||||
entries+=Entry.query.join(File).join(EntryDirLink).filter(EntryDirLink.dir_eid==dir.id).order_by(File.year,File.month,File.day,Entry.name).offset(OPT['offset']).limit(OPT['how_many']).all()
|
||||
elif OPT['noo'] == "Newest":
|
||||
entries+=Entry.query.join(File).join(EntryDirLink).filter(EntryDirLink.dir_eid==dir.id).order_by(File.year.desc(),File.month.desc(),File.day.desc(),Entry.name).offset(OPT['offset']).limit(OPT['how_many']).all()
|
||||
elif OPT['noo'] == "Z to A":
|
||||
entries+=Entry.query.join(File).join(EntryDirLink).filter(EntryDirLink.dir_eid==dir.id).order_by(Entry.name.desc()).offset(OPT['offset']).limit(OPT['how_many']).all()
|
||||
if OPT.noo == "Oldest":
|
||||
entries+=Entry.query.join(File).join(EntryDirLink).filter(EntryDirLink.dir_eid==dir.id).order_by(File.year,File.month,File.day,Entry.name).offset(OPT.offset).limit(OPT.how_many).all()
|
||||
elif OPT.noo == "Newest":
|
||||
entries+=Entry.query.join(File).join(EntryDirLink).filter(EntryDirLink.dir_eid==dir.id).order_by(File.year.desc(),File.month.desc(),File.day.desc(),Entry.name).offset(OPT.offset).limit(OPT.how_many).all()
|
||||
elif OPT.noo == "Z to A":
|
||||
entries+=Entry.query.join(File).join(EntryDirLink).filter(EntryDirLink.dir_eid==dir.id).order_by(Entry.name.desc()).offset(OPT.offset).limit(OPT.how_many).all()
|
||||
# just do A to Z by default or if no valid option
|
||||
else:
|
||||
entries+=Entry.query.join(File).join(EntryDirLink).filter(EntryDirLink.dir_eid==dir.id).order_by(Entry.name).offset(OPT['offset']).limit(OPT['how_many']).all()
|
||||
entries+=Entry.query.join(File).join(EntryDirLink).filter(EntryDirLink.dir_eid==dir.id).order_by(Entry.name).offset(OPT.offset).limit(OPT.how_many).all()
|
||||
|
||||
return entries
|
||||
|
||||
@@ -303,19 +239,19 @@ def GetEntries( OPT ):
|
||||
search_term=request.form['search_term']
|
||||
if 'AI:' in search_term:
|
||||
search_term = search_term.replace('AI:','')
|
||||
all_entries = Entry.query.join(File).join(FaceFileLink).join(Face).join(FaceRefimgLink).join(Refimg).join(PersonRefimgLink).join(Person).filter(Person.tag.ilike(f"%{search_term}%")).order_by(File.year.desc(),File.month.desc(),File.day.desc(),Entry.name).offset(OPT['offset']).limit(OPT['how_many']).all()
|
||||
all_entries = Entry.query.join(File).join(FaceFileLink).join(Face).join(FaceRefimgLink).join(Refimg).join(PersonRefimgLink).join(Person).filter(Person.tag.ilike(f"%{search_term}%")).order_by(File.year.desc(),File.month.desc(),File.day.desc(),Entry.name).offset(OPT.offset).limit(OPT.how_many).all()
|
||||
else:
|
||||
file_data=Entry.query.join(File).filter(Entry.name.ilike(f"%{search_term}%")).order_by(File.year.desc(),File.month.desc(),File.day.desc(),Entry.name).offset(OPT['offset']).limit(OPT['how_many']).all()
|
||||
dir_data=Entry.query.join(File).join(EntryDirLink).join(Dir).filter(Dir.rel_path.ilike(f"%{search_term}%")).order_by(File.year.desc(),File.month.desc(),File.day.desc(),Entry.name).offset(OPT['offset']).limit(OPT['how_many']).all()
|
||||
ai_data=Entry.query.join(File).join(FaceFileLink).join(Face).join(FaceRefimgLink).join(Refimg).join(PersonRefimgLink).join(Person).filter(Person.tag.ilike(f"%{search_term}%")).order_by(File.year.desc(),File.month.desc(),File.day.desc(),Entry.name).offset(OPT['offset']).limit(OPT['how_many']).all()
|
||||
file_data=Entry.query.join(File).filter(Entry.name.ilike(f"%{search_term}%")).order_by(File.year.desc(),File.month.desc(),File.day.desc(),Entry.name).offset(OPT.offset).limit(OPT.how_many).all()
|
||||
dir_data=Entry.query.join(File).join(EntryDirLink).join(Dir).filter(Dir.rel_path.ilike(f"%{search_term}%")).order_by(File.year.desc(),File.month.desc(),File.day.desc(),Entry.name).offset(OPT.offset).limit(OPT.how_many).all()
|
||||
ai_data=Entry.query.join(File).join(FaceFileLink).join(Face).join(FaceRefimgLink).join(Refimg).join(PersonRefimgLink).join(Person).filter(Person.tag.ilike(f"%{search_term}%")).order_by(File.year.desc(),File.month.desc(),File.day.desc(),Entry.name).offset(OPT.offset).limit(OPT.how_many).all()
|
||||
all_entries = file_data + dir_data + ai_data
|
||||
return all_entries
|
||||
|
||||
for path in OPT['paths']:
|
||||
for path in OPT.paths:
|
||||
if not os.path.exists(path):
|
||||
continue
|
||||
prefix = SymlinkName(OPT['path_type'],path,path+'/')
|
||||
if OPT['folders']:
|
||||
prefix = SymlinkName(OPT.path_type,path,path+'/')
|
||||
if OPT.folders:
|
||||
entries+=GetEntriesInFolderView( OPT, prefix )
|
||||
else:
|
||||
entries+=GetEntriesInFlatView( OPT, prefix )
|
||||
@@ -327,7 +263,7 @@ def GetEntries( OPT ):
|
||||
@app.route("/file_list_ip", methods=["GET","POST"])
|
||||
@login_required
|
||||
def file_list_ip():
|
||||
OPT=SetViewingOptions( request )
|
||||
OPT=Options( request )
|
||||
entries=GetEntries( OPT )
|
||||
return render_template("file_list.html", page_title='View File Details (Import Path)', entry_data=entries, OPT=OPT )
|
||||
|
||||
@@ -337,10 +273,10 @@ def file_list_ip():
|
||||
@app.route("/files_ip", methods=["GET", "POST"])
|
||||
@login_required
|
||||
def files_ip():
|
||||
OPT=SetViewingOptions( request )
|
||||
OPT=Options( request )
|
||||
entries=GetEntries( OPT )
|
||||
people = Person.query.all()
|
||||
return render_template("files.html", page_title=f"View Files ({OPT['path_type']} Path)", entry_data=entries, OPT=OPT, people=people )
|
||||
return render_template("files.html", page_title=f"View Files ({OPT.path_type} Path)", entry_data=entries, OPT=OPT, people=people )
|
||||
|
||||
################################################################################
|
||||
# /files -> show thumbnail view of files from storage_path
|
||||
@@ -348,10 +284,10 @@ def files_ip():
|
||||
@app.route("/files_sp", methods=["GET", "POST"])
|
||||
@login_required
|
||||
def files_sp():
|
||||
OPT=SetViewingOptions( request )
|
||||
OPT=Options( request )
|
||||
entries=GetEntries( OPT )
|
||||
people = Person.query.all()
|
||||
return render_template("files.html", page_title=f"View Files ({OPT['path_type']} Path)", entry_data=entries, OPT=OPT, people=people )
|
||||
return render_template("files.html", page_title=f"View Files ({OPT.path_type} Path)", entry_data=entries, OPT=OPT, people=people )
|
||||
|
||||
|
||||
################################################################################
|
||||
@@ -360,10 +296,10 @@ def files_sp():
|
||||
@app.route("/files_rbp", methods=["GET", "POST"])
|
||||
@login_required
|
||||
def files_rbp():
|
||||
OPT=SetViewingOptions( request )
|
||||
OPT=Options( request )
|
||||
entries=GetEntries( OPT )
|
||||
people = Person.query.all()
|
||||
return render_template("files.html", page_title=f"View Files ({OPT['path_type']} Path)", entry_data=entries, OPT=OPT )
|
||||
return render_template("files.html", page_title=f"View Files ({OPT.path_type} Path)", entry_data=entries, OPT=OPT )
|
||||
|
||||
|
||||
################################################################################
|
||||
@@ -372,9 +308,9 @@ def files_rbp():
|
||||
@app.route("/search", methods=["GET","POST"])
|
||||
@login_required
|
||||
def search():
|
||||
OPT=SetViewingOptions( request )
|
||||
OPT=Options( request )
|
||||
# always show flat results for search to start with
|
||||
OPT['folders']=False
|
||||
OPT.folders=False
|
||||
entries=GetEntries( OPT )
|
||||
return render_template("files.html", page_title='View Files', search_term=request.form['search_term'], entry_data=entries, OPT=OPT )
|
||||
|
||||
@@ -522,7 +458,7 @@ def move_files():
|
||||
@app.route("/viewlist", methods=["POST"])
|
||||
@login_required
|
||||
def viewlist():
|
||||
OPT=SetViewingOptions( request )
|
||||
OPT=Options( request )
|
||||
# Get next/prev set of data - e.g. if next set, then it will use orig_url
|
||||
# to go forward how_many from offset and then use viewer.html to show that
|
||||
# first obj of the new list of entries
|
||||
@@ -531,10 +467,10 @@ def viewlist():
|
||||
# it) and it just happened to also be the last in the DB...
|
||||
if not entries:
|
||||
# undo the skip by how_many and getentries again
|
||||
OPT['offset'] -= int(OPT['how_many'])
|
||||
OPT.offset -= int(OPT.how_many)
|
||||
entries=GetEntries( OPT )
|
||||
# now flag we are at the last in db, to reset current below
|
||||
OPT['last_entry_in_db']=1
|
||||
OPT.last_entry_in_db=1
|
||||
objs = {}
|
||||
eids=""
|
||||
for e in entries:
|
||||
@@ -550,10 +486,10 @@ def viewlist():
|
||||
current = int(lst[0])
|
||||
if 'prev' in request.form:
|
||||
current = int(lst[-1])
|
||||
if 'last_entry_in_db' in OPT:
|
||||
if hasattr( OPT, 'last_entry_in_db' ):
|
||||
# force this back to the last image of the last page - its the last in the DB, so set OPT for it
|
||||
current = int(lst[-1])
|
||||
OPT['last_entry_in_db']=current
|
||||
OPT.last_entry_in_db=current
|
||||
|
||||
return render_template("viewer.html", current=current, eids=eids, objs=objs, OPT=OPT )
|
||||
|
||||
@@ -563,7 +499,7 @@ def viewlist():
|
||||
@app.route("/view/<id>", methods=["POST"])
|
||||
@login_required
|
||||
def view_img(id):
|
||||
OPT=SetViewingOptions( request )
|
||||
OPT=Options( request )
|
||||
eids=request.form['eids'].rstrip(',')
|
||||
objs = {}
|
||||
lst = eids.split(',')
|
||||
@@ -638,7 +574,7 @@ def custom_static(filename):
|
||||
|
||||
###############################################################################
|
||||
# This func creates a new filter in jinja2 to test to see if the Dir being
|
||||
# checked, is a top-level folder of 'OPT['cwd']'
|
||||
# checked, is a top-level folder of 'OPT.cwd'
|
||||
################################################################################
|
||||
@app.template_filter('TopLevelFolderOf')
|
||||
def _jinja2_filter_toplevelfolderof(path, cwd):
|
||||
|
||||
161
internal/js/view_support.js
Normal file
161
internal/js/view_support.js
Normal file
@@ -0,0 +1,161 @@
|
||||
function NewWidth()
|
||||
{
|
||||
w_r=im.width/(window.innerWidth*gap)
|
||||
h_r=im.height/(window.innerHeight*gap)
|
||||
if( w_r > h_r )
|
||||
return window.innerWidth*gap
|
||||
else
|
||||
return im.width*gap / (im.height/window.innerHeight)
|
||||
}
|
||||
|
||||
function NewHeight()
|
||||
{
|
||||
w_r=im.width/(window.innerWidth*gap)
|
||||
h_r=im.height/(window.innerHeight*gap)
|
||||
if( h_r > w_r )
|
||||
return window.innerHeight*gap
|
||||
else
|
||||
return im.height*gap / (im.width/window.innerWidth)
|
||||
}
|
||||
|
||||
// Define this once and before it will be called, hence at the top of this file
|
||||
function DrawImg()
|
||||
{
|
||||
// another call to this func will occur on load, so skip this one
|
||||
if( im.width == 0 )
|
||||
return
|
||||
|
||||
canvas.width=NewWidth(im)
|
||||
canvas.height=NewHeight(im)
|
||||
|
||||
// actually draw the pixel images to the canvas at the right size
|
||||
if( grayscale )
|
||||
context.filter='grayscale(1)'
|
||||
context.drawImage(im, 0, 0, canvas.width, canvas.height )
|
||||
// -50 is a straight up hack, no idea why this works, but its good enough for me
|
||||
if( throbber )
|
||||
$('#throbber').attr('style', 'display:show; position:absolute; left:'+canvas.width/2+'px; top:'+(canvas.height/2-50)+'px' )
|
||||
else
|
||||
$('#throbber').hide();
|
||||
|
||||
|
||||
// show (or not) the whole figcaption with fname in it - based on state of fname_toggle
|
||||
if( $('#fname_toggle').prop('checked' ) )
|
||||
{
|
||||
$('.figcaption').attr('style', 'display:show' )
|
||||
// reset fname for new image (if navigated left/right to get here)
|
||||
$('#fname').html(objs[current].name)
|
||||
}
|
||||
else
|
||||
$('.figcaption').attr('style', 'display:none' )
|
||||
|
||||
// if we have faces, the enable the toggles, otherwise disable them
|
||||
// and reset model select too
|
||||
if( objs[current].faces.length )
|
||||
{
|
||||
$('#faces').attr('disabled', false)
|
||||
$('#distance').attr('disabled', false)
|
||||
$('#model').val( Number(objs[current].face_model) )
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#faces').attr('disabled', true)
|
||||
$('#distance').attr('disabled', true)
|
||||
// if no faces, then model is N/A (always 1st element - or 0 in select)
|
||||
$('#model').val(0)
|
||||
}
|
||||
|
||||
// okay, we want faces drawn so lets do it
|
||||
if( $('#faces').prop('checked') )
|
||||
{
|
||||
// draw rect on each face
|
||||
for( i=0; i<objs[current].faces.length; i++ )
|
||||
{
|
||||
x = objs[current].faces[i].x / ( im.width/canvas.width )
|
||||
y = objs[current].faces[i].y / ( im.height/canvas.height )
|
||||
w = objs[current].faces[i].w / ( im.width/canvas.width )
|
||||
h = objs[current].faces[i].h / ( im.height/canvas.height )
|
||||
context.beginPath()
|
||||
context.rect( x, y, w, h )
|
||||
context.lineWidth = 2
|
||||
context.strokeStyle = 'green'
|
||||
if( objs[current].faces[i].who )
|
||||
{
|
||||
// finish face box, need to clear out new settings for
|
||||
// transparent backed-name tag
|
||||
context.stroke();
|
||||
context.beginPath()
|
||||
context.lineWidth = 0.1
|
||||
context.font = "30px Arial"
|
||||
context.globalAlpha = 0.6
|
||||
str=objs[current].faces[i].who
|
||||
if( $('#distance').prop('checked') )
|
||||
str += "("+objs[current].faces[i].distance+")"
|
||||
|
||||
bbox = context.measureText(str);
|
||||
f_h=bbox.fontBoundingBoxAscent
|
||||
if( bbox.fontBoundingBoxDescent )
|
||||
f_h += bbox.fontBoundingBoxDescent
|
||||
f_h -= 8
|
||||
context.rect( x+w/2-bbox.width/2, y-f_h, bbox.width, f_h )
|
||||
context.fillStyle="white"
|
||||
context.fill()
|
||||
context.stroke();
|
||||
context.beginPath()
|
||||
context.globalAlpha = 1.0
|
||||
context.font = "30px Arial"
|
||||
context.textAlign = "center"
|
||||
context.fillStyle = "green"
|
||||
context.fillText(str, x+w/2, y-2)
|
||||
}
|
||||
/* can use to show lower left coords of a face for debugging
|
||||
else
|
||||
{
|
||||
context.font = "14px Arial"
|
||||
context.textAlign = "center"
|
||||
context.fillStyle = "black"
|
||||
context.fillText( 'x=' + objs[current].faces[i].x + ', y=' + objs[current].faces[i].y, x+w/2, y-2)
|
||||
context.fillText( 'x=' + objs[current].faces[i].x + ', y=' + objs[current].faces[i].y, x+w/2, y-2)
|
||||
}
|
||||
*/
|
||||
context.stroke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function ResizeVideo()
|
||||
{
|
||||
$('#video').height(window.innerHeight*gap)
|
||||
}
|
||||
|
||||
function FaceToggle()
|
||||
{
|
||||
$('#distance').prop('disabled', function(i, v) { return !v; });
|
||||
DrawImg()
|
||||
}
|
||||
|
||||
function ViewImageOrVideo()
|
||||
{
|
||||
if( objs[current].type == 'Image' )
|
||||
{
|
||||
im.src='http://mara.ddp.net:5000/' + objs[current].url
|
||||
$('#video').hide()
|
||||
$('#figure').show()
|
||||
if( fullscreen )
|
||||
{
|
||||
console.log('going fs on image')
|
||||
$('#canvas').get(0).requestFullscreen()
|
||||
}
|
||||
}
|
||||
if( objs[current].type == 'Video' )
|
||||
{
|
||||
$('#video').prop('src', 'http://mara.ddp.net:5000/' + objs[current].url )
|
||||
$('#figure').hide()
|
||||
$('#video').show()
|
||||
if( fullscreen )
|
||||
{
|
||||
console.log('going fs on video')
|
||||
$('#video').get(0).requestFullscreen()
|
||||
}
|
||||
}
|
||||
}
|
||||
64
options.py
Normal file
64
options.py
Normal file
@@ -0,0 +1,64 @@
|
||||
from settings import Settings
|
||||
from shared import PA
|
||||
|
||||
################################################################################
|
||||
# Options: class to store set of default values for viewing (order/size, etc.)
|
||||
# and if a request object (from a POST) is passed in, it returns those instead
|
||||
# it also handles the cwd appropriately, paths, fullscreen, search, etc.
|
||||
################################################################################
|
||||
class Options(PA):
|
||||
def __init__(self, request):
|
||||
self.noo="Oldest"
|
||||
self.grouping="None"
|
||||
self.how_many="50"
|
||||
self.offset="0"
|
||||
self.size="128"
|
||||
|
||||
self.folders=True
|
||||
settings=Settings.query.first()
|
||||
if 'orig_url' in request.form:
|
||||
url = request.form['orig_url']
|
||||
else:
|
||||
url = request.path
|
||||
if 'files_sp' in url:
|
||||
self.noo="A to Z"
|
||||
self.path_type = 'Storage'
|
||||
self.paths = settings.storage_path.split("#")
|
||||
elif 'files_rbp' in url:
|
||||
self.path_type = 'Bin'
|
||||
self.paths = settings.recycle_bin_path.split("#")
|
||||
else:
|
||||
self.folders=False
|
||||
self.path_type = 'Import'
|
||||
self.cwd='static/Import'
|
||||
self.paths = settings.import_path.split("#")
|
||||
|
||||
self.cwd='static/' + self.path_type
|
||||
self.root=self.cwd
|
||||
|
||||
# the above are defaults, if we are here, then we have current values, use them instead
|
||||
if request.method=="POST":
|
||||
self.noo=request.form['noo']
|
||||
self.how_many=request.form['how_many']
|
||||
self.offset=int(request.form['offset'])
|
||||
self.grouping=request.form['grouping']
|
||||
self.size = request.form['size']
|
||||
# seems html cant do boolean, but uses strings so convert
|
||||
if request.form['folders'] == "False":
|
||||
self.folders=False
|
||||
if request.form['folders'] == "True":
|
||||
self.folders=True
|
||||
# have to force grouping to None if we flick to folders from a flat
|
||||
# view with grouping (otherwise we print out group headings for
|
||||
# child content that is not in the CWD)
|
||||
self.grouping=None
|
||||
|
||||
self.cwd = request.form['cwd']
|
||||
if 'fullscreen' in request.form:
|
||||
self.fullscreen=request.form['fullscreen']
|
||||
if 'prev' in request.form:
|
||||
self.offset -= int(self.how_many)
|
||||
if self.offset < 0:
|
||||
self.offset=0
|
||||
if 'next' in request.form:
|
||||
self.offset += int(self.how_many)
|
||||
@@ -5,6 +5,15 @@ import io
|
||||
import base64
|
||||
from PIL import Image, ImageOps
|
||||
|
||||
class PA:
|
||||
def __repr__(self):
|
||||
str=f"<{self.__class__.__name__}("
|
||||
for k, v in self.__dict__.items():
|
||||
str += f"{k}={v!r}, "
|
||||
str=str.rstrip(", ") + ")>"
|
||||
return str
|
||||
|
||||
|
||||
hostname = socket.gethostname()
|
||||
PROD_HOST="pa_web"
|
||||
|
||||
|
||||
@@ -2,26 +2,26 @@
|
||||
<div class="container-fluid">
|
||||
<h3 class="offset-2">{{page_title}}</h3>
|
||||
<form id="main_form" method="POST">
|
||||
<input id="offset" type="hidden" name="offset" value="{{OPT['offset']}}">
|
||||
<input id="offset" type="hidden" name="offset" value="{{OPT.offset}}">
|
||||
<input id="grouping" type="hidden" name="grouping" value="">
|
||||
<input id="size" type="hidden" name="size" value="">
|
||||
<input id="cwd" type="hidden" name="cwd" value="">
|
||||
<input id="folders" type="hidden" name="folders" value="False">
|
||||
<div class="col col-auto">
|
||||
<div class="input-group">
|
||||
{{CreateSelect( "noo", OPT['noo'], ["Oldest", "Newest","A to Z", "Z to A"], "$('#offset').val(0)", "rounded-start py-1 my-1")|safe }}
|
||||
{{CreateSelect( "how_many", OPT['how_many'], ["10", "25", "50", "75", "100", "150", "200", "500"], "", "rounded-end py-1 my-1" )|safe }}
|
||||
{{CreateSelect( "noo", OPT.noo, ["Oldest", "Newest","A to Z", "Z to A"], "$('#offset').val(0)", "rounded-start py-1 my-1")|safe }}
|
||||
{{CreateSelect( "how_many", OPT.how_many, ["10", "25", "50", "75", "100", "150", "200", "500"], "", "rounded-end py-1 my-1" )|safe }}
|
||||
<div class="mb-1 col my-auto d-flex justify-content-center">
|
||||
{% set prv_disabled="" %}
|
||||
{% if OPT['offset']|int == 0 %}
|
||||
{% if OPT.offset|int == 0 %}
|
||||
{% set prv_disabled="disabled" %}
|
||||
{% endif %}
|
||||
<button id="prev" {{prv_disabled}} name="prev" class="prev sm-txt btn btn-outline-secondary">
|
||||
<svg width="16" height="16" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#prev"/></svg>
|
||||
</button>
|
||||
<span class="sm-txt my-auto"> {{OPT['how_many']}} files </span>
|
||||
<span class="sm-txt my-auto"> {{OPT.how_many}} files </span>
|
||||
{% set nxt_disabled="" %}
|
||||
{% if entry_data|length < OPT['how_many']|int %}
|
||||
{% if entry_data|length < OPT.how_many|int %}
|
||||
{% set nxt_disabled="disabled" %}
|
||||
{% endif %}
|
||||
<button id="next" {{nxt_disabled}} name="next" class="next sm-txt btn btn-outline-secondary">
|
||||
|
||||
@@ -6,38 +6,38 @@
|
||||
|
||||
<div class="container-fluid">
|
||||
<form id="main_form" method="POST">
|
||||
<input type="hidden" name="cwd" id="cwd" value="{{OPT['cwd']}}">
|
||||
<input type="hidden" name="cwd" id="cwd" value="{{OPT.cwd}}">
|
||||
{% if search_term is defined %}
|
||||
<input type="hidden" name="search_term" id="view_term" value="{{search_term}}">
|
||||
{% endif %}
|
||||
<div class="d-flex row mb-2">
|
||||
{% if OPT['folders'] %}
|
||||
{% if OPT.folders %}
|
||||
<div class="my-auto col col-auto">
|
||||
<span class="alert alert-primary py-2">
|
||||
{% if "files_ip" in request.url %}
|
||||
<svg width="20" height="20" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#import"/></svg>
|
||||
{% set tmp_path=OPT['cwd'] | replace( "static/Import", "" ) + "/" %}
|
||||
{% set tmp_path=OPT.cwd | replace( "static/Import", "" ) + "/" %}
|
||||
{% elif "files_sp" in request.url %}
|
||||
<svg width="20" height="20" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#db"/></svg>
|
||||
{% set tmp_path=OPT['cwd'] | replace( "static/Storage", "" ) + "/" %}
|
||||
{% set tmp_path=OPT.cwd | replace( "static/Storage", "" ) + "/" %}
|
||||
{% elif "files_rbp" in request.url %}
|
||||
<svg width="20" height="20" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#trash"/></svg>
|
||||
{% set tmp_path=OPT['cwd'] | replace( "static/Bin", "" ) + "/" %}
|
||||
{% set tmp_path=OPT.cwd | replace( "static/Bin", "" ) + "/" %}
|
||||
{% endif %}
|
||||
{{tmp_path}}</span>
|
||||
</div class="col my-auto">
|
||||
{% endif %}
|
||||
<div class="col col-auto">
|
||||
<div class="input-group">
|
||||
{{CreateSelect( "noo", OPT['noo'], ["Oldest", "Newest","A to Z", "Z to A"], "$('#offset').val(0)", "rounded-start py-2")|safe }}
|
||||
{{CreateSelect( "how_many", OPT['how_many'], ["10", "25", "50", "75", "100", "150", "200", "500"])|safe }}
|
||||
{% if OPT['folders'] %}
|
||||
<input type="hidden" name="grouping" id="grouping" value="{{OPT['grouping']}}">
|
||||
{{CreateFoldersSelect( OPT['folders'], "rounded-end" )|safe }}
|
||||
{{CreateSelect( "noo", OPT.noo, ["Oldest", "Newest","A to Z", "Z to A"], "$('#offset').val(0)", "rounded-start py-2")|safe }}
|
||||
{{CreateSelect( "how_many", OPT.how_many, ["10", "25", "50", "75", "100", "150", "200", "500"])|safe }}
|
||||
{% if OPT.folders %}
|
||||
<input type="hidden" name="grouping" id="grouping" value="{{OPT.grouping}}">
|
||||
{{CreateFoldersSelect( OPT.folders, "rounded-end" )|safe }}
|
||||
{% else %}
|
||||
{{CreateFoldersSelect( OPT['folders'] )|safe }}
|
||||
{{CreateFoldersSelect( OPT.folders )|safe }}
|
||||
<span class="sm-txt my-auto btn btn-outline-info disabled border-top border-bottom">grouped by:</span>
|
||||
{{CreateSelect( "grouping", OPT['grouping'], ["None", "Day", "Week", "Month"], "", "rounded-end")|safe }}
|
||||
{{CreateSelect( "grouping", OPT.grouping, ["None", "Day", "Week", "Month"], "", "rounded-end")|safe }}
|
||||
{% endif %}
|
||||
</div class="input-group">
|
||||
</div class="col">
|
||||
@@ -50,9 +50,9 @@
|
||||
<button id="prev" name="prev" class="prev sm-txt btn btn-outline-secondary">
|
||||
<svg width="16" height="16" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#prev"/></svg>
|
||||
</button>
|
||||
<span class="sm-txt my-auto"> {{OPT['how_many']}} files </span>
|
||||
<span class="sm-txt my-auto"> {{OPT.how_many}} files </span>
|
||||
{% set nxt_disabled="" %}
|
||||
{% if entry_data|length < OPT['how_many']|int %}
|
||||
{% if entry_data|length < OPT.how_many|int %}
|
||||
{% set nxt_disabled="disabled" %}
|
||||
{% endif %}
|
||||
<button id="next" {{nxt_disabled}} name="next" class="next sm-txt btn btn-outline-secondary">
|
||||
@@ -72,31 +72,31 @@
|
||||
</div>
|
||||
<div class="d-flex col col-auto justify-content-end">
|
||||
<div class="btn-group">
|
||||
{% if OPT['size'] == "64" %}
|
||||
{% if OPT.size == "64" %}
|
||||
{% set bt="btn-info text-white" %}
|
||||
{% else %}
|
||||
{% set bt="btn-outline-info" %}
|
||||
{% endif %}
|
||||
<button id="64" class="px-2 sm-txt sz-but btn {{bt}}" onClick="ChangeSize(this,64); return false;">XS</button>
|
||||
{% if OPT['size'] == "96" %}
|
||||
{% if OPT.size == "96" %}
|
||||
{% set bt="btn-info text-white" %}
|
||||
{% else %}
|
||||
{% set bt="btn-outline-info" %}
|
||||
{% endif %}
|
||||
<button id="96" class="px-2 sm-txt sz-but btn {{bt}}" onClick="ChangeSize(this,96); return false;">S</button>
|
||||
{% if OPT['size'] == "128" %}
|
||||
{% if OPT.size == "128" %}
|
||||
{% set bt="btn-info text-white" %}
|
||||
{% else %}
|
||||
{% set bt="btn-outline-info" %}
|
||||
{% endif %}
|
||||
<button id="128" class="px-2 sm-txt sz-but btn {{bt}}" onClick="ChangeSize(this,128); return false;">M</button>
|
||||
{% if OPT['size'] == "192" %}
|
||||
{% if OPT.size == "192" %}
|
||||
{% set bt="btn-info text-white" %}
|
||||
{% else %}
|
||||
{% set bt="btn-outline-info" %}
|
||||
{% endif %}
|
||||
<button id="192" class="px-2 sm-txt sz-but btn {{bt}}" onClick="ChangeSize(this,192); return false;">L</button>
|
||||
{% if OPT['size'] == "256" %}
|
||||
{% if OPT.size == "256" %}
|
||||
{% set bt="btn-info text-white" %}
|
||||
{% else %}
|
||||
{% set bt="btn-outline-info" %}
|
||||
@@ -104,8 +104,8 @@
|
||||
<button id="256" class="px-2 sm-txt sz-but btn {{bt}}" onClick="ChangeSize(this,256); return false;">XL</button>
|
||||
</div class="btn-group">
|
||||
</div class="col">
|
||||
<input id="offset" type="hidden" name="offset" value="{{OPT['offset']}}">
|
||||
<input id="size" type="hidden" name="size" value="{{OPT['size']}}">
|
||||
<input id="offset" type="hidden" name="offset" value="{{OPT.offset}}">
|
||||
<input id="size" type="hidden" name="size" value="{{OPT.size}}">
|
||||
</div class="form-row">
|
||||
{% set eids=namespace( str="" ) %}
|
||||
{# gather all the file eids and collect them in case we go gallery mode #}
|
||||
@@ -120,59 +120,59 @@
|
||||
<div class="row ms-2">
|
||||
{% set last = namespace(printed=0) %}
|
||||
{# rare event of empty folder, still need to show back button #}
|
||||
{% if OPT['folders'] and entry_data|length == 0 %}
|
||||
{% if OPT['cwd'] != OPT['root'] %}
|
||||
<figure id="_back" class="dir entry m-1" ecnt="1" dir="{{OPT['cwd']|ParentPath}}" type="Directory">
|
||||
<svg class="svg" width="{{OPT['size']|int-22}}" height="{{OPT['size']|int-22}}"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#folder_back"/></svg>
|
||||
{% if OPT.folders and entry_data|length == 0 %}
|
||||
{% if OPT.cwd != OPT.root %}
|
||||
<figure id="_back" class="dir entry m-1" ecnt="1" dir="{{OPT.cwd|ParentPath}}" type="Directory">
|
||||
<svg class="svg" width="{{OPT.size|int-22}}" height="{{OPT.size|int-22}}"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#folder_back"/></svg>
|
||||
<figcaption class="figure-caption text-center">Back</figcaption>
|
||||
</figure class="figure">
|
||||
<script>f=$('#_back'); w=f.find('svg').width(); f.find('figcaption').width(w);</script>
|
||||
{% else %}
|
||||
<div class="col col-auto g-0 m-1">
|
||||
<svg class="svg" width="{{OPT['size']|int-22}}" height="{{OPT['size']|int-22}}"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#folder_back_gray"/></svg>
|
||||
<svg class="svg" width="{{OPT.size|int-22}}" height="{{OPT.size|int-22}}"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#folder_back_gray"/></svg>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% for obj in entry_data %}
|
||||
{% if loop.index==1 and OPT['folders'] %}
|
||||
{% if OPT['cwd'] != OPT['root'] %}
|
||||
<figure class="col col-auto g-0 dir entry m-1" ecnt="{{loop.index}}" dir="{{OPT['cwd']|ParentPath}}" type="Directory">
|
||||
<svg class="svg" width="{{OPT['size']|int-22}}" height="{{OPT['size']|int-22}}" fill="currentColor">
|
||||
{% if loop.index==1 and OPT.folders %}
|
||||
{% if OPT.cwd != OPT.root %}
|
||||
<figure class="col col-auto g-0 dir entry m-1" ecnt="{{loop.index}}" dir="{{OPT.cwd|ParentPath}}" type="Directory">
|
||||
<svg class="svg" width="{{OPT.size|int-22}}" height="{{OPT.size|int-22}}" fill="currentColor">
|
||||
<use xlink:href="{{url_for('internal', filename='icons.svg')}}#folder_back"/></svg>
|
||||
<figcaption class="svg_cap figure-caption text-center">Back</figcaption>
|
||||
</figure class="figure">
|
||||
{% else %}
|
||||
{# create an even lighter-grey, unclickable back button - so folders dont jump around when you go into them #}
|
||||
<div class="col col-auto g-0 m-1">
|
||||
<svg class="svg" width="{{OPT['size']|int-22}}" height="{{OPT['size']|int-22}}"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#folder_back_gray"/></svg>
|
||||
<svg class="svg" width="{{OPT.size|int-22}}" height="{{OPT.size|int-22}}"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#folder_back_gray"/></svg>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if not OPT['folders'] and obj.type.name == "Directory" %}
|
||||
{% if not OPT.folders and obj.type.name == "Directory" %}
|
||||
{% continue %}
|
||||
{% endif %}
|
||||
{% if OPT['grouping'] == "Day" %}
|
||||
{% if OPT.grouping == "Day" %}
|
||||
{% if last.printed != obj.file_details.day %}
|
||||
<div class="row ps-3"><h6>Day: {{obj.file_details.day}} of {{obj.file_details.month}}/{{obj.file_details.year}}</h6></div>
|
||||
{% set last.printed = obj.file_details.day %}
|
||||
{% endif %}
|
||||
{% elif OPT['grouping'] == "Week" %}
|
||||
{% elif OPT.grouping == "Week" %}
|
||||
{% if last.printed != obj.file_details.woy %}
|
||||
<div class="row ps-3"><h6>Week #: {{obj.file_details.woy}} of {{obj.file_details.year}}</h6></div>
|
||||
{% set last.printed = obj.file_details.woy %}
|
||||
{% endif %}
|
||||
{% elif OPT['grouping'] == "Month" %}
|
||||
{% elif OPT.grouping == "Month" %}
|
||||
{% if last.printed != obj.file_details.month %}
|
||||
<div class="row ps-3"><h6>Month: {{obj.file_details.month}} of {{obj.file_details.year}}</h6></div>
|
||||
{% set last.printed = obj.file_details.month %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if obj.type.name != "Directory" %}
|
||||
{% if (not OPT['folders']) or ((obj.in_dir.in_path.path_prefix+'/'+obj.in_dir.rel_path+'/'+obj.name) | TopLevelFolderOf(OPT['cwd'])) %}
|
||||
{% if (not OPT.folders) or ((obj.in_dir.in_path.path_prefix+'/'+obj.in_dir.rel_path+'/'+obj.name) | TopLevelFolderOf(OPT.cwd)) %}
|
||||
<figure id="{{obj.id}}" ecnt="{{loop.index}}" class="col col-auto g-0 figure entry m-1" path_type="{{obj.in_dir.in_path.type.name}}" size="{{obj.file_details.size_mb}}" hash="{{obj.file_details.hash}}" in_dir="{{obj.in_dir.in_path.path_prefix}}/{{obj.in_dir.rel_path}}" fname="{{obj.name}}" yr="{{obj.file_details.year}}" date="{{obj.file_details.year}}{{"%02d" % obj.file_details.month}}{{"%02d" % obj.file_details.day}}" pretty_date="{{obj.file_details.day}}/{{obj.file_details.month}}/{{obj.file_details.year}}" type="{{obj.type.name}}">
|
||||
{% if obj.type.name=="Image" %}
|
||||
<div style="position:relative; width:100%">
|
||||
<a href="{{obj.in_dir.in_path.path_prefix}}/{{obj.in_dir.rel_path}}/{{obj.name}}"><img class="thumb" height="{{OPT['size']}}" src="data:image/jpeg;base64,{{obj.file_details.thumbnail}}"></img></a>
|
||||
<a href="{{obj.in_dir.in_path.path_prefix}}/{{obj.in_dir.rel_path}}/{{obj.name}}"><img class="thumb" height="{{OPT.size}}" src="data:image/jpeg;base64,{{obj.file_details.thumbnail}}"></img></a>
|
||||
{% if search_term is defined %}
|
||||
<div style="position:absolute; bottom: 0px; left: 2px;">
|
||||
<svg width="16" height="16" fill="white"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#{{LocationIcon(obj)}}"/></svg>
|
||||
@@ -184,7 +184,7 @@
|
||||
</div>
|
||||
{% elif obj.type.name == "Video" %}
|
||||
<div style="position:relative; width:100%">
|
||||
<a href="{{obj.in_dir.in_path.path_prefix}}/{{obj.in_dir.rel_path}}/{{obj.name}}"><img class="thumb" style="display:block" height="{{OPT['size']}}" src="data:image/jpeg;base64,{{obj.file_details.thumbnail}}"></img></a>
|
||||
<a href="{{obj.in_dir.in_path.path_prefix}}/{{obj.in_dir.rel_path}}/{{obj.name}}"><img class="thumb" style="display:block" height="{{OPT.size}}" src="data:image/jpeg;base64,{{obj.file_details.thumbnail}}"></img></a>
|
||||
<div style="position:absolute; top: 0px; left: 2px;">
|
||||
<svg width="16" height="16" fill="white"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#film"/></svg>
|
||||
</div>
|
||||
@@ -198,16 +198,16 @@
|
||||
</figure>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% if OPT['folders'] %}
|
||||
{% if OPT.folders %}
|
||||
{% if obj.dir_details.rel_path | length %}
|
||||
{% set dirname=obj.dir_details.in_path.path_prefix+'/'+obj.dir_details.rel_path %}
|
||||
{% else %}
|
||||
{% set dirname=obj.dir_details.in_path.path_prefix %}
|
||||
{% endif %}
|
||||
{# if this dir is the toplevel of the cwd, show the folder icon #}
|
||||
{% if dirname| TopLevelFolderOf(OPT['cwd']) %}
|
||||
{% if dirname| TopLevelFolderOf(OPT.cwd) %}
|
||||
<figure class="col col-auto g-0 figure dir entry m-1" id={{obj.id}} ecnt={{loop.index}} dir="{{dirname}}" type="Directory">
|
||||
<svg class="svg" width="{{OPT['size']|int-22}}" height="{{OPT['size']|int-22}}" fill="currentColor">
|
||||
<svg class="svg" width="{{OPT.size|int-22}}" height="{{OPT.size|int-22}}" fill="currentColor">
|
||||
<use xlink:href="{{url_for('internal', filename='icons.svg')}}#Directory"/></svg>
|
||||
<figcaption class="svg_cap figure-caption text-center text-wrap text-break">{{obj.name}}</figcaption>
|
||||
</figure class="figure">
|
||||
@@ -220,13 +220,13 @@
|
||||
</div>
|
||||
<div class="container-fluid">
|
||||
<form id="nav_form" method="POST"">
|
||||
<input type="hidden" name="cwd" id="cwd" value="{{OPT['cwd']}}">
|
||||
<input type="hidden" name="cwd" id="cwd" value="{{OPT.cwd}}">
|
||||
<div class="row">
|
||||
<div class="col my-auto d-flex justify-content-center">
|
||||
<button onClick="$.each( $('#main_form').serializeArray() , function( index, value ) { $('#nav_form').append( '<input type=hidden name=' + value['name'] +' value='+value['value'] + '>' ); })" id="prev" name="prev" class="prev sm-txt btn btn-outline-secondary">
|
||||
<svg width="16" height="16" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#prev"/></svg>
|
||||
</button>
|
||||
<span class="sm-txt my-auto"> {{OPT['how_many']}} files </span>
|
||||
<span class="sm-txt my-auto"> {{OPT.how_many}} files </span>
|
||||
<button onClick="$.each( $('#main_form').serializeArray() , function( index, value ) { $('#nav_form').append( '<input type=hidden name=' + value['name'] +' value='+value['value'] + '>' ); });" id="next" {{nxt_disabled}} name="next" class="next sm-txt btn btn-outline-secondary">
|
||||
<svg width="16" height="16" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#next"/></svg>
|
||||
</button>
|
||||
@@ -251,14 +251,14 @@ function CallViewRoute(id)
|
||||
{
|
||||
s='<form id="_fm" method="POST" action="/view/' + id + '">'
|
||||
s+='<input type="hidden" name="eids" value="'+$("#eids").val() + '">'
|
||||
s+='<input type="hidden" name="noo" value="{{OPT['noo']}}">'
|
||||
s+='<input type="hidden" name="cwd" value="{{OPT['cwd']}}">'
|
||||
s+='<input type="hidden" name="root" value="{{OPT['root']}}">'
|
||||
s+='<input type="hidden" name="size" value="{{OPT['size']}}">'
|
||||
s+='<input type="hidden" name="grouping" value="{{OPT['grouping']}}">'
|
||||
s+='<input type="hidden" name="offset" value="{{OPT['offset']}}">'
|
||||
s+='<input type="hidden" name="folders" value="{{OPT['folders']}}">'
|
||||
s+='<input type="hidden" name="how_many" value="{{OPT['how_many']}}">'
|
||||
s+='<input type="hidden" name="noo" value="{{OPT.noo}}">'
|
||||
s+='<input type="hidden" name="cwd" value="{{OPT.cwd}}">'
|
||||
s+='<input type="hidden" name="root" value="{{OPT.root}}">'
|
||||
s+='<input type="hidden" name="size" value="{{OPT.size}}">'
|
||||
s+='<input type="hidden" name="grouping" value="{{OPT.grouping}}">'
|
||||
s+='<input type="hidden" name="offset" value="{{OPT.offset}}">'
|
||||
s+='<input type="hidden" name="folders" value="{{OPT.folders}}">'
|
||||
s+='<input type="hidden" name="how_many" value="{{OPT.how_many}}">'
|
||||
s+='<input type="hidden" name="orig_url" value="{{request.path}}">'
|
||||
{% if search_term is defined %}
|
||||
s+='<input type="hidden" name="search_term" value="{{search_term}}">'
|
||||
@@ -344,7 +344,7 @@ $.contextMenu({
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
if( {{OPT['offset']}} == 0 )
|
||||
if( {{OPT.offset}} == 0 )
|
||||
{
|
||||
$('.prev').addClass('disabled')
|
||||
$('.prev').prop('disabled', true)
|
||||
|
||||
@@ -54,14 +54,14 @@
|
||||
{
|
||||
s='<form id="_fmv" method="POST" action="/viewlist">'
|
||||
s+='<input type="hidden" name="eids" value="'+$("#eids").val() + '">'
|
||||
s+='<input type="hidden" name="noo" value="{{OPT['noo']}}">'
|
||||
s+='<input type="hidden" name="cwd" value="{{OPT['cwd']}}">'
|
||||
s+='<input type="hidden" name="root" value="{{OPT['root']}}">'
|
||||
s+='<input type="hidden" name="size" value="{{OPT['size']}}">'
|
||||
s+='<input type="hidden" name="grouping" value="{{OPT['grouping']}}">'
|
||||
s+='<input type="hidden" name="offset" value="{{OPT['offset']}}">'
|
||||
s+='<input type="hidden" name="folders" value="{{OPT['folders']}}">'
|
||||
s+='<input type="hidden" name="how_many" value="{{OPT['how_many']}}">'
|
||||
s+='<input type="hidden" name="noo" value="{{OPT.noo}}">'
|
||||
s+='<input type="hidden" name="cwd" value="{{OPT.cwd}}">'
|
||||
s+='<input type="hidden" name="root" value="{{OPT.root}}">'
|
||||
s+='<input type="hidden" name="size" value="{{OPT.size}}">'
|
||||
s+='<input type="hidden" name="grouping" value="{{OPT.grouping}}">'
|
||||
s+='<input type="hidden" name="offset" value="{{OPT.offset}}">'
|
||||
s+='<input type="hidden" name="folders" value="{{OPT.folders}}">'
|
||||
s+='<input type="hidden" name="how_many" value="{{OPT.how_many}}">'
|
||||
s+='<input type="hidden" name="orig_url" value="{{request.path}}">'
|
||||
s+='<input type="hidden" name="' + dir + '" value="1">'
|
||||
{% if search_term is defined %}
|
||||
@@ -80,7 +80,7 @@
|
||||
<input type="hidden" name="eids" value={{eids}}>
|
||||
<div class="row">
|
||||
<button title="Show previous image" class="col-auto btn btn-outline-info px-2" style="padding: 10%" id="la"
|
||||
{% if OPT['offset'] == 0 and eids.find(current|string) == 0 %}
|
||||
{% if OPT.offset == 0 and eids.find(current|string) == 0 %}
|
||||
disabled
|
||||
{% endif %}
|
||||
onClick="
|
||||
@@ -90,7 +90,7 @@
|
||||
prev=cidx-1
|
||||
if( prev < 0 )
|
||||
{
|
||||
if( {{OPT['offset']}} )
|
||||
if( {{OPT.offset}} )
|
||||
{
|
||||
CallViewListRoute('prev')
|
||||
return
|
||||
@@ -136,8 +136,8 @@
|
||||
|
||||
<button title="Show next image" class="col-auto btn btn-outline-info px-2" style="padding: 10%" id="ra"
|
||||
onClick="
|
||||
{% if 'last_entry_in_db' in OPT %}
|
||||
if( current == {{OPT['last_entry_in_db']}} )
|
||||
{% if OPT.last_entry_in_db is defined %}
|
||||
if( current == {{OPT.last_entry_in_db}} )
|
||||
{
|
||||
$('#ra').attr('disabled', true )
|
||||
return
|
||||
@@ -155,7 +155,7 @@
|
||||
else
|
||||
{
|
||||
{# only go next route if list contains as many elements as we asked to display... can be more than how_many on any page in reality, as its really how_many per dir? #}
|
||||
if( eid_lst.length >= {{OPT['how_many']}} )
|
||||
if( eid_lst.length >= {{OPT.how_many}} )
|
||||
CallViewListRoute('next')
|
||||
}
|
||||
">
|
||||
@@ -240,7 +240,7 @@ $( document ).keydown(function(event) {
|
||||
});
|
||||
|
||||
var fullscreen=false;
|
||||
{% if OPT['fullscreen']=='true' %}
|
||||
{% if OPT.fullscreen=='true' %}
|
||||
fullscreen=true;
|
||||
ViewImageOrVideo()
|
||||
{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user