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 os
|
||||
# Import base packages
|
||||
import time
|
||||
import sys
|
||||
sys.path.insert(1, './packages')
|
||||
import os
|
||||
|
||||
# Import database manager
|
||||
import onlylegsDB
|
||||
print("""OnlyLegs - created by Fluffy Bean
|
||||
Version: 060123
|
||||
---------------------------------
|
||||
Starting...
|
||||
""")
|
||||
time.sleep(1)
|
||||
|
||||
# Import required OnlyLegs packages
|
||||
from packages import onlylegsDB
|
||||
onlylegsDB = onlylegsDB.DBmanager()
|
||||
# Import sass compiler
|
||||
import onlylegsSass
|
||||
from packages import onlylegsSass
|
||||
onlylegsSass = onlylegsSass.Sassy('default')
|
||||
|
||||
# Import flask
|
||||
|
@ -31,28 +37,24 @@ def method_not_allowed(e):
|
|||
msg = 'Method sussy wussy'
|
||||
return render_template('error.html', error=error, msg=msg), 404
|
||||
|
||||
|
||||
@app.errorhandler(404)
|
||||
def page_not_found(e):
|
||||
error = '404'
|
||||
msg = 'Could not find what you need!'
|
||||
return render_template('error.html', error=error, msg=msg), 404
|
||||
|
||||
|
||||
@app.errorhandler(403)
|
||||
def forbidden(e):
|
||||
error = '403'
|
||||
msg = 'Go away! This is no place for you!'
|
||||
return render_template('error.html', error=error, msg=msg), 403
|
||||
|
||||
|
||||
@app.errorhandler(410)
|
||||
def gone(e):
|
||||
error = '410'
|
||||
msg = 'The page is no longer available! *sad face*'
|
||||
return render_template('error.html', error=error, msg=msg), 410
|
||||
|
||||
|
||||
@app.errorhandler(500)
|
||||
def internal_server_error(e):
|
||||
error = '500'
|
||||
|
@ -67,7 +69,6 @@ def internal_server_error(e):
|
|||
def home():
|
||||
return render_template('home.html')
|
||||
|
||||
|
||||
@app.route('/image/<request_id>')
|
||||
def image(request_id):
|
||||
# Check if request_id is valid
|
||||
|
@ -78,8 +79,6 @@ def image(request_id):
|
|||
|
||||
result = onlylegsDB.getImage(request_id)
|
||||
|
||||
print (result)
|
||||
|
||||
return render_template('image.html', fileName=result[1], id=request_id)
|
||||
|
||||
|
||||
|
@ -98,7 +97,6 @@ def image_list(item_type):
|
|||
|
||||
return jsonify(item_list)
|
||||
|
||||
|
||||
@app.route('/uploads/<quality>/<request_file>', methods=['GET'])
|
||||
def uploads(quality, request_file):
|
||||
if request.method != 'GET':
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import time
|
||||
import sys
|
||||
import os
|
||||
|
||||
|
@ -8,19 +9,19 @@ class DBmanager():
|
|||
from mysql.connector import Error
|
||||
from dotenv import load_dotenv
|
||||
except ImportError:
|
||||
print("Error: could not import required modules")
|
||||
print("Error: could not import required packages")
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
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('HOST'),
|
||||
port=os.environ.get('PORT'),
|
||||
database=os.environ.get('DATABASE'),
|
||||
user=os.environ.get('USERNAME'),
|
||||
password=os.environ.get('PASSWORD')
|
||||
database = mysql.connector.connect(host=os.environ.get('DB_HOST'),
|
||||
port=os.environ.get('DB_PORT'),
|
||||
database=os.environ.get('DB_NAME'),
|
||||
user=os.environ.get('DB_USER'),
|
||||
password=os.environ.get('DB_PASS')
|
||||
)
|
||||
|
||||
if database.is_connected():
|
||||
|
@ -33,8 +34,11 @@ class DBmanager():
|
|||
record = cursor.fetchone()
|
||||
print("Connected to database:", record[0])
|
||||
|
||||
print("Finished\n")
|
||||
|
||||
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)
|
||||
|
||||
self.database = database
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
import time
|
||||
import sys
|
||||
import os
|
||||
|
||||
class Sassy():
|
||||
def __init__(self, theme):
|
||||
print("### OnlyLegs Theme Manager ###")
|
||||
|
||||
try:
|
||||
import sass
|
||||
except ImportError:
|
||||
print("Error: libsass not found")
|
||||
print("Could not find libsass!")
|
||||
print("Exiting...")
|
||||
sys.exit(1)
|
||||
|
||||
path_to_sass = os.path.join('usr', 'themes', theme, 'style.scss')
|
||||
|
@ -16,13 +20,17 @@ class Sassy():
|
|||
self.sass = sass
|
||||
self.loadTheme(path_to_sass)
|
||||
else:
|
||||
print("Error: theme not found")
|
||||
print("No theme found!")
|
||||
print("Exiting...")
|
||||
sys.exit(1)
|
||||
|
||||
def loadTheme (self, theme):
|
||||
with open('static/css/style.css', 'w') as f:
|
||||
try:
|
||||
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:
|
||||
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]);
|
||||
}
|
||||
}
|
||||
imageIndex = startIndex + amount;
|
||||
}
|
||||
|
||||
function loadImg(id, fileName) {
|
||||
|
@ -40,16 +41,13 @@
|
|||
type: 'get',
|
||||
success: function(response) {
|
||||
imageList = response;
|
||||
|
||||
loadMore(0, 30);
|
||||
imageIndex += 30;
|
||||
}
|
||||
});
|
||||
|
||||
$(window).scroll(function() {
|
||||
if ($(window).height() + $(window).scrollTop() >= $(document).height() - 500) {
|
||||
loadMore(imageIndex);
|
||||
imageIndex += 10;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -15,13 +15,13 @@
|
|||
<body>
|
||||
<nav id="navRoot">
|
||||
<div>
|
||||
<a href="{{ url_for('home') }}" class="btn"><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') }}" class="btn"><i class="ph-upload"></i><span>Upload</span></a>
|
||||
<a href="{{ url_for('home') }}"><i class="ph-house-line"></i><span>Home</span></a>
|
||||
<a href="{{ url_for('home') }}"><i class="ph-package"></i><span>Groups</span></a>
|
||||
<a href="{{ url_for('home') }}"><i class="ph-upload"></i><span>Upload</span></a>
|
||||
</div>
|
||||
<div>
|
||||
<a href="{{ url_for('home') }}" class="btn"><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-user-circle"></i><span>Profile</span></a>
|
||||
<a href="{{ url_for('home') }}"><i class="ph-gear"></i><span>Settings</span></a>
|
||||
</div>
|
||||
</nav>
|
||||
<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 {
|
||||
padding: 0.5rem 1rem;
|
||||
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;
|
||||
|
||||
&:hover {
|
||||
background-color: rgba($white100, 0.2);
|
||||
}
|
||||
&:active {
|
||||
border-color: rgba($white100, 1);
|
||||
background-color: rgba($white100, 0.5);
|
||||
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;
|
||||
|
||||
a {
|
||||
margin: 0.5rem;
|
||||
margin: 0;
|
||||
padding: 1rem 1rem 1rem calc(1rem - 2px);
|
||||
|
||||
width: 100%;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue