Browse Source

start of public custom css sharing

current_wdka_release
crunk 3 years ago
parent
commit
4eef509a74
  1. 14
      verse/forms/editorform.py
  2. 8
      verse/start.py
  3. 14
      verse/templates/editor.html
  4. 4
      verse/templates/index.html

14
verse/forms/editorform.py

@ -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")

8
verse/start.py

@ -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,

14
verse/templates/editor.html

@ -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>

4
verse/templates/index.html

@ -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%}

Loading…
Cancel
Save