]> git.mdlowis.com Git - projs/awiki.git/commitdiff
updated from mdlowis.com branch master
authorMichael D. Lowis <mike@mdlowis.com>
Sun, 24 May 2020 02:51:22 +0000 (22:51 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Sun, 24 May 2020 02:51:22 +0000 (22:51 -0400)
awiki.rb
config/page.html.erb

index 6128e9ec25190e730f02d7aac5154887b51c5a20..10e3c527318f2f56f56eca544fab87d5314619ad 100755 (executable)
--- a/awiki.rb
+++ b/awiki.rb
@@ -5,9 +5,7 @@ require 'webrick'
 require 'redcarpet'
 
 # TODO:
 require 'redcarpet'
 
 # TODO:
-# * Copy auxiliary files over
 # * Add page attachment mechanism
 # * Add page attachment mechanism
-# * Add edit shortcut
 # * Add save shortcut
 # * Add a create method
 # * Add a delete method
 # * Add save shortcut
 # * Add a create method
 # * Add a delete method
@@ -22,6 +20,14 @@ VIEW_TEMPLATE = "config/page.html.erb"
 EDIT_TEMPLATE = "config/editor.html.erb"
 PLANTUML_JAR  = "config/plantuml.jar"
 PLANTUML_CMD  = "java -jar #{PLANTUML_JAR} -tsvg -pipe"
 EDIT_TEMPLATE = "config/editor.html.erb"
 PLANTUML_JAR  = "config/plantuml.jar"
 PLANTUML_CMD  = "java -jar #{PLANTUML_JAR} -tsvg -pipe"
+EDIT_SCRIPT   = <<-eos
+  <script>
+  (() => {
+    const keys = { "e": () => { window.location = window.location + "?edit=true" } };
+    document.onkeydown = (ev) => (!!keys[ev.key] ? (keys[ev.key])(ev) : true);
+  })();
+  </script>
+eos
 
 class Page
   def initialize(src)
 
 class Page
   def initialize(src)
@@ -110,8 +116,9 @@ def genpage(path, src, force=false)
     html = File.read(htmlfile)
   end
   gensitemap()
     html = File.read(htmlfile)
   end
   gensitemap()
-  html.sub("<!--EDIT-->",
-           "<a class='navLink shrink' href='#{path}?edit=true'>[edit]</a>")
+  html = html.sub("<!--EDIT-->",
+    "<a class='navLink shrink' href='#{path}?edit=true'>[edit]</a>")
+  html.sub("<!--EDIT_SCRIPT-->", EDIT_SCRIPT)
 end
 
 def do_post(req, res, path)
 end
 
 def do_post(req, res, path)
index 23f089378b5293e6e5cdaef590dcede27326c899..5faa1472366b5674f75b19131ec829edeffd621d 100644 (file)
   </style>
 </head>
 <body>
   </style>
 </head>
 <body>
-    <div class="header">
-        <hr/>
-        <div class="box">
-            <a class="headerLink grow" href="./index.html">
-              <%= @site_title %>
-            </a>
-            <a class="navLink shrink" href='./index.html'>home</a>
-            <a class="navLink shrink" href='./sitemap.html'>sitemap</a>
-            <!--EDIT-->
-        </div>
-        <hr/>
+  <div class="header">
+    <hr/>
+    <div class="box">
+      <a class="headerLink grow" href="/index.html">
+        <%= @site_title %>
+      </a>
+      <a class="navLink shrink" href='/index.html'>home</a>
+      <a class="navLink shrink" href='/sitemap.html'>sitemap</a>
+      <!--EDIT-->
     </div>
     </div>
+    <hr/>
+  </div>
 
 
-    <article>
-      <%= @article %>
-    </article>
+  <article>
+    <%= @article %>
+  </article>
 
 
-    <div class="footer">
-        <hr style="margin-top: 2em"/>
-        <div style="text-align: center">
-          <%= @gendate %>
-        </div>
+  <div class="footer">
+    <hr style="margin-top: 2em"/>
+    <div style="text-align: center">
+      <%= @gendate %>
     </div>
     </div>
+  </div>
+  <!--EDIT_SCRIPT-->
 </body>
 </html>
 </body>
 </html>