diff -uNr a/logotron/MANIFEST.TXT b/logotron/MANIFEST.TXT --- a/logotron/MANIFEST.TXT 9b223e8847a05c7dee552a786d8290316bf1dbf3dfca3ce7bc2080ec7b357b5c031fabc47d2586097e8f1bb0100a0e6f6c44c37acf53aa3d3fe903ff074fcd67 +++ b/logotron/MANIFEST.TXT 1b16a235827578071c913387d8fe7601d6d0ab67661b6b27ead056d42cd1e1ca763ff1896f4c02a96551b5b2468801f94ef270176df5008df344c02a1281873f @@ -16,3 +16,4 @@ 598372 shlex_removal asciilifeform "Reverted defective attempt at double-quoted search." 640165 hide_inactive asciilifeform "Configurable default-hide of idle chans" 641046 search_all_chans asciilifeform "Button to search in all logged chans" +641484 navbar_date_auto asciilifeform "Automatically skip empty days in navbar. Handle 'dawn of time' case." diff -uNr a/logotron/README.txt b/logotron/README.txt --- a/logotron/README.txt 0a75ab02402bd83bda90e41a341753044860eb7e0013943687b0b0797356e8d9e21ba4346a71123357d791ce422ecf789a29ad8ea759bc8799f88c54ca7e66d3 +++ b/logotron/README.txt 77626555d2a7ac7388c19298a36a8e412b809c6be8532703f18d1e41c197a41a5b3fbc76e964bbd4627b8bb09e3b98cd3ee31bcfb677ea90c1fb3ad9ca8dac4f @@ -151,3 +151,11 @@ (1) Fix unclosed 'table' tag from earlier. (2) 'Search all chans' button. + +#################### +Jul. 2020 Update #3: +#################### + +(1) Automatically skip empty days in date navigation bar. At the same time, handle empty days correctly when these are requested. +(2) Handle 'dawn of time' case for any given channel, to avoid infinite loop insanity from search engines. + diff -uNr a/logotron/reader.py b/logotron/reader.py --- a/logotron/reader.py 3b5645290a520a3f935b44372a1c98f60a0bc967ea3d6ad4160ef72e455c7c9636847847007334053703765fa80176a2509e3609005e4ab8d2518d27869f8002 +++ b/logotron/reader.py a56af711977a55e1332e0a42d8e2acfdfb7c2d9db72dc86c276949c337f0e66acbe6455b19cb156fabb1b242bc7c7f8a69e48987f20d745bcbf44e60d52e9b46 @@ -306,31 +306,6 @@ app.jinja_env.globals.update(format_logline=format_logline) -# Generate navbar for the given date: -def generate_navbar(date, tail, chan): - cur_day = datetime.strptime(date, Date_Short_Format) - prev_day = cur_day - timedelta(days=1) - prev_day_txt = prev_day.strftime(Date_Short_Format) - - s = "← {2}".format( - get_base(), - chan, - prev_day_txt) - - if not tail: - next_day = cur_day + timedelta(days=1) - next_day_txt = next_day.strftime(Date_Short_Format) - s = s + " | {2} →".format( - get_base(), - chan, - next_day_txt) - - return s - -# Make above callable from inside htm templater: -app.jinja_env.globals.update(generate_navbar=generate_navbar) - - @app.route('/rnd/') def rnd(chan): # Handle rubbish chan: @@ -387,7 +362,7 @@ # Enable 'tail' is day_end is after end of current day if day_end > now: tail = True - + # Get the loglines from DB lines = query_db( '''select * from loglines where chan=%s @@ -397,14 +372,36 @@ # Optional 'reverse gear' knob: if rev == 1: lines.reverse() - + + # Generate navbar for the given date: + prev_day = "" + next_day = "" + + prev_t = query_db( + '''select t from loglines where chan=%s + and t < %s order by idx desc limit 1;''', + [chan, day_start], one=True) + + if prev_t != None: + prev_day = prev_t['t'].strftime(Date_Short_Format) + + if not tail: + next_t = query_db( + '''select t from loglines where chan=%s + and t > %s order by idx asc limit 1;''', + [chan, day_end], one=True) + + if next_t != None: + next_day = next_t['t'].strftime(Date_Short_Format) + # Return the HTMLized text return render_template('log.html', chan = chan, loglines = lines, sel = (sel_start, sel_end), date = date, - tail = tail, + prev_day = prev_day, + next_day = next_day, rev = not rev, show_all = show_all, idle_day = Days_Hide) diff -uNr a/logotron/templates/layout.html b/logotron/templates/layout.html --- a/logotron/templates/layout.html c65b0971e605cbf05445f2562f4e363bfbfac914d389d81f946fd534e79ff3ba4b00245536fbfbaa3527127a4dec005fbe1c3242182c76c47112498cef0505d6 +++ b/logotron/templates/layout.html 6812442d036ef3f18cd4f148f2e7fe1b5833afd87555625293783246b10224e946a7c89fb8b762b82fd02b7a1b1a86abd6e1b006b095b254ac9ea446f3acd003 @@ -138,8 +138,6 @@