summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app.py17
-rw-r--r--static/.gallery.scss2
-rw-r--r--static/.popup.scss2
-rw-r--r--static/edit.js2
-rw-r--r--static/main.css20
-rw-r--r--static/main.css.map2
-rw-r--r--static/main.scss21
-rw-r--r--templates/base.html14
-rw-r--r--templates/delete.html12
-rw-r--r--templates/edit_project.html3
-rw-r--r--templates/gallery.html9
-rw-r--r--templates/login.html2
-rw-r--r--templates/new.html1
-rw-r--r--templates/project.html6
-rw-r--r--templates/project_fields.html1
15 files changed, 100 insertions, 14 deletions
diff --git a/app.py b/app.py
index ec70ffc..ae6ec36 100644
--- a/app.py
+++ b/app.py
@@ -37,7 +37,8 @@ def check_password(password) -> bool:
def inject():
return {
'projects': from_json(db.all(), List[Project]),
- 'empty_project': Project()
+ 'empty_project': Project(),
+ 'admin': session.get('logged_in', False)
}
@@ -136,6 +137,20 @@ def projects(project_name):
return render_template('project.html', project=find_project(project_name))
+@app.route('/projects/<project_name>/delete/', methods=['GET'])
+@require_admin()
+def delete_project(project_name):
+ return render_template('delete.html', project=find_project(project_name))
+
+
+@app.route('/projects/<project_name>/delete/', methods=['POST'])
+@require_admin()
+def delete_project_confirm(project_name):
+ Q = Query()
+ db.remove(Q.id == project_name.lower())
+ return redirect('/')
+
+
@app.route('/')
def index():
return render_template('index.html')
diff --git a/static/.gallery.scss b/static/.gallery.scss
index 0b75b92..9594dd3 100644
--- a/static/.gallery.scss
+++ b/static/.gallery.scss
@@ -11,7 +11,7 @@
padding: 10px;
width: 32%;
min-height: 200px;
- margin: 0.8%;
+ margin: 0.6%;
border: gray 1px solid;
}
diff --git a/static/.popup.scss b/static/.popup.scss
index 4bc4650..a3e9df6 100644
--- a/static/.popup.scss
+++ b/static/.popup.scss
@@ -3,7 +3,7 @@
animation-duration: 6s;
animation-iteration-count: 1;
position: fixed;
- bottom: 10px;
+ bottom: 60px;
text-align: center;
animation-fill-mode: forwards;
}
diff --git a/static/edit.js b/static/edit.js
index 7bdc575..41a82ca 100644
--- a/static/edit.js
+++ b/static/edit.js
@@ -1,6 +1,6 @@
function save_changes() {
let summary = $("#summary").val();
- let description = $("#description").text();
+ let description = $("#description").val();
let link = $("#link").val();
let name = $("#name").val();
$.ajax({
diff --git a/static/main.css b/static/main.css
index 85292fb..7cc478c 100644
--- a/static/main.css
+++ b/static/main.css
@@ -69,7 +69,7 @@ table {
padding: 10px;
width: 32%;
min-height: 200px;
- margin: 0.8%;
+ margin: 0.6%;
border: gray 1px solid; }
.gallery-element:hover {
@@ -89,7 +89,7 @@ table {
animation-duration: 6s;
animation-iteration-count: 1;
position: fixed;
- bottom: 10px;
+ bottom: 60px;
text-align: center;
animation-fill-mode: forwards; }
@@ -121,4 +121,20 @@ a {
color: inherit;
text-decoration: inherit; }
+.footer {
+ border-top: 1px black solid;
+ bottom: 0;
+ position: fixed;
+ text-align: center;
+ height: 50px;
+ width: 100%;
+ margin: 0;
+ background: #e2e1e1; }
+
+body {
+ padding-bottom: 50px; }
+
+b {
+ font-weight: 500; }
+
/*# sourceMappingURL=main.css.map */
diff --git a/static/main.css.map b/static/main.css.map
index 941eab4..b0f4831 100644
--- a/static/main.css.map
+++ b/static/main.css.map
@@ -1,6 +1,6 @@
{
"version": 3,
-"mappings": "AAEA,cAAe;EACb,OAAO,EAAE,aAAa;EACtB,kBAAkB,EAAE,WAAW;EAC/B,eAAe,EAAE,WAAW;EAC5B,cAAc,EAAE,WAAW;EAC3B,aAAa,EAAE,WAAW;EAC1B,UAAU,EAAE,WAAW;EACvB,KAAK,EATM,OAAO;;AAapB,oBAAqB;EACnB,KAAK,EAbM,KAAK;;AAgBlB,QAAS;EACP,UAAU,EAlBC,OAAO;EAmBlB,KAAK,EAlBM,KAAK;;ACDlB;;;;;;;;;;;;wBAYyB;EACvB,MAAM,EAAE,CAAC;EACT,OAAO,EAAE,CAAC;EACV,MAAM,EAAE,CAAC;EACT,SAAS,EAAE,IAAI;EACf,IAAI,EAAE,OAAO;EACb,cAA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I;;AAGtB,CAAE;EACA,WAAW,EAAE,GAAG",
"sources": [".spoiler.scss",".reset.scss",".gallery.scss",".popup.scss","main.scss"],
"names": [],
"file": "main.css"
diff --git a/static/main.scss b/static/main.scss
index 36a275e..0aa858e 100644
--- a/static/main.scss
+++ b/static/main.scss
@@ -27,4 +27,23 @@ h1 {
a {
color: inherit;
text-decoration: inherit;
-} \ No newline at end of file
+}
+
+.footer {
+ border-top: 1px black solid;
+ bottom: 0;
+ position: fixed;
+ text-align: center;
+ height: 50px;
+ width: 100%;
+ margin: 0;
+ background: #e2e1e1;
+}
+
+body {
+ padding-bottom: 50px;
+}
+
+b {
+ font-weight: 500;
+}
diff --git a/templates/base.html b/templates/base.html
index 99a419b..9f45c87 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -16,5 +16,19 @@
No content found. THIS IS AN ERROR
{% endblock %}
</div>
+<div class="footer">
+ <a href="/">Home</a>
+ &bullet;
+ {% if admin %}
+ <a href="{{ url_for('logout') }}">Admin logout</a>
+ &bullet;
+ <a href="{{ url_for('new_project_form') }}">New Project</a>
+ {% block admin_footer %}{% endblock %}
+ {% else %}
+ <a href="{{ url_for('login') }}">Admin login</a>
+ {% endif %}
+ {% block footer %}
+ {% endblock %}
+</div>
</body>
</html> \ No newline at end of file
diff --git a/templates/delete.html b/templates/delete.html
new file mode 100644
index 0000000..2641260
--- /dev/null
+++ b/templates/delete.html
@@ -0,0 +1,12 @@
+{% extends"base.html" %}
+{% block body %}
+ <p>Do you really want to delete the project <b>{{ project.name }}</b></p>
+ <form action="." method="post">
+ <p>
+ <a href="{{ url_for('projects', project_name=project.id) }}">
+ No
+ </a>
+ <input style="color: red;" type="submit" value="Yes">
+ </p>
+ </form>
+{% endblock %} \ No newline at end of file
diff --git a/templates/edit_project.html b/templates/edit_project.html
index fbbafdc..dc2d78e 100644
--- a/templates/edit_project.html
+++ b/templates/edit_project.html
@@ -7,3 +7,6 @@
</p>
<script src="{{ url_for('static', filename="edit.js") }}"></script>
{% endblock %}
+{% block footer %}
+ &bullet; <a href="{{ url_for('projects', project_name=project.id) }}">Back to project</a>
+{% endblock %}
diff --git a/templates/gallery.html b/templates/gallery.html
index 6f6b013..590b38b 100644
--- a/templates/gallery.html
+++ b/templates/gallery.html
@@ -1,13 +1,14 @@
<div class="gallery">
{% for project in projects %}
- <a href="{{ url_for("projects", project_name=project.id) }}">
- <div class="gallery-element">
+ <a class="gallery-element" href="{{ url_for("projects", project_name=project.id) }}">
+ <div>
+ <b>{{ project.name }}</b><br/>
{{ project.summary }}
</div>
</a>
{% endfor %}
- <a href="https://github.com/romangraef">
- <div class="gallery-element">
+ <a class="gallery-element" href="https://github.com/romangraef">
+ <div>
And many more on Github
</div>
</a>
diff --git a/templates/login.html b/templates/login.html
index 118bf99..32059c6 100644
--- a/templates/login.html
+++ b/templates/login.html
@@ -8,7 +8,7 @@
</p>
<p>
<label for="pass">Password</label>
- <input id="pass" name="pass" placeholder="Password">
+ <input id="pass" name="pass" type="password" placeholder="Password">
</p>
<p>
<input type="submit" value="Login">
diff --git a/templates/new.html b/templates/new.html
index 32e0eff..79df385 100644
--- a/templates/new.html
+++ b/templates/new.html
@@ -2,6 +2,7 @@
{% block body %}
<form id="form" action="{{ url_for('new_project') }}" method="post">
{% set id_disabled = False %}
+ {% set project = empty_project %}
{% include "project_fields.html" %}
<input type="submit" value="Create">
</form>
diff --git a/templates/project.html b/templates/project.html
index 076e0a2..e4fcfc8 100644
--- a/templates/project.html
+++ b/templates/project.html
@@ -2,5 +2,11 @@
{% block body %}
<h1>{{ project.name }}</h1>
<p>{{ project.description }}</p>
+ <p class="spacer"></p>
<p><a href="{{ project.link }}">Link</a></p>
{% endblock %}
+{% block admin_footer %}
+ &bullet; <a href="{{ url_for('edit_project', project_name=project.id) }}">Edit</a>
+ &bullet; <a href="{{ url_for('delete_project', project_name=project.id) }}" style="color:red;">Delete</a>
+{% endblock %}
+
diff --git a/templates/project_fields.html b/templates/project_fields.html
index 50472c1..c128fd5 100644
--- a/templates/project_fields.html
+++ b/templates/project_fields.html
@@ -1,4 +1,3 @@
-{% set project = empty_project %}
<p>
<label for="id">Id</label><input name="id" id="id" value="{{ project.id }}"
{% if id_disabled %}