Browse Source

scroll into view the next step

current_wdka_release
crunk 3 years ago
parent
commit
0cb57548fa
  1. 5
      verse/forms/selectorform.py
  2. 12
      verse/start.py
  3. 1
      verse/static/css/style.css
  4. 19
      verse/static/js/script.js
  5. 10
      verse/statuspengguna/helper.py
  6. 3
      verse/templates/distribusi.html
  7. 4
      verse/templates/distribusiworkflow/launch.html
  8. 3
      verse/templates/distribusiworkflow/selector.html
  9. 2
      verse/templates/distribusiworkflow/upload.html

5
verse/forms/selectorform.py

@ -1,12 +1,9 @@
from flask_wtf import FlaskForm from flask_wtf import FlaskForm
from wtforms import SubmitField, SelectField from wtforms import SubmitField, SelectField
from distribusimodel import Distribusis
from usermodel import User
from flask_login import current_user
class SelectorForm(FlaskForm): class SelectorForm(FlaskForm):
distribusis = SelectField(u'Your existing distribusi:') distribusis = SelectField("Your existing distribusi:")
new = SubmitField("new") new = SubmitField("new")

12
verse/start.py

@ -43,6 +43,7 @@ from upload import UploadUpdatedFiles
# UserPengguna # UserPengguna
from statuspengguna.helper import IsZipUploaded from statuspengguna.helper import IsZipUploaded
from statuspengguna.helper import IsCssSelected
from statuspengguna.helper import CurrentDistribusi from statuspengguna.helper import CurrentDistribusi
from statuspengguna.helper import ResetUserState from statuspengguna.helper import ResetUserState
from statuspengguna.loginuser import LoginUser from statuspengguna.loginuser import LoginUser
@ -86,6 +87,7 @@ def distribusi():
selectorvisible = SelectorVisible() selectorvisible = SelectorVisible()
current_distribusi = CurrentDistribusi() current_distribusi = CurrentDistribusi()
files_uploaded = IsZipUploaded(current_distribusi) files_uploaded = IsZipUploaded(current_distribusi)
css_selected = IsCssSelected(current_distribusi)
user = User.query.filter_by(email=current_user.email).first() user = User.query.filter_by(email=current_user.email).first()
distribusi = Distribusis.query.filter_by( distribusi = Distribusis.query.filter_by(
distribusiname=current_distribusi distribusiname=current_distribusi
@ -122,6 +124,7 @@ def distribusi():
themeform=themeform, themeform=themeform,
selectorform=selectorform, selectorform=selectorform,
files_uploaded=files_uploaded, files_uploaded=files_uploaded,
css_selected=css_selected,
selectorvisible=selectorvisible, selectorvisible=selectorvisible,
) )
return template return template
@ -143,7 +146,7 @@ def upload():
else: else:
uploadform = UploadUpdatedFiles(APP.config["UPLOAD_FOLDER"]) uploadform = UploadUpdatedFiles(APP.config["UPLOAD_FOLDER"])
files_uploaded = IsZipUploaded(uploadform.sitename.data) files_uploaded = IsZipUploaded(uploadform.sitename.data)
css_selected = IsCssSelected(current_distribusi)
template = render_template( template = render_template(
"distribusi.html", "distribusi.html",
uploadform=uploadform, uploadform=uploadform,
@ -151,6 +154,7 @@ def upload():
themeform=themeform, themeform=themeform,
selectorform=selectorform, selectorform=selectorform,
files_uploaded=files_uploaded, files_uploaded=files_uploaded,
css_selected=css_selected,
selectorvisible=selectorvisible, selectorvisible=selectorvisible,
) )
return template return template
@ -168,7 +172,7 @@ def theme():
selectorvisible = SelectorVisible() selectorvisible = SelectorVisible()
current_distribusi = CurrentDistribusi() current_distribusi = CurrentDistribusi()
files_uploaded = IsZipUploaded(current_distribusi) files_uploaded = IsZipUploaded(current_distribusi)
css_selected = IsCssSelected(current_distribusi)
if themeform.validate_on_submit(): if themeform.validate_on_submit():
newuserfolder = os.path.join("stash", current_distribusi) newuserfolder = os.path.join("stash", current_distribusi)
copycssfile = os.path.join( copycssfile = os.path.join(
@ -176,6 +180,7 @@ def theme():
"{}.css".format(themeform.theme.data), "{}.css".format(themeform.theme.data),
) )
shutil.copy(copycssfile, newuserfolder) shutil.copy(copycssfile, newuserfolder)
css_selected = IsCssSelected(current_distribusi)
template = render_template( template = render_template(
"distribusi.html", "distribusi.html",
@ -184,6 +189,7 @@ def theme():
themeform=themeform, themeform=themeform,
selectorform=selectorform, selectorform=selectorform,
files_uploaded=files_uploaded, files_uploaded=files_uploaded,
css_selected=css_selected,
selectorvisible=selectorvisible, selectorvisible=selectorvisible,
) )
return template return template
@ -242,6 +248,7 @@ def selector():
uploadform.tags.data = distribusi.tags uploadform.tags.data = distribusi.tags
files_uploaded = IsZipUploaded(current_distribusi) files_uploaded = IsZipUploaded(current_distribusi)
css_selected = IsCssSelected(current_distribusi)
selectorvisible = SelectorVisible() selectorvisible = SelectorVisible()
template = render_template( template = render_template(
@ -251,6 +258,7 @@ def selector():
themeform=themeform, themeform=themeform,
selectorform=selectorform, selectorform=selectorform,
files_uploaded=files_uploaded, files_uploaded=files_uploaded,
css_selected=css_selected,
selectorvisible=selectorvisible, selectorvisible=selectorvisible,
) )
return template return template

1
verse/static/css/style.css

@ -37,7 +37,6 @@ div#upload form {
margin-top: 1em; margin-top: 1em;
padding: 0.5em; padding: 0.5em;
width: 30em; width: 30em;
border: 3px solid #E0B0FF;
background-color:#383C4A; background-color:#383C4A;
text-decoration: none; text-decoration: none;
scroll-behavior: smooth; scroll-behavior: smooth;

19
verse/static/js/script.js

@ -1,5 +1,24 @@
console.log("everything is still smooth") console.log("everything is still smooth")
function scrollToTheme() {
var uploadsuccessful = document.getElementById("uploadsuccessful");
if(uploadsuccessful){
const theme = document.getElementById('theme')
theme.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
}
function scrollToLaunch() {
var cssSelected = document.getElementById("cssSelected");
if(cssSelected){
const launch = document.getElementById('launch')
launch.scrollIntoView({ behavior: 'smooth', block: 'end' });
}
}
document.addEventListener("DOMContentLoaded", scrollToTheme);
document.addEventListener("DOMContentLoaded", scrollToLaunch);
// function(e) { // function(e) {
// (e.keyCode === 13 || e.keyCode === 32) && $(this).trigger("click") // (e.keyCode === 13 || e.keyCode === 32) && $(this).trigger("click")
// } // }

10
verse/statuspengguna/helper.py

@ -17,6 +17,16 @@ def IsZipUploaded(distribusiname):
return False return False
def IsCssSelected(distribusiname):
userfolder = os.path.join("stash", distribusiname)
if os.path.exists(userfolder):
for file in os.listdir(userfolder):
if file.endswith(".css"):
return True
print("distribusi folder has no css file")
return False
def HasDistribusi(): def HasDistribusi():
user = User.query.filter_by(email=current_user.email).first() user = User.query.filter_by(email=current_user.email).first()
distribusi = Distribusis.query.filter_by(userid=user.id).first() distribusi = Distribusis.query.filter_by(userid=user.id).first()

3
verse/templates/distribusi.html

@ -35,4 +35,7 @@
{% endblock launch%} {% endblock launch%}
{%endif%} {%endif%}
</div> </div>
{% if css_selected %}
<p id="cssSelected" hidden>css selected</p>
{% endif %}
{% endblock main %} {% endblock main %}

4
verse/templates/distribusiworkflow/launch.html

@ -1,6 +1,6 @@
<div id="distribusi" class="workflow"> <div id="launch" class="workflow">
<h3>Step 4: Distribusi</h3> <h3>Step 4: Distribusi</h3>
<p>run distribusi on your files, this will generate your website and make <p>Run distribusi on your files, this will generate your website and make
your content public.</p> your content public.</p>
<form method="POST" enctype="multipart/form-data" action="{{ url_for('distribusi') }}"> <form method="POST" enctype="multipart/form-data" action="{{ url_for('distribusi') }}">
{{ distribusiform.csrf_token }} {{ distribusiform.csrf_token }}

3
verse/templates/distribusiworkflow/selector.html

@ -13,14 +13,17 @@
</div> </div>
</fieldset> </fieldset>
<fieldset class="button required multiselect"> <fieldset class="button required multiselect">
{{ selectorform.update.label }}
{{ selectorform.update }} {{ selectorform.update }}
</fieldset> </fieldset>
<fieldset class="button required multiselect warning"> <fieldset class="button required multiselect warning">
{{ selectorform.delete.label }}
{{ selectorform.delete }} {{ selectorform.delete }}
</fieldset> </fieldset>
<p>Alternatively you can make a new site</p> <p>Alternatively you can make a new site</p>
<fieldset class="button required multiselect"> <fieldset class="button required multiselect">
{{ selectorform.new.label }}
{{ selectorform.new }} {{ selectorform.new }}
</fieldset> </fieldset>
</form> </form>

2
verse/templates/distribusiworkflow/upload.html

@ -54,6 +54,6 @@
</fieldset> </fieldset>
</form> </form>
{% if files_uploaded %} {% if files_uploaded %}
<p>Your files have been uploaded successfully</p> <p id="uploadsuccessful">Your files have been uploaded successfully</p>
{% endif %} {% endif %}
</div> </div>

Loading…
Cancel
Save