Browse Source

Use separate stylesheet, clean up styles

master
Dylan Baker 5 years ago
parent
commit
3d75af53e2
5 changed files with 69 additions and 64 deletions
  1. 1
    1
      Cargo.toml
  2. 2
    0
      src/main.rs
  3. 61
    0
      static/style.css
  4. 4
    14
      templates/index.html.tera
  5. 1
    49
      templates/snippets/show.html.tera

+ 1
- 1
Cargo.toml View File

@@ -21,4 +21,4 @@ syntect = "3.2.0"
21 21
 [dependencies.rocket_contrib]
22 22
 version = "0.4.0"
23 23
 default-features = false
24
-features = ["json", "tera_templates"]
24
+features = ["json", "serve", "tera_templates"]

+ 2
- 0
src/main.rs View File

@@ -16,6 +16,7 @@ extern crate serde_derive;
16 16
 extern crate syntect;
17 17
 
18 18
 use dotenv::dotenv;
19
+use rocket_contrib::serve::StaticFiles;
19 20
 use rocket_contrib::templates::Template;
20 21
 
21 22
 mod connection;
@@ -39,6 +40,7 @@ fn main() {
39 40
             "/",
40 41
             routes![index, show_snippet, show_raw_snippet, create_snippet],
41 42
         )
43
+        .mount("/static", StaticFiles::from("static"))
42 44
         .register(catchers![bad_request, not_found])
43 45
         .launch();
44 46
 }

+ 61
- 0
static/style.css View File

@@ -0,0 +1,61 @@
1
+.container {
2
+  margin: auto;
3
+  max-width: 800px;
4
+}
5
+
6
+.container--narrow {
7
+  max-width: 500px;
8
+}
9
+
10
+.header {
11
+  align-items: baseline;
12
+  display: flex;
13
+  flex-wrap: wrap;
14
+  font-family: serif;
15
+  justify-content: space-between;
16
+  margin-bottom: 10px;
17
+  padding: 0;
18
+}
19
+
20
+.header__title {
21
+  font-size: 28px;
22
+  margin-right: 10px;
23
+}
24
+
25
+.header__date {
26
+  font-size: 16px;
27
+  font-weight: normal;
28
+  margin-right: 10px;
29
+}
30
+
31
+.header__raw-link {
32
+  font-size: 16px;
33
+  font-weight: normal;
34
+}
35
+
36
+pre {
37
+  background-color: #f5f5f5;
38
+  counter-reset: line;
39
+  font-size: 16px;
40
+  margin: 0;
41
+  padding: 15px;
42
+}
43
+
44
+pre code {
45
+    counter-increment: line;
46
+}
47
+
48
+pre code:before {
49
+    content: counter(line);
50
+    margin-right: 10px;
51
+}
52
+
53
+pre.shell {
54
+  margin: 10px 0;
55
+  padding: 5px;
56
+}
57
+
58
+pre.shell:before {
59
+  content: '$';
60
+  margin-right: 10px;
61
+}

+ 4
- 14
templates/index.html.tera View File

@@ -1,21 +1,11 @@
1 1
 <html>
2 2
   <head>
3 3
     <title>bngl.ws</title>
4
-    <style>
5
-      .container {
6
-        margin: auto;
7
-        max-width: 500px;
8
-      }
9
-
10
-      pre {
11
-        background: #f5f5f5;
12
-        padding: 5px;
13
-      }
14
-    </style>
4
+    <link rel="stylesheet" href="/static/style.css">
15 5
     <meta name="viewport" content="width=device-width">
16 6
   </head>
17 7
   <body>
18
-    <div class="container">
8
+    <div class="container container--narrow">
19 9
       <h1>bngl.ws</h1>
20 10
 			<p>
21 11
 				bngl.ws is a pastebin service that you can access from the command
@@ -24,9 +14,9 @@
24 14
 				cargo</a> installed, you can install the CLI client by cloning the
25 15
 				<a href="https://git.sr.ht/~simulacrumparty/bnglws-client" target="_blank">client repo</a>
26 16
 				and running
27
-				<pre>cargo install --path .</pre>
17
+				<pre class="shell">cargo install --path .</pre>
28 18
 				Then, you can create snippets by running something like
29
-				<pre>echo 'Hello world' | bngl new "First snippet"</pre>
19
+				<pre class="shell">echo 'Hello world' | bngl new "First snippet"</pre>
30 20
 			</p>
31 21
     </div>
32 22
   </body>

+ 1
- 49
templates/snippets/show.html.tera View File

@@ -2,55 +2,7 @@
2 2
 <html>
3 3
   <head>
4 4
     <title>{{ snippet.title }}</title>
5
-    <style>
6
-      .container {
7
-        margin: auto;
8
-        max-width: 800px;
9
-      }
10
-
11
-      .header {
12
-        align-items: baseline;
13
-        display: flex;
14
-        flex-wrap: wrap;
15
-        font-family: serif;
16
-        justify-content: space-between;
17
-        margin-bottom: 10px;
18
-        padding: 0;
19
-      }
20
-
21
-      .header__title {
22
-        font-size: 28px;
23
-        margin-right: 10px;
24
-      }
25
-
26
-      .header__date {
27
-        font-size: 16px;
28
-        font-weight: normal;
29
-        margin-right: 10px;
30
-      }
31
-
32
-      .header__raw-link {
33
-        font-size: 16px;
34
-        font-weight: normal;
35
-      }
36
-
37
-      pre {
38
-        background-color: #f5f5f5;
39
-        counter-reset: line;
40
-        font-size: 16px;
41
-        margin: 0;
42
-        padding: 15px;
43
-      }
44
-
45
-      pre code {
46
-          counter-increment: line;
47
-      }
48
-
49
-      pre code:before {
50
-          content: counter(line);
51
-          margin-right: 10px;
52
-      }
53
-    </style>
5
+    <link rel="stylesheet" href="/static/style.css">
54 6
     <meta name="viewport" content="width=device-width">
55 7
   </head>
56 8
   <body>

Loading…
Cancel
Save