| @@ -1,2 +1,3 @@ | |||
| __pycache__ | |||
| venv/ | |||
| libs/ | |||
| @@ -76,6 +76,10 @@ const Hanabi = { | |||
| card.ts = +new Date() | |||
| Hanabi.sync() | |||
| }, | |||
| ondragenter: (ev) => { | |||
| /* needed for drag-drop shim */ | |||
| ev.preventDefault() | |||
| }, | |||
| ondragover: (ev) => { | |||
| ev.preventDefault() | |||
| ev.dataTransfer.dropEffect = 'move' | |||
| @@ -1,15 +1,15 @@ | |||
| default: deploy | |||
| test: venv/ | |||
| test: venv/ libs/ | |||
| venv/bin/python -u test.py | |||
| run: venv/ | |||
| run: venv/ libs/ | |||
| pkill Python || true | |||
| make test | |||
| venv/bin/python -u pico.py | |||
| deploy: | |||
| rsync --archive --exclude-from=.gitignore . root@roderic.ca:/home/pico.chat/ | |||
| deploy: libs/ | |||
| rsync --archive --exclude=.git --exclude-from=.gitignore . root@roderic.ca:/home/pico.chat/ | |||
| ssh root@roderic.ca "cd /home/pico.chat/ && service pico.chat restart" | |||
| venv/: requirements.txt | |||
| @@ -17,3 +17,11 @@ venv/: requirements.txt | |||
| python3 -m venv venv | |||
| venv/bin/pip install websockets | |||
| touch requirements.txt venv | |||
| libs/: requirements.txt | |||
| rm -rf libs | |||
| mkdir libs | |||
| curl -o libs/mithril.min.js https://unpkg.com/mithril@2.0.4/mithril.min.js | |||
| curl -o libs/marked.min.js https://unpkg.com/marked@0.8.0/marked.min.js | |||
| curl -o libs/purify.min.js https://cdnjs.cloudflare.com/ajax/libs/dompurify/2.0.2/purify.min.js | |||
| curl -o libs/mobile-drag-drop.min.js https://unpkg.com/mobile-drag-drop@2.3.0-rc.2/index.min.js | |||
| @@ -1,13 +1,23 @@ | |||
| <!DOCTYPE html> | |||
| <html> | |||
| <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> | |||
| <script src="https://unpkg.com/mithril/mithril.min.js"></script> | |||
| <script src="https://unpkg.com/marked/marked.min.js"></script> | |||
| <script src="https://cdnjs.cloudflare.com/ajax/libs/dompurify/2.0.2/purify.min.js"></script> | |||
| <link rel="stylesheet" href="/hanabi.css" /> | |||
| <script src="/hanabi.js" defer></script> | |||
| <script src="/pico.js" defer></script> | |||
| <link rel="stylesheet" href="/pico.css" /> | |||
| <link rel="icon" href="/pico.svg" /> | |||
| <script src="/libs/mithril.min.js"></script> | |||
| <script src="/libs/marked.min.js"></script> | |||
| <script src="/libs/purify.min.js"></script> | |||
| <script src="/libs/mobile-drag-drop.min.js"></script> | |||
| <link rel="stylesheet" href="/apps/hanabi.css" /> | |||
| <script src="/apps/hanabi.js" defer></script> | |||
| <link rel="stylesheet" href="/pico.css" /> | |||
| <script src="/pico.js" defer></script> | |||
| <script> | |||
| MobileDragDrop.polyfill({}) | |||
| addEventListener('touchmove', () => {}) | |||
| </script> | |||
| <body>PicoChat requires JS</body> | |||
| </html> | |||
| @@ -411,7 +411,7 @@ const Chat = { | |||
| )), | |||
| ), | |||
| /* we could make these into like tabs .... */ | |||
| m(Media), | |||
| // m(Media), | |||
| m(Hanabi), | |||
| ) | |||
| }, | |||
| @@ -16,9 +16,10 @@ rooms = collections.defaultdict(dict) | |||
| class PicoProtocol(websockets.WebSocketServerProtocol): | |||
| def serve_file(self, path): | |||
| document = Path(__file__, '..', Path(path).name).resolve() | |||
| home = Path(__file__).parent | |||
| document = home.joinpath(path.lstrip('/')) | |||
| if not document.is_file(): | |||
| document = Path(__file__, '..', 'pico.html').resolve() | |||
| document = home.joinpath('pico.html').resolve() | |||
| if document.suffix == '.html': | |||
| content_type = 'text/html; charset=utf-8' | |||