Browse Source

added zipfile upload functionality and described workflow in notes.md

current_wdka_release
crunk 3 years ago
parent
commit
61c8a74e84
  1. 1
      .gitignore
  2. 5
      README.md
  3. 38
      notes.md
  4. 21
      verse/start.py
  5. 8
      verse/static/css/style.css
  6. 27
      verse/templates/distribusi.html
  7. 24
      verse/uploadform.py

1
.gitignore

@ -7,4 +7,5 @@ build/
dist/ dist/
pip-wheel-metadata/ pip-wheel-metadata/
verse/tmpupload/*
*.db *.db

5
README.md

@ -31,3 +31,8 @@ $ python deploydb.py
## Distribusi ## Distribusi
This is currently added as a git submodule but I have no clue how that actually works This is currently added as a git submodule but I have no clue how that actually works
to install a local git repository into your virtual env pip you can try.
```
$ pip install git+file:///home/full/path/to/distribusi#egg=distribusi
```

38
notes.md

@ -0,0 +1,38 @@
#notes
pip install git+file:///distribusi#egg=distribusi
# Shit! We need entire CRUD functionality.
##Create:
### Uploading
User can upload based on $distribusiname field in db.
the zip file is changed to $distribusiname.
and a folder is made in the stash called $distribusiname
### CSS editing.
a user can edit CSS of a file in the folder called $distribusiname
### Theme selection
a user can select a CSS file from a dropdown menu.
### Distribusi
A flag in de DB is set to true and distribusi is run on the folder of the users
called $distribusiname
## Read:
Based on flags set in the user DB the distribusi folders are set to visible.
on the main index page there is a listing of distribusi sites.
## Update:
Same as create, uploading just redoes the entire process.
$distribusiname is overwritten.
CSS editing, and Theme selection is editing a single file in the folder.
$distribusiname stays the same
Distribusi button can only be reset when a new file is uploaded.
## Delete
$distribusiname is deleted, files are removed, visible flag is set to false.

21
verse/start.py

@ -1,4 +1,7 @@
"""This is the main flask distribusi page""" """This is the main flask distribusi page"""
import os
from datetime import timedelta
from flask import ( from flask import (
render_template, render_template,
redirect, redirect,
@ -25,12 +28,15 @@ from flask_login import (
from werkzeug.routing import BuildError from werkzeug.routing import BuildError
from flask_bcrypt import generate_password_hash, check_password_hash from flask_bcrypt import generate_password_hash, check_password_hash
from flask_wtf.csrf import CSRFError from flask_wtf.csrf import CSRFError
from datetime import timedelta
from app import create_app, db, login_manager from app import create_app, db, login_manager
from usermodel import User from usermodel import User
from loginform import LoginForm from loginform import LoginForm
from registerform import RegisterForm from registerform import RegisterForm
from uploadform import UploadForm
# Tada!
import distribusi
APP = create_app() APP = create_app()
@ -108,7 +114,18 @@ def register():
@APP.route("/distribusi") @APP.route("/distribusi")
@login_required @login_required
def distribusi(): def distribusi():
return "distribusi" uploadform = UploadForm()
return render_template("distribusi.html", uploadform=uploadform)
@APP.route("/upload", methods=["POST"])
@login_required
def upload():
uploadform = UploadForm()
if (uploadform.validate_on_submit()):
zipfile = uploadform.zipfile.data
zipfile.save(os.path.join(APP.config['UPLOAD_FOLDER'], zipfile.filename))
return render_template("distribusi.html", uploadform=uploadform)
@APP.route("/admin") @APP.route("/admin")

8
verse/static/css/style.css

@ -1,7 +1,7 @@
body body
{ {
font-family: monospace; font-family: monospace;
background-color: black; background-color: #383C4A;
color:#E0B0FF; color:#E0B0FF;
} }
@ -9,7 +9,7 @@ section#login{
width: 30%; width: 30%;
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;
background-color:black; background-color:#383C4A;
text-decoration: none; text-decoration: none;
} }
@ -20,14 +20,14 @@ section#login form {
padding-right: 15%; padding-right: 15%;
} }
section#login .required{ fieldset.required {
padding: 6px; padding: 6px;
border: none; border: none;
float: left; float: left;
} }
section#login input[type=text], input[type=password]{ section#login input[type=text], input[type=password]{
background-color: black; background-color: #383C4A;
color: white; color: white;
border: 1px solid #E0B0FF; border: 1px solid #E0B0FF;
} }

27
verse/templates/distribusi.html

@ -1,4 +1,29 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block main %} {% block main %}
<h3>Upload</h3>
<p>Upload button</p>
<form method="POST" enctype="multipart/form-data" action="{{ url_for('upload') }}">
{{ uploadform.csrf_token }}
<fieldset class="required">
{{ uploadform.sitename.label }}
{{ uploadform.sitename }}
{% for message in uploadform.sitename.errors %}
<div class="error">{{ message }}</div>
{% endfor %}
</fieldset>
<fieldset class="required">
{{ uploadform.zipfile.label }}
{{ uploadform.zipfile }}
{% for message in uploadform.zipfile.errors %}
<div class="error">{{ message }}</div>
{% endfor %}
</fieldset>
{{ uploadform.submit }}
</form>
<h3>Theme</h3>
<p>dropdown css file selector</p>
<h3>Edit</h3>
<p>go to CSS editor</p>
<h3>Distribusi</h3>
<p>run distribusi on your files</p>
{% endblock main %} {% endblock main %}

24
verse/uploadform.py

@ -0,0 +1,24 @@
from flask_wtf import FlaskForm
from flask_wtf.file import FileField, FileAllowed
from wtforms import validators
from wtforms.validators import Length
from wtforms import (
FileField,
SubmitField,
StringField,
)
class UploadForm(FlaskForm):
"""File upload class for a new site in distribusi-verse"""
sitename = StringField(
"Name of your website:",
validators=[validators.InputRequired(), Length(6, 100)],
)
zipfile = FileField(
'Upload your zip file with content here:',
validators=[FileAllowed(['zip'], 'Zip archives only!')]
)
submit = SubmitField("Upload")
Loading…
Cancel
Save