downloadable public themes on index

This commit is contained in:
crunk 2022-03-28 18:33:48 +02:00
parent b3f7e1fb6f
commit fd9f623193
5 changed files with 20 additions and 4 deletions

View File

@ -5,6 +5,7 @@ from flask import (
redirect, redirect,
url_for, url_for,
session, session,
send_from_directory,
Blueprint, Blueprint,
) )
from flask_login import ( from flask_login import (
@ -17,6 +18,7 @@ from flask_wtf.csrf import CSRFError
from app import create_app, login_manager from app import create_app, login_manager
from usermodel import User from usermodel import User
from distribusimodel import Distribusis
# Use upload form to populate filters # Use upload form to populate filters
from forms.uploadform import UploadForm from forms.uploadform import UploadForm
@ -107,6 +109,15 @@ def theme():
return ThemeSelector() return ThemeSelector()
@APP.route("/publicthemes/<path>")
def publicthemes(path):
distribusi = Distribusis.query.filter_by(distribusiname=path).first()
publicthemefolder = f"publicthemes/{distribusi.distribusiname}/"
cssfile = f"{publicthemefolder}/{distribusi.publictheme}.css"
print(cssfile)
return send_from_directory("themes", cssfile, as_attachment=True)
@APP.route("/editor", methods=["GET", "POST"]) @APP.route("/editor", methods=["GET", "POST"])
@login_required @login_required
def editor(): def editor():
@ -156,7 +167,6 @@ def forgotpassword():
@APP.route("/resetpassword/<path>", methods=["GET", "POST"]) @APP.route("/resetpassword/<path>", methods=["GET", "POST"])
def resetpassword(path): def resetpassword(path):
print(path)
return ResetPassword(path) return ResetPassword(path)

View File

@ -66,6 +66,9 @@ div#upload form {
#distribusiverse { #distribusiverse {
margin-bottom: 11em; margin-bottom: 11em;
} }
#distribusi-index {
padding-left: 1em;
}
div#buttons{ div#buttons{
position: fixed; position: fixed;

View File

@ -1,5 +1,5 @@
<div id="edit" class="workflow"> <div id="edit" class="workflow">
<h2>(Optional) Step 3: Edit</h2> <h2>Step 3: Edit Custom CSS (Optional)</h2>
{% if files_uploaded or distribusi_live %} {% if files_uploaded or distribusi_live %}
<p><a href="/editor">Go to CSS editor</a></p> <p><a href="/editor">Go to CSS editor</a></p>
{% else %} {% else %}

View File

@ -1,5 +1,5 @@
<div id="theme" class="workflow"> <div id="theme" class="workflow">
<h2>(Optional) Step 2: Choose a theme</h2> <h2>Step 2: Choose a theme (Optional)</h2>
<p>Select your Theme here. If you want to make own custom css, skip and go to <p>Select your Theme here. If you want to make own custom css, skip and go to
step 3.</p> step 3.</p>
<p>Don't forget to press Save</p> <p>Don't forget to press Save</p>

View File

@ -56,13 +56,16 @@
<div id="distribusiverse" class="maincontent"> <div id="distribusiverse" class="maincontent">
<h2>List of distribusis</h2> <h2>List of distribusis</h2>
{% include 'filtermenu.html' %} {% include 'filtermenu.html' %}
<ul> <ul id="distribusi-index">
{% for name, distribusi in distribusisindex.items() %} {% for name, distribusi in distribusisindex.items() %}
<li class='distribusi filter {{ distribusi["term"] }} {{ distribusi["year"] }} {{ distribusi["course"] }}'> <li class='distribusi filter {{ distribusi["term"] }} {{ distribusi["year"] }} {{ distribusi["course"] }}'>
<a href='stash/{{name}}/index.html'>{{distribusi["username"]}}:{{name}}</a> <a href='stash/{{name}}/index.html'>{{distribusi["username"]}}:{{name}}</a>
{% for tag in distribusi["tags"] %} {% for tag in distribusi["tags"] %}
<span class="tags">{{tag}}</span> <span class="tags">{{tag}}</span>
{% endfor%} {% endfor%}
{% if distribusi.publictheme != None %}
<a href="publicthemes/{{name}}">theme 🗎</a>
{% endif %}
</li> </li>
{% endfor%} {% endfor%}
</ul> </ul>