瀏覽代碼

Snippet view styles

master
Dylan Baker 5 年之前
父節點
當前提交
39ccc764c3
共有 2 個文件被更改,包括 26 次插入7 次删除
  1. 3
    2
      src/snippet.rs
  2. 23
    5
      templates/snippets/show.html.tera

+ 3
- 2
src/snippet.rs 查看文件

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

+ 23
- 5
templates/snippets/show.html.tera 查看文件

11
       .header {
11
       .header {
12
         align-items: baseline;
12
         align-items: baseline;
13
         display: flex;
13
         display: flex;
14
+        flex-wrap: wrap;
15
+        font-family: serif;
14
         justify-content: space-between;
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
       .header__raw-link {
32
       .header__raw-link {
24
         background-color: #f5f5f5;
38
         background-color: #f5f5f5;
25
         counter-reset: line;
39
         counter-reset: line;
26
         font-size: 16px;
40
         font-size: 16px;
41
+        margin: 0;
27
         padding: 15px;
42
         padding: 15px;
28
       }
43
       }
29
 
44
 
41
   <body>
56
   <body>
42
     <div class="container">
57
     <div class="container">
43
       <h1 class="header">
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
       </h1>
66
       </h1>
49
       <div class="body">
67
       <div class="body">
50
         {% set length = context.lines | length - 1 %}
68
         {% set length = context.lines | length - 1 %}

Loading…
取消
儲存