forked from crunk/distribusi-verse
added zipfile upload functionality and described workflow in notes.md
This commit is contained in:
parent
efb4252f81
commit
61c8a74e84
1
.gitignore
vendored
1
.gitignore
vendored
@ -7,4 +7,5 @@ build/
|
||||
dist/
|
||||
pip-wheel-metadata/
|
||||
|
||||
verse/tmpupload/*
|
||||
*.db
|
||||
|
@ -31,3 +31,8 @@ $ python deploydb.py
|
||||
|
||||
## Distribusi
|
||||
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
Normal file
38
notes.md
Normal file
@ -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.
|
@ -1,4 +1,7 @@
|
||||
"""This is the main flask distribusi page"""
|
||||
import os
|
||||
from datetime import timedelta
|
||||
|
||||
from flask import (
|
||||
render_template,
|
||||
redirect,
|
||||
@ -25,12 +28,15 @@ from flask_login import (
|
||||
from werkzeug.routing import BuildError
|
||||
from flask_bcrypt import generate_password_hash, check_password_hash
|
||||
from flask_wtf.csrf import CSRFError
|
||||
from datetime import timedelta
|
||||
|
||||
from app import create_app, db, login_manager
|
||||
from usermodel import User
|
||||
from loginform import LoginForm
|
||||
from registerform import RegisterForm
|
||||
from uploadform import UploadForm
|
||||
|
||||
# Tada!
|
||||
import distribusi
|
||||
|
||||
APP = create_app()
|
||||
|
||||
@ -108,7 +114,18 @@ def register():
|
||||
@APP.route("/distribusi")
|
||||
@login_required
|
||||
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")
|
||||
|
@ -1,7 +1,7 @@
|
||||
body
|
||||
{
|
||||
font-family: monospace;
|
||||
background-color: black;
|
||||
background-color: #383C4A;
|
||||
color:#E0B0FF;
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@ section#login{
|
||||
width: 30%;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
background-color:black;
|
||||
background-color:#383C4A;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
@ -20,14 +20,14 @@ section#login form {
|
||||
padding-right: 15%;
|
||||
}
|
||||
|
||||
section#login .required{
|
||||
fieldset.required {
|
||||
padding: 6px;
|
||||
border: none;
|
||||
float: left;
|
||||
}
|
||||
|
||||
section#login input[type=text], input[type=password]{
|
||||
background-color: black;
|
||||
background-color: #383C4A;
|
||||
color: white;
|
||||
border: 1px solid #E0B0FF;
|
||||
}
|
||||
|
@ -1,4 +1,29 @@
|
||||
{% extends "base.html" %}
|
||||
{% 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 %}
|
||||
|
24
verse/uploadform.py
Normal file
24
verse/uploadform.py
Normal file
@ -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…
Reference in New Issue
Block a user