Make gkeep understand list indentation, tweaks to the countdown bar in
authorScott Gasch <[email protected]>
Mon, 13 Jul 2020 23:10:50 +0000 (16:10 -0700)
committerScott Gasch <[email protected]>
Mon, 13 Jul 2020 23:10:50 +0000 (16:10 -0700)
kiosk.py (client side javascript) and add pubdate in generic RSS renderer.

generic_news_rss_renderer.py
gkeep_renderer.py
kiosk.py

index 798c06c90962d001a87ed93f1a9a2114a3ccbc88..5cf6e6c897109bb810b615e39e58560f9f091fe2 100644 (file)
@@ -238,8 +238,8 @@ a:active {
                 if pubdate is not None:
                     pubdate = self.munge_pubdate(pubdate)
                     ts = parse(pubdate)
-                    blurb += u" <FONT COLOR=#cccccc>%s</FONT>" % (
-                        ts.strftime("%b %d"))
+                    blurb += u"  <FONT COLOR=#cccccc>%s</FONT>" % (
+                        ts.strftime("%b&nbsp;%d"))
 
                 if (description is not None and
                     self.item_is_interesting_for_article(title,
index 0285cf13fa70b64af3e2eda480013195014e237e..bad6830e09b85247e333846f8357e6d8f4593251 100644 (file)
@@ -37,7 +37,7 @@ class gkeep_renderer(renderer.debuggable_abstaining_renderer):
         return "gkeep"
 
     def periodic_render(self, key):
-        strikethrough = re.compile('\u2611([^\n]*)\n', re.UNICODE)
+        strikethrough = re.compile('(\u2611[^\n]*)\n', re.UNICODE)
         linkify = re.compile(r'.*(https?:\/\/\S+).*')
 
         self.keep.sync()
@@ -51,18 +51,33 @@ class gkeep_renderer(renderer.debuggable_abstaining_renderer):
             contents = note.text + "\n"
             self.debug_print("Note title '%s'" % title)
             if contents != '' and not contents.isspace():
-                contents = strikethrough.sub(r'<font color="#999999">` <del>\1</del></font>\n', contents)
-                contents = contents.replace('`', '\u2611')
+                contents = strikethrough.sub('', contents)
+                contents = contents.replace(u'\u2610',
+                                            u'<LI><INPUT TYPE="checkbox">&nbsp;')
+
                 #self.debug_print("Note contents:\n%s" % contents)
                 contents = linkify.sub(r'<a href="\1">\1</a>', contents)
+
                 individual_lines = contents.split("\n")
                 num_lines = len(individual_lines)
                 max_length = 0
+                indent = 0
+                contents = ""
                 for x in individual_lines:
                     length = len(x)
                     if length > max_length:
                         max_length = length
-                contents = contents.replace("\n", "<BR>\n")
+                    spaces = len(x) - len(x.lstrip(' '))
+                    spaces /= 2
+                    x = x.lstrip(' ')
+                    if spaces > indent:
+                        x = "<UL>" + x
+                    elif spaces < indent:
+                        x = "</UL>" + x
+                    indent = spaces
+                    contents = contents + x + "\n"
+
+                individual_lines = contents.split("\n")
                 color = note.color.name.lower()
                 if color in list(self.colors_by_name.keys()):
                     color = self.colors_by_name[color]
@@ -71,7 +86,8 @@ class gkeep_renderer(renderer.debuggable_abstaining_renderer):
                 f = file_writer.file_writer(filename)
                 f.write("""
 <STYLE type="text/css">
-a:link { color:#88bfbf; }
+  a:link { color:#88bfbf; }
+  ul { list-style-type:none; }
 </STYLE>
 <DIV STYLE="border-radius: 25px; border-style: solid; padding: 20px; background-color: %s; color: #eeeeee; font-size: x-large;">
 <p style="color: #ffffff; font-size:larger"><B>%s</B></p>
@@ -81,20 +97,20 @@ a:link { color:#88bfbf; }
                                      (num_lines, max_length))
                     f.write("<TABLE BORDER=0 WIDTH=100%%><TR valign=\"top\">")
                     f.write("<TD WIDTH=50%% style=\"color:#eeeeee; font-size:large\">\n")
-                    f.write("<FONT>")
+                    f.write("<FONT><UL>")
                     count = 0
                     for x in individual_lines:
-                        f.write(x + "<BR>\n")
+                        f.write(x + "\n")
                         count += 1
                         if count == num_lines / 2:
-                            f.write("</FONT></TD>\n")
+                            f.write("</UL></FONT></TD>\n")
                             f.write("<TD WIDTH=50%% style=\"color:#eeeeee; font-size:large\">\n")
-                            f.write("<FONT>")
-                    f.write("</FONT></TD></TR></TABLE></DIV>\n");
+                            f.write("<FONT><UL>")
+                    f.write("</UL></FONT></TD></TR></TABLE></DIV>\n");
                 else:
                     self.debug_print("%d lines (max=%d chars): one column" %
                                      (num_lines, max_length))
-                    f.write("<FONT>%s</FONT>" % contents)
+                    f.write("<FONT><UL>%s</UL></FONT>" % contents)
                 f.write("</DIV>")
                 f.close()
             else:
index 5bc28cda4843aba9428c20bf162109173b8ac1eb..fd509101804bf41312d77eccc01ea99b91500bc6 100755 (executable)
--- a/kiosk.py
+++ b/kiosk.py
@@ -172,29 +172,28 @@ def emit_wrapped(f, filename):
     return new Promise(resolve => setTimeout(resolve, milliseconds))
   }
 
-  var loaded = false;
   var loadedDate = new Date();
 
   addLoadEvent(zoomScreen);
   addLoadEvent(runClock);
   addLoadEvent(lateLoadImages);
-  addLoadEvent(function() {
-    loaded = true;
-  });
 
-  // Reload the page after a certain amount of time has passed or
-  // immediately if told to do so.
-  (function poll() {
+  // Runs the countdown line at the bottom and is responsible for
+  // normal page reloads caused by the expiration of a timer.
+  (function countdown() {
     setTimeout(
       function() {
         var now = new Date();
         var deltaMs = now.getTime() - loadedDate.getTime();
-
         var totalMs = %d;
         var remainingMs = (totalMs - deltaMs);
+
         if (remainingMs > 0) {
           var hr = document.getElementById("countdown");
-          var width = (remainingMs / totalMs) * 100.0;
+          var width = (remainingMs / (totalMs - 5000)) * 100.0;
+          if (width > 100) {
+            width = 100;
+          }
           hr.style.width = " ".concat(width, "%%");
           hr.style.backgroundColor = "maroon";
         } else {
@@ -202,7 +201,17 @@ def emit_wrapped(f, filename):
           window.location.reload();
         }
 
-        // Also reload immediately if told to do so.
+        // Brief sleep before doing it all over again.
+        sleep(50).then(() => {
+          countdown();
+        });
+      }, 50)
+  })();
+
+  // Periodically checks for emergency reload events.
+  (function poll() {
+    setTimeout(
+      function() {
         var xhr = new XMLHttpRequest();
         xhr.open('GET',
                  'http://wannabe.house/kiosk/pages/reload_immediately.html');