Explorar el Código

Show flash after generating static files

master
Dylan Baker hace 5 años
padre
commit
29c5f767a1
Se han modificado 3 ficheros con 23 adiciones y 2 borrados
  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 Ver fichero

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

+ 5
- 2
yird/app.py Ver fichero

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

+ 9
- 0
yird/templates/layout.html.j2 Ver fichero

37
           </form>
37
           </form>
38
         </p>
38
         </p>
39
       {% endif %}
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
     </header>
49
     </header>
41
     <main class="main">
50
     <main class="main">
42
       {% block content %}{% endblock %}
51
       {% block content %}{% endblock %}

Loading…
Cancelar
Guardar