mirror of
https://github.com/Derpy-Leggies/OnlyLegs.git
synced 2025-06-29 03:26:16 +00:00
Fixed multiple requests for images
Started adding SQL table layouts Making package loading prettier
This commit is contained in:
parent
5951baadaf
commit
a7e79ab5a5
10 changed files with 60 additions and 75 deletions
28
app.py
28
app.py
|
@ -1,13 +1,19 @@
|
||||||
# Import required OnlyLegs packages
|
# Import base packages
|
||||||
import os
|
import time
|
||||||
import sys
|
import sys
|
||||||
sys.path.insert(1, './packages')
|
import os
|
||||||
|
|
||||||
# Import database manager
|
print("""OnlyLegs - created by Fluffy Bean
|
||||||
import onlylegsDB
|
Version: 060123
|
||||||
|
---------------------------------
|
||||||
|
Starting...
|
||||||
|
""")
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
# Import required OnlyLegs packages
|
||||||
|
from packages import onlylegsDB
|
||||||
onlylegsDB = onlylegsDB.DBmanager()
|
onlylegsDB = onlylegsDB.DBmanager()
|
||||||
# Import sass compiler
|
from packages import onlylegsSass
|
||||||
import onlylegsSass
|
|
||||||
onlylegsSass = onlylegsSass.Sassy('default')
|
onlylegsSass = onlylegsSass.Sassy('default')
|
||||||
|
|
||||||
# Import flask
|
# Import flask
|
||||||
|
@ -31,28 +37,24 @@ def method_not_allowed(e):
|
||||||
msg = 'Method sussy wussy'
|
msg = 'Method sussy wussy'
|
||||||
return render_template('error.html', error=error, msg=msg), 404
|
return render_template('error.html', error=error, msg=msg), 404
|
||||||
|
|
||||||
|
|
||||||
@app.errorhandler(404)
|
@app.errorhandler(404)
|
||||||
def page_not_found(e):
|
def page_not_found(e):
|
||||||
error = '404'
|
error = '404'
|
||||||
msg = 'Could not find what you need!'
|
msg = 'Could not find what you need!'
|
||||||
return render_template('error.html', error=error, msg=msg), 404
|
return render_template('error.html', error=error, msg=msg), 404
|
||||||
|
|
||||||
|
|
||||||
@app.errorhandler(403)
|
@app.errorhandler(403)
|
||||||
def forbidden(e):
|
def forbidden(e):
|
||||||
error = '403'
|
error = '403'
|
||||||
msg = 'Go away! This is no place for you!'
|
msg = 'Go away! This is no place for you!'
|
||||||
return render_template('error.html', error=error, msg=msg), 403
|
return render_template('error.html', error=error, msg=msg), 403
|
||||||
|
|
||||||
|
|
||||||
@app.errorhandler(410)
|
@app.errorhandler(410)
|
||||||
def gone(e):
|
def gone(e):
|
||||||
error = '410'
|
error = '410'
|
||||||
msg = 'The page is no longer available! *sad face*'
|
msg = 'The page is no longer available! *sad face*'
|
||||||
return render_template('error.html', error=error, msg=msg), 410
|
return render_template('error.html', error=error, msg=msg), 410
|
||||||
|
|
||||||
|
|
||||||
@app.errorhandler(500)
|
@app.errorhandler(500)
|
||||||
def internal_server_error(e):
|
def internal_server_error(e):
|
||||||
error = '500'
|
error = '500'
|
||||||
|
@ -67,7 +69,6 @@ def internal_server_error(e):
|
||||||
def home():
|
def home():
|
||||||
return render_template('home.html')
|
return render_template('home.html')
|
||||||
|
|
||||||
|
|
||||||
@app.route('/image/<request_id>')
|
@app.route('/image/<request_id>')
|
||||||
def image(request_id):
|
def image(request_id):
|
||||||
# Check if request_id is valid
|
# Check if request_id is valid
|
||||||
|
@ -78,8 +79,6 @@ def image(request_id):
|
||||||
|
|
||||||
result = onlylegsDB.getImage(request_id)
|
result = onlylegsDB.getImage(request_id)
|
||||||
|
|
||||||
print (result)
|
|
||||||
|
|
||||||
return render_template('image.html', fileName=result[1], id=request_id)
|
return render_template('image.html', fileName=result[1], id=request_id)
|
||||||
|
|
||||||
|
|
||||||
|
@ -98,7 +97,6 @@ def image_list(item_type):
|
||||||
|
|
||||||
return jsonify(item_list)
|
return jsonify(item_list)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/uploads/<quality>/<request_file>', methods=['GET'])
|
@app.route('/uploads/<quality>/<request_file>', methods=['GET'])
|
||||||
def uploads(quality, request_file):
|
def uploads(quality, request_file):
|
||||||
if request.method != 'GET':
|
if request.method != 'GET':
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import time
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
@ -8,19 +9,19 @@ class DBmanager():
|
||||||
from mysql.connector import Error
|
from mysql.connector import Error
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("Error: could not import required modules")
|
print("Error: could not import required packages")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
load_dotenv(os.path.join('usr', '.env'))
|
load_dotenv(os.path.join('usr', '.env'))
|
||||||
|
print("### OnlyLegs Database Manager ###")
|
||||||
|
print("Connecting to database...")
|
||||||
|
|
||||||
print("Connecting to MySQL database...")
|
database = mysql.connector.connect(host=os.environ.get('DB_HOST'),
|
||||||
|
port=os.environ.get('DB_PORT'),
|
||||||
database = mysql.connector.connect(host=os.environ.get('HOST'),
|
database=os.environ.get('DB_NAME'),
|
||||||
port=os.environ.get('PORT'),
|
user=os.environ.get('DB_USER'),
|
||||||
database=os.environ.get('DATABASE'),
|
password=os.environ.get('DB_PASS')
|
||||||
user=os.environ.get('USERNAME'),
|
|
||||||
password=os.environ.get('PASSWORD')
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if database.is_connected():
|
if database.is_connected():
|
||||||
|
@ -33,8 +34,11 @@ class DBmanager():
|
||||||
record = cursor.fetchone()
|
record = cursor.fetchone()
|
||||||
print("Connected to database:", record[0])
|
print("Connected to database:", record[0])
|
||||||
|
|
||||||
|
print("Finished\n")
|
||||||
|
|
||||||
except Error as e:
|
except Error as e:
|
||||||
print("Error while connecting to MySQL!\n", e)
|
print("Error while connecting to Database! Full error:\n", e)
|
||||||
|
print("Exiting...")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
self.database = database
|
self.database = database
|
||||||
|
|
|
@ -1,12 +1,16 @@
|
||||||
|
import time
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
|
||||||
class Sassy():
|
class Sassy():
|
||||||
def __init__(self, theme):
|
def __init__(self, theme):
|
||||||
|
print("### OnlyLegs Theme Manager ###")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import sass
|
import sass
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("Error: libsass not found")
|
print("Could not find libsass!")
|
||||||
|
print("Exiting...")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
path_to_sass = os.path.join('usr', 'themes', theme, 'style.scss')
|
path_to_sass = os.path.join('usr', 'themes', theme, 'style.scss')
|
||||||
|
@ -16,13 +20,17 @@ class Sassy():
|
||||||
self.sass = sass
|
self.sass = sass
|
||||||
self.loadTheme(path_to_sass)
|
self.loadTheme(path_to_sass)
|
||||||
else:
|
else:
|
||||||
print("Error: theme not found")
|
print("No theme found!")
|
||||||
|
print("Exiting...")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def loadTheme (self, theme):
|
def loadTheme (self, theme):
|
||||||
with open('static/css/style.css', 'w') as f:
|
with open('static/css/style.css', 'w') as f:
|
||||||
try:
|
try:
|
||||||
f.write(self.sass.compile(filename=theme, output_style='compressed'))
|
f.write(self.sass.compile(filename=theme, output_style='compressed'))
|
||||||
print("Sass compiled successfully to:", f.name)
|
print("Compiled successfully to:", f.name)#
|
||||||
|
print("Finished\n")
|
||||||
except self.sass.CompileError as e:
|
except self.sass.CompileError as e:
|
||||||
print("Error: sass compilation failed:\n", e)
|
print("Failed to compile! Full error:\n", e)
|
||||||
|
print("Exiting...")
|
||||||
|
sys.exit(1)
|
7
packages/tables/admins.sql
Normal file
7
packages/tables/admins.sql
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
CREATE IF NOT EXISTS TABLE abilities (
|
||||||
|
id INT(69) PRIMARY KEY AUTO_INCREMENT,
|
||||||
|
user INT(69) NOT NULL,
|
||||||
|
admin BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
create_posts BOOLEAN NOT NULL DEFAULT TRUE,
|
||||||
|
updated_at TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW()
|
||||||
|
);
|
8
packages/tables/users.sql
Normal file
8
packages/tables/users.sql
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
CREATE IF NOT EXISTS TABLE users (
|
||||||
|
id INT(69) PRIMARY KEY AUTO_INCREMENT,
|
||||||
|
username VARCHAR(255) NOT NULL,
|
||||||
|
email VARCHAR(255) NOT NULL,
|
||||||
|
password VARCHAR(255) NOT NULL,
|
||||||
|
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||||
|
updated_at TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW()
|
||||||
|
);
|
|
@ -18,6 +18,7 @@
|
||||||
loadImg(imageList[i][0], imageList[i][1]);
|
loadImg(imageList[i][0], imageList[i][1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
imageIndex = startIndex + amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadImg(id, fileName) {
|
function loadImg(id, fileName) {
|
||||||
|
@ -40,16 +41,13 @@
|
||||||
type: 'get',
|
type: 'get',
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
imageList = response;
|
imageList = response;
|
||||||
|
|
||||||
loadMore(0, 30);
|
loadMore(0, 30);
|
||||||
imageIndex += 30;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$(window).scroll(function() {
|
$(window).scroll(function() {
|
||||||
if ($(window).height() + $(window).scrollTop() >= $(document).height() - 500) {
|
if ($(window).height() + $(window).scrollTop() >= $(document).height() - 500) {
|
||||||
loadMore(imageIndex);
|
loadMore(imageIndex);
|
||||||
imageIndex += 10;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -15,13 +15,13 @@
|
||||||
<body>
|
<body>
|
||||||
<nav id="navRoot">
|
<nav id="navRoot">
|
||||||
<div>
|
<div>
|
||||||
<a href="{{ url_for('home') }}" class="btn"><i class="ph-house-line"></i><span>Home</span></a>
|
<a href="{{ url_for('home') }}"><i class="ph-house-line"></i><span>Home</span></a>
|
||||||
<a href="{{ url_for('home') }}" class="btn"><i class="ph-package"></i><span>Groups</span></a>
|
<a href="{{ url_for('home') }}"><i class="ph-package"></i><span>Groups</span></a>
|
||||||
<a href="{{ url_for('home') }}" class="btn"><i class="ph-upload"></i><span>Upload</span></a>
|
<a href="{{ url_for('home') }}"><i class="ph-upload"></i><span>Upload</span></a>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<a href="{{ url_for('home') }}" class="btn"><i class="ph-user-circle"></i><span>Profile</span></a>
|
<a href="{{ url_for('home') }}"><i class="ph-user-circle"></i><span>Profile</span></a>
|
||||||
<a href="{{ url_for('home') }}" class="btn"><i class="ph-gear"></i><span>Settings</span></a>
|
<a href="{{ url_for('home') }}"><i class="ph-gear"></i><span>Settings</span></a>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
<main>
|
<main>
|
||||||
|
|
|
@ -1,18 +1,3 @@
|
||||||
@mixin button($color) {
|
|
||||||
border-color: rgba($color, 0.3);
|
|
||||||
background-color: rgba($color, 0);
|
|
||||||
color: $color;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
background-color: rgba($color, 0.2);
|
|
||||||
}
|
|
||||||
&:active {
|
|
||||||
border-color: rgba($color, 1);
|
|
||||||
background-color: rgba($color, 0.5);
|
|
||||||
color: $color;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn {
|
.btn {
|
||||||
padding: 0.5rem 1rem;
|
padding: 0.5rem 1rem;
|
||||||
border-radius: 0.25rem;
|
border-radius: 0.25rem;
|
||||||
|
@ -23,31 +8,8 @@
|
||||||
|
|
||||||
transition: background-color 0.3s ease-in-out, border-color 0.3s ease-in-out, color 0.3s ease-in-out;
|
transition: background-color 0.3s ease-in-out, border-color 0.3s ease-in-out, color 0.3s ease-in-out;
|
||||||
|
|
||||||
&:hover {
|
|
||||||
background-color: rgba($white100, 0.2);
|
|
||||||
}
|
|
||||||
&:active {
|
&:active {
|
||||||
border-color: rgba($white100, 1);
|
border-color: rgba($white100, 1);
|
||||||
background-color: rgba($white100, 0.5);
|
|
||||||
color: $white100;
|
color: $white100;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.red {
|
|
||||||
@include button($red);
|
|
||||||
}
|
|
||||||
&.orange {
|
|
||||||
@include button($orange);
|
|
||||||
}
|
|
||||||
&.yellow {
|
|
||||||
@include button($yellow);
|
|
||||||
}
|
|
||||||
&.green {
|
|
||||||
@include button($green);
|
|
||||||
}
|
|
||||||
&.blue {
|
|
||||||
@include button($blue);
|
|
||||||
}
|
|
||||||
&.purple {
|
|
||||||
@include button($purple);
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -84,7 +84,7 @@ nav {
|
||||||
gap: 0.25rem;
|
gap: 0.25rem;
|
||||||
|
|
||||||
a {
|
a {
|
||||||
margin: 0.5rem;
|
margin: 0;
|
||||||
padding: 1rem 1rem 1rem calc(1rem - 2px);
|
padding: 1rem 1rem 1rem calc(1rem - 2px);
|
||||||
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue