Browse Source

Add stash link to index page. opens a list of files to edit to easy access.

ozgurOdun 6 years ago
parent
commit
19306b6e55
4 changed files with 81 additions and 2 deletions
  1. 2 2
      main.go
  2. 33 0
      static/css/index.css
  3. 1 0
      templates/index.tmpl
  4. 45 0
      templates/stash.tmpl

+ 2 - 2
main.go

@@ -113,8 +113,8 @@ func NewApp() *gin.Engine {
 		for _, file := range files {
 			stash = append(stash, file.Name())
 		}
-		c.JSON(200, gin.H{
-			"data": stash,
+		c.HTML(200, "stash.tmpl", gin.H{
+			"stash": stash,
 		})
 	})
 

+ 33 - 0
static/css/index.css

@@ -38,3 +38,36 @@ body {
   width: 100%;
   border: none;
 }
+#stash-pane {
+  position: fixed;
+  top: 0;
+  width: 60%;
+  height: 100%;
+  font-size: 16px;
+}
+#stash-pane #controls {
+  color: #2e2e2e;
+  position: absolute;
+  right: 0;
+  top: 0;
+  z-index: 1;
+  margin: 5px 5px 0 0;
+}
+#stash-pane #controls a {
+  font-weight: bold;
+  text-decoration: none;
+  color: #2e2e2e;
+}
+th, td {
+    text-align: left;
+    padding: 8px;
+     border-bottom: 1px solid #ddd;
+     font-size: 16px;
+}
+
+tr:nth-child(even){background-color: #f2f2f2}
+
+th {
+    background-color: #2e2e2e;
+    color: white;
+}

+ 1 - 0
templates/index.tmpl

@@ -14,6 +14,7 @@
     <body>
         <div id="edit-pane">
           <div id="controls">
+          <a href="/stash" target="_blank" onclick="save();"> Stash</a> | 
             <a href="/published/{{ .pubTo}}" target="_blank" onclick="save();"> Present</a> |
             <a href="/published/{{ .pubTo}}?print-pdf" target="_blank" onclick="save();"> Pdf</a>
           </div>

+ 45 - 0
templates/stash.tmpl

@@ -0,0 +1,45 @@
+{{ define "stash.tmpl"}}
+<!DOCTYPE html>
+<html lang="en">
+
+    <head>
+        <meta charset="utf-8">
+
+        <title>Hacker Slides</title>
+
+        <link rel="stylesheet" href="/static/css/index.css">
+    </head>
+
+    <body>
+        <div id="stash-pane">
+          <div id="controls">
+          <a href="/stash" target="_blank" onclick="save();"> Stash</a> | 
+            <a href="/published/{{ .pubTo}}" target="_blank" onclick="save();"> Present</a> |
+            <a href="/published/{{ .pubTo}}?print-pdf" target="_blank" onclick="save();"> Pdf</a>
+          </div>
+          <div></div>
+          <div id ="list">
+          	<table>
+          		<tr>
+          			<th>Name</th>
+          			<th>Action</th>
+          		</tr>
+	          	{{range .stash}}
+	          		<tr>
+		          		<td><p>{{.}}</p></td>
+		          		<td><a href="/stash/edit/{{.}}" target ="_blank" onclick="save();">Edit</a></td>
+	          		</tr>
+	          	{{end}}
+          	</table>
+          </div>
+        </div>
+      
+        <script src="/static/revealjs/js/ace-1.1.8/ace.js" type="text/javascript" charset="utf-8"></script>
+        <script src="/static/revealjs/js/jquery-2.1.3.min.js" type="text/javascript" charset="utf-8"></script>
+        <script src="/static/revealjs/js/jquery-debounce-1.0.5.js" type="text/javascript" charset="utf-8"></script>
+        <script src="/static/js/save.js" type="text/javascript" charset="utf-8"></script>
+        <script src="/static/js/index.js" type="text/javascript" charset="utf-8"></script>
+    </body>
+</html>
+
+{{ end }}