start of public custom css sharing

This commit is contained in:
crunk 2022-03-08 22:58:05 +01:00
parent 2d34ab0af5
commit 4eef509a74
4 changed files with 33 additions and 7 deletions

View File

@ -2,11 +2,13 @@
from wtforms import (
StringField,
TextAreaField,
BooleanField,
SubmitField,
)
from wtforms import validators
from wtforms.validators import Length
from flask_wtf.file import FileField, FileAllowed, FileSize
from flask_wtf import FlaskForm
@ -17,5 +19,17 @@ class EditorForm(FlaskForm):
"fill in a name for your css style:",
validators=[validators.InputRequired(), Length(5, 200)],
)
cssfile = FileField(
"(Optional) upload your own css file:",
validators=[
FileAllowed(["css"], "css files only!"),
FileSize(
max_size=10485760,
message="Zipfile size must be smaller than 100MB",
),
],
)
css = TextAreaField()
public = BooleanField("Make your CSS public so others can use it")
submit = SubmitField("Save")

View File

@ -72,20 +72,18 @@ def index():
distribusies = {}
for distribusi in distribusis:
user = User.query.filter_by(id=distribusi.userid).first()
#distribusies[distribusi.distribusiname] = user.email
distribusies[user.email] = distribusi
singledistribusi = {
"name": distribusi.distribusiname,
"useremail": user.email,
"term": distribusi.term,
"course": distribusi.course,
"year": distribusi.year,
"tags": distribusi.tags.split(','),
}
distribusies[user.email] = singledistribusi
distribusies[distribusi.distribusiname] = singledistribusi
years = uploadform.academicyear.choices
terms = uploadform.term.choices
courses = uploadform.course.choices
print(type(courses[0]))
template = render_template(
"index.html",
distribusies=distribusies,

View File

@ -27,6 +27,20 @@
<div class="error">{{ message }}</div>
{% endfor %}
</fieldset>
<fieldset class="required">
{{ editorform.cssfile.label }}
{{ editorform.cssfile }}
{% for message in editorform.cssfile.errors %}
<div class="error">{{ message }}</div>
{% endfor %}
</fieldset>
<fieldset class="button">
{{ editorform.public.label }}
{{ editorform.public }}
{% for message in editorform.public.errors %}
<div class="error">{{ message }}</div>
{% endfor %}
</fieldset>
<fieldset class="button required">
{{ editorform.submit }}
</fieldset>

View File

@ -44,9 +44,9 @@
<h2>List of distribusis</h2>
{% include 'filtermenu.html' %}
<ul>
{% for id, distribusi in distribusies.items() %}
{% for name, distribusi in distribusies.items() %}
<li class='distribusi filter {{ distribusi["term"] }} {{ distribusi["year"] }} {{ distribusi["course"] }}'>
{{id}}: <a href='stash/{{distribusi["name"]}}/index.html'>{{distribusi["name"]}}</a>
{{distribusi["useremail"]}}: <a href='stash/{{name}}/index.html'>{{name}}</a>
{% for tag in distribusi["tags"] %}
<span class="tags">{{tag}}</span>
{% endfor%}