removed unneeded ref to font-awesome, added compression, ttl for static files, several small cleanups on labels, etc. for lighthouse improvements

This commit is contained in:
2021-09-14 17:22:42 +10:00
parent 6e96c83d9e
commit 56f3853bfc
7 changed files with 34 additions and 24 deletions

4
README
View File

@@ -46,10 +46,6 @@ upstream packages...
wget https://cdnjs.cloudflare.com/ajax/libs/jquery-contextmenu/2.9.2/jquery.contextMenu.min.js.map wget https://cdnjs.cloudflare.com/ajax/libs/jquery-contextmenu/2.9.2/jquery.contextMenu.min.js.map
wget https://cdnjs.cloudflare.com/ajax/libs/jquery-contextmenu/2.9.2/jquery.ui.position.min.js wget https://cdnjs.cloudflare.com/ajax/libs/jquery-contextmenu/2.9.2/jquery.ui.position.min.js
# font-awesome
### browse to https://fontawesome.com/download, grab zip, unzip it into static/upstream
# in fa-stack hand change width:2.5em to width:2em
### I tried to update via pip3, with this: ### I tried to update via pip3, with this:
sudo apt-get install libcairo2-dev libjpeg-dev libgif-dev libgirepository1.0-dev libcups2-dev sudo apt-get install libcairo2-dev libjpeg-dev libgif-dev libgirepository1.0-dev libcups2-dev
pip3 list | tail -n +3 | grep -v mysqlclient | grep -v duplicity | grep -v gpg | awk ' { print $1 } ' | xargs pip3 install --upgrade pip3 list | tail -n +3 | grep -v mysqlclient | grep -v duplicity | grep -v gpg | awk ' { print $1 } ' | xargs pip3 install --upgrade

11
TODO
View File

@@ -1,5 +1,11 @@
## GENERAL ## GENERAL
* face locations -- START FORM SCRATCH for prod so all images have face_locn data * get build process to create a random string for secret for PROD, otherwise use builtin for dev
* lighthouse -> leverage this for cache control for static...
https://www.kite.com/python/docs/flask.Flask.get_send_file_max_age
* comment your code
* html files?
* per file you could select an unknown face and add it as a ref img to an existing person, or make a new person and attach? * per file you could select an unknown face and add it as a ref img to an existing person, or make a new person and attach?
* from menu, we could try to get smart/fancy... say find face with largest size, check it vs. other faces, if it matches more than say 10? we offer it up as a required ref img, then cut that face (with margin) out and use it is a new ref image / person * from menu, we could try to get smart/fancy... say find face with largest size, check it vs. other faces, if it matches more than say 10? we offer it up as a required ref img, then cut that face (with margin) out and use it is a new ref image / person
@@ -7,8 +13,6 @@
https://www.pyimagesearch.com/2018/07/09/face-clustering-with-python/ https://www.pyimagesearch.com/2018/07/09/face-clustering-with-python/
* fix up logging in general * fix up logging in general
* comment your code
* html files?
## DB ## DB
* Dir can have date in the DB, so we can do Oldest/Newest dirs in Folder view * Dir can have date in the DB, so we can do Oldest/Newest dirs in Folder view
@@ -29,6 +33,7 @@
Admin Admin
-> delete old jobs / auto delete jobs older than ??? -> delete old jobs / auto delete jobs older than ???
-> do I want to have admin roles/users? -> do I want to have admin roles/users?
-> purge deleted files (and associated DB data)
### AI ### AI
* faces per file (need a threshold for too many? OR * faces per file (need a threshold for too many? OR

View File

@@ -1,4 +1,5 @@
from flask import Flask, render_template, request, redirect, jsonify, url_for, render_template_string from flask import Flask, render_template, request, redirect, jsonify, url_for, render_template_string
from flask_compress import Compress
from flask_sqlalchemy import SQLAlchemy from flask_sqlalchemy import SQLAlchemy
from sqlalchemy.exc import SQLAlchemyError from sqlalchemy.exc import SQLAlchemyError
from flask_marshmallow import Marshmallow from flask_marshmallow import Marshmallow
@@ -29,6 +30,7 @@ app.config['SQLALCHEMY_DATABASE_URI'] = DB_URL
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config['ENV'] = os.environ['FLASK_ENV'] app.config['ENV'] = os.environ['FLASK_ENV']
app.config['SECRET_KEY'] = b'my_insecure_PA_token_with_random_2134876adsfjhlkasdf87' app.config['SECRET_KEY'] = b'my_insecure_PA_token_with_random_2134876adsfjhlkasdf87'
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 31536000
# ldap config vars: (the last one is required, or python ldap freaks out) # ldap config vars: (the last one is required, or python ldap freaks out)
app.config['LDAP_HOST'] = 'mara.ddp.net' app.config['LDAP_HOST'] = 'mara.ddp.net'
@@ -48,6 +50,8 @@ login_manager = LoginManager(app) # Setup a Flask-Login Manager
ldap_manager = LDAP3LoginManager(app) # Setup a LDAP3 Login Manager. ldap_manager = LDAP3LoginManager(app) # Setup a LDAP3 Login Manager.
login_manager.login_view = "login" # default login route, failed with url_for, so hard-coded login_manager.login_view = "login" # default login route, failed with url_for, so hard-coded
Compress(app)
################################# Now, import separated class files ################################### ################################# Now, import separated class files ###################################
from ai import aistats from ai import aistats
from settings import Settings from settings import Settings

View File

@@ -16,3 +16,4 @@ pytz
dlib dlib
face_recognition face_recognition
Werkzeug Werkzeug
flask-compress

View File

@@ -1,13 +1,12 @@
{% if not InDBox %} {% if not InDBox %}
<!DOCTYPE html> <!DOCTYPE html>
<html> <html lang="en">
<head> <head>
<title>Photo Assistant</title>
<!-- Required meta tags --> <!-- Required meta tags -->
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="Photo Assistant">
<!-- font awesome -->
<link rel="stylesheet" href="{{ url_for( 'internal', filename='upstream/fontawesome-free-5.15.3-web/css/all.min.css' ) }}">
<!-- Bootstrap CSS --> <!-- Bootstrap CSS -->
<link rel="stylesheet" href="{{ url_for( 'internal', filename='upstream/bootstrap-5.0.2-dist/css/bootstrap.min.css' ) }}"> <link rel="stylesheet" href="{{ url_for( 'internal', filename='upstream/bootstrap-5.0.2-dist/css/bootstrap.min.css' ) }}">

View File

@@ -55,15 +55,16 @@
<thead> <thead>
<tr class="table-primary"><th>Active Jobs</th><th>Job Started</th><th>Progress</th></tr> <tr class="table-primary"><th>Active Jobs</th><th>Job Started</th><th>Progress</th></tr>
</thead> </thead>
<tbody> <tbody id="job_tbl_body">
<script>
for(el in active_rows)
document.write(active_rows[el])
document.write( '<tr class="table-primary"><th>Completed Jobs</th><th>Job Started</th><th>Job Completed</th></tr>' )
for(el in completed_rows)
document.write(completed_rows[el])
</script>
</tbody> </tbody>
</table> </table>
</div class="container-fluid"> </div class="container-fluid">
<script>
for(el in active_rows)
$('#job_tbl_body').append(active_rows[el])
$('#job_tbl_body').append( '<tr class="table-primary"><th>Completed Jobs</th><th>Job Started</th><th>Job Completed</th></tr>' )
for(el in completed_rows)
$('#job_tbl_body').append(completed_rows[el])
</script>
{% endblock main_content %} {% endblock main_content %}

View File

@@ -1,8 +1,12 @@
<html> <!DOCTYPE html>
<html lang="en">
<head> <head>
<title>Photo Assistant Login</title>
<!-- Required meta tags --> <!-- Required meta tags -->
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="Photo Assistant">
<!-- Bootstrap CSS --> <!-- Bootstrap CSS -->
<link rel="stylesheet" href="{{ url_for( 'internal', filename='upstream/bootstrap-5.0.2-dist/css/bootstrap.min.css' ) }}"> <link rel="stylesheet" href="{{ url_for( 'internal', filename='upstream/bootstrap-5.0.2-dist/css/bootstrap.min.css' ) }}">
@@ -46,12 +50,12 @@
<svg width="64" height="64" fill="currentColor"><use xlink:href="internal/icons.svg#pa_logo" /></svg>&nbsp;Photo Assistant Login</h3> <svg width="64" height="64" fill="currentColor"><use xlink:href="internal/icons.svg#pa_logo" /></svg>&nbsp;Photo Assistant Login</h3>
<form class="" method="POST"> <form class="" method="POST">
<div class="input-group"> <div class="input-group">
<label labelfor="username" class="text-right input-group-text col-4 text-info">Username:</label> <label for="username" class="text-right input-group-text col-4 text-info">Username:</label>
<input class="form-control" type="text" name="username"></input> <input class="form-control" type="text" id="username" name="username"></input>
</div> </div>
<div class="input-group"> <div class="input-group">
<label labelfor="password" class="text-right input-group-text col-4 text-info">Password:</label> <label for="password" class="text-right input-group-text col-4 text-info">Password:</label>
<input class="form-control col-8" type="password" name="password"></input> <input class="form-control col-8" type="password" id="password" name="password"></input>
</div> </div>
<div class="col-12 my-2 text-center"> <div class="col-12 my-2 text-center">