diff --git a/.gitignore b/.gitignore index 9e3d04c..784ffa0 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ +.venv* venv* +print/__pycache__* diff --git a/.gitmodules b/.gitmodules index c1c87c9..bf4c20f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "tools/ascii-art-but-with-unicode"] - path = tools/ascii-art-but-with-unicode +[submodule "screen/tools/ascii-art-but-with-unicode"] + path = screen/tools/ascii-art-but-with-unicode url = https://git.vvvvvvaria.org/mb/ascii-art-but-with-unicode.git diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..db4809b --- /dev/null +++ b/Makefile @@ -0,0 +1,11 @@ +setup: + @python3 -m venv .venv && \ + .venv/bin/pip install -r requirements.txt + +screen: + @cd screen && \ + .venv/bin/python televex.py + +print: + $cd print && \ + .venv/bin/python start.py diff --git a/README.md b/README.md new file mode 100644 index 0000000..76e9929 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# TeleVex + +https://televex.vvvvvvaria.org/ + + +Experimental communication tools (televex screen + televex print). + diff --git a/print/start.py b/print/start.py new file mode 100644 index 0000000..6ac4b1e --- /dev/null +++ b/print/start.py @@ -0,0 +1,52 @@ +# https://github.com/python-escpos/python-escpos +# https://python-escpos.readthedocs.io/en/latest/ + +import sys +import os +import flask +from flask import request +import urllib +import json +from escpos.escpos import Escpos +from escpos import printer + +# Create the application. +APP = flask.Flask(__name__) + +# File Initialization +try: + lp = printer.File("/dev/usb/lp0") +except: + lp = sys.stdout + +# USB initialization +# Bus 001 Device 006: ID 04b8:0e15 Seiko Epson Corp. +# lp = printer.Usb(0x4b8, 0xe15) + +lp.text('test :)') +lp.image('') +lp.cut() + + +@APP.route('/', methods=['GET', 'POST']) +def index(): + + plaintext = request.args.get('plaintext', '') + + if plaintext: + lp.text(plaintext) + lp.cut() + + url = 'https://multi.vvvvvvaria.org/API/latest/5' + response = urllib.request.urlopen(url).read() + multifeeder = json.loads(response) + + url = 'https://multi.vvvvvvaria.org/API/today/' + response = urllib.request.urlopen(url).read() + feedstoday = json.loads(response) + + return flask.render_template('index.html', plaintext=plaintext, multifeeder=multifeeder, feedstoday=feedstoday) + +if __name__ == '__main__': + APP.debug=True + APP.run(port=5000) \ No newline at end of file diff --git a/print/static/stylesheet.css b/print/static/stylesheet.css new file mode 100644 index 0000000..9423eb9 --- /dev/null +++ b/print/static/stylesheet.css @@ -0,0 +1,16 @@ +body{ + color:magenta; + margin:2em; +} +div#print, +div#multifeeder, +div#webcam{ + + +} +div#multifeeder div.multipost{ + margin:1em 0; +} +div#webcam img{ + width:500px; +} \ No newline at end of file diff --git a/print/templates/index.html b/print/templates/index.html new file mode 100644 index 0000000..3306727 --- /dev/null +++ b/print/templates/index.html @@ -0,0 +1,43 @@ + + + + + TeleVex (print) + + + +
+ +
+

Plain Text Printing Point (ASCII only)

+
+ +
+
+ +
+
+

Image printing access point

+
+ + +
+
+
+
+

Multifeeder

+
Last 5 posts added to the Televex print stream:
+
+ {% for post in multifeeder %} +
+ Title: {{ post.title }}
+ Link: {{ post.link }}
+ Author: {{ post.author }}
+ Date: {{ post.published }}
+
+ {% endfor %} +
+ +
+ + \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 52dc9e0..b8890db 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,4 +2,4 @@ feedparser icalendar requests pypandoc -pyhyphen +python-escpos diff --git a/televex.py b/screen/televex.py similarity index 100% rename from televex.py rename to screen/televex.py diff --git a/texts/about.txt b/screen/texts/about.txt similarity index 100% rename from texts/about.txt rename to screen/texts/about.txt diff --git a/tools/ascii-art-but-with-unicode b/tools/ascii-art-but-with-unicode deleted file mode 160000 index 24c3d8a..0000000 --- a/tools/ascii-art-but-with-unicode +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 24c3d8af3e94cf3ce439a945605600d16475f0c4