|
|
@ -47,6 +47,7 @@ from statuspengguna.helper import ( |
|
|
|
IsCssSelected, |
|
|
|
CurrentDistribusi, |
|
|
|
HasDistribusi, |
|
|
|
IsDistribusiLive, |
|
|
|
ResetUserState, |
|
|
|
) |
|
|
|
from statuspengguna.loginuser import LoginUser |
|
|
@ -70,7 +71,7 @@ def index(): |
|
|
|
ResetUserState() |
|
|
|
uploadform = UploadForm() |
|
|
|
distribusis = Distribusis.query.filter( |
|
|
|
Distribusis.distribusiname.isnot(None) |
|
|
|
Distribusis.visible.isnot(False) |
|
|
|
).all() |
|
|
|
distribusies = {} |
|
|
|
for distribusi in distribusis: |
|
|
@ -109,6 +110,7 @@ def distribusi(): |
|
|
|
selectorvisible = SelectorVisible() |
|
|
|
current_distribusi = CurrentDistribusi() |
|
|
|
files_uploaded = IsZipUploaded(current_distribusi) |
|
|
|
distribusi_live = IsDistribusiLive(current_distribusi) |
|
|
|
css_selected = IsCssSelected(current_distribusi) |
|
|
|
user = User.query.filter_by(email=current_user.email).first() |
|
|
|
distribusi = Distribusis.query.filter_by( |
|
|
@ -128,15 +130,17 @@ def distribusi(): |
|
|
|
os.remove(os.path.join(userfolder, zipfilename)) |
|
|
|
# To Do: Make sure nothing can be executed from the upload folder |
|
|
|
cssfile = "" |
|
|
|
for filename in os.listdir(userfolder): |
|
|
|
cssfolder = os.path.join("themes/userstyles", distribusi.distribusiname) |
|
|
|
for filename in os.listdir(cssfolder): |
|
|
|
if filename.endswith(".css"): |
|
|
|
cssfile = os.path.join(userfolder, filename) |
|
|
|
cssfile = os.path.join(cssfolder, filename) |
|
|
|
|
|
|
|
parser = build_argparser() |
|
|
|
args = parser.parse_args(["-s", cssfile]) |
|
|
|
distribusify(args, userfolder) |
|
|
|
distribusi.visible = True |
|
|
|
user.currentdistribusi = None |
|
|
|
os.remove(cssfile) |
|
|
|
db.session.commit() |
|
|
|
return redirect(url_for("index")) |
|
|
|
template = render_template( |
|
|
@ -146,6 +150,7 @@ def distribusi(): |
|
|
|
themeform=themeform, |
|
|
|
selectorform=selectorform, |
|
|
|
files_uploaded=files_uploaded, |
|
|
|
distribusi_live=distribusi_live, |
|
|
|
css_selected=css_selected, |
|
|
|
selectorvisible=selectorvisible, |
|
|
|
) |
|
|
@ -168,6 +173,7 @@ def upload(): |
|
|
|
else: |
|
|
|
uploadform = UploadUpdatedFiles(APP.config["UPLOAD_FOLDER"]) |
|
|
|
files_uploaded = IsZipUploaded(uploadform.sitename.data) |
|
|
|
distribusi_live = IsDistribusiLive(current_distribusi) |
|
|
|
css_selected = IsCssSelected(current_distribusi) |
|
|
|
template = render_template( |
|
|
|
"distribusi.html", |
|
|
@ -176,6 +182,7 @@ def upload(): |
|
|
|
themeform=themeform, |
|
|
|
selectorform=selectorform, |
|
|
|
files_uploaded=files_uploaded, |
|
|
|
distribusi_live=distribusi_live, |
|
|
|
css_selected=css_selected, |
|
|
|
selectorvisible=selectorvisible, |
|
|
|
) |
|
|
@ -193,15 +200,20 @@ def theme(): |
|
|
|
|
|
|
|
selectorvisible = SelectorVisible() |
|
|
|
current_distribusi = CurrentDistribusi() |
|
|
|
print(current_distribusi) |
|
|
|
files_uploaded = IsZipUploaded(current_distribusi) |
|
|
|
distribusi_live = IsDistribusiLive(current_distribusi) |
|
|
|
|
|
|
|
css_selected = IsCssSelected(current_distribusi) |
|
|
|
if themeform.validate_on_submit(): |
|
|
|
newuserfolder = os.path.join("stash", current_distribusi) |
|
|
|
newcssfolder = os.path.join("themes/userstyles", current_distribusi) |
|
|
|
if not os.path.exists(newcssfolder): |
|
|
|
os.mkdir(newcssfolder) |
|
|
|
copycssfile = os.path.join( |
|
|
|
"themes", |
|
|
|
"{}.css".format(themeform.theme.data), |
|
|
|
) |
|
|
|
shutil.copy(copycssfile, newuserfolder) |
|
|
|
shutil.copy(copycssfile, newcssfolder) |
|
|
|
css_selected = IsCssSelected(current_distribusi) |
|
|
|
|
|
|
|
template = render_template( |
|
|
@ -211,6 +223,7 @@ def theme(): |
|
|
|
themeform=themeform, |
|
|
|
selectorform=selectorform, |
|
|
|
files_uploaded=files_uploaded, |
|
|
|
distribusi_live=distribusi_live, |
|
|
|
css_selected=css_selected, |
|
|
|
selectorvisible=selectorvisible, |
|
|
|
) |
|
|
@ -223,6 +236,7 @@ def editor(): |
|
|
|
editorform = EditorForm() |
|
|
|
current_distribusi = CurrentDistribusi() |
|
|
|
files_uploaded = IsZipUploaded(current_distribusi) |
|
|
|
distribusi_live = IsDistribusiLive(current_distribusi) |
|
|
|
cssplaceholder = "Try out your CSS here" |
|
|
|
with open('themes/editor/placeholder.css') as f: |
|
|
|
cssplaceholder = f.read() |
|
|
@ -233,7 +247,8 @@ def editor(): |
|
|
|
htmlplaceholder = f.read() |
|
|
|
print(htmlplaceholder) |
|
|
|
if editorform.validate_on_submit(): |
|
|
|
userfolder = os.path.join("stash", current_distribusi) |
|
|
|
userfolder = os.path.join("themes/userstyles", current_distribusi) |
|
|
|
os.mkdir(newuserfolder) |
|
|
|
cssfilename = "{}.css".format(editorform.cssname.data) |
|
|
|
with open(os.path.join(userfolder, cssfilename), "w") as cssfile: |
|
|
|
cssfile.write(editorform.css.data) |
|
|
@ -242,6 +257,7 @@ def editor(): |
|
|
|
template = render_template( |
|
|
|
"editor.html", |
|
|
|
files_uploaded=files_uploaded, |
|
|
|
distribusi_live=distribusi_live, |
|
|
|
editorform=editorform, |
|
|
|
htmlplaceholder=htmlplaceholder, |
|
|
|
) |
|
|
@ -280,7 +296,10 @@ def selector(): |
|
|
|
uploadform.tags.data = distribusi.tags |
|
|
|
|
|
|
|
files_uploaded = IsZipUploaded(current_distribusi) |
|
|
|
css_selected = IsCssSelected(current_distribusi) |
|
|
|
distribusi_live = IsDistribusiLive(current_distribusi) |
|
|
|
# because the user has chosen to update his distribusi, we assume |
|
|
|
# no selected css. |
|
|
|
css_selected = False |
|
|
|
selectorvisible = SelectorVisible() |
|
|
|
|
|
|
|
template = render_template( |
|
|
@ -290,6 +309,7 @@ def selector(): |
|
|
|
themeform=themeform, |
|
|
|
selectorform=selectorform, |
|
|
|
files_uploaded=files_uploaded, |
|
|
|
distribusi_live=distribusi_live, |
|
|
|
css_selected=css_selected, |
|
|
|
selectorvisible=selectorvisible, |
|
|
|
) |
|
|
|