From c994ccfe6c73c5eb4782ebe6ace56c5d2f97e75e Mon Sep 17 00:00:00 2001 From: Francesco Luzzana Date: Wed, 6 Apr 2022 18:16:29 +0200 Subject: [PATCH] test list files --- .../bureau/soup/{ => contents}/dish_1.txt | 0 .../bureau/soup/{ => contents}/dish_2.txt | 0 screenless/bureau/soup/files.html | 168 ++++++++---------- screenless/bureau/soup/functions.html | 86 +++++++++ screenless/bureau/soup/list of functions.html | 95 ---------- screenless/bureau/soup/soup.py | 36 +++- 6 files changed, 192 insertions(+), 193 deletions(-) rename screenless/bureau/soup/{ => contents}/dish_1.txt (100%) rename screenless/bureau/soup/{ => contents}/dish_2.txt (100%) create mode 100644 screenless/bureau/soup/functions.html delete mode 100644 screenless/bureau/soup/list of functions.html diff --git a/screenless/bureau/soup/dish_1.txt b/screenless/bureau/soup/contents/dish_1.txt similarity index 100% rename from screenless/bureau/soup/dish_1.txt rename to screenless/bureau/soup/contents/dish_1.txt diff --git a/screenless/bureau/soup/dish_2.txt b/screenless/bureau/soup/contents/dish_2.txt similarity index 100% rename from screenless/bureau/soup/dish_2.txt rename to screenless/bureau/soup/contents/dish_2.txt diff --git a/screenless/bureau/soup/files.html b/screenless/bureau/soup/files.html index e96a4c9..92ef25e 100644 --- a/screenless/bureau/soup/files.html +++ b/screenless/bureau/soup/files.html @@ -1,104 +1,82 @@ - - - - -Ingredients - - - - - -
-

THE INGREDIENTS

-

+ .column { + float: left; + padding: 45px; + height: 200px; + } -
- -
- -

- ☾ POTATO [ barcode_weaver ] -

- -

- ⚪ SWEET POTATO [ barcode_weaver ] -

- -
- -
- -

- ☾ etcetera = ['et cetera', ' etc ', ' etc.', '...', '[...]', '[. ...]', 'and-so-on', 'and-so-forth', 'and others', 'et al.', 'and all the rest', 'and on and on', 'along with others’, ‘blablabla’, ‘blabla’, ‘and much more’] + .left { + width: 60%; + } -

- -

- ⚪ *My dear lovely dad that I love with all my heart -

- -
-
- - - \ No newline at end of file + .right { + width: 40%; + } + + .row:after { + content: ""; + display: table; + clear: both; + } + + .barcode { + width: 120px; + height: 50px; + } + + + + +
+

THE INGREDIENTS

+
+ + % for content in contents +
+
+

${content.title} ${content.barcode}

+
+
+

☾ {content.content[:200]}...

+
+
+ %endfor + + diff --git a/screenless/bureau/soup/functions.html b/screenless/bureau/soup/functions.html new file mode 100644 index 0000000..aa78bff --- /dev/null +++ b/screenless/bureau/soup/functions.html @@ -0,0 +1,86 @@ + + + + + + The CookBook + + + +
+

THE COOKBOOK

+
+ + % for function in functions +
+
+

+ ${function.title} + +

+
+ +
+

☻ ${function.description}

+
+
+ % endfor + + diff --git a/screenless/bureau/soup/list of functions.html b/screenless/bureau/soup/list of functions.html deleted file mode 100644 index 5c82876..0000000 --- a/screenless/bureau/soup/list of functions.html +++ /dev/null @@ -1,95 +0,0 @@ - - - - - -The CookBook - - - - -
-

THE COOKBOOK

-

- -
-
- -

- ☻ DOUGH WEAVER [ barcode_weaver ] -

- -
- -
- -

☻ Create a unique textual recipe with the Dough Weaver. Spice up your kitchen daydreaming with a custom recipe-mix of already existing dishes!
-
- Spice up your kitchen experience by plugging the six black and yellow cables, to A or B, in whatever order you see fit. Then once you are happy with your selection, press the button to submit your custom pattern.

- -
-
- - - - - \ No newline at end of file diff --git a/screenless/bureau/soup/soup.py b/screenless/bureau/soup/soup.py index 92eb033..d86951a 100644 --- a/screenless/bureau/soup/soup.py +++ b/screenless/bureau/soup/soup.py @@ -6,6 +6,8 @@ import subprocess import urllib import yaml from random import choice +import kode256 +import b64encode from PIL import Image @@ -20,6 +22,7 @@ class Soup(Bureau): name = "Canteen of the Screenless Office" prefix = "SB" version = 0 + input_queue = [] def __init__(self): Bureau.__init__(self) @@ -48,14 +51,28 @@ class Soup(Bureau): @add_command('list', 'Return a list of contents') def list_contents(self): - files = glob.glob(os.path.join(self.mdir, 'contents', '*.txt')) prn = self._get_small_printer() + contents = [] + files = glob.glob(os.path.join(self.mdir, 'contents', '*.txt')) for file in files: filename, ext = os.path.basename(file).split('.') - self.print_small(filename) - prn.soft_barcode("code128", "SBtp." + filename) + + svg = kode256.svg("SBaq." + filename) + encoded_svg = b64encode(svg.encode()).decode() + encoded_data = "data:image/svg+xml;charset=utf-8;base64," + encoded_svg + + with open(os.path.join(self.mdir, 'contents', filename + '.txt'), 'r') as f: + text = f.read() + + contents.append({ + "title": filename, + "barcode": encoded_data, + "content": text + }) + + self.print_full('files.html', contents=contents) @add_command('tp', 'Print a short excerpt of a text') def print_preview(self, data): @@ -66,6 +83,19 @@ class Soup(Bureau): self.print_small(filename + '\n' + text[:200] + '...') + @add_command('aq', 'Add a text to the queue') + def add_to_queue(self, data): + filename, _ = data.split(".") + self.input_queue.append(filename) + + @add_command('cq', 'clear inputs in the queue') + def clear_q(self): + self.input_queue = [] + self.print_small("queue cleared!") + + # @add_command('fx', 'execute the chosen function') + # def ex_function + def main(): sb = Soup()