Skip to content

Commit

Permalink
Merge pull request #175 from sbs20/staging
Browse files Browse the repository at this point in the history
Mandarin and directory check
  • Loading branch information
sbs20 authored Apr 7, 2021
2 parents d234221 + 85aee08 commit 7c2895c
Show file tree
Hide file tree
Showing 8 changed files with 150 additions and 22 deletions.
20 changes: 20 additions & 0 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,26 @@ rm scanservjs.tar.gz
rm -r scanservjs
```

## Troubleshooting

Scanservjs works by wrapping CLI calls to `scanimage` as the user `scanservjs`
which is a member of the `scanner` group. If connected by USB then we ultimately
need access to some hardware and that access may not be granted by default. To
debug where the problem is:

* First, check that you've followed the instructions [here](./sane.md).
* Try running `sudo scanimage -L` (for diagnostic purposes) - this really should
work. If it doesn't, then it's most likely a SANE / driver related issue.
* Now try running as a normal user without sudo: `scanimage -L`. If you've
installed scanservjs then there should be a `scanservjs` user. Try the same
command as that user: `sudo su - scanservjs -c 'scanimage -L'`. If this
doesn't show your scanner then most likely you need a udev rule (see
[here](./sane.md)) to allow certain groups access to the hardware - but it's
also worth verifying that the `scanservjs` user is a member of the `scanner`
group (or the group specified in your udev rule): `groups scanservjs`.
* Getting logs: use `journalctl`. See the journalctl manpage for details but
`sudo journalctl -e -u scanservjs` should be enough to get you started.

## Old Debian
For more on problems installing an up to date nodejs on Debian which includes
`npm`. See
Expand Down
2 changes: 1 addition & 1 deletion server/bin/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,4 @@ systemctl start scanservjs
echo "scanservjs starting"
echo "http://127.0.0.1:8080"
echo
echo "If you have problems, try 'journalctl -xe'"
echo "If you have problems, try 'sudo journalctl -e -u scanservjs'"
2 changes: 1 addition & 1 deletion server/package-lock.json

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

2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "scanservjs-server",
"version": "2.8.3",
"version": "2.8.4",
"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. scanserv does not do image conversion or manipulation (beyond the bare minimum necessary for the purposes of browser preview) or OCR.",
"scripts": {
"serve": "nodemon --exec 'vue-cli-service serve'",
Expand Down
54 changes: 36 additions & 18 deletions server/src/configure.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const express = require('express');
const fs = require('fs');
const rootLog = require('loglevel');
const prefix = require('loglevel-plugin-prefix');
Expand All @@ -10,10 +11,14 @@ rootLog.setLevel(Config.log.level);
prefix.apply(rootLog, Config.log.prefix);

const log = rootLog.getLogger('Http');
const bodyParser = require('body-parser');
const Api = require('./api');

const sendError = (res, code, data) => {
/**
* @param {import('express').Response} res
* @param {number} code
* @param {any} data
*/
function sendError(res, code, data) {
let content = {
message: ''
};
Expand All @@ -25,9 +30,12 @@ const sendError = (res, code, data) => {
content.message = data;
}
res.status(code).send(content);
};
}

const logRequest = (req) => {
/**
* @param {import('express').Request} req
*/
function logRequest(req) {
const properties = ['method', 'path', 'params', 'query', 'body'];
const output = {};
for (const property of properties) {
Expand All @@ -40,9 +48,12 @@ const logRequest = (req) => {
}
}
log.debug('request: ', output);
};
}

const initialize = (rootPath) => {
/**
* @param {string} rootPath
*/
function initialize(rootPath) {
if (rootPath) {
// Only required for running in development
Object.assign(Config, {
Expand All @@ -54,17 +65,24 @@ const initialize = (rootPath) => {
});
}

fs.mkdirSync(Config.outputDirectory, { recursive: true });
fs.mkdirSync(Config.tempDirectory, { recursive: true });
};

module.exports = (app, rootPath) => {
try {
fs.mkdirSync(Config.outputDirectory, { recursive: true });
fs.mkdirSync(Config.tempDirectory, { recursive: true });
} catch (exception) {
log.warn(`Error ensuring output and temp directories exist: ${exception}`);
log.warn(`Currently running node version ${process.version}.`);
}
}

/**
* Configures express
* @param {import('express').Express} app
* @param {string} rootPath
*/
function configure(app, rootPath) {
initialize(rootPath);
app.use(bodyParser.urlencoded({
extended: true
}));

app.use(bodyParser.json());
app.use(express.urlencoded({ extended: true }));
app.use(express.json());

app.get(['/context', '/context/:force'], async (req, res) => {
logRequest(req);
Expand Down Expand Up @@ -141,6 +159,6 @@ module.exports = (app, rootPath) => {
sendError(res, 500, error);
}
});
}

app.use(bodyParser.json());
};
module.exports = configure;
1 change: 1 addition & 0 deletions webui/src/classes/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const Constants = {
Version: process.env.VUE_APP_VERSION,

Locales: [
'cn',
'cz',
'de',
'en',
Expand Down
89 changes: 89 additions & 0 deletions webui/src/locales/cn.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
{
"global": {
"application-name": "scanservjs"
},

"about": {
"main": "scanservjs 是一个基于网页的扫描仪UI。 它可以实现在局域网内共享一个或多个扫描仪(用SANE实现)而免去繁复的驱动安装。 扫描的文件可保存为 TIF, JPG, PNG, PDF 和 TXT (使用Tesseract OCR) 等格式,并可配置多种压缩率。 它亦支持多页扫描以及所有与SANE兼容的设备",
"issue": "反馈问题或查看源码"
},

"batch-dialog": {
"btn-finish": "完成",
"btn-rescan": "重新扫描",
"btn-next": "下一张"
},

"files": {
"filename": "文件名",
"date": "日期",
"size": "大小",
"message:deleted": "已删除"
},

"navigation": {
"scan": "扫描",
"files": "文件",
"settings": "设置",
"about": "关于",
"version": "版本"
},

"pipeline": {
"high-quality": "高画质",
"medium-quality": "中画质",
"low-quality": "低画质",
"uncompressed": "无压缩",
"lzw-compressed": "LZW 压缩",
"ocr": "OCR",
"text-file": "文本文件"
},

"scan": {
"device": "设备",
"source": "来源",
"resolution": "分辨率",
"mode": "模式",
"dynamic-lineart": "动态线性",
"dynamic-lineart:enabled": "开启",
"dynamic-lineart:disabled": "关闭",
"batch": "批量",
"batch:none": "",
"batch:manual": "手动 (有提示)",
"batch:auto": "自动 (进纸器)",
"batch:auto-collate-standard": "自动 (标准校对 1, 3... 4, 2)",
"batch:auto-collate-reverse": "自动 (逆向校对 1, 3... 2, 4)",
"filters": "滤镜",
"filters:auto-level": "自动调整",
"filters:threshold": "阈值",
"filters:blur": "模糊",
"format": "格式",
"btn-preview": "预览",
"btn-clear": "清除",
"btn-scan": "扫描",
"btn-reset": "重置",
"top": "上边距",
"left": "左边距",
"width": "宽度",
"height": "高度",
"brightness": "亮度",
"contrast": "对比度",
"message:loading-devices": "加载设备 ...",
"message:no-devices": "未找到设备",
"message:deleted-preview": "删除预览",
"message:turn-documents": "旋转",
"message:preview-of-page": "预览"
},

"settings": {
"title": "@:navigation.settings",
"behaviour-ui": "用户界面",
"locale": "语言",
"locale:description": "选择语言",
"theme": "主题",
"theme:description": "界面主题。 若切换主题,请重新加载页面。",
"theme:system": "系统默认",
"theme:light": "浅色",
"theme:dark": "深色"
}
}
2 changes: 1 addition & 1 deletion webui/src/styles/variables.scss
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
$body-font-family: 'Segoe UI', 'Roboto', 'San Francisco', 'Lucidabright', 'Helvetica';
$body-font-family: 'Segoe UI', 'Roboto', 'Lucida Grande', 'San Francisco', 'Lucidabright', 'Helvetica';
$navigation-drawer-border-width: 0;

0 comments on commit 7c2895c

Please sign in to comment.