Skip to content

Commit

Permalink
A new start!
Browse files Browse the repository at this point in the history
  • Loading branch information
NaitLee committed Apr 6, 2022
1 parent 01eb4c6 commit 1de73c7
Show file tree
Hide file tree
Showing 47 changed files with 2,567 additions and 1,336 deletions.
166 changes: 27 additions & 139 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,140 +1,28 @@

bleak
www/skin.css
www/fabric.js
www/fabric.min.js
www/html2canvas.js
www/html2canvas.min.js
www/qrcode.js
www/qrcode.min.js
# python cache
__pycache__

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
# Compatibility version of script, for old-old webView,
# generated by typescript tsc
www/main.comp.js
# https://github.com/roddeh/i18njs
www/i18n.js
www/i18n.d.ts
# https://www.npmjs.com/package/vconsole
www/vconsole.js
# https://github.com/delight-im/Android-AdvancedWebView
build-android/advancedwebview
# python bytecode
*.pyc
# releases
build-android/dist
*.apk
cat-printer*.zip
# bleak, the bare pip package as a folder
build-common/bleak
# python embeddable package, with bleak_winrt inside
build-common/python-win32*
# dev config
config.json
# some other junk
.directory
thumbs.db
thumbs.db:encryptable
30 changes: 30 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

# Apply this pylint-rc for better experience
# Configurable in VSCode settings `python.linting.pylintArgs`
# $ pylint --rcfile=.pylint-rc

[MASTER]
jobs=4

[BASIC]
class-const-naming-style=snake_case
const-naming-style=snake_case

[MESSAGES CONTROL]
disable=broad-except,
global-statement,
fixme,
import-outside-toplevel

[BASIC]
good-names=i,
j,
k,
ex,
Run,
_,
e,
do_GET,
do_POST,
do_HEAD,
do_PUT
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug Web Interface",
"type": "python",
"request": "launch",
"program": "server.py",
"args": ["-a", "-s"],
"console": "integratedTerminal",
"justMyCode": true
}
]
}
4 changes: 4 additions & 0 deletions 0-transpile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
cd www
npx tsc --allowJs --outFile main.comp.js polyfill.js i18n.js image.js main.js
cd ..
6 changes: 6 additions & 0 deletions COPYING
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
118 changes: 70 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,85 +1,107 @@
English | [简体中文](README.zh-CN.md)

# Cat-Printer

*A friendly cat (kitty) printer App/driver for everyone (GB01,GB02,GT01)*
A project that provides support to some Bluetooth "Cat Printer" models, on *many* platforms!

![Poster](https://repository-images.githubusercontent.com/403563361/0a315f6a-7cae-48d7-bfd4-d6fac5415d7c)
## Models

(According to [official website](http://office.frogtosea.com/jjfa), maybe there are also normal-, piggy- and frog-shaped printers with these models)
Currently:
GB01, GB02, and GT01

## Features

- Print jpg/png images directly to cat printer from a web interface
- Print a document (.doc, .docx, .odt etc) by copy-paste
- Custom print content, put text, image, QRcode on a canvas
- (more will be here...)
- Simple!
- Operate via a Web UI just in browser,
- or get the Android release!
- ~~Feature-rich~~
- Currently it is in Alpha stage. More will be there soon!
- You can still use the legacy version (0.0.2), with some more editing features
- Friendly!
- Language support! You can participate in translation!
- Good user interface, with PC/mobile/light/dark mode variants! (system config adaptive)
- Cross platform!
- Newer Windows 10 and above
- GNU/Linux
- MacOS *(Needs testing)*
- and a lot of extra efforts for Android!
- Free, as in [freedom](https://www.gnu.org/philosophy/free-sw.html)!
- Unlike the "official" proprietary app,
this project is for everyone that concerns *open-mind and freedom*!
- and Fun!
- Do whatever you like!

## How to use
## Get Started

On Windows 10:
### Android

- Get a release, extract, open `start.bat`.
- Make sure bluetooth of your computer is opened and cat printer is launched.
Get the newest apk release and install, then well done!

On GNU/Linux:
It may ask for background location permission, which is mysterious to me.
You can deny it safely.

- You can also use a Windows release, or prepare dependencies according to developer note.
- Open `server.py` in `printer` folder with `python3`.
### Windows:

Notes:
Get the newest release archive with "windows" in the file name,
extract to somewhere and run `start.bat`

- Newest Firefox users need to manually allow the permission of extracting canvas data, at left side of address bar after clicking preview button
- Windows version needs to be at least 10 (`10.0.16299`)
- GNU/Linux needs BlueZ (`bluetoothctl`)
- Maybe also compatible to Mac (Darwin) with CoreBluetooth Framework
### GNU/Linux

## Why?
You can get the "pure" release, extract it, fire a terminal inside and run:
```bash
python3 server.py
```

These bluetooth cat printers, with model name GB01, GB02 and GT01, have poor support at applications.
On Arch Linux based distros you may first install `bluez`, as it's often missing
```bash
sudo pacman -S bluez bluez-utils
```

Official apps are, proprietary, also have only mobile version.
### MacOS

I hate both proprietary and platform-binding things. So I decided to make this.
For MacOS please install [Python 3](https://www.python.org/).

Thankfully, people here are really warm-hearted, logged their experiences online in a [central repo](https://github.com/JJJollyjim/catprinter), and I am able to walk further 😃
Fetch a "pure" release and do the same in a shell:
```bash
python3 server.py
```

## Trivial
Currently in Mac the browser will not pop up automatically. Please run manually and go to `http://127.0.0.1:8095`

- Many one choose these cat thermal printers because they are cute... or, just cheap 🙃

- Here we tell "**Cat Printer**" because other developers also call the printer as this, but what oversea shops call is "**Kitty Printer**". Search engines, please optimize it 😝
### Note

- The official app is protected by law & copyright. I don't know if my work is not good...
For all supported platforms,
You can also use "pure" edition once you have [Python 3](https://www.python.org/) installed,
or "bare" edition if you also managed to install `bleak` via `pip`.

## Developer Note
See the [releases](./releases) now! (`0.0.*` versions are legacy/deprecated)

This application uses server/client model, and have fewest possible dependencies on server side.
## Problems?

### Prepare
Please open an issue if there's something in your mind!

- Python3 & Browser
- [fabric.min.js](https://github.com/fabricjs/fabric.js/tree/master/dist)
- [html2canvas.min.js](https://html2canvas.hertzen.com/)
- [qrcode.min.js](https://davidshimjs.github.io/qrcodejs/)
- (Optional) Any css for plain webpage, e.g. [minicss](https://minicss.org/), rename to `skin.css`
Of course PRs are welcome if you can handle them!

Put any web-related files to folder `www`.
## License

### Supported Platforms
Copyright © 2022 NaitLee Soft. Some rights reserved.

Support for both Windows and GNU/Linux are included. And Windows release package will contain all needed things for a **normal** user to play with.
See file `COPYING`, `LICENSE`, and detail of used JavaScript in file `www/jslicense.html`

### Plans
--------

- Smoother mono-color converting
- Make remote-print by web interface more standard/compatible/secure
## Development

Possible features:
You may interested in language support, anyway. See the translation files in directory `www/lang`!

- Remote print with printer protocols
Also interested in code development? See [development.md](development.md)!

### Files
### Credits

- `server.py`: Contains a BaseHTTP server that hooks user actions and printer driver
- `printer.py`: Contains the driver of bluetooth cat printer, which depends on bleak. You can also run this file in commandline.
- Of course, Python & the Web!
- [Bleak](https://bleak.readthedocs.io/en/latest/) BLE lib! The overall Hero!
- [roddeh-i18n](https://github.com/roddeh/i18njs), good work!
- [python-for-android](https://python-for-android.readthedocs.io/en/latest/), though there are some painful troubles
- [AdvancedWebView](https://github.com/delight-im/Android-AdvancedWebView) for saving my life from Java
- Stack Overflow & the whole Internet, you let me know Android `Activity` all from empty
- ... Everyone is Awesome!
Loading

0 comments on commit 1de73c7

Please sign in to comment.