added image logic and changed html
This commit is contained in:
parent
3cd8fcea28
commit
471e7153e7
|
@ -2,5 +2,6 @@ from flask import Flask, Blueprint
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.secret_key = 'super secret key'
|
app.secret_key = 'super secret key'
|
||||||
|
isDebugging = False
|
||||||
|
|
||||||
from . import routes
|
from . import routes
|
||||||
|
|
|
@ -9,7 +9,7 @@ from flask_uploads import UploadSet, configure_uploads, ALL
|
||||||
from werkzeug.utils import secure_filename
|
from werkzeug.utils import secure_filename
|
||||||
|
|
||||||
# Application Imports
|
# Application Imports
|
||||||
from . import app
|
from . import app, isDebugging
|
||||||
from .MessageHandler import MessageHandler
|
from .MessageHandler import MessageHandler
|
||||||
|
|
||||||
|
|
||||||
|
@ -154,8 +154,10 @@ def deleteText():
|
||||||
decodedStrPart = base64.urlsafe_b64decode(encodedStr.encode('utf-8')).decode('utf-8')
|
decodedStrPart = base64.urlsafe_b64decode(encodedStr.encode('utf-8')).decode('utf-8')
|
||||||
decodedStr = unquote(decodedStrPart)
|
decodedStr = unquote(decodedStrPart)
|
||||||
|
|
||||||
print("Encoded String:\n\t" + encodedStr)
|
if isDebugging:
|
||||||
print("Decoded String:\n\t" + decodedStr)
|
print("Encoded String:\n\t" + encodedStr)
|
||||||
|
print("Decoded String:\n\t" + decodedStr)
|
||||||
|
|
||||||
notesListEncoded.remove(encodedStr)
|
notesListEncoded.remove(encodedStr)
|
||||||
notesListDecoded.remove(decodedStr)
|
notesListDecoded.remove(decodedStr)
|
||||||
updateNotesFile()
|
updateNotesFile()
|
||||||
|
@ -192,8 +194,12 @@ def addNote():
|
||||||
decodedStrPart = base64.urlsafe_b64decode(encodedStr.encode('utf-8')).decode('utf-8')
|
decodedStrPart = base64.urlsafe_b64decode(encodedStr.encode('utf-8')).decode('utf-8')
|
||||||
decodedStr = unquote(decodedStrPart)
|
decodedStr = unquote(decodedStrPart)
|
||||||
|
|
||||||
notesListDecoded.append(decodedStr)
|
if isDebugging:
|
||||||
|
print("Encoded String:\n\t" + encodedStr)
|
||||||
|
print("Decoded String:\n\t" + decodedStr)
|
||||||
|
|
||||||
notesListEncoded.append(encodedStr)
|
notesListEncoded.append(encodedStr)
|
||||||
|
notesListDecoded.append(decodedStr)
|
||||||
updateNotesFile()
|
updateNotesFile()
|
||||||
|
|
||||||
msg = "[Success] Added text entry!"
|
msg = "[Success] Added text entry!"
|
||||||
|
@ -220,17 +226,8 @@ def updateNotesFile():
|
||||||
file.close()
|
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):
|
def hash_file(filename):
|
||||||
# Make a hash object
|
h = hashlib.sha1() # Make a sha1 hash object
|
||||||
h = hashlib.sha1()
|
h.update(filename.encode("utf-8")) # Encode string to byte string to update digest
|
||||||
# Open file for reading in binary mode
|
return h.hexdigest() # Return digest string
|
||||||
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()
|
|
||||||
|
|
|
@ -43,23 +43,52 @@
|
||||||
<span id="notesToView"></span>
|
<span id="notesToView"></span>
|
||||||
{% for note in notes %}
|
{% for note in notes %}
|
||||||
<li class="row rtext t{{ loop.index }}">
|
<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">
|
<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..."
|
<img class="menu-item" src="{{ url_for('static', filename='imgs/octicons/trashcan.svg')}}" title="Delete..."
|
||||||
alt="Delete" data-toggle="modal" data-target="#deleteDialogModalText"
|
alt="Delete" data-toggle="modal" data-target="#deleteDialogModalText"
|
||||||
onclick="preDeleteText(this.parentElement.parentElement.parentElement)" />
|
onclick="preDeleteText(this.parentElement.parentElement.parentElement)" />
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</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>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue