mirror of
https://github.com/Derpy-Leggies/OnlyLegs.git
synced 2025-06-29 11:36:16 +00:00
Themes can now include font files
Updated example env New fonts added to default theme
This commit is contained in:
parent
a7e79ab5a5
commit
463c5ecd03
11 changed files with 117 additions and 24 deletions
|
@ -13,7 +13,14 @@ class DBmanager():
|
|||
sys.exit(1)
|
||||
|
||||
try:
|
||||
load_dotenv(os.path.join('usr', '.env'))
|
||||
env_path = os.path.join('usr', '.env')
|
||||
|
||||
if not os.path.exists(env_path):
|
||||
print("Error: could not find .env file")
|
||||
print("Exiting...")
|
||||
sys.exit(1)
|
||||
|
||||
load_dotenv(env_path)
|
||||
print("### OnlyLegs Database Manager ###")
|
||||
print("Connecting to database...")
|
||||
|
||||
|
@ -34,10 +41,10 @@ class DBmanager():
|
|||
record = cursor.fetchone()
|
||||
print("Connected to database:", record[0])
|
||||
|
||||
print("Finished\n")
|
||||
print("Done!\n")
|
||||
|
||||
except Error as e:
|
||||
print("Error while connecting to Database! Full error:\n", e)
|
||||
print("Error while connecting to Database!\nFull error:", e)
|
||||
print("Exiting...")
|
||||
sys.exit(1)
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import time
|
||||
import sys
|
||||
import shutil
|
||||
import os
|
||||
|
||||
class Sassy():
|
||||
|
@ -13,24 +14,82 @@ class Sassy():
|
|||
print("Exiting...")
|
||||
sys.exit(1)
|
||||
|
||||
path_to_sass = os.path.join('usr', 'themes', theme, 'style.scss')
|
||||
theme_path = os.path.join('usr', 'themes', theme, 'style.scss')
|
||||
|
||||
if os.path.exists(path_to_sass):
|
||||
print(f"Theme '{theme}' found at:", path_to_sass)
|
||||
if os.path.exists(theme_path):
|
||||
print(f"Theme '{theme}' found at:", theme_path)
|
||||
self.sass = sass
|
||||
self.loadTheme(path_to_sass)
|
||||
self.loadTheme(theme_path)
|
||||
else:
|
||||
print("No theme found!")
|
||||
print("Exiting...")
|
||||
sys.exit(1)
|
||||
|
||||
font_path = os.path.join('usr', 'themes', theme, 'fonts')
|
||||
|
||||
if os.path.exists(font_path):
|
||||
print("Fonts found at:", font_path)
|
||||
self.loadFonts(font_path)
|
||||
else:
|
||||
print("No fonts found!")
|
||||
|
||||
print("Done!\n")
|
||||
|
||||
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("Compiled successfully to:", f.name)#
|
||||
print("Finished\n")
|
||||
print("Compiled successfully to:", f.name)
|
||||
except self.sass.CompileError as e:
|
||||
print("Failed to compile! Full error:\n", e)
|
||||
print("Failed to compile!\nFull error:", e)
|
||||
print("Exiting...")
|
||||
sys.exit(1)
|
||||
sys.exit(1)
|
||||
|
||||
def loadFonts (self, font_path):
|
||||
dest = os.path.join('static', 'css', 'fonts')
|
||||
|
||||
if os.path.exists(dest):
|
||||
print("Removing old fonts...")
|
||||
try:
|
||||
shutil.rmtree(dest)
|
||||
print("Removed old fonts!")
|
||||
except Exception as e:
|
||||
print("Failed to remove old fonts!\nFull error:", e)
|
||||
print("Exiting...")
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
shutil.copytree(font_path, dest)
|
||||
print("Copied fonts to:", dest)
|
||||
except Exception as e:
|
||||
print("Failed to copy fonts!\nFull error:", e)
|
||||
print("Exiting...")
|
||||
sys.exit(1)
|
||||
|
||||
#print ("Removing old fonts from:", dest)
|
||||
#for old in os.listdir(dest):
|
||||
# dir = os.path.join(dest , old)
|
||||
#
|
||||
# try:
|
||||
# if os.path.isfile(dir) or os.path.islink(dir):
|
||||
# os.unlink(dir)
|
||||
# print("Removed:", old)
|
||||
# elif os.path.isdir(dir):
|
||||
# shutil.rmtree(dir)
|
||||
# print("Removed:", old)
|
||||
# except Exception as e:
|
||||
# print("Failed to remove:", dir)
|
||||
# print("Full error:", e)
|
||||
|
||||
#print ("Loading new fonts")
|
||||
#for font in os.listdir(font_path):
|
||||
# dir = os.path.join(font_path, dest)
|
||||
# new_dir = os.path.join(dest, font)
|
||||
#
|
||||
# try:
|
||||
# if os.path.isfile(dir):
|
||||
# shutil.copy(dir, new_dir)
|
||||
# print("Copied font:", font)
|
||||
# except Exception as e:
|
||||
# print("Failed to copy font:", font)
|
||||
# print("Full error:", e)
|
Loading…
Add table
Add a link
Reference in a new issue