Browse Source

Snippet view styles

master
Dylan Baker 5 years ago
parent
commit
39ccc764c3
2 changed files with 26 additions and 7 deletions
  1. 3
    2
      src/snippet.rs
  2. 23
    5
      templates/snippets/show.html.tera

+ 3
- 2
src/snippet.rs View File

@@ -47,10 +47,11 @@ fn format_snippet(filetype: Option<String>, body: String) -> String {
47 47
             ps.find_syntax_by_extension(&filetype).map_or(
48 48
                 format!("<pre class='plaintext'>\n{}\n</pre>", body),
49 49
                 |syntax| {
50
+                    let content = htmlescape::decode_html(&body).expect("Invalid HTML");
50 51
                     highlighted_html_for_string(
51
-                        &htmlescape::decode_html(&body).expect("Invalid HTML"),
52
+                        &content,
52 53
                         &ps,
53
-                        syntax,
54
+                        &syntax,
54 55
                         &ts.themes["Solarized (light)"],
55 56
                     )
56 57
                 },

+ 23
- 5
templates/snippets/show.html.tera View File

@@ -11,8 +11,22 @@
11 11
       .header {
12 12
         align-items: baseline;
13 13
         display: flex;
14
+        flex-wrap: wrap;
15
+        font-family: serif;
14 16
         justify-content: space-between;
15
-        padding: 0 15px;
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;
16 30
       }
17 31
 
18 32
       .header__raw-link {
@@ -24,6 +38,7 @@
24 38
         background-color: #f5f5f5;
25 39
         counter-reset: line;
26 40
         font-size: 16px;
41
+        margin: 0;
27 42
         padding: 15px;
28 43
       }
29 44
 
@@ -41,10 +56,13 @@
41 56
   <body>
42 57
     <div class="container">
43 58
       <h1 class="header">
44
-        {{ snippet.title }}
45
-        <a class="header__raw-link" href="/snippets/{{ snippet.uuid }}/raw">
46
-          raw
47
-        </a>
59
+        <span class="header__title">{{ snippet.title }}</span>
60
+        <div class="header__right">
61
+          <span class="header__date">{{ snippet.created_at | date(format="%Y-%m-%d %H:%M:%S") }} UTC</span>
62
+          <a class="header__raw-link" href="/snippets/{{ snippet.uuid }}/raw">
63
+            view raw
64
+          </a>
65
+        </div>
48 66
       </h1>
49 67
       <div class="body">
50 68
         {% set length = context.lines | length - 1 %}

Loading…
Cancel
Save