diff --git a/.dockerignore b/.dockerignore
index b512c09d..f9e25392 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -1 +1,2 @@
-node_modules
\ No newline at end of file
+server/node_modules
+webui/node_modules
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 22e63a26..a5378e38 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -1,4 +1,4 @@
-name: Node.js CI
+name: NodeCI
on:
workflow_dispatch:
@@ -40,14 +40,13 @@ jobs:
- run: sudo sed -i 's/policy domain="coder" rights="none" pattern="PDF"/policy domain="coder" rights="read | write" pattern="PDF"'/ /etc/ImageMagick-6/policy.xml
# Install packages and build
- - run: npm install
- - run: npm run server-lint
- - run: npm run server-build
- - run: npm run client-build
- - run: npm run test
+ - run: cd server && npm i --loglevel=error && cd ../webui && npm i --loglevel=error
+ - run: cd server && npm run server-lint
+ - run: cd server && npm run test
+ - run: cd webui && npm run build && cd ../server && npm run server-build
env:
CI: true
- - run: npm run package
+ - run: cd server && npm run package
# We may need the package name for a release later (if not the dev branch and it's node 12)
- name: Retrieve package name
diff --git a/.gitignore b/.gitignore
index 13c69989..eb742617 100644
--- a/.gitignore
+++ b/.gitignore
@@ -85,19 +85,17 @@ $RECYCLE.BIN/
*.lnk
# Release folders
-release/**/*
-dist/**/*
+release
+dist
# VSCode
.vscode
# Project specific
-*.tif
-*.pdf
-*.png
-data/output/*
-data/temp/*
+server/config/devices.json
+server/data/output/*
+server/data/temp/*
+server/data/preview/*.tif
scan*.jpg
-config/devices.json
var
diff --git a/Dockerfile b/Dockerfile
index b20334d9..b959f501 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,23 +1,40 @@
-# builder image
+# Builder image. Alpine doesn't have python which is required by node-sass
FROM node:buster AS builder
ENV APP_DIR=/app
WORKDIR "$APP_DIR"
-COPY package*.json "$APP_DIR/"
-RUN npm install
-COPY . "$APP_DIR"
-RUN npm run server-build && npm run client-build
+
+COPY server/package*.json "$APP_DIR/server/"
+COPY webui/package*.json "$APP_DIR/webui/"
+
+RUN cd server \
+ && npm i --loglevel=error \
+ && cd ../webui \
+ && npm i --loglevel=error
+
+COPY webui/ "$APP_DIR/webui/"
+COPY server/ "$APP_DIR/server/"
+
+RUN cd webui \
+ && npm run build \
+ && cd ../server \
+ && npm run server-build
# production image
FROM node:buster-slim
ENV APP_DIR=/app
WORKDIR "$APP_DIR"
-RUN apt-get update && \
- apt-get install -yq curl gpg && \
- echo 'deb http://download.opensuse.org/repositories/home:/pzz/Debian_10/ /' | tee /etc/apt/sources.list.d/home:pzz.list && \
- curl -fsSL https://download.opensuse.org/repositories/home:pzz/Debian_10/Release.key | gpg --dearmor | tee /etc/apt/trusted.gpg.d/home:pzz.gpg > /dev/null && \
- apt-get update && \
- apt-get install -yq sane sane-utils imagemagick tesseract-ocr sane-airscan && \
- sed -i 's/policy domain="coder" rights="none" pattern="PDF"/policy domain="coder" rights="read | write" pattern="PDF"'/ /etc/ImageMagick-6/policy.xml
+RUN apt-get update \
+ && apt-get install -yq curl gpg \
+ && echo 'deb http://download.opensuse.org/repositories/home:/pzz/Debian_10/ /' | tee /etc/apt/sources.list.d/home:pzz.list \
+ && curl -fsSL https://download.opensuse.org/repositories/home:pzz/Debian_10/Release.key | gpg --dearmor | tee /etc/apt/trusted.gpg.d/home:pzz.gpg > /dev/null \
+ && apt-get update \
+ && apt-get install -yq \
+ imagemagick \
+ sane \
+ sane-utils \
+ sane-airscan \
+ tesseract-ocr \
+ && sed -i 's/policy domain="coder" rights="none" pattern="PDF"/policy domain="coder" rights="read | write" pattern="PDF"'/ /etc/ImageMagick-6/policy.xml
COPY --from=builder "$APP_DIR/dist" "$APP_DIR/"
@@ -32,7 +49,7 @@ ENV AIRSCAN_DEVICES=""
# This directs scanserv not to bother querying `scanimage -L`
ENV SCANIMAGE_LIST_IGNORE=""
-# This gets added to scanservjs/config/config.js:devices
+# This gets added to scanservjs/server/config.js:devices
ENV DEVICES=""
# Override OCR language
diff --git a/README.md b/README.md
index bfb1dbfd..d6f4261c 100644
--- a/README.md
+++ b/README.md
@@ -1,42 +1,59 @@
# scanservjs
-scanservjs is a simple web-based UI for your scanner. It allows you to share one
-or more scanners (using SANE) on a network without the need for drivers or
-complicated installation. It can save to TIF, JPG, PNG, PDF and TXT (with
-Tesseract OCR) with varying compression settings, all of which can configured.
-It supports multipage scanning and all
+
+[![Build Status](https://github.com/sbs20/scanservjs/workflows/NodeCI/badge.svg)](https://github.com/sbs20/scanservjs/actions)
+[![Code QL Status](https://github.com/sbs20/scanservjs/workflows/CodeQL/badge.svg)](https://github.com/sbs20/scanservjs/actions)
+[![Docker Image Size (latest by date)](https://img.shields.io/docker/image-size/sbs20/scanservjs)](https://hub.docker.com/r/sbs20/scanservjs)
+[![Docker Pulls](https://img.shields.io/docker/pulls/sbs20/scanservjs)](https://hub.docker.com/r/sbs20/scanservjs)
+[![GitHub stars](https://img.shields.io/github/stars/sbs20/scanservjs?label=Github%20stars)](https://github.com/sbs20/scanservjs)
+[![GitHub watchers](https://img.shields.io/github/watchers/sbs20/scanservjs?label=Github%20Watchers)](https://github.com/sbs20/scanservjs)
+[![Docker Stars](https://img.shields.io/docker/stars/sbs20/scanservjs)](https://hub.docker.com/r/sbs20/scanservjs)
+[![GitHub](https://img.shields.io/github/license/sbs20/scanservjs)](https://github.com/sbs20/scanservjs/blob/master/LICENSE.md)
+
+
+scanservjs is a web-based UI for your scanner. It allows you to share one or
+more scanners (using SANE) on a network without the need for drivers or
+complicated installation. It enables easy cropping, sources, resolution, output
+formats (TIF, JPG, PNG, PDF and TXT with Tesseract OCR) with varying compression
+settings, all of which can be configured. It supports multipage scanning and all
[SANE compatible devices](http://www.sane-project.org/sane-supported-devices.html).
![screenshot](https://github.com/sbs20/scanservjs/raw/master/docs/screen0.png)
-Copyright 2016-2020 [Sam Strachan](https://github.com/sbs20)
+Copyright 2016-2021 [Sam Strachan](https://github.com/sbs20)
## Requirements
-* SANE
-* ImageMagick
-* Tesseract (optional)
-* nodejs
+* SANE Scanner
+* Linux host (or VM with necessary pass-through e.g. USB)
+* Software sane-utils, ImageMagick, Tesseract (optional) and nodejs
## Installation notes
For an easy docker-based install (assuming that SANE supports your scanner
-out-of-the-box on Debian) use the following commands. Please note that by
-default, configuration and scanned images are stored within the container and
-will be lost if you recreate it. If you want to map your scanned images then
-specify the volume mapping option `-v /local/path/:/app/data/output/`
-
-**Please note that the docker image is amd64 only - and will not work on ARM
-devices such as the Raspberry Pi. Please follow the manual installation process
-in these cases**
+out-of-the-box on Debian) use the following commands:
```console
docker pull sbs20/scanservjs:latest
docker rm --force scanservjs-container 2> /dev/null
docker run -d -p 8080:8080 -v /var/run/dbus:/var/run/dbus --restart unless-stopped --name scanservjs-container --privileged sbs20/scanservjs:latest
```
-(`--privileged` is required for the container to access the host's devices, to
-allow it to talk to the scanner)
scanservjs will now be accessible from `http://$host:8080/`
+* ⚠ By default, configuration and scanned images are stored within the container
+ and will be lost if you recreate it. If you want to map your scanned images
+ then specify the volume mapping option `-v /local/path/:/app/data/output/`
+* ⚠ The docker image is amd64 only - and will not work on ARM devices such as
+ the Raspberry Pi. Please follow the manual installation process in these
+ cases
+* ⚠ `--privileged` is required for the container to access the host's devices,
+ to allow it to talk to the scanner. The best way to do this is to map the
+ actual USB ports. Run `sudo sane-find-scanner -q` and you will get a result
+ like
+ `found USB scanner (vendor=0x04a9 [Canon], product=0x220d [CanoScan], chip=LM9832/3) at libusb:001:003`.
+ This translates to `/dev/bus/usb/001/003`. In turn the docker argument would
+ be `--device=/dev/bus/usb/001/003:/dev/bus/usb/001/003`. However, oftentimes,
+ there are [reports](#66) that devices change address across reboots which
+ complicates matters.
+
If you want to install the latest staging branch (this may contain newer code)
```console
@@ -66,6 +83,34 @@ More installation options:
* `DEVICES`: Force add devices use `DEVICES` (semicolon delimited)
* `SCANIMAGE_LIST_IGNORE`: To force ignore `scanimage -L`
+## Configuration override
+If you want to override some specific configuration setting then you can do so
+within `./config/config.local.js`. Using docker you will need to map the volume
+using `-v /my/local/path/:/app/config/` then create a file in your directory
+called `config.local.js`. See [example source](./server/config/config.local.js)
+for more options.
+
+```javascript
+module.exports = {
+ afterConfig(config) {
+ // Set default preview resolution
+ config.previewResolution = 300;
+
+ // Add a custom print pipeline
+ config.pipelines.push({
+ extension: 'pdf',
+ description: 'Print PDF',
+ commands: [
+ 'convert @- -quality 92 tmp-%04d.jpg && ls tmp-*.jpg',
+ 'convert @- scan-0000.pdf',
+ 'lp -d MY_PRINTER scan-0000.pdf',
+ 'ls scan-*.*'
+ ]
+ });
+ }
+};
+```
+
## Airscan
[sane-airscan](https://github.com/alexpevzner/sane-airscan) uses Avahi /
Zeroconf / Bonjour to discover devices on the local network. If you are running
@@ -89,7 +134,7 @@ use `scanimage -L`, force a list of devices and override the OCR language
```console
docker run -d -p 8080:8080 \
- -e SANED_HOSTS="10.0.100.30;10.0.100.31" \
+ -e SANED_NET_HOSTS="10.0.100.30;10.0.100.31" \
-e AIRSCAN_DEVICES='"Canon MFD" = "http://192.168.0.10/eSCL";"EPSON MFD" = "http://192.168.0.11/eSCL"' \
-e SCANIMAGE_LIST_IGNORE=true \
-e DEVICES="net:10.0.100.30:plustek:libusb:001:003;net:10.0.100.31:plustek:libusb:001:003;airscan:e0:Canon TR8500 series;airscan:e1:EPSON Cool Series" \
@@ -103,11 +148,12 @@ This is yet another scanimage-web-front-end. Why? It originally started as an
adaptation of phpsane - just to make everything a bit newer, give it a refresh
and make it work on minimal installations without imagemagick - that version is
[still available](https://github.com/sbs20/scanserv) but is no longer
-maintained. Then, I just wanted to write it in node and enhance it a bit, and
-it's been a labour of love ever since.
+maintained. Since then, I just wanted to write it in node and enhance it a bit,
+and it's been a labour of love ever since.
## Acknowledgements
- * This project owes a lot to [phpsane](http://sourceforge.net/projects/phpsane/)
+ * This project owes its genesis to
+ [phpsane](http://sourceforge.net/projects/phpsane/)
## More about SANE
* http://www.sane-project.org/
\ No newline at end of file
diff --git a/client/App.vue b/client/App.vue
deleted file mode 100644
index a823b5d3..00000000
--- a/client/App.vue
+++ /dev/null
@@ -1,113 +0,0 @@
-
-
-
-
-
-
-
diff --git a/client/assets/autorenew-24px.svg b/client/assets/autorenew-24px.svg
deleted file mode 100644
index 2561b211..00000000
--- a/client/assets/autorenew-24px.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/client/assets/delete-24px.svg b/client/assets/delete-24px.svg
deleted file mode 100644
index 3acec0ad..00000000
--- a/client/assets/delete-24px.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/client/assets/photo_camera-24px.svg b/client/assets/photo_camera-24px.svg
deleted file mode 100644
index 17898e64..00000000
--- a/client/assets/photo_camera-24px.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/client/assets/refresh-24px.svg b/client/assets/refresh-24px.svg
deleted file mode 100644
index b8d69f40..00000000
--- a/client/assets/refresh-24px.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/client/assets/search-24px.svg b/client/assets/search-24px.svg
deleted file mode 100644
index 7c2111eb..00000000
--- a/client/assets/search-24px.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/client/components/Scanserv.vue b/client/components/Scanserv.vue
deleted file mode 100644
index 7829f8c1..00000000
--- a/client/components/Scanserv.vue
+++ /dev/null
@@ -1,526 +0,0 @@
-
-
+ scanservjs is a simple web-based UI for your scanner. It allows you to
+ share one or more scanners (using SANE) on a network without the need for
+ drivers or complicated installation. It can save to TIF, JPG, PNG, PDF and
+ TXT (with Tesseract OCR) with varying compression settings, all of which
+ can be configured. It supports multipage scanning and all SANE compatible
+ devices.
+