Skip to content

Commit ea582b7

Browse files
committed
Rewrite as browser-based web application
Convert Python CLI tool to client-side web app using CREngine WASM. - EPUB to XTC/XTCH converter with live preview - EPUB optimizer for e-ink readers - Batch processing with ZIP export - Google Fonts integration + custom font upload - Device presets, orientation, text/image settings - Configurable progress bar - Floyd-Steinberg dithering via Web Worker - GitHub Pages deployment
1 parent 96d125f commit ea582b7

40 files changed

+3134
-6938
lines changed

.coverage

-52 KB
Binary file not shown.

.github/workflows/deploy.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
pages: write
12+
id-token: write
13+
14+
concurrency:
15+
group: "pages"
16+
cancel-in-progress: true
17+
18+
jobs:
19+
deploy:
20+
environment:
21+
name: github-pages
22+
url: ${{ steps.deployment.outputs.page_url }}
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
28+
- name: Setup Pages
29+
uses: actions/configure-pages@v4
30+
31+
- name: Upload artifact
32+
uses: actions/upload-pages-artifact@v3
33+
with:
34+
path: 'web'
35+
36+
- name: Deploy to GitHub Pages
37+
id: deployment
38+
uses: actions/deploy-pages@v4

.github/workflows/test.yml

Lines changed: 0 additions & 50 deletions
This file was deleted.

.gitignore

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
1-
# Python-generated files
2-
__pycache__/
3-
*.py[oc]
4-
build/
5-
dist/
6-
wheels/
7-
*.egg-info
8-
9-
.venv
10-
.pio
11-
.idea
1+
# OS files
122
.DS_Store
13-
.vscode
3+
Thumbs.db
4+
5+
# IDE
6+
.idea/
7+
.vscode/
8+
*.swp
9+
*.swo
10+
11+
# Claude
12+
.claude/
1413
CLAUDE.md
1514

16-
# Font files (keep directory structure with .gitkeep)
17-
fonts/*
18-
!fonts/.gitkeep
15+
# Test files
16+
*.epub
17+
*.xtc
18+
*.xtch
19+
20+
# Node modules (if any)
21+
node_modules/

.python-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

Makefile

Lines changed: 27 additions & 224 deletions
Original file line numberDiff line numberDiff line change
@@ -1,237 +1,40 @@
1-
.PHONY: help
1+
# Makefile for EPUB to XTC Converter & Optimizer
22

3-
#################################################################################
4-
# GLOBALS #
5-
#################################################################################
3+
.PHONY: all serve tag help
64

7-
PROJECT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
8-
PROJECT_NAME = xteink-epub-optimizer
5+
# Default target
6+
all: help
97

10-
CURRENT_PATH = $(shell pwd)
8+
## Development:
119

12-
VENV := $(or ${VIRTUAL_ENV},${VIRTUAL_ENV},.venv)
13-
PYTHON = $(VENV)/bin/python
14-
PIP = $(VENV)/bin/pip
15-
UV = $(VENV)/bin/uv
10+
serve: ## Run local web server (http://localhost:8000)
11+
@echo "Starting server at http://localhost:8000"
12+
@cd web && python3 -m http.server 8000
1613

17-
PYTHON_VERSION=3.12
18-
PYTHONPATH := $(or ${PYTHONPATH},.)
19-
TEST_DIR = tests/
14+
## Release:
2015

21-
LINT_SOURCES_PATHS = src/ tests/
22-
23-
export PYTHONPATH
24-
25-
#######################
26-
### System commands
27-
#######################
28-
.PHONY: tag
29-
## Create and push tag
30-
tag:
16+
tag: ## Create and push a version tag (triggers GitHub release)
3117
@read -p "Enter tag version (e.g., 1.0.0): " TAG; \
3218
if [[ $$TAG =~ ^[0-9]+\.[0-9]+\.[0-9]+$$ ]]; then \
33-
git tag -a $$TAG -m $$TAG; \
34-
git push origin $$TAG; \
35-
echo "Tag $$TAG created and pushed successfully."; \
19+
git tag -a v$$TAG -m "v$$TAG"; \
20+
git push origin v$$TAG; \
21+
echo "Tag v$$TAG created and pushed successfully."; \
3622
else \
3723
echo "Invalid tag format. Please use X.Y.Z (e.g., 1.0.0)"; \
3824
exit 1; \
3925
fi
40-
#######################
41-
### Virtual environment
42-
#######################
43-
44-
.PHONY: venv/create
45-
venv/create: ## Create virtual environment
46-
@echo "create virtual environment..."
47-
python -m venv ${VENV}
48-
@echo "done"
49-
@echo
50-
51-
.PHONY: venv/install/main
52-
## Install main dependencies
53-
venv/install/main:
54-
@echo "install virtual environment..."
55-
$(UV) sync --no-group dev
56-
57-
.PHONY: venv/install/all
58-
## Install all dependencies
59-
venv/install/all:
60-
@echo "install virtual environment..."
61-
$(UV) sync --all-groups
62-
63-
########################################
64-
### EPUB Processing
65-
########################################
66-
67-
.PHONY: optimize
68-
## Optimize EPUBs for Xteink X4 (usage: make optimize INPUT=./input OUTPUT=./output)
69-
optimize:
70-
$(PYTHON) src/optimizer.py $(INPUT) $(OUTPUT)
71-
72-
# Default font path for conversion
73-
FONT ?= fonts/Bookerly.ttf
74-
FONT_BOLD ?= fonts/Bookerly Bold.ttf
75-
FONT_ITALIC ?= fonts/Bookerly Italic.ttf
76-
FONT_BOLD_ITALIC ?= fonts/Bookerly Bold Italic.ttf
77-
FONT_SIZE ?= 34
78-
79-
.PHONY: convert
80-
## Convert EPUB to XTC/XTCH (usage: make convert INPUT=book.epub OUTPUT=book.xtch FONT_SIZE=40)
81-
convert:
82-
$(PYTHON) src/converter.py $(INPUT) $(OUTPUT) \
83-
--font "$(FONT)" \
84-
--font-bold "$(FONT_BOLD)" \
85-
--font-italic "$(FONT_ITALIC)" \
86-
--font-bold-italic "$(FONT_BOLD_ITALIC)" \
87-
--font-size $(FONT_SIZE)
88-
89-
.PHONY: convert-mono
90-
## Convert EPUB to XTC (1-bit mono) (usage: make convert-mono INPUT=book.epub OUTPUT=book.xtc)
91-
convert-mono:
92-
$(PYTHON) src/converter.py $(INPUT) $(OUTPUT) --format xtc \
93-
--font "$(FONT)" \
94-
--font-bold "$(FONT_BOLD)" \
95-
--font-italic "$(FONT_ITALIC)" \
96-
--font-bold-italic "$(FONT_BOLD_ITALIC)" \
97-
--font-size $(FONT_SIZE)
98-
99-
########################################
100-
### Code style & formatting tools
101-
########################################
102-
103-
.PHONY: lint/black
104-
lint/black:
105-
@echo "linting using black..."
106-
$(PYTHON) -m black --check --diff $(LINT_SOURCES_PATHS)
107-
@echo "done"
108-
@echo
109-
110-
.PHONY: lint/flake8
111-
lint/flake8:
112-
@echo "linting using flake8..."
113-
$(PYTHON) -m flake8 $(LINT_SOURCES_PATHS)
114-
@echo "done"
115-
@echo
116-
117-
.PHONY: lint/isort
118-
lint/isort:
119-
@echo "linting using isort..."
120-
$(PYTHON) -m isort --check-only --diff $(LINT_SOURCES_PATHS)
121-
@echo "done"
122-
@echo
123-
124-
125-
.PHONY: lint
126-
## Running all linters
127-
lint: lint/black lint/flake8 lint/isort
128-
129-
.PHONY: format
130-
## Formatting source code
131-
format:
132-
@echo "formatting using black..."
133-
$(PYTHON) -m black $(LINT_SOURCES_PATHS)
134-
@echo "done"
135-
@echo "linting using isort..."
136-
$(PYTHON) -m isort $(LINT_SOURCES_PATHS)
137-
@echo "done"
138-
@echo
139-
140-
## Delete all compiled Python files
141-
clean: ## Clear temporary information
142-
@echo "Clear cache directories"
143-
rm -rf .mypy_cache .pytest_cache .coverage
144-
@rm -rf `find . -name __pycache__`
145-
@rm -rf `find . -type f -name '*.py[co]' `
146-
@rm -rf `find . -type f -name '*~' `
147-
@rm -rf `find . -type f -name '.*~' `
148-
@rm -rf `find . -type f -name '@*' `
149-
@rm -rf `find . -type f -name '#*#' `
150-
@rm -rf `find . -type f -name '*.orig' `
151-
@rm -rf `find . -type f -name '*.rej' `
152-
@rm -rf .coverage
153-
@rm -rf coverage.html
154-
@rm -rf coverage.xml
155-
@rm -rf htmlcov
156-
@rm -rf build
157-
@rm -rf cover
158-
@rm -rf .develop
159-
@rm -rf .flake
160-
@rm -rf .install-deps
161-
@rm -rf *.egg-info
162-
@rm -rf .pytest_cache
163-
@rm -rf .mypy_cache
164-
@rm -rf dist
165-
@rm -rf test-reports
166-
167-
####################
168-
### Tests
169-
####################
170-
171-
.PHONY: test
172-
## Run all tests with coverage
173-
test:
174-
PYTHONPATH=$(PYTHONPATH):src \
175-
$(PYTHON) -m pytest --cov=src --cov-report=term-missing --cov-report=html $(TEST_DIR)
176-
177-
178-
#################################################################################
179-
# Self Documenting Commands #
180-
#################################################################################
181-
182-
.DEFAULT_GOAL := help
18326

184-
# Inspired by <http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html>
185-
# sed script explained:
186-
# /^##/:
187-
# * save line in hold space
188-
# * purge line
189-
# * Loop:
190-
# * append newline + line to hold space
191-
# * go to next line
192-
# * if line starts with doc comment, strip comment character off and loop
193-
# * remove target prerequisites
194-
# * append hold space (+ newline) to line
195-
# * replace newline plus comments by `---`
196-
# * print line
197-
# Separate expressions are necessary because labels cannot be delimited by
198-
# semicolon; see <http://stackoverflow.com/a/11799865/1968>
199-
.PHONY: help
200-
help:
201-
@echo "$$(tput bold)Available rules:$$(tput sgr0)"
202-
@echo
203-
@sed -n -e "/^## / { \
204-
h; \
205-
s/.*//; \
206-
:doc" \
207-
-e "H; \
208-
n; \
209-
s/^## //; \
210-
t doc" \
211-
-e "s/:.*//; \
212-
G; \
213-
s/\\n## /---/; \
214-
s/\\n/ /g; \
215-
p; \
216-
}" ${MAKEFILE_LIST} \
217-
| LC_ALL='C' sort --ignore-case \
218-
| awk -F '---' \
219-
-v ncol=$$(tput cols) \
220-
-v indent=19 \
221-
-v col_on="$$(tput setaf 6)" \
222-
-v col_off="$$(tput sgr0)" \
223-
'{ \
224-
printf "%s%*s%s ", col_on, -indent, $$1, col_off; \
225-
n = split($$2, words, " "); \
226-
line_length = ncol - indent; \
227-
for (i = 1; i <= n; i++) { \
228-
line_length -= length(words[i]) + 1; \
229-
if (line_length <= 0) { \
230-
line_length = ncol - indent - length(words[i]) - 1; \
231-
printf "\n%*s ", -indent, " "; \
232-
} \
233-
printf "%s ", words[i]; \
234-
} \
235-
printf "\n"; \
236-
}' \
237-
| more $(shell test $(shell uname) = Darwin && echo '--no-init --raw-control-chars')
27+
## Help:
28+
29+
help: ## Show this help
30+
@echo "EPUB to XTC Converter - Commands"
31+
@echo ""
32+
@echo "Usage: make [target]"
33+
@echo ""
34+
@awk 'BEGIN {FS = ":.*##"; section=""} \
35+
/^##/ { section=substr($$0, 4); next } \
36+
/^[a-zA-Z_-]+:.*##/ { \
37+
if (section != "") { printf "\n\033[1m%s\033[0m\n", section; section="" } \
38+
printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 \
39+
}' $(MAKEFILE_LIST)
40+
@echo ""

0 commit comments

Comments
 (0)