added image logic and changed html

This commit is contained in:
Maxim Stewart 2020-06-21 18:04:12 -05:00
parent 3cd8fcea28
commit 471e7153e7
3 changed files with 55 additions and 28 deletions

View File

@ -2,5 +2,6 @@ from flask import Flask, Blueprint
app = Flask(__name__)
app.secret_key = 'super secret key'
isDebugging = False
from . import routes

View File

@ -9,7 +9,7 @@ from flask_uploads import UploadSet, configure_uploads, ALL
from werkzeug.utils import secure_filename
# Application Imports
from . import app
from . import app, isDebugging
from .MessageHandler import MessageHandler
@ -154,8 +154,10 @@ def deleteText():
decodedStrPart = base64.urlsafe_b64decode(encodedStr.encode('utf-8')).decode('utf-8')
decodedStr = unquote(decodedStrPart)
print("Encoded String:\n\t" + encodedStr)
print("Decoded String:\n\t" + decodedStr)
if isDebugging:
print("Encoded String:\n\t" + encodedStr)
print("Decoded String:\n\t" + decodedStr)
notesListEncoded.remove(encodedStr)
notesListDecoded.remove(decodedStr)
updateNotesFile()
@ -192,8 +194,12 @@ def addNote():
decodedStrPart = base64.urlsafe_b64decode(encodedStr.encode('utf-8')).decode('utf-8')
decodedStr = unquote(decodedStrPart)
notesListDecoded.append(decodedStr)
if isDebugging:
print("Encoded String:\n\t" + encodedStr)
print("Decoded String:\n\t" + decodedStr)
notesListEncoded.append(encodedStr)
notesListDecoded.append(decodedStr)
updateNotesFile()
msg = "[Success] Added text entry!"
@ -220,17 +226,8 @@ def updateNotesFile():
file.close()
""""This function returns the SHA-1 hash of the file passed into it"""
""""This function returns the SHA-1 hash of the file path/name passed into it"""
def hash_file(filename):
# Make a hash object
h = hashlib.sha1()
# Open file for reading in binary mode
with open(filename,'rb') as file:
# Loop till the end of the file
chunk = 0
while chunk != b'':
# Read only 1024 bytes at a time
chunk = file.read(1024)
h.update(chunk)
# Return the hex representation of digest
return h.hexdigest()
h = hashlib.sha1() # Make a sha1 hash object
h.update(filename.encode("utf-8")) # Encode string to byte string to update digest
return h.hexdigest() # Return digest string

View File

@ -43,23 +43,52 @@
<span id="notesToView"></span>
{% for note in notes %}
<li class="row rtext t{{ loop.index }}">
<div class="col-md-10 list-group-item">
{% if note.strip().startswith( ("http:", "https:", "ftp:", "file:") ) %}
<a class="list-group-item list-group-item-action" href="{{note}}" target="_blank">
{{note}}
</a>
{% elif note.strip() %}
<span class="list-group-item list-group-item-action">{{note}}</span>
{% endif %}
</div>
<div class="col-sm-2 list-group-item text-center">
<p class="server-file-card text-right">
<p class="server-file-card text-left">
<img class="menu-item" src="{{ url_for('static', filename='imgs/octicons/trashcan.svg')}}" title="Delete..."
alt="Delete" data-toggle="modal" data-target="#deleteDialogModalText"
onclick="preDeleteText(this.parentElement.parentElement.parentElement)" />
</p>
</div>
<div class="col-md-10 list-group-item">
{% if "youtu.be" in note.strip().lower() or "www.youtube.com/watch?v=" in note.strip().lower() %}
{% if "youtu.be" in note.strip() %}
<span class="list-group-item list-group-item-action justify-content-center text-center">
{{note}}
<iframe
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
autoplay="" allowfullscreen="true" width="650px" height="400px" frameborder="0"
src="{{note | replace('youtu.be/', 'www.youtube.com/embed/')}}">
</iframe>
</span>
{% elif "www.youtube.com/watch?v=" in note.strip().lower() %}
<span class="list-group-item list-group-item-action justify-content-center text-center">
{{note}}
<iframe
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
autoplay="" allowfullscreen="true" width="650px" height="400px" frameborder="0"
src="{{note | replace('www.youtube.com/', 'www.youtube.com/embed/')}}">
</iframe>
</span>
{% endif %}
{% elif note.strip().startswith( ("http:", "https:", "ftp:", "file:") ) %}
{% if note.strip().endswith( (".jpg", ".jpeg", ".png", ".gif") ) %}
<div clclass="list-group-item list-group-item-action"">
<a href="{{note}}" target="_blank">
{{note}}
</a>
<img src="{{note}}" width="25em" height="auto" />
</div>
{% else %}
<a class="list-group-item list-group-item-action" href="{{note}}" target="_blank">
{{note}}
</a>
{% endif %}
{% elif note.strip() %}
<span class="list-group-item list-group-item-action">{{note}}</span>
{% endif %}
</div>
</li>
{% endfor %}