Przeglądaj źródła

Style tweaks, add site_name setting

master
Dylan Baker 5 lat temu
rodzic
commit
e7bf107409

+ 101
- 45
assets/scss/style.scss Wyświetl plik

1
+/* variables */
2
+
3
+$black:       #000000;
4
+$white:       #ffffff;
5
+$blue:        #496893;
6
+$red:         #ff0000;
7
+$light-gray:  #f5f5f5;
8
+$medium-gray: #c8c8c8;
9
+
10
+$body-font-family: Georgia, serif;
11
+
12
+$body-font-size:    18px;
13
+$heading-font-size: 26px;
14
+
1
 /* global */
15
 /* global */
2
 
16
 
3
 * {
17
 * {
11
 }
25
 }
12
 
26
 
13
 a {
27
 a {
28
+  color: $blue;
14
   text-decoration: none;
29
   text-decoration: none;
30
+
31
+  &:hover {
32
+   text-decoration: underline;
33
+  }
34
+}
35
+
36
+body {
37
+  font-family: $body-font-family;
38
+  font-size: $body-font-size;
39
+  line-height: 1.5;
40
+  min-height: 100vh;
15
 }
41
 }
16
 
42
 
17
 .heading {
43
 .heading {
18
-  border-bottom: 1px solid #000000;
19
-  font-size: 24px;
44
+  border-bottom: 1px solid $black;
45
+  font-size: $heading-font-size;
20
   margin-bottom: 15px;
46
   margin-bottom: 15px;
21
 }
47
 }
22
 
48
 
23
 /* layout */
49
 /* layout */
24
 
50
 
25
 .container {
51
 .container {
52
+  border-left: 1px solid $medium-gray;
53
+  border-right: 1px solid $medium-gray;
26
   display: flex;
54
   display: flex;
55
+  flex-direction: column;
56
+  margin: auto;
57
+  max-width: 768px;
58
+  min-height: 100vh;
27
 }
59
 }
28
 
60
 
29
 .main {
61
 .main {
62
+  background: $light-gray;
30
   display: flex;
63
   display: flex;
31
   flex: 1;
64
   flex: 1;
32
-  justify-content: center;
33
   padding: 20px;
65
   padding: 20px;
66
+  width: 100%;
34
 }
67
 }
35
 
68
 
36
-.main__container {
37
-  width: 768px;
38
-}
69
+/* header */
70
+.header {
71
+  background: $blue;
72
+  color: $white;
39
 
73
 
40
-/* sidebar */
41
-.sidebar {
42
-  background: #496893;
43
-  color: #ffffff;
44
-  min-height: 100vh;
45
-  padding: 20px 0;
46
-  width: 150px;
74
+  @media(max-width: 1000px) {
75
+    min-height: auto;
76
+    width: 100%;
77
+  }
47
 }
78
 }
48
 
79
 
49
-.sidebar__title {
50
-  color: #ffffff;
80
+.header__title {
81
+  color: $white;
51
   font-size: 24px;
82
   font-size: 24px;
83
+  padding: 15px;
52
 }
84
 }
53
 
85
 
54
-.sidebar__title,
55
-.nav__item {
56
-  padding: 5px 10px;
57
-}
58
-
59
-.nav__item:hover {
60
-  background: #ffffff;
86
+.nav {
87
+  background: $white;
88
+  display: flex;
89
+  justify-content: space-between;
90
+  padding: 10px 0;
61
 }
91
 }
62
 
92
 
63
-.nav__item:hover a {
64
-  color: #496893;
93
+.nav__item {
94
+  padding: 5px 10px;
65
 }
95
 }
66
 
96
 
67
-.nav__link {
68
-  color: white;
69
-}
97
+/* forms */
70
 
98
 
71
-.nav__link:hover {
72
-  text-decoration: underline;
99
+.form {
100
+  width: 100%;
73
 }
101
 }
74
 
102
 
75
-/* forms */
76
-
77
 .form__field {
103
 .form__field {
78
   display: flex;
104
   display: flex;
79
   flex-direction: column;
105
   flex-direction: column;
80
-  margin: 5px 0;
106
+  margin: 15px 0;
81
   width: 100%;
107
   width: 100%;
82
 }
108
 }
83
 
109
 
110
+.form__field--submit {
111
+  display: block;
112
+}
113
+
84
 .form__field,
114
 .form__field,
85
 .form__label {
115
 .form__label {
86
   margin-bottom: 5px;
116
   margin-bottom: 5px;
89
 .form__date-field,
119
 .form__date-field,
90
 .form__textarea,
120
 .form__textarea,
91
 .form__text-field {
121
 .form__text-field {
92
-  border: 1px solid #e8e8e8;
93
-  font-family: serif;
94
-  font-size: 16px;
95
-  padding: 5px;
122
+  border: 1px solid $medium-gray;
123
+  font-family: $body-font-family;
124
+  font-size: $body-font-size;
125
+  padding: 10px;
96
 }
126
 }
97
 
127
 
98
 .form__textarea {
128
 .form__textarea {
99
   resize: vertical;
129
   resize: vertical;
100
 }
130
 }
101
 
131
 
102
-.form__submit {
103
-  border: 1px solid #e8e8e8;
104
-  padding: 5px 10px;
132
+.button.form__submit {
133
+  background: $white;
134
+  border: 1px solid $medium-gray;
135
+  cursor: pointer;
136
+  font-family: $body-font-family;
137
+  font-size: $body-font-size;
138
+  padding: 10px;
139
+
140
+  &:hover {
141
+    background: $light-gray;
142
+  }
143
+
144
+  @media(max-width: 500px) {
145
+    width: 100%;
146
+  }
105
 }
147
 }
106
 
148
 
107
 /* post listing */
149
 /* post listing */
150
+
151
+.post-listing {
152
+  width: 100%;
153
+}
154
+
108
 .post-listing__item {
155
 .post-listing__item {
156
+  display: flex;
157
+  padding: 10px;
109
   position: relative;
158
   position: relative;
159
+  width: 100%;
160
+
161
+  &:nth-child(even) {
162
+    background: white;
163
+  }
110
 }
164
 }
111
 
165
 
112
 .post-listing__item--changed:before {
166
 .post-listing__item--changed:before {
113
-  background-color: red;
114
-  border-radius: 50%;
115
-  content: '';
167
+  color: $red;
168
+  content: '•';
116
   display: block;
169
   display: block;
117
-  height: 10px;
170
+  font-size: $heading-font-size;
118
   left: -15px;
171
   left: -15px;
172
+  line-height: 16px;
119
   position: absolute;
173
   position: absolute;
120
-  top: 3px;
121
-  width: 10px;
174
+}
175
+
176
+.post-listing__link {
177
+  flex: 1;
122
 }
178
 }

+ 2
- 1
tests/test_posts.py Wyświetl plik

16
     os.mkdir(os.path.join(temp_dir.name, 'public'))
16
     os.mkdir(os.path.join(temp_dir.name, 'public'))
17
     with open(os.path.join(temp_dir.name, 'settings.json'), "w") as f:
17
     with open(os.path.join(temp_dir.name, 'settings.json'), "w") as f:
18
         f.write(json.dumps({
18
         f.write(json.dumps({
19
-            "PUBLIC_PATH": os.path.join(temp_dir.name, 'public')
19
+            "PUBLIC_PATH": os.path.join(temp_dir.name, 'public'),
20
+            "SITE_NAME": "test website"
20
         }))
21
         }))
21
 
22
 
22
     # Importing PostsService initializes a Settings object which depends on
23
     # Importing PostsService initializes a Settings object which depends on

+ 2
- 1
tests/test_settings.py Wyświetl plik

20
     os.environ["YIRD_PATH"] = root
20
     os.environ["YIRD_PATH"] = root
21
     with open(os.path.join(root, "settings.json"), "w") as f:
21
     with open(os.path.join(root, "settings.json"), "w") as f:
22
         f.write(json.dumps({
22
         f.write(json.dumps({
23
-            "PUBLIC_PATH": os.path.join(root, "public")
23
+            "PUBLIC_PATH": os.path.join(root, "public"),
24
+            "SITE_NAME": "test website"
24
         }))
25
         }))
25
     assert Settings().YIRD_PATH == root
26
     assert Settings().YIRD_PATH == root
26
     shutil.rmtree(root)
27
     shutil.rmtree(root)

+ 7
- 0
yird/app.py Wyświetl plik

20
 yird_settings = Settings()
20
 yird_settings = Settings()
21
 
21
 
22
 
22
 
23
+@app.context_processor
24
+def inject_site_name():
25
+    return {
26
+        "site_name": yird_settings.SITE_NAME
27
+    }
28
+
29
+
23
 @app.route('/admin')
30
 @app.route('/admin')
24
 def index():
31
 def index():
25
     posts = PostsService.get_posts()
32
     posts = PostsService.get_posts()

+ 1
- 0
yird/settings.py Wyświetl plik

11
         with open(os.path.join(self.YIRD_PATH, 'settings.json')) as f:
11
         with open(os.path.join(self.YIRD_PATH, 'settings.json')) as f:
12
             settings_file = json.loads(f.read())
12
             settings_file = json.loads(f.read())
13
             self.PUBLIC_PATH = settings_file['PUBLIC_PATH']
13
             self.PUBLIC_PATH = settings_file['PUBLIC_PATH']
14
+            self.SITE_NAME = settings_file['SITE_NAME']

+ 2
- 2
yird/templates/index.html.j2 Wyświetl plik

4
     <h3 class="heading">all posts</h3>
4
     <h3 class="heading">all posts</h3>
5
     {% for post in posts %}
5
     {% for post in posts %}
6
       <li class="post-listing__item {% if post.changed %}post-listing__item--changed{% endif %}">
6
       <li class="post-listing__item {% if post.changed %}post-listing__item--changed{% endif %}">
7
-        <span>{{ post.date }}</span>
8
-        <a href="{{ url_for('edit_post', post_id = post.id) }}">
7
+        <a href="{{ url_for('edit_post', post_id = post.id) }}" class="post-listing__link">
9
           {{ post.title }}
8
           {{ post.title }}
10
          </a>
9
          </a>
10
+        <span>{{ post.date }}</span>
11
       </li>
11
       </li>
12
     {% endfor %}
12
     {% endfor %}
13
   </ul>
13
   </ul>

+ 5
- 7
yird/templates/layout.html.j2 Wyświetl plik

4
   <meta charset="UTF-8">
4
   <meta charset="UTF-8">
5
   <meta name="viewport" content="width=device-width">
5
   <meta name="viewport" content="width=device-width">
6
   <link rel="stylesheet" href="{{ url_for('static', filename=asset_url_for('app_css.css')) }}">
6
   <link rel="stylesheet" href="{{ url_for('static', filename=asset_url_for('app_css.css')) }}">
7
-  <title>My Website</title>
7
+  <title>{{ site_name }} - yird</title>
8
 </head>
8
 </head>
9
 <body>
9
 <body>
10
   <div class="container">
10
   <div class="container">
11
-    <aside class="sidebar">
12
-      <h3 class="sidebar__title">yird</h3>
11
+    <header class="header">
12
+      <h3 class="header__title">{{ site_name }}</h3>
13
       <ul class="nav">
13
       <ul class="nav">
14
      		<li class="nav__item">
14
      		<li class="nav__item">
15
 					<a class="nav__link" href="{{ url_for('index') }}">
15
 					<a class="nav__link" href="{{ url_for('index') }}">
27
           </a>
27
           </a>
28
         </li>
28
         </li>
29
       </ul>
29
       </ul>
30
-    </aside>
30
+    </header>
31
     <main class="main">
31
     <main class="main">
32
-      <div class="main__container">
33
-        {% block content %}{% endblock %}
34
-      </div>
32
+      {% block content %}{% endblock %}
35
     </main>
33
     </main>
36
   </div>
34
   </div>
37
   <script src="{{ url_for('static', filename=asset_url_for('app_js.js')) }}"></script>
35
   <script src="{{ url_for('static', filename=asset_url_for('app_js.js')) }}"></script>

+ 2
- 2
yird/templates/posts/form.html.j2 Wyświetl plik

21
       <label class="form__label">{{ form.content.label }}</label>
21
       <label class="form__label">{{ form.content.label }}</label>
22
       {{ form.content(class="form__textarea", rows=10) }}
22
       {{ form.content(class="form__textarea", rows=10) }}
23
     </div>
23
     </div>
24
-    <div class="form__field">
25
-      <input type="submit" value="Submit" class="form__submit">
24
+    <div class="form__field form__field--submit">
25
+      <input type="submit" value="Submit" class="form__submit button">
26
     </div>
26
     </div>
27
   </form>
27
   </form>
28
 {% endblock %}
28
 {% endblock %}

Ładowanie…
Anuluj
Zapisz