Browse Source

Show flash after generating static files

master
Dylan Baker 5 years ago
parent
commit
29c5f767a1
3 changed files with 23 additions and 2 deletions
  1. 9
    0
      assets/scss/style.scss
  2. 5
    2
      yird/app.py
  3. 9
    0
      yird/templates/layout.html.j2

+ 9
- 0
assets/scss/style.scss View File

@@ -4,6 +4,7 @@ $black:       #000000;
4 4
 $white:       #ffffff;
5 5
 $blue:        #496893;
6 6
 $red:         #d9534f;
7
+$green:       #5cb85c;
7 8
 $light-gray:  #f5f5f5;
8 9
 $medium-gray: #c8c8c8;
9 10
 
@@ -46,6 +47,9 @@ body {
46 47
   margin-bottom: 15px;
47 48
 }
48 49
 
50
+/* errors & flashes */
51
+
52
+.notice,
49 53
 .error {
50 54
   align-items: center;
51 55
   color: $white;
@@ -58,6 +62,11 @@ body {
58 62
   background: $red;
59 63
 }
60 64
 
65
+.notice {
66
+  background: $green;
67
+}
68
+
69
+.notice__message,
61 70
 .error__message {
62 71
   flex: 1;
63 72
 }

+ 5
- 2
yird/app.py View File

@@ -1,4 +1,4 @@
1
-from flask import Flask, redirect, render_template, request, url_for
1
+from flask import Flask, flash, redirect, render_template, request, url_for
2 2
 
3 3
 from flask_webpack import Webpack
4 4
 
@@ -12,7 +12,8 @@ app = Flask(__name__)
12 12
 
13 13
 params = {
14 14
     'DEBUG': True,
15
-    'WEBPACK_MANIFEST_PATH': '../manifest.json'
15
+    'WEBPACK_MANIFEST_PATH': '../manifest.json',
16
+    'SECRET_KEY': b'flasndfjlasfnlajsnfs'
16 17
 }
17 18
 app.config.update(params)
18 19
 
@@ -68,6 +69,8 @@ def update_post(post_id):
68 69
 @app.route('/admin/generate')
69 70
 def generate():
70 71
     PostsService.generate_posts()
72
+    flash('Generated static files successfully')
73
+    return redirect(url_for('index'))
71 74
 
72 75
 
73 76
 @app.route('/admin/repo', methods=["GET"])

+ 9
- 0
yird/templates/layout.html.j2 View File

@@ -37,6 +37,15 @@
37 37
           </form>
38 38
         </p>
39 39
       {% endif %}
40
+      {% with messages = get_flashed_messages() %}
41
+        {% if messages %}
42
+          {% for message in messages %}
43
+            <div class="notice">
44
+              <p class="notice__message">{{ message }}</p>
45
+            </div>
46
+          {% endfor %}
47
+        {% endif %}
48
+      {% endwith %}
40 49
     </header>
41 50
     <main class="main">
42 51
       {% block content %}{% endblock %}

Loading…
Cancel
Save