commit d597321a76af29356074ac502cf5dd28ba70b22f
parent e6df7f30af8a97a3cff1db7e10bde7e5af8e24b3
Author: parazyd <parazyd@dyne.org>
Date: Sat, 19 Jan 2019 21:42:46 +0100
Remove Contact and add City.
Diffstat:
8 files changed, 127 insertions(+), 127 deletions(-)
diff --git a/db.py b/db.py
@@ -50,7 +50,7 @@ def initdb(dbpath):
embark text NOT NULL,
disembark text NOT NULL,
email text,
- contact text,
+ city text,
story text NOT NULL,
timestamp integer NOT NULL,
visible integer NOT NULL,
diff --git a/diaspora.py b/diaspora.py
@@ -35,13 +35,13 @@ app = Flask(__name__)
app.add_template_global(makenav)
-@app.route('/submit', methods=['GET', 'POST'])
-def submit():
+@app.route('/write', methods=['GET', 'POST'])
+def write():
"""
- Route for submitting a story.
+ Route for writing a story.
"""
if request.method != 'POST':
- return render_template('submit.html')
+ return render_template('write.html')
delkey = randomstring(32)
storyargs = [
@@ -50,7 +50,7 @@ def submit():
request.form['Embark'],
request.form['Disembark'],
request.form['Email'],
- request.form['Contact'],
+ request.form['City'],
request.form['Story'],
int(time()),
0,
@@ -63,7 +63,7 @@ def submit():
if request.form['Email']:
make_profile(request.form['Name'], request.form['Email'])
- return render_template('success_submit.html', delkey=delkey)
+ return render_template('success_write.html', delkey=delkey)
@app.route('/edit', methods=['GET', 'POST'])
@@ -82,7 +82,7 @@ def edit():
('embark', request.form['Embark']),
('disembark', request.form['Disembark']),
('email', request.form['Email']),
- ('contact', request.form['Contact']),
+ ('city', request.form['City']),
('story', request.form['Story']),
('abstract', request.form['Abstract']),
]
diff --git a/templates/nav.html b/templates/nav.html
@@ -13,7 +13,7 @@
<a class="nav-link" href="/">Home</a>
</li>
<li class="nav-item">
- <a class="nav-link" href="/submit">Write!</a>
+ <a class="nav-link" href="/write">Write!</a>
</li>
<li class="nav-item dropdown">
diff --git a/templates/submit.html b/templates/submit.html
@@ -1,94 +0,0 @@
-{% include 'header.html' %}
-
- <title>Write | Diaspora Diaries</title>
-
- <link href="https://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.11/summernote-bs4.css" rel="stylesheet">
- <script src="https://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.11/summernote-bs4.js"></script>
- <script src="/static/js/summernote-cleaner.js"></script>
-
- <script>
- function countryCheck(that, idname) {
- if (that.value == "nn") {
- document.getElementById(idname).style.display = "inline";
- } else {
- document.getElementById(idname).style.display = "none";
- }
- }
- </script>
-
-{% include 'nav.html' %}
-
- <main role="main" class="container">
-
- <form action="/submit" method="POST" id="storyform">
- <p class="lead">Name:<br>
- <input type="text" name="Name" required placeholder="Name">
- </p>
-
- <p class="lead">Country of embarkment:<br>
- <select name="Embark" form="storyform" onchange="countryCheck(this, 'embarkother');">
- {% include 'cc.html' %}
- </select>
- <input type="text" name="EmbarkOther" id="embarkother" style="display: none;" placeholder="Type country here">
- </p>
-
- <p class="lead">Country of disembarkment:<br>
- <select name="Disembark" form="storyform" onchange="countryCheck(this, 'disembarkother');">
- {% include 'cc.html' %}
- </select>
- <input type="text" name="DisembarkOther" id="disembarkother" style="display: none;" placeholder="Type country here">
- </p>
-
- <p class="lead">Email:<br>
- <input type="email" name="Email" placeholder="Email">
- </p>
-
- <p class="lead">Contact info:<br>
- <textarea name="Contact" form="storyform"></textarea>
- </p>
-
- <p class="lead">Write your story:<br>
- <textarea id="storytext" name="Story" form="storyform" required></textarea>
- </p>
-
- <input type="submit" value="Submit">
- </form>
-
- </main>
-
- <script>
- $('.summernote').summernote({
- toolbar:[
- ['cleaner',['cleaner']], // The Button
- ['style',['style']],
- ['font',['bold','underline','clear']],
- ['fontname',['fontname']],
- ['color',['color']],
- ['para',['ul','ol','paragraph']],
- ['height',['height']],
- ['table',['table']],
- ['insert',['media','link','hr']],
- ['view',['fullscreen','codeview']],
- ['help',['help']]
- ],
- cleaner:{
- action: 'both', // both|button|paste
- newline: '<br>', // Summernote's default is to use '<p><br></p>'
- notStyle: 'position:absolute;top:0;left:0;right:0', // Position of Notification
- icon: '<i class="note-icon">[Your Button]</i>',
- keepHtml: false, // Remove all Html formats
- keepOnlyTags: ['<p>', '<br>', '<ul>', '<li>', '<b>', '<strong>','<i>', '<a>'], // If keepHtml is true, remove all tags except these
- keepClasses: false, // Remove Classes
- badTags: ['style', 'script', 'applet', 'embed', 'noframes', 'noscript', 'html'], // Remove full tags with contents
- badAttributes: ['style', 'start'], // Remove attributes from remaining tags
- limitChars: false, // 0/false|# 0/false disables option
- limitDisplay: 'both', // text|html|both
- limitStop: false // true/false
- }
- });
-
- $(document).ready(function() {
- $('#storytext').summernote();
- });
- </script>
-{% include 'footer.html' %}
diff --git a/templates/success_submit.html b/templates/success_submit.html
@@ -1,21 +0,0 @@
-{% include 'header.html' %}
-
- <title>Submitted | Diaspora Diaries</title>
-
-{% include 'nav.html' %}
-
- <main role="main" class="container cover">
-
- <h1 class="cover-heading">Story submitted!</h1>
-
- <p class="lead">Thank you for submitting your story!</p>
-
- <p class="lead">Bookmark or copy the following link if you ever wish to
- delete your post: <a href="/delete?key={{ delkey }}">delete link</a>
- </p>
-
- <p class="lead">You can return to the <a href="/">homepage</a> now.</p>
-
- </main>
-
-{% include 'footer.html' %}
diff --git a/templates/success_write.html b/templates/success_write.html
@@ -0,0 +1,21 @@
+{% include 'header.html' %}
+
+ <title>Submitted | Diaspora Diaries</title>
+
+{% include 'nav.html' %}
+
+ <main role="main" class="container cover">
+
+ <h1 class="cover-heading">Story submitted!</h1>
+
+ <p class="lead">Thank you for writing your story!</p>
+
+ <p class="lead">Bookmark or copy the following link if you ever wish to
+ delete your post: <a href="/delete?key={{ delkey }}">delete link</a>
+ </p>
+
+ <p class="lead">You can return to the <a href="/">homepage</a> now.</p>
+
+ </main>
+
+{% include 'footer.html' %}
diff --git a/templates/write.html b/templates/write.html
@@ -0,0 +1,94 @@
+{% include 'header.html' %}
+
+ <title>Write | Diaspora Diaries</title>
+
+ <link href="https://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.11/summernote-bs4.css" rel="stylesheet">
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.11/summernote-bs4.js"></script>
+ <script src="/static/js/summernote-cleaner.js"></script>
+
+ <script>
+ function countryCheck(that, idname) {
+ if (that.value == "nn") {
+ document.getElementById(idname).style.display = "inline";
+ } else {
+ document.getElementById(idname).style.display = "none";
+ }
+ }
+ </script>
+
+{% include 'nav.html' %}
+
+ <main role="main" class="container">
+
+ <form action="/submit" method="POST" id="storyform">
+ <p class="lead">Name:<br>
+ <input type="text" name="Name" required placeholder="Name">
+ </p>
+
+ <p class="lead">Country of embarkment:<br>
+ <select name="Embark" form="storyform" onchange="countryCheck(this, 'embarkother');">
+ {% include 'cc.html' %}
+ </select>
+ <input type="text" name="EmbarkOther" id="embarkother" style="display: none;" placeholder="Type country here">
+ </p>
+
+ <p class="lead">Country of disembarkment:<br>
+ <select name="Disembark" form="storyform" onchange="countryCheck(this, 'disembarkother');">
+ {% include 'cc.html' %}
+ </select>
+ <input type="text" name="DisembarkOther" id="disembarkother" style="display: none;" placeholder="Type country here">
+ </p>
+
+ <p class="lead">City of the story:<br>
+ <input type="city" name="City" placeholder="City (optional)">
+ </p>
+
+ <p class="lead">Email:<br>
+ <input type="email" name="Email" placeholder="Email (optional)">
+ </p>
+
+ <p class="lead">Write your story:<br>
+ <textarea id="storytext" name="Story" form="storyform" required></textarea>
+ </p>
+
+ <input type="submit" value="Submit">
+ </form>
+
+ </main>
+
+ <script>
+ $('.summernote').summernote({
+ toolbar:[
+ ['cleaner',['cleaner']], // The Button
+ ['style',['style']],
+ ['font',['bold','underline','clear']],
+ ['fontname',['fontname']],
+ ['color',['color']],
+ ['para',['ul','ol','paragraph']],
+ ['height',['height']],
+ ['table',['table']],
+ ['insert',['media','link','hr']],
+ ['view',['fullscreen','codeview']],
+ ['help',['help']]
+ ],
+ cleaner:{
+ action: 'both', // both|button|paste
+ newline: '<br>', // Summernote's default is to use '<p><br></p>'
+ notStyle: 'position:absolute;top:0;left:0;right:0', // Position of Notification
+ icon: '<i class="note-icon">[Your Button]</i>',
+ keepHtml: false, // Remove all Html formats
+ keepOnlyTags: ['<p>', '<br>', '<ul>', '<li>', '<b>', '<strong>','<i>', '<a>'], // If keepHtml is true, remove all tags except these
+ keepClasses: false, // Remove Classes
+ badTags: ['style', 'script', 'applet', 'embed', 'noframes', 'noscript', 'html'], // Remove full tags with contents
+ badAttributes: ['style', 'start'], // Remove attributes from remaining tags
+ limitChars: false, // 0/false|# 0/false disables option
+ limitDisplay: 'both', // text|html|both
+ limitStop: false // true/false
+ }
+ });
+
+ $(document).ready(function() {
+ $('#storytext').summernote();
+ });
+ </script>
+{% include 'footer.html' %}
diff --git a/utils.py b/utils.py
@@ -64,7 +64,7 @@ def fill_story(row):
'disembark': row[3],
'disembarkname': getcountryname(row[3]),
'email': row[4],
- 'contact': row[5],
+ 'city': row[5],
'story': row[6],
'date': strftime('%d.%m.%Y.', gmtime(row[7])),
'time': strftime('%H:%M UTC', gmtime(row[7])),
@@ -131,8 +131,8 @@ def makenav(randomize=True):
havec = list(set(havec))
navlist = [(i, getcountryname(i)) for i in havec]
- if randomize:
- shuffle(navlist)
+ #if randomize:
+ # shuffle(navlist)
return navlist