Skip to content

Commit

Permalink
Merge pull request #261 from sbs20/staging
Browse files Browse the repository at this point in the history
Monorepo; Settings; OCR lang fix; Device Names
  • Loading branch information
sbs20 authored May 18, 2021
2 parents 2ac6ca7 + 0072c54 commit aeebdb6
Show file tree
Hide file tree
Showing 93 changed files with 942 additions and 2,376 deletions.
6 changes: 4 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
server/node_modules
webui/node_modules
packages/server/node_modules
packages/client/node_modules
release
var
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,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: 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
- run: npm run install
- run: npm run lint
- run: npm run test
- run: npm run build
env:
CI: true
- run: cd server && npm run package
- run: 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
Expand Down
12 changes: 6 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ dist


# Project specific
server/config/devices.json
server/data/output/*
server/data/temp/*
server/data/preview/*.tif
scan*.jpg
var
**/server/config/devices.json
**/server/data/output/*
**/server/data/temp/*
**/server/data/preview/*.tif
**/scan*.jpg
**/config.local.js
var
19 changes: 7 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,16 @@ FROM node:14-buster AS builder
ENV APP_DIR=/app
WORKDIR "$APP_DIR"

COPY server/package*.json "$APP_DIR/server/"
COPY webui/package*.json "$APP_DIR/webui/"
COPY package*.json "$APP_DIR/"
COPY packages/server/package*.json "$APP_DIR/packages/server/"
COPY packages/client/package*.json "$APP_DIR/packages/client/"

RUN cd server \
&& npm i --loglevel=error \
&& cd ../webui \
&& npm i --loglevel=error
RUN npm run docker-install

COPY webui/ "$APP_DIR/webui/"
COPY server/ "$APP_DIR/server/"
COPY packages/client/ "$APP_DIR/packages/client/"
COPY packages/server/ "$APP_DIR/packages/server/"

RUN cd webui \
&& npm run build \
&& cd ../server \
&& npm run server-build
RUN npm run docker-build

# production image
FROM node:14-buster-slim
Expand Down
79 changes: 51 additions & 28 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ two functions at different stages in the processing:
function before being either used or sent down tot he browser.
* `afterDevices(devices)`: whenever the devices are read, the result is passed
to this function before being used.
* See [example source](../server/config/config.default.js) for more options.
* See [example source](../packages/server/config/config.default.js) for more options.
* Please note that the config file only gets read at start-up - so if you make
changes, you will need to restart.

Expand Down Expand Up @@ -62,16 +62,17 @@ module.exports = {
*/
afterDevices(devices) {
// Override the defaults for plustek scanners
const device = devices.filter(d => d.id.startsWith('plustek'))[0];
if (device) {
device.features['--mode'].default = 'Color';
device.features['--resolution'].default = 150;
device.features['--resolution'].options = [75, 150, 300, 600];
device.features['--brightness'].default = 0;
device.features['--contrast'].default = 5;
device.features['-x'].default = 215;
device.features['-y'].default = 297;
}
devices
.filter(d => d.id.includes('plustek'))
.forEach(device => {
device.features['--mode'].default = 'Color';
device.features['--resolution'].default = 150;
device.features['--resolution'].options = [75, 150, 300, 600];
device.features['--brightness'].default = 0;
device.features['--contrast'].default = 5;
device.features['-x'].default = 215;
device.features['-y'].default = 297;
});
}
};
```
Expand All @@ -90,13 +91,14 @@ options.
*/
afterDevices(devices) {
// Override the defaults for plustek scanners
const device = devices.filter(d => d.id.startsWith('plustek'))[0];
if (device) {
device.features['--resolution'].default = 150;
device.features['--resolution'].options = [75, 150, 300, 600];
device.features['-x'].default = 215;
device.features['-y'].default = 297;
}
devices
.filter(d => d.id.includes('plustek'))
.forEach(device => {
device.features['--resolution'].default = 150;
device.features['--resolution'].options = [75, 150, 300, 600];
device.features['-x'].default = 215;
device.features['-y'].default = 297;
});
}
```

Expand All @@ -108,23 +110,44 @@ the cropping logic because scanservjs incorrectly trusts the SANE output.

```javascript
afterDevices(devices) {
const device = devices.filter(d => d.id.includes('brother'))[0];
if (device) {
device.features['-l'].limits = [0, 215];
device.features['-t'].limits = [0, 297];
device.features['-x'].default = 215;
device.features['-x'].limits = [0, 215];
device.features['-y'].default = 297;
device.features['-y'].limits = [0, 297];
}
devices
.filter(d => d.id.includes('brother'))
.forEach(device => {
device.features['-l'].limits = [0, 215];
device.features['-t'].limits = [0, 297];
device.features['-x'].default = 215;
device.features['-x'].limits = [0, 215];
device.features['-y'].default = 297;
device.features['-y'].limits = [0, 297];
});
}
```

### Friendly device name

If you have many scanners available then you may wish to give devices friendly
names as per [#212](https://github.com/sbs20/scanservjs/issues/212).
`{ScanDevice}` objects have a `name` attribute which defaults to the `id` but
can be anything you want it to be. You just need to override it.

```javascript
afterDevices(devices) {
const deviceNames = {
'plustek:libusb:001:003': 'Downstairs Canon Flatbed',
'test:device:unreal': 'Upstairs Canon MFD'
};

devices
.filter(d => d.id in deviceNames)
.forEach(d => d.name = deviceNames[d.id]);
}
```

### Insert your own pipelines

You may wish to add your own custom pipelines. Pipelines are arrays of shell
commands which run after scans. To learn more read the
[example source](../server/config/config.default.js). This will insert your own
[example source](../packages/server/config/config.default.js). This will insert your own
pipelines at the top of the list.

```javascript
Expand Down
13 changes: 7 additions & 6 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,29 @@
* Navigate to the repo directory
```
sudo npm install -g @vue/cli @vue/cli-service-global gulp-cli
cd server && npm i . && cd ../webui && npm i .
npm run install
```

## Run for development

```
cd webui && npm run serve
npm run serve
```

This will hook the server component into webpack (see vue.config.js) and
references below.

## Build

Convenience method which performs linting and builds the client and server
Before committing please verify and build
```
cd server && gulp
npm run verify
npm run build
```

or do a release:
Create a local release package
```
cd server && gulp release
npm run release
```

## Updating node dependencies
Expand Down
2 changes: 1 addition & 1 deletion docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
script. But please note that this will install dependecies and needs to run as
root:
```sh
curl -s https://raw.githubusercontent.com/sbs20/scanservjs/master/server/bin/installer.sh | sudo bash -s -- -a
curl -s https://raw.githubusercontent.com/sbs20/scanservjs/master/packages/server/installer.sh | sudo bash -s -- -a
```
* If you're using another distro, then for the time being you either need to
manually run the steps in the install script or use docker.
Expand Down
14 changes: 14 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "scanservjs",
"version": "2.13.0",
"description": "scanservjs is a simple web-based UI for SANE which allows you to share a scanner on a network without the need for drivers or complicated installation.",
"scripts": {
"clean": "rm -rf ./dist",
"version": "npm i && cd packages/client && npm --allow-same-version --no-git-tag-version version $npm_package_version && cd ../server && npm --allow-same-version --no-git-tag-version version $npm_package_version",
"install": "cd packages/client && npm i --loglevel=error && cd ../server && npm i --loglevel=error",
"lint": "cd packages/server && npm run lint",
"test": "cd packages/server && npm run test",
"build": "npm run clean && cd packages/client && npm run build && cd ../server && npm run build",
"package": "cd packages/server && npm run package",
"docker-install": "npm run install",
"docker-build": "npm run build",
"verify": "npm run version && npm run lint && npm run test",
"release": "npm run verify && npm run build && npm run package",
"serve": "cd packages/client && npm run serve"
},
"repository": {
"type": "git",
"url": "https://github.com/sbs20/scanservjs"
},
"author": "Sam Strachan",
"license": "GPL-2.0"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions packages/client/jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"exclude": [
"node_modules"
],
"include": [
"**/*"
]
}
Loading

0 comments on commit aeebdb6

Please sign in to comment.