mirror of
https://github.com/hkalexling/Mango.git
synced 2026-04-25 00:00:52 -04:00
Compare commits
93 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2645e8cd05 | |||
| b2dc44a919 | |||
| c8db397a3b | |||
| 6384d4b77a | |||
| 1039732d87 | |||
| 011123f690 | |||
| e602a35b0c | |||
| 7792d3426e | |||
| b59c8f85ad | |||
| 18834ac28e | |||
| bf68e32ac8 | |||
| 54eb041fe4 | |||
| 57d8c100f9 | |||
| 56d973b99d | |||
| 670e5cdf6a | |||
| 1b35392f9c | |||
| c4e1ffe023 | |||
| 44f4959477 | |||
| 0582b57d60 | |||
| 83d96fd2a1 | |||
| 8ac89c420c | |||
| 968c2f4ad5 | |||
| ad940f30d5 | |||
| 308ad4e063 | |||
| 4d709b7eb5 | |||
| 5760ad924e | |||
| fff171c8c9 | |||
| 44ff566a1d | |||
| 853f422964 | |||
| 3bb0917374 | |||
| a86f0d0f34 | |||
| 16a9d7fc2e | |||
| ee2b4abc85 | |||
| a6c2799521 | |||
| 2370e4d2c6 | |||
| 32b0384ea0 | |||
| 50d4ffdb7b | |||
| 96463641f9 | |||
| ddbba5d596 | |||
| 2a04f4531e | |||
| a5b6fb781f | |||
| 8dfdab9d73 | |||
| 3a95270dfb | |||
| 2960ca54df | |||
| f5fe3c6b1c | |||
| a612cc15fb | |||
| c9c0818069 | |||
| 2f8efc382f | |||
| a0fb1880bd | |||
| a408f14425 | |||
| 243b6c8927 | |||
| ff3a44d017 | |||
| 67ef1f7112 | |||
| 5d7b8a1ef9 | |||
| a68f3eea95 | |||
| 220fc42bf2 | |||
| a45e6ea3da | |||
| 88394d4636 | |||
| ef1ab940f5 | |||
| 97a1c408d8 | |||
| abbf77df13 | |||
| 3b4021f680 | |||
| 68b1923cb6 | |||
| 3cdd4b29a5 | |||
| af84c0f6de | |||
| 85a65f84d0 | |||
| 5027a911cd | |||
| ac63bf7599 | |||
| 30b0e0b8fb | |||
| ddda058d8d | |||
| 46db25e8e0 | |||
| c07f421322 | |||
| 99a77966ad | |||
| d00b917575 | |||
| 4fd8334c37 | |||
| 3aa4630558 | |||
| cde5af7066 | |||
| eb528e1726 | |||
| 5e01cc38fe | |||
| 9a787ccbc3 | |||
| 8a83c0df4e | |||
| 87dea01917 | |||
| 586ee4f0ba | |||
| 53f3387e1a | |||
| be5d1918aa | |||
| df2cc0ffa9 | |||
| b8cfc3a201 | |||
| 8dc60ac2ea | |||
| 1719335d02 | |||
| 0cd46abc66 | |||
| e4fd7c58ee | |||
| d4abee52db | |||
| d29c94e898 |
@@ -0,0 +1,2 @@
|
|||||||
|
node_modules
|
||||||
|
lib
|
||||||
@@ -17,15 +17,24 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: apk add --no-cache yarn yaml sqlite-static libarchive-dev libarchive-static acl-static expat-static zstd-static lz4-static bzip2-static
|
run: apk add --no-cache yarn yaml sqlite-static libarchive-dev libarchive-static acl-static expat-static zstd-static lz4-static bzip2-static libjpeg-turbo-dev libpng-dev tiff-dev
|
||||||
- name: Build
|
- name: Build
|
||||||
run: make static
|
run: make static || make static
|
||||||
- name: Linter
|
- name: Linter
|
||||||
run: make check
|
run: make check
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: make test
|
run: make test
|
||||||
- name: Upload artifact
|
- name: Upload binary
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: mango
|
name: mango
|
||||||
path: mango
|
path: mango
|
||||||
|
- name: build arm32v7 object file
|
||||||
|
run: make arm32v7 || make arm32v7
|
||||||
|
- name: build arm64v8 object file
|
||||||
|
run: make arm64v8 || make arm64v8
|
||||||
|
- name: Upload object files
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: object files
|
||||||
|
path: ./*.o
|
||||||
|
|||||||
+2
-3
@@ -3,9 +3,8 @@ FROM crystallang/crystal:0.34.0-alpine AS builder
|
|||||||
WORKDIR /Mango
|
WORKDIR /Mango
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
COPY package*.json .
|
RUN apk add --no-cache yarn yaml sqlite-static libarchive-dev libarchive-static acl-static expat-static zstd-static lz4-static bzip2-static libjpeg-turbo-dev libpng-dev tiff-dev
|
||||||
RUN apk add --no-cache yarn yaml sqlite-static libarchive-dev libarchive-static acl-static expat-static zstd-static lz4-static bzip2-static \
|
RUN make static || make static
|
||||||
&& make static
|
|
||||||
|
|
||||||
FROM library/alpine
|
FROM library/alpine
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
FROM arm32v7/ubuntu:18.04
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y wget git make llvm-8 llvm-8-dev g++ libsqlite3-dev libyaml-dev libgc-dev libssl-dev libcrypto++-dev libevent-dev libgmp-dev zlib1g-dev libpcre++-dev pkg-config libarchive-dev libxml2-dev libacl1-dev nettle-dev liblzo2-dev liblzma-dev libbz2-dev libjpeg-turbo8-dev libpng-dev libtiff-dev
|
||||||
|
|
||||||
|
RUN git clone https://github.com/crystal-lang/crystal && cd crystal && git checkout 0.34.0 && make deps && cd ..
|
||||||
|
RUN git clone https://github.com/kostya/myhtml && cd myhtml/src/ext && git checkout v1.5.0 && make && cd ..
|
||||||
|
RUN git clone https://github.com/jessedoyle/duktape.cr && cd duktape.cr/ext && git checkout v0.20.0 && make && cd ..
|
||||||
|
RUN git clone https://github.com/hkalexling/image_size.cr && cd image_size.cr && git checkout v0.2.0 && make && cd ..
|
||||||
|
|
||||||
|
COPY mango-arm32v7.o .
|
||||||
|
|
||||||
|
RUN cc 'mango-arm32v7.o' -o 'mango' -rdynamic -lxml2 -L/image_size.cr/ext/libwebp -lwebp -L/image_size.cr/ext/stbi -lstbi /myhtml/src/ext/modest-c/lib/libmodest_static.a -L/duktape.cr/src/.build/lib -L/duktape.cr/src/.build/include -lduktape -lm `pkg-config libarchive --libs` -lz `command -v pkg-config > /dev/null && pkg-config --libs --silence-errors libssl || printf %s '-lssl -lcrypto'` `command -v pkg-config > /dev/null && pkg-config --libs --silence-errors libcrypto || printf %s '-lcrypto'` -lgmp -lsqlite3 -lyaml -lpcre -lm /usr/lib/arm-linux-gnueabihf/libgc.so -lpthread /crystal/src/ext/libcrystal.a -levent -lrt -ldl -L/usr/bin/../lib/crystal/lib -L/usr/bin/../lib/crystal/lib
|
||||||
|
|
||||||
|
CMD ["./mango"]
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
FROM arm64v8/ubuntu:18.04
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y wget git make llvm-8 llvm-8-dev g++ libsqlite3-dev libyaml-dev libgc-dev libssl-dev libcrypto++-dev libevent-dev libgmp-dev zlib1g-dev libpcre++-dev pkg-config libarchive-dev libxml2-dev libacl1-dev nettle-dev liblzo2-dev liblzma-dev libbz2-dev libjpeg-turbo8-dev libpng-dev libtiff-dev
|
||||||
|
|
||||||
|
RUN git clone https://github.com/crystal-lang/crystal && cd crystal && git checkout 0.34.0 && make deps && cd ..
|
||||||
|
RUN git clone https://github.com/kostya/myhtml && cd myhtml/src/ext && git checkout v1.5.0 && make && cd ..
|
||||||
|
RUN git clone https://github.com/jessedoyle/duktape.cr && cd duktape.cr/ext && git checkout v0.20.0 && make && cd ..
|
||||||
|
RUN git clone https://github.com/hkalexling/image_size.cr && cd image_size.cr && git checkout v0.2.0 && make && cd ..
|
||||||
|
|
||||||
|
COPY mango-arm64v8.o .
|
||||||
|
|
||||||
|
RUN cc 'mango-arm64v8.o' -o 'mango' -rdynamic -lxml2 -L/image_size.cr/ext/libwebp -lwebp -L/image_size.cr/ext/stbi -lstbi /myhtml/src/ext/modest-c/lib/libmodest_static.a -L/duktape.cr/src/.build/lib -L/duktape.cr/src/.build/include -lduktape -lm `pkg-config libarchive --libs` -lz `command -v pkg-config > /dev/null && pkg-config --libs --silence-errors libssl || printf %s '-lssl -lcrypto'` `command -v pkg-config > /dev/null && pkg-config --libs --silence-errors libcrypto || printf %s '-lcrypto'` -lgmp -lsqlite3 -lyaml -lpcre -lm /usr/lib/aarch64-linux-gnu/libgc.so -lpthread /crystal/src/ext/libcrystal.a -levent -lrt -ldl -L/usr/bin/../lib/crystal/lib -L/usr/bin/../lib/crystal/lib
|
||||||
|
|
||||||
|
CMD ["./mango"]
|
||||||
@@ -12,10 +12,10 @@ setup: libs
|
|||||||
yarn gulp dev
|
yarn gulp dev
|
||||||
|
|
||||||
build: libs
|
build: libs
|
||||||
crystal build src/mango.cr --release --progress
|
crystal build src/mango.cr --release --progress --error-trace
|
||||||
|
|
||||||
static: uglify | libs
|
static: uglify | libs
|
||||||
crystal build src/mango.cr --release --progress --static
|
crystal build src/mango.cr --release --progress --static --error-trace
|
||||||
|
|
||||||
libs:
|
libs:
|
||||||
shards install --production
|
shards install --production
|
||||||
@@ -31,6 +31,12 @@ check:
|
|||||||
./bin/ameba
|
./bin/ameba
|
||||||
./dev/linewidth.sh
|
./dev/linewidth.sh
|
||||||
|
|
||||||
|
arm32v7:
|
||||||
|
crystal build src/mango.cr --release --progress --error-trace --cross-compile --target='arm-linux-gnueabihf' -o mango-arm32v7
|
||||||
|
|
||||||
|
arm64v8:
|
||||||
|
crystal build src/mango.cr --release --progress --error-trace --cross-compile --target='aarch64-linux-gnu' -o mango-arm64v8
|
||||||
|
|
||||||
install:
|
install:
|
||||||
cp mango $(INSTALL_DIR)/mango
|
cp mango $(INSTALL_DIR)/mango
|
||||||
|
|
||||||
|
|||||||
@@ -12,8 +12,9 @@ Mango is a self-hosted manga server and reader. Its features include
|
|||||||
- Supported formats: `.cbz`, `.zip`, `.cbr` and `.rar`
|
- Supported formats: `.cbz`, `.zip`, `.cbr` and `.rar`
|
||||||
- Supports nested folders in library
|
- Supports nested folders in library
|
||||||
- Automatically stores reading progress
|
- Automatically stores reading progress
|
||||||
|
- Thumbnail generation
|
||||||
- Built-in [MangaDex](https://mangadex.org/) downloader
|
- Built-in [MangaDex](https://mangadex.org/) downloader
|
||||||
- [Plugins](https://github.com/hkalexling/mango-plugins) support
|
- Supports [plugins](https://github.com/hkalexling/mango-plugins) to download from thrid-party sites
|
||||||
- The web reader is responsive and works well on mobile, so there is no need for a mobile app
|
- The web reader is responsive and works well on mobile, so there is no need for a mobile app
|
||||||
- All the static files are embedded in the binary, so the deployment process is easy and painless
|
- All the static files are embedded in the binary, so the deployment process is easy and painless
|
||||||
|
|
||||||
@@ -51,7 +52,7 @@ The official docker images are available on [Dockerhub](https://hub.docker.com/r
|
|||||||
### CLI
|
### CLI
|
||||||
|
|
||||||
```
|
```
|
||||||
Mango - Manga Server and Web Reader. Version 0.9.0
|
Mango - Manga Server and Web Reader. Version 0.16.0
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
|
|
||||||
@@ -76,22 +77,27 @@ The default config file location is `~/.config/mango/config.yml`. It might be di
|
|||||||
---
|
---
|
||||||
port: 9000
|
port: 9000
|
||||||
base_url: /
|
base_url: /
|
||||||
|
session_secret: mango-session-secret
|
||||||
library_path: ~/mango/library
|
library_path: ~/mango/library
|
||||||
db_path: ~/mango/mango.db
|
db_path: ~/mango/mango.db
|
||||||
scan_interval_minutes: 5
|
scan_interval_minutes: 5
|
||||||
|
thumbnail_generation_interval_hours: 24
|
||||||
|
db_optimization_interval_hours: 24
|
||||||
log_level: info
|
log_level: info
|
||||||
upload_path: ~/mango/uploads
|
upload_path: ~/mango/uploads
|
||||||
|
plugin_path: ~/mango/plugins
|
||||||
|
download_timeout_seconds: 30
|
||||||
mangadex:
|
mangadex:
|
||||||
base_url: https://mangadex.org
|
base_url: https://mangadex.org
|
||||||
api_url: https://mangadex.org/api
|
api_url: https://mangadex.org/api
|
||||||
download_wait_seconds: 5
|
download_wait_seconds: 5
|
||||||
download_retries: 4
|
download_retries: 4
|
||||||
download_queue_db_path: ~/mango/queue.db
|
download_queue_db_path: /home/alex_ling/mango/queue.db
|
||||||
chapter_rename_rule: '[Vol.{volume} ][Ch.{chapter} ]{title|id}'
|
chapter_rename_rule: '[Vol.{volume} ][Ch.{chapter} ]{title|id}'
|
||||||
manga_rename_rule: '{title}'
|
manga_rename_rule: '{title}'
|
||||||
```
|
```
|
||||||
|
|
||||||
- `scan_interval_minutes` can be any non-negative integer. Setting it to `0` disables the periodic scan
|
- `scan_interval_minutes`, `thumbnail_generation_interval_hours` and `db_optimization_interval_hours` can be any non-negative integer. Setting them to `0` disables the periodic tasks
|
||||||
- `log_level` can be `debug`, `info`, `warn`, `error`, `fatal` or `off`. Setting it to `off` disables the logging
|
- `log_level` can be `debug`, `info`, `warn`, `error`, `fatal` or `off`. Setting it to `off` disables the logging
|
||||||
|
|
||||||
### Library Structure
|
### Library Structure
|
||||||
@@ -139,8 +145,13 @@ Mobile UI:
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
## Sponsors
|
||||||
|
|
||||||
|
<a href="https://casinoshunter.com/online-casinos/"><img src="https://i.imgur.com/EJb3wBo.png" width="150" height="auto"></a>
|
||||||
|
<a href="https://www.browserstack.com/open-source"><img src="https://i.imgur.com/hGJUJXD.png" width="150" height="auto"></a>
|
||||||
|
|
||||||
## Contributors
|
## Contributors
|
||||||
|
|
||||||
Please check the [development guideline](https://github.com/hkalexling/Mango/wiki/Development) if you are interest in code contributions.
|
Please check the [development guideline](https://github.com/hkalexling/Mango/wiki/Development) if you are interested in code contributions.
|
||||||
|
|
||||||
[](https://sourcerer.io/fame/hkalexling/hkalexling/Mango/links/0)[](https://sourcerer.io/fame/hkalexling/hkalexling/Mango/links/1)[](https://sourcerer.io/fame/hkalexling/hkalexling/Mango/links/2)[](https://sourcerer.io/fame/hkalexling/hkalexling/Mango/links/3)[](https://sourcerer.io/fame/hkalexling/hkalexling/Mango/links/4)[](https://sourcerer.io/fame/hkalexling/hkalexling/Mango/links/5)[](https://sourcerer.io/fame/hkalexling/hkalexling/Mango/links/6)[](https://sourcerer.io/fame/hkalexling/hkalexling/Mango/links/7)
|
[](https://sourcerer.io/fame/hkalexling/hkalexling/Mango/links/0)[](https://sourcerer.io/fame/hkalexling/hkalexling/Mango/links/1)[](https://sourcerer.io/fame/hkalexling/hkalexling/Mango/links/2)[](https://sourcerer.io/fame/hkalexling/hkalexling/Mango/links/3)[](https://sourcerer.io/fame/hkalexling/hkalexling/Mango/links/4)[](https://sourcerer.io/fame/hkalexling/hkalexling/Mango/links/5)[](https://sourcerer.io/fame/hkalexling/hkalexling/Mango/links/6)[](https://sourcerer.io/fame/hkalexling/hkalexling/Mango/links/7)
|
||||||
|
|||||||
+45
-31
@@ -1,15 +1,43 @@
|
|||||||
const gulp = require('gulp');
|
const gulp = require('gulp');
|
||||||
const minify = require("gulp-babel-minify");
|
const babel = require('gulp-babel');
|
||||||
|
const minify = require('gulp-babel-minify');
|
||||||
const minifyCss = require('gulp-minify-css');
|
const minifyCss = require('gulp-minify-css');
|
||||||
const less = require('gulp-less');
|
const less = require('gulp-less');
|
||||||
|
|
||||||
gulp.task('copy-uikit-js', () => {
|
// Copy libraries from node_moduels to public/js
|
||||||
return gulp.src('node_modules/uikit/dist/js/*.min.js')
|
gulp.task('copy-js', () => {
|
||||||
|
return gulp.src([
|
||||||
|
'node_modules/@fortawesome/fontawesome-free/js/fontawesome.min.js',
|
||||||
|
'node_modules/@fortawesome/fontawesome-free/js/solid.min.js',
|
||||||
|
'node_modules/uikit/dist/js/uikit.min.js',
|
||||||
|
'node_modules/uikit/dist/js/uikit-icons.min.js'
|
||||||
|
])
|
||||||
.pipe(gulp.dest('public/js'));
|
.pipe(gulp.dest('public/js'));
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('minify-js', () => {
|
// Copy UIKit SVG icons to public/img
|
||||||
return gulp.src('public/js/*.js')
|
gulp.task('copy-uikit-icons', () => {
|
||||||
|
return gulp.src('node_modules/uikit/src/images/backgrounds/*.svg')
|
||||||
|
.pipe(gulp.dest('public/img'));
|
||||||
|
});
|
||||||
|
|
||||||
|
// Compile less
|
||||||
|
gulp.task('less', () => {
|
||||||
|
return gulp.src('public/css/*.less')
|
||||||
|
.pipe(less())
|
||||||
|
.pipe(gulp.dest('public/css'));
|
||||||
|
});
|
||||||
|
|
||||||
|
// Transpile and minify JS files and output to dist
|
||||||
|
gulp.task('babel', () => {
|
||||||
|
return gulp.src(['public/js/*.js', '!public/js/*.min.js'])
|
||||||
|
.pipe(babel({
|
||||||
|
presets: [
|
||||||
|
['@babel/preset-env', {
|
||||||
|
targets: '>0.25%, not dead, ios>=9'
|
||||||
|
}]
|
||||||
|
],
|
||||||
|
}))
|
||||||
.pipe(minify({
|
.pipe(minify({
|
||||||
removeConsole: true,
|
removeConsole: true,
|
||||||
builtIns: false
|
builtIns: false
|
||||||
@@ -17,40 +45,26 @@ gulp.task('minify-js', () => {
|
|||||||
.pipe(gulp.dest('dist/js'));
|
.pipe(gulp.dest('dist/js'));
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('less', () => {
|
// Minify CSS and output to dist
|
||||||
return gulp.src('public/css/*.less')
|
|
||||||
.pipe(less())
|
|
||||||
.pipe(gulp.dest('public/css'));
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('minify-css', () => {
|
gulp.task('minify-css', () => {
|
||||||
return gulp.src('public/css/*.css')
|
return gulp.src('public/css/*.css')
|
||||||
.pipe(minifyCss())
|
.pipe(minifyCss())
|
||||||
.pipe(gulp.dest('dist/css'));
|
.pipe(gulp.dest('dist/css'));
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('copy-uikit-icons', () => {
|
// Copy static files (includeing images) to dist
|
||||||
return gulp.src('node_modules/uikit/src/images/backgrounds/*.svg')
|
|
||||||
.pipe(gulp.dest('public/img'));
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('img', () => {
|
|
||||||
return gulp.src('public/img/*')
|
|
||||||
.pipe(gulp.dest('dist/img'));
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('copy-files', () => {
|
gulp.task('copy-files', () => {
|
||||||
return gulp.src('public/*.*')
|
return gulp.src(['public/img/*', 'public/*.*', 'public/js/*.min.js'], {
|
||||||
|
base: 'public'
|
||||||
|
})
|
||||||
.pipe(gulp.dest('dist'));
|
.pipe(gulp.dest('dist'));
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('default', gulp.parallel(
|
// Set up the public folder for development
|
||||||
gulp.series('copy-uikit-js', 'minify-js'),
|
gulp.task('dev', gulp.parallel('copy-js', 'copy-uikit-icons', 'less'));
|
||||||
gulp.series('less', 'minify-css'),
|
|
||||||
gulp.series('copy-uikit-icons', 'img'),
|
|
||||||
'copy-files'
|
|
||||||
));
|
|
||||||
|
|
||||||
gulp.task('dev', gulp.parallel(
|
// Set up the dist folder for deployment
|
||||||
'copy-uikit-js', 'less', 'copy-uikit-icons'
|
gulp.task('deploy', gulp.parallel('babel', 'minify-css', 'copy-files'));
|
||||||
));
|
|
||||||
|
// Default task
|
||||||
|
gulp.task('default', gulp.series('dev', 'deploy'));
|
||||||
|
|||||||
+22
-19
@@ -1,21 +1,24 @@
|
|||||||
{
|
{
|
||||||
"name": "mango",
|
"name": "mango",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"repository": "https://github.com/hkalexling/Mango.git",
|
"repository": "https://github.com/hkalexling/Mango.git",
|
||||||
"author": "Alex Ling <hkalexling@gmail.com>",
|
"author": "Alex Ling <hkalexling@gmail.com>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"gulp": "^4.0.2",
|
"@babel/preset-env": "^7.11.5",
|
||||||
"gulp-babel-minify": "^0.5.1",
|
"gulp": "^4.0.2",
|
||||||
"gulp-less": "^4.0.1",
|
"gulp-babel": "^8.0.0",
|
||||||
"gulp-minify-css": "^1.2.4",
|
"gulp-babel-minify": "^0.5.1",
|
||||||
"less": "^3.11.3"
|
"gulp-less": "^4.0.1",
|
||||||
},
|
"gulp-minify-css": "^1.2.4",
|
||||||
"scripts": {
|
"less": "^3.11.3"
|
||||||
"uglify": "gulp"
|
},
|
||||||
},
|
"scripts": {
|
||||||
"dependencies": {
|
"uglify": "gulp"
|
||||||
"uikit": "^3.5.4"
|
},
|
||||||
}
|
"dependencies": {
|
||||||
|
"@fortawesome/fontawesome-free": "^5.14.0",
|
||||||
|
"uikit": "^3.5.4"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.uk-card-media-top {
|
.uk-card-media-top {
|
||||||
|
width: 100%;
|
||||||
height: 250px;
|
height: 250px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,3 +123,32 @@ td>.uk-dropdown {
|
|||||||
.uk-light .uk-description-list>dt {
|
.uk-light .uk-description-list>dt {
|
||||||
color: #555;
|
color: #555;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[x-cloak] {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#select-bar-controls a {
|
||||||
|
transform: scale(1.5, 1.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
#select-bar-controls a:hover {
|
||||||
|
color: orange;
|
||||||
|
}
|
||||||
|
|
||||||
|
#main-section {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
#totop-wrapper {
|
||||||
|
position: absolute;
|
||||||
|
top: 100vh;
|
||||||
|
right: 2em;
|
||||||
|
bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#totop-wrapper a {
|
||||||
|
position: fixed;
|
||||||
|
position: sticky;
|
||||||
|
top: calc(100vh - 5em);
|
||||||
|
}
|
||||||
|
|||||||
+82
-32
@@ -1,40 +1,90 @@
|
|||||||
let scanning = false;
|
|
||||||
|
|
||||||
const scan = () => {
|
|
||||||
scanning = true;
|
|
||||||
$('#scan-status > div').removeAttr('hidden');
|
|
||||||
$('#scan-status > span').attr('hidden', '');
|
|
||||||
const color = $('#scan').css('color');
|
|
||||||
$('#scan').css('color', 'gray');
|
|
||||||
$.post(base_url + 'api/admin/scan', (data) => {
|
|
||||||
const ms = data.milliseconds;
|
|
||||||
const titles = data.titles;
|
|
||||||
$('#scan-status > span').text('Scanned ' + titles + ' titles in ' + ms + 'ms');
|
|
||||||
$('#scan-status > span').removeAttr('hidden');
|
|
||||||
$('#scan').css('color', color);
|
|
||||||
$('#scan-status > div').attr('hidden', '');
|
|
||||||
scanning = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
String.prototype.capitalize = function() {
|
|
||||||
return this.charAt(0).toUpperCase() + this.slice(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
$(() => {
|
$(() => {
|
||||||
$('li').click((e) => {
|
|
||||||
const url = $(e.currentTarget).attr('data-url');
|
|
||||||
if (url) {
|
|
||||||
$(location).attr('href', url);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const setting = loadThemeSetting();
|
const setting = loadThemeSetting();
|
||||||
$('#theme-select').val(setting.capitalize());
|
$('#theme-select').val(capitalize(setting));
|
||||||
|
|
||||||
$('#theme-select').change((e) => {
|
$('#theme-select').change((e) => {
|
||||||
const newSetting = $(e.currentTarget).val().toLowerCase();
|
const newSetting = $(e.currentTarget).val().toLowerCase();
|
||||||
saveThemeSetting(newSetting);
|
saveThemeSetting(newSetting);
|
||||||
setTheme();
|
setTheme();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
getProgress();
|
||||||
|
setInterval(getProgress, 5000);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Capitalize String
|
||||||
|
*
|
||||||
|
* @function capitalize
|
||||||
|
* @param {string} str - The string to be capitalized
|
||||||
|
* @return {string} The capitalized string
|
||||||
|
*/
|
||||||
|
const capitalize = (str) => {
|
||||||
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set an alpine.js property
|
||||||
|
*
|
||||||
|
* @function setProp
|
||||||
|
* @param {string} key - Key of the data property
|
||||||
|
* @param {*} prop - The data property
|
||||||
|
*/
|
||||||
|
const setProp = (key, prop) => {
|
||||||
|
$('#root').get(0).__x.$data[key] = prop;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an alpine.js property
|
||||||
|
*
|
||||||
|
* @function getProp
|
||||||
|
* @param {string} key - Key of the data property
|
||||||
|
* @return {*} The data property
|
||||||
|
*/
|
||||||
|
const getProp = (key) => {
|
||||||
|
return $('#root').get(0).__x.$data[key];
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the thumbnail generation progress from the API
|
||||||
|
*
|
||||||
|
* @function getProgress
|
||||||
|
*/
|
||||||
|
const getProgress = () => {
|
||||||
|
$.get(`${base_url}api/admin/thumbnail_progress`)
|
||||||
|
.then(data => {
|
||||||
|
setProp('progress', data.progress);
|
||||||
|
const generating = data.progress > 0
|
||||||
|
setProp('generating', generating);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trigger the thumbnail generation
|
||||||
|
*
|
||||||
|
* @function generateThumbnails
|
||||||
|
*/
|
||||||
|
const generateThumbnails = () => {
|
||||||
|
setProp('generating', true);
|
||||||
|
setProp('progress', 0.0);
|
||||||
|
$.post(`${base_url}api/admin/generate_thumbnails`)
|
||||||
|
.then(getProgress);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trigger the scan
|
||||||
|
*
|
||||||
|
* @function scan
|
||||||
|
*/
|
||||||
|
const scan = () => {
|
||||||
|
setProp('scanning', true);
|
||||||
|
setProp('scanMs', -1);
|
||||||
|
setProp('scanTitles', 0);
|
||||||
|
$.post(`${base_url}api/admin/scan`)
|
||||||
|
.then(data => {
|
||||||
|
setProp('scanMs', data.milliseconds);
|
||||||
|
setProp('scanTitles', data.titles);
|
||||||
|
})
|
||||||
|
.always(() => {
|
||||||
|
setProp('scanning', false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
+22
-13
@@ -1,17 +1,26 @@
|
|||||||
const truncate = () => {
|
/**
|
||||||
$('.uk-card-title').each((i, e) => {
|
* Truncate a .uk-card-title element
|
||||||
$(e).dotdotdot({
|
*
|
||||||
truncate: 'letter',
|
* @function truncate
|
||||||
watch: true,
|
* @param {object} e - The title element to truncate
|
||||||
callback: (truncated) => {
|
*/
|
||||||
if (truncated) {
|
const truncate = (e) => {
|
||||||
$(e).attr('uk-tooltip', $(e).attr('data-title'));
|
$(e).dotdotdot({
|
||||||
} else {
|
truncate: 'letter',
|
||||||
$(e).removeAttr('uk-tooltip');
|
watch: true,
|
||||||
}
|
callback: (truncated) => {
|
||||||
|
if (truncated) {
|
||||||
|
$(e).attr('uk-tooltip', $(e).attr('data-title'));
|
||||||
|
} else {
|
||||||
|
$(e).removeAttr('uk-tooltip');
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
truncate();
|
$('.uk-card-title').each((i, e) => {
|
||||||
|
// Truncate the title when it first enters the view
|
||||||
|
$(e).one('inview', () => {
|
||||||
|
truncate(e);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ const search = () => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const path = new URL(input).pathname;
|
const path = new URL(input).pathname;
|
||||||
const match = /\/title\/([0-9]+)/.exec(path);
|
const match = /\/(?:title|manga)\/([0-9]+)/.exec(path);
|
||||||
int_id = parseInt(match[1]);
|
int_id = parseInt(match[1]);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
int_id = parseInt(input);
|
int_id = parseInt(input);
|
||||||
|
|||||||
Vendored
-5
File diff suppressed because one or more lines are too long
+296
-70
@@ -1,64 +1,172 @@
|
|||||||
$(function() {
|
let lastSavedPage = page;
|
||||||
function bind() {
|
let items = [];
|
||||||
var controller = new ScrollMagic.Controller();
|
let longPages = false;
|
||||||
|
|
||||||
// replace history on scroll
|
$(() => {
|
||||||
$('img').each(function(idx) {
|
getPages();
|
||||||
var scene = new ScrollMagic.Scene({
|
|
||||||
triggerElement: $(this).get(),
|
|
||||||
triggerHook: 'onEnter',
|
|
||||||
reverse: true
|
|
||||||
})
|
|
||||||
.addTo(controller)
|
|
||||||
.on('enter', function(event) {
|
|
||||||
current = $(event.target.triggerElement()).attr('id');
|
|
||||||
replaceHistory(current);
|
|
||||||
})
|
|
||||||
.on('leave', function(event) {
|
|
||||||
var prev = $(event.target.triggerElement()).prev();
|
|
||||||
current = $(prev).attr('id');
|
|
||||||
replaceHistory(current);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// poor man's infinite scroll
|
$('#page-select').change(() => {
|
||||||
var scene = new ScrollMagic.Scene({
|
const p = parseInt($('#page-select').val());
|
||||||
triggerElement: $('.next-url').get(),
|
toPage(p);
|
||||||
triggerHook: 'onEnter',
|
});
|
||||||
offset: -500
|
|
||||||
})
|
$('#mode-select').change(() => {
|
||||||
.addTo(controller)
|
const mode = $('#mode-select').val();
|
||||||
.on('enter', function() {
|
const curIdx = parseInt($('#page-select').val());
|
||||||
var nextURL = $('.next-url').attr('href');
|
|
||||||
$('.next-url').remove();
|
updateMode(mode, curIdx);
|
||||||
if (!nextURL) {
|
});
|
||||||
console.log('No .next-url found. Reached end of page');
|
});
|
||||||
var lastURL = $('img').last().attr('id');
|
|
||||||
// load the reader URL for the last page to update reading progrss to 100%
|
$(window).resize(() => {
|
||||||
$.get(lastURL);
|
const mode = getProp('mode');
|
||||||
$('#next-btn').removeAttr('hidden');
|
if (mode === 'continuous') return;
|
||||||
return;
|
|
||||||
}
|
const wideScreen = $(window).width() > $(window).height();
|
||||||
$('#hidden').load(encodeURI(nextURL) + ' .uk-container', function(res, status, xhr) {
|
const propMode = wideScreen ? 'height' : 'width';
|
||||||
if (status === 'error') console.log(xhr.statusText);
|
setProp('mode', propMode);
|
||||||
if (status === 'success') {
|
});
|
||||||
console.log(nextURL + ' loaded');
|
|
||||||
// new page loaded to #hidden, we now append it
|
/**
|
||||||
$('.uk-section > .uk-container').append($('#hidden .uk-container').children());
|
* Update the reader mode
|
||||||
$('#hidden').empty();
|
*
|
||||||
bind();
|
* @function updateMode
|
||||||
}
|
* @param {string} mode - The mode. Can be one of the followings:
|
||||||
});
|
* {'continuous', 'paged', 'height', 'width'}
|
||||||
});
|
* @param {number} targetPage - The one-based index of the target page
|
||||||
|
*/
|
||||||
|
const updateMode = (mode, targetPage) => {
|
||||||
|
localStorage.setItem('mode', mode);
|
||||||
|
|
||||||
|
// The mode to be put into the `mode` prop. It can't be `screen`
|
||||||
|
let propMode = mode;
|
||||||
|
|
||||||
|
if (mode === 'paged') {
|
||||||
|
const wideScreen = $(window).width() > $(window).height();
|
||||||
|
propMode = wideScreen ? 'height' : 'width';
|
||||||
}
|
}
|
||||||
|
|
||||||
bind();
|
setProp('mode', propMode);
|
||||||
});
|
|
||||||
$('#page-select').change(function() {
|
|
||||||
jumpTo(parseInt($('#page-select').val()));
|
|
||||||
});
|
|
||||||
|
|
||||||
function showControl(idx) {
|
if (mode === 'continuous') {
|
||||||
|
waitForPage(items.length, () => {
|
||||||
|
setupScroller();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
waitForPage(targetPage, () => {
|
||||||
|
setTimeout(() => {
|
||||||
|
toPage(targetPage);
|
||||||
|
}, 100);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set an alpine.js property
|
||||||
|
*
|
||||||
|
* @function setProp
|
||||||
|
* @param {string} key - Key of the data property
|
||||||
|
* @param {*} prop - The data property
|
||||||
|
*/
|
||||||
|
const setProp = (key, prop) => {
|
||||||
|
$('#root').get(0).__x.$data[key] = prop;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an alpine.js property
|
||||||
|
*
|
||||||
|
* @function getProp
|
||||||
|
* @param {string} key - Key of the data property
|
||||||
|
* @return {*} The data property
|
||||||
|
*/
|
||||||
|
const getProp = (key) => {
|
||||||
|
return $('#root').get(0).__x.$data[key];
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get dimension of the pages in the entry from the API and update the view
|
||||||
|
*/
|
||||||
|
const getPages = () => {
|
||||||
|
$.get(`${base_url}api/dimensions/${tid}/${eid}`)
|
||||||
|
.then(data => {
|
||||||
|
if (!data.success && data.error)
|
||||||
|
throw new Error(resp.error);
|
||||||
|
const dimensions = data.dimensions;
|
||||||
|
|
||||||
|
items = dimensions.map((d, i) => {
|
||||||
|
return {
|
||||||
|
id: i + 1,
|
||||||
|
url: `${base_url}api/page/${tid}/${eid}/${i+1}`,
|
||||||
|
width: d.width,
|
||||||
|
height: d.height
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
const avgRatio = items.reduce((acc, cur) => {
|
||||||
|
return acc + cur.height / cur.width
|
||||||
|
}, 0) / items.length;
|
||||||
|
|
||||||
|
console.log(avgRatio);
|
||||||
|
longPages = avgRatio > 2;
|
||||||
|
|
||||||
|
setProp('items', items);
|
||||||
|
setProp('loading', false);
|
||||||
|
|
||||||
|
const storedMode = localStorage.getItem('mode') || 'continuous';
|
||||||
|
|
||||||
|
setProp('mode', storedMode);
|
||||||
|
updateMode(storedMode, page);
|
||||||
|
$('#mode-select').val(storedMode);
|
||||||
|
})
|
||||||
|
.catch(e => {
|
||||||
|
const errMsg = `Failed to get the page dimensions. ${e}`;
|
||||||
|
console.error(e);
|
||||||
|
setProp('alertClass', 'uk-alert-danger');
|
||||||
|
setProp('msg', errMsg);
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Jump to a specific page
|
||||||
|
*
|
||||||
|
* @function toPage
|
||||||
|
* @param {number} idx - One-based index of the page
|
||||||
|
*/
|
||||||
|
const toPage = (idx) => {
|
||||||
|
const mode = getProp('mode');
|
||||||
|
if (mode === 'continuous') {
|
||||||
|
$(`#${idx}`).get(0).scrollIntoView(true);
|
||||||
|
} else {
|
||||||
|
if (idx >= 1 && idx <= items.length) {
|
||||||
|
setProp('curItem', items[idx - 1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
replaceHistory(idx);
|
||||||
|
UIkit.modal($('#modal-sections')).hide();
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a page exists every 100ms. If so, invoke the callback function.
|
||||||
|
*
|
||||||
|
* @function waitForPage
|
||||||
|
* @param {number} idx - One-based index of the page
|
||||||
|
* @param {function} cb - Callback function
|
||||||
|
*/
|
||||||
|
const waitForPage = (idx, cb) => {
|
||||||
|
if ($(`#${idx}`).length > 0) return cb();
|
||||||
|
setTimeout(() => {
|
||||||
|
waitForPage(idx, cb)
|
||||||
|
}, 100);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the control modal
|
||||||
|
*
|
||||||
|
* @function showControl
|
||||||
|
* @param {object} event - The onclick event that triggers the function
|
||||||
|
*/
|
||||||
|
const showControl = (event) => {
|
||||||
|
const idx = parseInt($(event.currentTarget).attr('id'));
|
||||||
const pageCount = $('#page-select > option').length;
|
const pageCount = $('#page-select > option').length;
|
||||||
const progressText = `Progress: ${idx}/${pageCount} (${(idx/pageCount * 100).toFixed(1)}%)`;
|
const progressText = `Progress: ${idx}/${pageCount} (${(idx/pageCount * 100).toFixed(1)}%)`;
|
||||||
$('#progress-label').text(progressText);
|
$('#progress-label').text(progressText);
|
||||||
@@ -66,19 +174,137 @@ function showControl(idx) {
|
|||||||
UIkit.modal($('#modal-sections')).show();
|
UIkit.modal($('#modal-sections')).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
function jumpTo(page) {
|
/**
|
||||||
var ary = window.location.pathname.split('/');
|
* Redirect to a URL
|
||||||
ary[ary.length - 1] = page;
|
*
|
||||||
ary.shift(); // remove leading `/`
|
* @function redirect
|
||||||
ary.unshift(window.location.origin);
|
* @param {string} url - The target URL
|
||||||
window.location.replace(ary.join('/'));
|
*/
|
||||||
}
|
const redirect = (url) => {
|
||||||
|
|
||||||
function replaceHistory(url) {
|
|
||||||
history.replaceState(null, "", url);
|
|
||||||
console.log('reading ' + url);
|
|
||||||
}
|
|
||||||
|
|
||||||
function redirect(url) {
|
|
||||||
window.location.replace(url);
|
window.location.replace(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replace the address bar history and save th ereading progress if necessary
|
||||||
|
*
|
||||||
|
* @function replaceHistory
|
||||||
|
* @param {number} idx - One-based index of the current page
|
||||||
|
*/
|
||||||
|
const replaceHistory = (idx) => {
|
||||||
|
const ary = window.location.pathname.split('/');
|
||||||
|
ary[ary.length - 1] = idx;
|
||||||
|
ary.shift(); // remove leading `/`
|
||||||
|
ary.unshift(window.location.origin);
|
||||||
|
const url = ary.join('/');
|
||||||
|
saveProgress(idx);
|
||||||
|
history.replaceState(null, "", url);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set up the scroll handler that calls `replaceHistory` when an image
|
||||||
|
* enters the view port
|
||||||
|
*
|
||||||
|
* @function setupScroller
|
||||||
|
*/
|
||||||
|
const setupScroller = () => {
|
||||||
|
const mode = getProp('mode');
|
||||||
|
if (mode !== 'continuous') return;
|
||||||
|
$('#root img').each((idx, el) => {
|
||||||
|
$(el).on('inview', (event, inView) => {
|
||||||
|
if (inView) {
|
||||||
|
const current = $(event.currentTarget).attr('id');
|
||||||
|
replaceHistory(current);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the backend reading progress if:
|
||||||
|
* 1) the current page is more than five pages away from the last
|
||||||
|
* saved page, or
|
||||||
|
* 2) the average height/width ratio of the pages is over 2, or
|
||||||
|
* 3) the current page is the first page, or
|
||||||
|
* 4) the current page is the last page
|
||||||
|
*
|
||||||
|
* @function saveProgress
|
||||||
|
* @param {number} idx - One-based index of the page
|
||||||
|
* @param {function} cb - Callback
|
||||||
|
*/
|
||||||
|
const saveProgress = (idx, cb) => {
|
||||||
|
idx = parseInt(idx);
|
||||||
|
if (Math.abs(idx - lastSavedPage) >= 5 ||
|
||||||
|
longPages ||
|
||||||
|
idx === 1 || idx === items.length
|
||||||
|
) {
|
||||||
|
lastSavedPage = idx;
|
||||||
|
console.log('saving progress', idx);
|
||||||
|
|
||||||
|
const url = `${base_url}api/progress/${tid}/${idx}?${$.param({entry: eid})}`;
|
||||||
|
$.post(url)
|
||||||
|
.then(data => {
|
||||||
|
if (data.error) throw new Error(data.error);
|
||||||
|
if (cb) cb();
|
||||||
|
})
|
||||||
|
.catch(e => {
|
||||||
|
console.error(e);
|
||||||
|
alert('danger', e);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mark progress to 100% and redirect to the next entry
|
||||||
|
* Used as the onclick handler for the "Next Entry" button
|
||||||
|
*
|
||||||
|
* @function nextEntry
|
||||||
|
* @param {string} nextUrl - URL of the next entry
|
||||||
|
*/
|
||||||
|
const nextEntry = (nextUrl) => {
|
||||||
|
saveProgress(items.length, () => {
|
||||||
|
redirect(nextUrl);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the next or the previous page
|
||||||
|
*
|
||||||
|
* @function flipPage
|
||||||
|
* @param {bool} isNext - Whether we are going to the next page
|
||||||
|
*/
|
||||||
|
const flipPage = (isNext) => {
|
||||||
|
const curItem = getProp('curItem');
|
||||||
|
const idx = parseInt(curItem.id);
|
||||||
|
const delta = isNext ? 1 : -1;
|
||||||
|
const newIdx = idx + delta;
|
||||||
|
|
||||||
|
toPage(newIdx);
|
||||||
|
|
||||||
|
if (isNext)
|
||||||
|
setProp('flipAnimation', 'right');
|
||||||
|
else
|
||||||
|
setProp('flipAnimation', 'left');
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
setProp('flipAnimation', null);
|
||||||
|
}, 500);
|
||||||
|
|
||||||
|
replaceHistory(newIdx);
|
||||||
|
saveProgress(newIdx);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the global keydown events
|
||||||
|
*
|
||||||
|
* @function keyHandler
|
||||||
|
* @param {event} event - The $event object
|
||||||
|
*/
|
||||||
|
const keyHandler = (event) => {
|
||||||
|
const mode = getProp('mode');
|
||||||
|
if (mode === 'continuous') return;
|
||||||
|
|
||||||
|
if (event.key === 'ArrowLeft' || event.key === 'k')
|
||||||
|
flipPage(false);
|
||||||
|
if (event.key === 'ArrowRight' || event.key === 'j')
|
||||||
|
flipPage(true);
|
||||||
|
};
|
||||||
|
|||||||
Vendored
-5
File diff suppressed because one or more lines are too long
+61
-1
@@ -55,7 +55,7 @@ function showModal(encodedPath, pages, percentage, encodedeTitle, encodedEntryTi
|
|||||||
|
|
||||||
$('#modal-edit-btn').attr('onclick', `edit("${entryID}")`);
|
$('#modal-edit-btn').attr('onclick', `edit("${entryID}")`);
|
||||||
|
|
||||||
$('#modal-download-btn').attr('href', `/opds/download/${titleID}/${entryID}`);
|
$('#modal-download-btn').attr('href', `${base_url}opds/download/${titleID}/${entryID}`);
|
||||||
|
|
||||||
UIkit.modal($('#modal')).show();
|
UIkit.modal($('#modal')).show();
|
||||||
}
|
}
|
||||||
@@ -182,3 +182,63 @@ const setupUpload = (eid) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const deselectAll = () => {
|
||||||
|
$('.item .uk-card').each((i, e) => {
|
||||||
|
const data = e.__x.$data;
|
||||||
|
data['selected'] = false;
|
||||||
|
});
|
||||||
|
$('#select-bar')[0].__x.$data['count'] = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
const selectAll = () => {
|
||||||
|
let count = 0;
|
||||||
|
$('.item .uk-card').each((i, e) => {
|
||||||
|
const data = e.__x.$data;
|
||||||
|
if (!data['disabled']) {
|
||||||
|
data['selected'] = true;
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$('#select-bar')[0].__x.$data['count'] = count;
|
||||||
|
};
|
||||||
|
|
||||||
|
const selectedIDs = () => {
|
||||||
|
const ary = [];
|
||||||
|
$('.item .uk-card').each((i, e) => {
|
||||||
|
const data = e.__x.$data;
|
||||||
|
if (!data['disabled'] && data['selected']) {
|
||||||
|
const item = $(e).closest('.item');
|
||||||
|
ary.push($(item).attr('id'));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return ary;
|
||||||
|
};
|
||||||
|
|
||||||
|
const bulkProgress = (action, el) => {
|
||||||
|
const tid = $(el).attr('data-id');
|
||||||
|
const ids = selectedIDs();
|
||||||
|
const url = `${base_url}api/bulk-progress/${action}/${tid}`;
|
||||||
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: url,
|
||||||
|
contentType: "application/json",
|
||||||
|
dataType: 'json',
|
||||||
|
data: JSON.stringify({
|
||||||
|
ids: ids
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.done(data => {
|
||||||
|
if (data.error) {
|
||||||
|
alert('danger', `Failed to mark entries as ${action}. Error: ${data.error}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
location.reload();
|
||||||
|
})
|
||||||
|
.fail((jqXHR, status) => {
|
||||||
|
alert('danger', `Failed to mark entries as ${action}. Error: [${jqXHR.status}] ${jqXHR.statusText}`);
|
||||||
|
})
|
||||||
|
.always(() => {
|
||||||
|
deselectAll();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|||||||
@@ -28,6 +28,14 @@ shards:
|
|||||||
github: crystal-loot/exception_page
|
github: crystal-loot/exception_page
|
||||||
version: 0.1.4
|
version: 0.1.4
|
||||||
|
|
||||||
|
http_proxy:
|
||||||
|
github: mamantoha/http_proxy
|
||||||
|
version: 0.7.1
|
||||||
|
|
||||||
|
image_size:
|
||||||
|
github: hkalexling/image_size.cr
|
||||||
|
version: 0.4.0
|
||||||
|
|
||||||
kemal:
|
kemal:
|
||||||
github: kemalcr/kemal
|
github: kemalcr/kemal
|
||||||
version: 0.26.1
|
version: 0.26.1
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
name: mango
|
name: mango
|
||||||
version: 0.9.0
|
version: 0.16.0
|
||||||
|
|
||||||
authors:
|
authors:
|
||||||
- Alex Ling <hkalexling@gmail.com>
|
- Alex Ling <hkalexling@gmail.com>
|
||||||
@@ -32,3 +32,7 @@ dependencies:
|
|||||||
version: ~> 0.20.0
|
version: ~> 0.20.0
|
||||||
myhtml:
|
myhtml:
|
||||||
github: kostya/myhtml
|
github: kostya/myhtml
|
||||||
|
http_proxy:
|
||||||
|
github: mamantoha/http_proxy
|
||||||
|
image_size:
|
||||||
|
github: hkalexling/image_size.cr
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ require "spec"
|
|||||||
require "../src/queue"
|
require "../src/queue"
|
||||||
require "../src/server"
|
require "../src/server"
|
||||||
require "../src/config"
|
require "../src/config"
|
||||||
|
require "../src/main_fiber"
|
||||||
|
|
||||||
class State
|
class State
|
||||||
@@hash = {} of String => String
|
@@hash = {} of String => String
|
||||||
|
|||||||
+6
-8
@@ -11,13 +11,15 @@ class Config
|
|||||||
property library_path : String = File.expand_path "~/mango/library",
|
property library_path : String = File.expand_path "~/mango/library",
|
||||||
home: true
|
home: true
|
||||||
property db_path : String = File.expand_path "~/mango/mango.db", home: true
|
property db_path : String = File.expand_path "~/mango/mango.db", home: true
|
||||||
@[YAML::Field(key: "scan_interval_minutes")]
|
property scan_interval_minutes : Int32 = 5
|
||||||
property scan_interval : Int32 = 5
|
property thumbnail_generation_interval_hours : Int32 = 24
|
||||||
|
property db_optimization_interval_hours : Int32 = 24
|
||||||
property log_level : String = "info"
|
property log_level : String = "info"
|
||||||
property upload_path : String = File.expand_path "~/mango/uploads",
|
property upload_path : String = File.expand_path "~/mango/uploads",
|
||||||
home: true
|
home: true
|
||||||
property plugin_path : String = File.expand_path "~/mango/plugins",
|
property plugin_path : String = File.expand_path "~/mango/plugins",
|
||||||
home: true
|
home: true
|
||||||
|
property download_timeout_seconds : Int32 = 30
|
||||||
property mangadex = Hash(String, String | Int32).new
|
property mangadex = Hash(String, String | Int32).new
|
||||||
|
|
||||||
@[YAML::Field(ignore: true)]
|
@[YAML::Field(ignore: true)]
|
||||||
@@ -52,12 +54,8 @@ class Config
|
|||||||
config.fill_defaults
|
config.fill_defaults
|
||||||
return config
|
return config
|
||||||
end
|
end
|
||||||
puts "The config file #{cfg_path} does not exist." \
|
puts "The config file #{cfg_path} does not exist. " \
|
||||||
" Do you want mango to dump the default config there? [Y/n]"
|
"Dumping the default config there."
|
||||||
input = gets
|
|
||||||
if input && input.downcase == "n"
|
|
||||||
abort "Aborting..."
|
|
||||||
end
|
|
||||||
default = self.allocate
|
default = self.allocate
|
||||||
default.path = path
|
default.path = path
|
||||||
default.fill_defaults
|
default.fill_defaults
|
||||||
|
|||||||
+63
-6
@@ -1,3 +1,5 @@
|
|||||||
|
require "image_size"
|
||||||
|
|
||||||
class Entry
|
class Entry
|
||||||
property zip_path : String, book : Title, title : String,
|
property zip_path : String, book : Title, title : String,
|
||||||
size : String, pages : Int32, id : String, encoded_path : String,
|
size : String, pages : Int32, id : String, encoded_path : String,
|
||||||
@@ -67,7 +69,7 @@ class Entry
|
|||||||
|
|
||||||
def cover_url
|
def cover_url
|
||||||
return "#{Config.current.base_url}img/icon.png" if @err_msg
|
return "#{Config.current.base_url}img/icon.png" if @err_msg
|
||||||
url = "#{Config.current.base_url}api/page/#{@book.id}/#{@id}/1"
|
url = "#{Config.current.base_url}api/cover/#{@book.id}/#{@id}"
|
||||||
TitleInfo.new @book.dir do |info|
|
TitleInfo.new @book.dir do |info|
|
||||||
info_url = info.entry_cover_url[@title]?
|
info_url = info.entry_cover_url[@title]?
|
||||||
unless info_url.nil? || info_url.empty?
|
unless info_url.nil? || info_url.empty?
|
||||||
@@ -77,11 +79,9 @@ class Entry
|
|||||||
url
|
url
|
||||||
end
|
end
|
||||||
|
|
||||||
def read_page(page_num)
|
private def sorted_archive_entries
|
||||||
raise "Unreadble archive. #{@err_msg}" if @err_msg
|
|
||||||
img = nil
|
|
||||||
ArchiveFile.open @zip_path do |file|
|
ArchiveFile.open @zip_path do |file|
|
||||||
page = file.entries
|
entries = file.entries
|
||||||
.select { |e|
|
.select { |e|
|
||||||
SUPPORTED_IMG_TYPES.includes? \
|
SUPPORTED_IMG_TYPES.includes? \
|
||||||
MIME.from_filename? e.filename
|
MIME.from_filename? e.filename
|
||||||
@@ -89,7 +89,15 @@ class Entry
|
|||||||
.sort { |a, b|
|
.sort { |a, b|
|
||||||
compare_numerically a.filename, b.filename
|
compare_numerically a.filename, b.filename
|
||||||
}
|
}
|
||||||
.[page_num - 1]
|
yield file, entries
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def read_page(page_num)
|
||||||
|
raise "Unreadble archive. #{@err_msg}" if @err_msg
|
||||||
|
img = nil
|
||||||
|
sorted_archive_entries do |file, entries|
|
||||||
|
page = entries[page_num - 1]
|
||||||
data = file.read_entry page
|
data = file.read_entry page
|
||||||
if data
|
if data
|
||||||
img = Image.new data, MIME.from_filename(page.filename), page.filename,
|
img = Image.new data, MIME.from_filename(page.filename), page.filename,
|
||||||
@@ -99,6 +107,26 @@ class Entry
|
|||||||
img
|
img
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def page_dimensions
|
||||||
|
sizes = [] of Hash(String, Int32)
|
||||||
|
sorted_archive_entries do |file, entries|
|
||||||
|
entries.each_with_index do |e, i|
|
||||||
|
begin
|
||||||
|
data = file.read_entry(e).not_nil!
|
||||||
|
size = ImageSize.get data
|
||||||
|
sizes << {
|
||||||
|
"width" => size.width,
|
||||||
|
"height" => size.height,
|
||||||
|
}
|
||||||
|
rescue e
|
||||||
|
Logger.warn "Failed to read page #{i} of entry #{zip_path}. #{e}"
|
||||||
|
sizes << {"width" => 1000_i32, "height" => 1000_i32}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
sizes
|
||||||
|
end
|
||||||
|
|
||||||
def next_entry(username)
|
def next_entry(username)
|
||||||
entries = @book.sorted_entries username
|
entries = @book.sorted_entries username
|
||||||
idx = entries.index self
|
idx = entries.index self
|
||||||
@@ -179,4 +207,33 @@ class Entry
|
|||||||
def started?(username)
|
def started?(username)
|
||||||
load_progress(username) > 0
|
load_progress(username) > 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def generate_thumbnail : Image?
|
||||||
|
return if @err_msg
|
||||||
|
|
||||||
|
img = read_page(1).not_nil!
|
||||||
|
begin
|
||||||
|
size = ImageSize.get img.data
|
||||||
|
if size.height > size.width
|
||||||
|
thumbnail = ImageSize.resize img.data, width: 200
|
||||||
|
else
|
||||||
|
thumbnail = ImageSize.resize img.data, height: 300
|
||||||
|
end
|
||||||
|
img.data = thumbnail
|
||||||
|
img.size = thumbnail.size
|
||||||
|
unless img.mime == "image/webp"
|
||||||
|
# image_size.cr resizes non-webp images to jpg
|
||||||
|
img.mime = "image/jpeg"
|
||||||
|
end
|
||||||
|
Storage.default.save_thumbnail @id, img
|
||||||
|
rescue e
|
||||||
|
Logger.warn "Failed to generate thumbnail for file #{@zip_path}. #{e}"
|
||||||
|
end
|
||||||
|
|
||||||
|
img
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_thumbnail : Image?
|
||||||
|
Storage.default.get_thumbnail @id
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+129
-41
@@ -1,5 +1,5 @@
|
|||||||
class Library
|
class Library
|
||||||
property dir : String, title_ids : Array(String), scan_interval : Int32,
|
property dir : String, title_ids : Array(String),
|
||||||
title_hash : Hash(String, Title)
|
title_hash : Hash(String, Title)
|
||||||
|
|
||||||
use_default
|
use_default
|
||||||
@@ -8,20 +8,48 @@ class Library
|
|||||||
register_mime_types
|
register_mime_types
|
||||||
|
|
||||||
@dir = Config.current.library_path
|
@dir = Config.current.library_path
|
||||||
@scan_interval = Config.current.scan_interval
|
|
||||||
# explicitly initialize @titles to bypass the compiler check. it will
|
# explicitly initialize @titles to bypass the compiler check. it will
|
||||||
# be filled with actual Titles in the `scan` call below
|
# be filled with actual Titles in the `scan` call below
|
||||||
@title_ids = [] of String
|
@title_ids = [] of String
|
||||||
@title_hash = {} of String => Title
|
@title_hash = {} of String => Title
|
||||||
|
|
||||||
return scan if @scan_interval < 1
|
@entries_count = 0
|
||||||
spawn do
|
@thumbnails_count = 0
|
||||||
loop do
|
|
||||||
start = Time.local
|
scan_interval = Config.current.scan_interval_minutes
|
||||||
scan
|
if scan_interval < 1
|
||||||
ms = (Time.local - start).total_milliseconds
|
scan
|
||||||
Logger.info "Scanned #{@title_ids.size} titles in #{ms}ms"
|
else
|
||||||
sleep @scan_interval * 60
|
spawn do
|
||||||
|
loop do
|
||||||
|
start = Time.local
|
||||||
|
scan
|
||||||
|
ms = (Time.local - start).total_milliseconds
|
||||||
|
Logger.info "Scanned #{@title_ids.size} titles in #{ms}ms"
|
||||||
|
sleep scan_interval.minutes
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
thumbnail_interval = Config.current.thumbnail_generation_interval_hours
|
||||||
|
unless thumbnail_interval < 1
|
||||||
|
spawn do
|
||||||
|
loop do
|
||||||
|
# Wait for scan to complete (in most cases)
|
||||||
|
sleep 1.minutes
|
||||||
|
generate_thumbnails
|
||||||
|
sleep thumbnail_interval.hours
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
db_interval = Config.current.db_optimization_interval_hours
|
||||||
|
unless db_interval < 1
|
||||||
|
spawn do
|
||||||
|
loop do
|
||||||
|
Storage.default.optimize
|
||||||
|
sleep db_interval.hours
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -30,6 +58,41 @@ class Library
|
|||||||
@title_ids.map { |tid| self.get_title!(tid) }
|
@title_ids.map { |tid| self.get_title!(tid) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def sorted_titles(username, opt : SortOptions? = nil)
|
||||||
|
if opt.nil?
|
||||||
|
opt = SortOptions.from_info_json @dir, username
|
||||||
|
else
|
||||||
|
TitleInfo.new @dir do |info|
|
||||||
|
info.sort_by[username] = opt.to_tuple
|
||||||
|
info.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# This is a hack to bypass a compiler bug
|
||||||
|
ary = titles
|
||||||
|
|
||||||
|
case opt.not_nil!.method
|
||||||
|
when .time_modified?
|
||||||
|
ary.sort! { |a, b| (a.mtime <=> b.mtime).or \
|
||||||
|
compare_numerically a.title, b.title }
|
||||||
|
when .progress?
|
||||||
|
ary.sort! do |a, b|
|
||||||
|
(a.load_percentage(username) <=> b.load_percentage(username)).or \
|
||||||
|
compare_numerically a.title, b.title
|
||||||
|
end
|
||||||
|
else
|
||||||
|
unless opt.method.auto?
|
||||||
|
Logger.warn "Unknown sorting method #{opt.not_nil!.method}. Using " \
|
||||||
|
"Auto instead"
|
||||||
|
end
|
||||||
|
ary.sort! { |a, b| compare_numerically a.title, b.title }
|
||||||
|
end
|
||||||
|
|
||||||
|
ary.reverse! unless opt.not_nil!.ascend
|
||||||
|
|
||||||
|
ary
|
||||||
|
end
|
||||||
|
|
||||||
def deep_titles
|
def deep_titles
|
||||||
titles + titles.map { |t| t.deep_titles }.flatten
|
titles + titles.map { |t| t.deep_titles }.flatten
|
||||||
end
|
end
|
||||||
@@ -57,7 +120,6 @@ class Library
|
|||||||
"Attempting to create it"
|
"Attempting to create it"
|
||||||
Dir.mkdir_p @dir
|
Dir.mkdir_p @dir
|
||||||
end
|
end
|
||||||
@title_ids.clear
|
|
||||||
|
|
||||||
storage = Storage.new auto_close: false
|
storage = Storage.new auto_close: false
|
||||||
|
|
||||||
@@ -68,6 +130,7 @@ class Library
|
|||||||
.map { |path| Title.new path, "", storage, self }
|
.map { |path| Title.new path, "", storage, self }
|
||||||
.select { |title| !(title.entries.empty? && title.titles.empty?) }
|
.select { |title| !(title.entries.empty? && title.titles.empty?) }
|
||||||
.sort { |a, b| a.title <=> b.title }
|
.sort { |a, b| a.title <=> b.title }
|
||||||
|
.tap { |_| @title_ids.clear }
|
||||||
.each do |title|
|
.each do |title|
|
||||||
@title_hash[title.id] = title
|
@title_hash[title.id] = title
|
||||||
@title_ids << title.id
|
@title_ids << title.id
|
||||||
@@ -83,7 +146,7 @@ class Library
|
|||||||
cr_entries = deep_titles
|
cr_entries = deep_titles
|
||||||
.map { |t| t.get_last_read_entry username }
|
.map { |t| t.get_last_read_entry username }
|
||||||
# Select elements with type `Entry` from the array and ignore all `Nil`s
|
# Select elements with type `Entry` from the array and ignore all `Nil`s
|
||||||
.select(Entry)[0..11]
|
.select(Entry)[0...ENTRIES_IN_HOME_SECTIONS]
|
||||||
.map { |e|
|
.map { |e|
|
||||||
# Get the last read time of the entry. If it hasn't been started, get
|
# Get the last read time of the entry. If it hasn't been started, get
|
||||||
# the last read time of the previous entry
|
# the last read time of the previous entry
|
||||||
@@ -143,41 +206,66 @@ class Library
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
recently_added[0..11]
|
recently_added[0...ENTRIES_IN_HOME_SECTIONS]
|
||||||
end
|
end
|
||||||
|
|
||||||
def sorted_titles(username, opt : SortOptions? = nil)
|
def get_start_reading_titles(username)
|
||||||
if opt.nil?
|
# Here we are not using `deep_titles` as it may cause unexpected behaviors
|
||||||
opt = SortOptions.from_info_json @dir, username
|
# For example, consider the following nested titles:
|
||||||
else
|
# - One Puch Man
|
||||||
TitleInfo.new @dir do |info|
|
# - Vol. 1
|
||||||
info.sort_by[username] = opt.to_tuple
|
# - Vol. 2
|
||||||
info.save
|
# If we use `deep_titles`, the start reading section might include `Vol. 2`
|
||||||
|
# when the user hasn't started `Vol. 1` yet
|
||||||
|
titles
|
||||||
|
.select { |t| t.load_percentage(username) == 0 }
|
||||||
|
.sample(ENTRIES_IN_HOME_SECTIONS)
|
||||||
|
.shuffle
|
||||||
|
end
|
||||||
|
|
||||||
|
def thumbnail_generation_progress
|
||||||
|
return 0 if @entries_count == 0
|
||||||
|
@thumbnails_count / @entries_count
|
||||||
|
end
|
||||||
|
|
||||||
|
def generate_thumbnails
|
||||||
|
if @thumbnails_count > 0
|
||||||
|
Logger.debug "Thumbnail generation in progress"
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
Logger.info "Starting thumbnail generation"
|
||||||
|
entries = deep_titles.map(&.deep_entries).flatten.reject &.err_msg
|
||||||
|
@entries_count = entries.size
|
||||||
|
@thumbnails_count = 0
|
||||||
|
|
||||||
|
# Report generation progress regularly
|
||||||
|
spawn do
|
||||||
|
loop do
|
||||||
|
unless @thumbnails_count == 0
|
||||||
|
Logger.debug "Thumbnail generation progress: " \
|
||||||
|
"#{(thumbnail_generation_progress * 100).round 1}%"
|
||||||
|
end
|
||||||
|
# Generation is completed. We reset the count to 0 to allow subsequent
|
||||||
|
# calls to the function, and break from the loop to stop the progress
|
||||||
|
# report fiber
|
||||||
|
if thumbnail_generation_progress.to_i == 1
|
||||||
|
@thumbnails_count = 0
|
||||||
|
break
|
||||||
|
end
|
||||||
|
sleep 10.seconds
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# This is a hack to bypass a compiler bug
|
entries.each do |e|
|
||||||
ary = titles
|
unless e.get_thumbnail
|
||||||
|
e.generate_thumbnail
|
||||||
case opt.not_nil!.method
|
# Sleep after each generation to minimize the impact on disk IO
|
||||||
when .time_modified?
|
# and CPU
|
||||||
ary.sort! { |a, b| (a.mtime <=> b.mtime).or \
|
sleep 0.5.seconds
|
||||||
compare_numerically a.title, b.title }
|
|
||||||
when .progress?
|
|
||||||
ary.sort! do |a, b|
|
|
||||||
(a.load_percentage(username) <=> b.load_percentage(username)).or \
|
|
||||||
compare_numerically a.title, b.title
|
|
||||||
end
|
end
|
||||||
else
|
@thumbnails_count += 1
|
||||||
unless opt.method.auto?
|
|
||||||
Logger.warn "Unknown sorting method #{opt.not_nil!.method}. Using " \
|
|
||||||
"Auto instead"
|
|
||||||
end
|
|
||||||
ary.sort! { |a, b| compare_numerically a.title, b.title }
|
|
||||||
end
|
end
|
||||||
|
Logger.info "Thumbnail generation finished"
|
||||||
ary.reverse! unless opt.not_nil!.ascend
|
|
||||||
|
|
||||||
ary
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -355,4 +355,24 @@ class Title
|
|||||||
return zip if title_ids.empty?
|
return zip if title_ids.empty?
|
||||||
zip + titles.map { |t| t.deep_entries_with_date_added }.flatten
|
zip + titles.map { |t| t.deep_entries_with_date_added }.flatten
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def bulk_progress(action, ids : Array(String), username)
|
||||||
|
selected_entries = ids
|
||||||
|
.map { |id|
|
||||||
|
@entries.find { |e| e.id == id }
|
||||||
|
}
|
||||||
|
.select(Entry)
|
||||||
|
|
||||||
|
TitleInfo.new @dir do |info|
|
||||||
|
selected_entries.each do |e|
|
||||||
|
page = action == "read" ? e.pages : 0
|
||||||
|
if info.progress[username]?.nil?
|
||||||
|
info.progress[username] = {e.title => page}
|
||||||
|
else
|
||||||
|
info.progress[username][e.title] = page
|
||||||
|
end
|
||||||
|
end
|
||||||
|
info.save
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -57,6 +57,16 @@ struct Image
|
|||||||
|
|
||||||
def initialize(@data, @mime, @filename, @size)
|
def initialize(@data, @mime, @filename, @size)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.from_db(res : DB::ResultSet)
|
||||||
|
img = Image.allocate
|
||||||
|
res.read String
|
||||||
|
img.data = res.read Bytes
|
||||||
|
img.filename = res.read String
|
||||||
|
img.mime = res.read String
|
||||||
|
img.size = res.read Int32
|
||||||
|
img
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class TitleInfo
|
class TitleInfo
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
# On ARM, connecting to the SQLite DB from a spawned fiber would crash
|
||||||
|
# https://github.com/crystal-lang/crystal-sqlite3/issues/30
|
||||||
|
# This is a temporary workaround that forces the relevant code to run in the
|
||||||
|
# main fiber
|
||||||
|
|
||||||
|
class MainFiber
|
||||||
|
@@channel = Channel(-> Nil).new
|
||||||
|
@@done = Channel(Bool).new
|
||||||
|
@@main_fiber = Fiber.current
|
||||||
|
|
||||||
|
def self.start_and_block
|
||||||
|
loop do
|
||||||
|
if proc = @@channel.receive
|
||||||
|
begin
|
||||||
|
proc.call
|
||||||
|
ensure
|
||||||
|
@@done.send true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Fiber.yield
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.run(&block : -> Nil)
|
||||||
|
if @@main_fiber == Fiber.current
|
||||||
|
block.call
|
||||||
|
else
|
||||||
|
@@channel.send block
|
||||||
|
until @@done.receive
|
||||||
|
Fiber.yield
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
require "http/client"
|
|
||||||
require "json"
|
require "json"
|
||||||
require "csv"
|
require "csv"
|
||||||
require "../rename"
|
require "../rename"
|
||||||
|
|||||||
@@ -27,14 +27,16 @@ module MangaDex
|
|||||||
|
|
||||||
def pop : Queue::Job?
|
def pop : Queue::Job?
|
||||||
job = nil
|
job = nil
|
||||||
DB.open "sqlite3://#{@queue.path}" do |db|
|
MainFiber.run do
|
||||||
begin
|
DB.open "sqlite3://#{@queue.path}" do |db|
|
||||||
db.query_one "select * from queue where id not like '%-%' " \
|
begin
|
||||||
"and (status = 0 or status = 1) " \
|
db.query_one "select * from queue where id not like '%-%' " \
|
||||||
"order by time limit 1" do |res|
|
"and (status = 0 or status = 1) " \
|
||||||
job = Queue::Job.from_query_result res
|
"order by time limit 1" do |res|
|
||||||
|
job = Queue::Job.from_query_result res
|
||||||
|
end
|
||||||
|
rescue
|
||||||
end
|
end
|
||||||
rescue
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
job
|
job
|
||||||
|
|||||||
+31
-6
@@ -1,12 +1,29 @@
|
|||||||
require "./config"
|
require "./config"
|
||||||
require "./queue"
|
require "./queue"
|
||||||
require "./server"
|
require "./server"
|
||||||
|
require "./main_fiber"
|
||||||
require "./mangadex/*"
|
require "./mangadex/*"
|
||||||
require "option_parser"
|
require "option_parser"
|
||||||
require "clim"
|
require "clim"
|
||||||
require "./plugin/*"
|
require "./plugin/*"
|
||||||
|
|
||||||
MANGO_VERSION = "0.9.0"
|
MANGO_VERSION = "0.16.0"
|
||||||
|
|
||||||
|
# From http://www.network-science.de/ascii/
|
||||||
|
BANNER = %{
|
||||||
|
|
||||||
|
_| _|
|
||||||
|
_|_| _|_| _|_|_| _|_|_| _|_|_| _|_|
|
||||||
|
_| _| _| _| _| _| _| _| _| _| _|
|
||||||
|
_| _| _| _| _| _| _| _| _| _|
|
||||||
|
_| _| _|_|_| _| _| _|_|_| _|_|
|
||||||
|
_|
|
||||||
|
_|_|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
DESCRIPTION = "Mango - Manga Server and Web Reader. Version #{MANGO_VERSION}"
|
||||||
|
|
||||||
macro common_option
|
macro common_option
|
||||||
option "-c PATH", "--config=PATH", type: String,
|
option "-c PATH", "--config=PATH", type: String,
|
||||||
@@ -22,20 +39,28 @@ end
|
|||||||
|
|
||||||
class CLI < Clim
|
class CLI < Clim
|
||||||
main do
|
main do
|
||||||
desc "Mango - Manga Server and Web Reader. Version #{MANGO_VERSION}"
|
desc DESCRIPTION
|
||||||
usage "mango [sub_command] [options]"
|
usage "mango [sub_command] [options]"
|
||||||
help short: "-h"
|
help short: "-h"
|
||||||
version "Version #{MANGO_VERSION}", short: "-v"
|
version "Version #{MANGO_VERSION}", short: "-v"
|
||||||
common_option
|
common_option
|
||||||
run do |opts|
|
run do |opts|
|
||||||
|
puts BANNER
|
||||||
|
puts DESCRIPTION
|
||||||
|
puts
|
||||||
|
|
||||||
|
# empty ARGV so it won't be passed to Kemal
|
||||||
|
ARGV.clear
|
||||||
|
|
||||||
Config.load(opts.config).set_current
|
Config.load(opts.config).set_current
|
||||||
MangaDex::Downloader.default
|
MangaDex::Downloader.default
|
||||||
Plugin::Downloader.default
|
Plugin::Downloader.default
|
||||||
|
|
||||||
# empty ARGV so it won't be passed to Kemal
|
spawn do
|
||||||
ARGV.clear
|
Server.new.start
|
||||||
server = Server.new
|
end
|
||||||
server.start
|
|
||||||
|
MainFiber.start_and_block
|
||||||
end
|
end
|
||||||
|
|
||||||
sub "admin" do
|
sub "admin" do
|
||||||
|
|||||||
@@ -8,14 +8,16 @@ class Plugin
|
|||||||
|
|
||||||
def pop : Queue::Job?
|
def pop : Queue::Job?
|
||||||
job = nil
|
job = nil
|
||||||
DB.open "sqlite3://#{@queue.path}" do |db|
|
MainFiber.run do
|
||||||
begin
|
DB.open "sqlite3://#{@queue.path}" do |db|
|
||||||
db.query_one "select * from queue where id like '%-%' " \
|
begin
|
||||||
"and (status = 0 or status = 1) " \
|
db.query_one "select * from queue where id like '%-%' " \
|
||||||
"order by time limit 1" do |res|
|
"and (status = 0 or status = 1) " \
|
||||||
job = Queue::Job.from_query_result res
|
"order by time limit 1" do |res|
|
||||||
|
job = Queue::Job.from_query_result res
|
||||||
|
end
|
||||||
|
rescue
|
||||||
end
|
end
|
||||||
rescue
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
job
|
job
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
require "duktape/runtime"
|
require "duktape/runtime"
|
||||||
require "myhtml"
|
require "myhtml"
|
||||||
require "http"
|
|
||||||
require "xml"
|
require "xml"
|
||||||
|
|
||||||
class Plugin
|
class Plugin
|
||||||
|
|||||||
+87
-59
@@ -119,22 +119,24 @@ class Queue
|
|||||||
"Attepmting to create it"
|
"Attepmting to create it"
|
||||||
Dir.mkdir_p dir
|
Dir.mkdir_p dir
|
||||||
end
|
end
|
||||||
DB.open "sqlite3://#{@path}" do |db|
|
MainFiber.run do
|
||||||
begin
|
DB.open "sqlite3://#{@path}" do |db|
|
||||||
db.exec "create table if not exists queue " \
|
begin
|
||||||
"(id text, manga_id text, title text, manga_title " \
|
db.exec "create table if not exists queue " \
|
||||||
"text, status integer, status_message text, " \
|
"(id text, manga_id text, title text, manga_title " \
|
||||||
"pages integer, success_count integer, " \
|
"text, status integer, status_message text, " \
|
||||||
"fail_count integer, time integer)"
|
"pages integer, success_count integer, " \
|
||||||
db.exec "create unique index if not exists id_idx " \
|
"fail_count integer, time integer)"
|
||||||
"on queue (id)"
|
db.exec "create unique index if not exists id_idx " \
|
||||||
db.exec "create index if not exists manga_id_idx " \
|
"on queue (id)"
|
||||||
"on queue (manga_id)"
|
db.exec "create index if not exists manga_id_idx " \
|
||||||
db.exec "create index if not exists status_idx " \
|
"on queue (manga_id)"
|
||||||
"on queue (status)"
|
db.exec "create index if not exists status_idx " \
|
||||||
rescue e
|
"on queue (status)"
|
||||||
Logger.error "Error when checking tables in DB: #{e}"
|
rescue e
|
||||||
raise e
|
Logger.error "Error when checking tables in DB: #{e}"
|
||||||
|
raise e
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -143,23 +145,27 @@ class Queue
|
|||||||
# inserted. Any job already exists in the queue will be ignored.
|
# inserted. Any job already exists in the queue will be ignored.
|
||||||
def push(jobs : Array(Job))
|
def push(jobs : Array(Job))
|
||||||
start_count = self.count
|
start_count = self.count
|
||||||
DB.open "sqlite3://#{@path}" do |db|
|
MainFiber.run do
|
||||||
jobs.each do |job|
|
DB.open "sqlite3://#{@path}" do |db|
|
||||||
db.exec "insert or ignore into queue values " \
|
jobs.each do |job|
|
||||||
"(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
db.exec "insert or ignore into queue values " \
|
||||||
job.id, job.manga_id, job.title, job.manga_title,
|
"(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||||
job.status.to_i, job.status_message, job.pages,
|
job.id, job.manga_id, job.title, job.manga_title,
|
||||||
job.success_count, job.fail_count, job.time.to_unix_ms
|
job.status.to_i, job.status_message, job.pages,
|
||||||
|
job.success_count, job.fail_count, job.time.to_unix_ms
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self.count - start_count
|
self.count - start_count
|
||||||
end
|
end
|
||||||
|
|
||||||
def reset(id : String)
|
def reset(id : String)
|
||||||
DB.open "sqlite3://#{@path}" do |db|
|
MainFiber.run do
|
||||||
db.exec "update queue set status = 0, status_message = '', " \
|
DB.open "sqlite3://#{@path}" do |db|
|
||||||
"pages = 0, success_count = 0, fail_count = 0 " \
|
db.exec "update queue set status = 0, status_message = '', " \
|
||||||
"where id = (?)", id
|
"pages = 0, success_count = 0, fail_count = 0 " \
|
||||||
|
"where id = (?)", id
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -169,16 +175,20 @@ class Queue
|
|||||||
|
|
||||||
# Reset all failed tasks (missing pages and error)
|
# Reset all failed tasks (missing pages and error)
|
||||||
def reset
|
def reset
|
||||||
DB.open "sqlite3://#{@path}" do |db|
|
MainFiber.run do
|
||||||
db.exec "update queue set status = 0, status_message = '', " \
|
DB.open "sqlite3://#{@path}" do |db|
|
||||||
"pages = 0, success_count = 0, fail_count = 0 " \
|
db.exec "update queue set status = 0, status_message = '', " \
|
||||||
"where status = 2 or status = 4"
|
"pages = 0, success_count = 0, fail_count = 0 " \
|
||||||
|
"where status = 2 or status = 4"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete(id : String)
|
def delete(id : String)
|
||||||
DB.open "sqlite3://#{@path}" do |db|
|
MainFiber.run do
|
||||||
db.exec "delete from queue where id = (?)", id
|
DB.open "sqlite3://#{@path}" do |db|
|
||||||
|
db.exec "delete from queue where id = (?)", id
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -187,71 +197,89 @@ class Queue
|
|||||||
end
|
end
|
||||||
|
|
||||||
def delete_status(status : JobStatus)
|
def delete_status(status : JobStatus)
|
||||||
DB.open "sqlite3://#{@path}" do |db|
|
MainFiber.run do
|
||||||
db.exec "delete from queue where status = (?)", status.to_i
|
DB.open "sqlite3://#{@path}" do |db|
|
||||||
|
db.exec "delete from queue where status = (?)", status.to_i
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def count_status(status : JobStatus)
|
def count_status(status : JobStatus)
|
||||||
num = 0
|
num = 0
|
||||||
DB.open "sqlite3://#{@path}" do |db|
|
MainFiber.run do
|
||||||
num = db.query_one "select count(*) from queue where " \
|
DB.open "sqlite3://#{@path}" do |db|
|
||||||
"status = (?)", status.to_i, as: Int32
|
num = db.query_one "select count(*) from queue where " \
|
||||||
|
"status = (?)", status.to_i, as: Int32
|
||||||
|
end
|
||||||
end
|
end
|
||||||
num
|
num
|
||||||
end
|
end
|
||||||
|
|
||||||
def count
|
def count
|
||||||
num = 0
|
num = 0
|
||||||
DB.open "sqlite3://#{@path}" do |db|
|
MainFiber.run do
|
||||||
num = db.query_one "select count(*) from queue", as: Int32
|
DB.open "sqlite3://#{@path}" do |db|
|
||||||
|
num = db.query_one "select count(*) from queue", as: Int32
|
||||||
|
end
|
||||||
end
|
end
|
||||||
num
|
num
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_status(status : JobStatus, job : Job)
|
def set_status(status : JobStatus, job : Job)
|
||||||
DB.open "sqlite3://#{@path}" do |db|
|
MainFiber.run do
|
||||||
db.exec "update queue set status = (?) where id = (?)",
|
DB.open "sqlite3://#{@path}" do |db|
|
||||||
status.to_i, job.id
|
db.exec "update queue set status = (?) where id = (?)",
|
||||||
|
status.to_i, job.id
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_all
|
def get_all
|
||||||
jobs = [] of Job
|
jobs = [] of Job
|
||||||
DB.open "sqlite3://#{@path}" do |db|
|
MainFiber.run do
|
||||||
jobs = db.query_all "select * from queue order by time" do |rs|
|
DB.open "sqlite3://#{@path}" do |db|
|
||||||
Job.from_query_result rs
|
jobs = db.query_all "select * from queue order by time" do |rs|
|
||||||
|
Job.from_query_result rs
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
jobs
|
jobs
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_success(job : Job)
|
def add_success(job : Job)
|
||||||
DB.open "sqlite3://#{@path}" do |db|
|
MainFiber.run do
|
||||||
db.exec "update queue set success_count = success_count + 1 " \
|
DB.open "sqlite3://#{@path}" do |db|
|
||||||
"where id = (?)", job.id
|
db.exec "update queue set success_count = success_count + 1 " \
|
||||||
|
"where id = (?)", job.id
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_fail(job : Job)
|
def add_fail(job : Job)
|
||||||
DB.open "sqlite3://#{@path}" do |db|
|
MainFiber.run do
|
||||||
db.exec "update queue set fail_count = fail_count + 1 " \
|
DB.open "sqlite3://#{@path}" do |db|
|
||||||
"where id = (?)", job.id
|
db.exec "update queue set fail_count = fail_count + 1 " \
|
||||||
|
"where id = (?)", job.id
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_pages(pages : Int32, job : Job)
|
def set_pages(pages : Int32, job : Job)
|
||||||
DB.open "sqlite3://#{@path}" do |db|
|
MainFiber.run do
|
||||||
db.exec "update queue set pages = (?), success_count = 0, " \
|
DB.open "sqlite3://#{@path}" do |db|
|
||||||
"fail_count = 0 where id = (?)", pages, job.id
|
db.exec "update queue set pages = (?), success_count = 0, " \
|
||||||
|
"fail_count = 0 where id = (?)", pages, job.id
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_message(msg : String, job : Job)
|
def add_message(msg : String, job : Job)
|
||||||
DB.open "sqlite3://#{@path}" do |db|
|
MainFiber.run do
|
||||||
db.exec "update queue set status_message = " \
|
DB.open "sqlite3://#{@path}" do |db|
|
||||||
"status_message || (?) || (?) where id = (?)",
|
db.exec "update queue set status_message = " \
|
||||||
"\n", msg, job.id
|
"status_message || (?) || (?) where id = (?)",
|
||||||
|
"\n", msg, job.id
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,28 @@ class APIRouter < Router
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
get "/api/cover/:tid/:eid" do |env|
|
||||||
|
begin
|
||||||
|
tid = env.params.url["tid"]
|
||||||
|
eid = env.params.url["eid"]
|
||||||
|
|
||||||
|
title = @context.library.get_title tid
|
||||||
|
raise "Title ID `#{tid}` not found" if title.nil?
|
||||||
|
entry = title.get_entry eid
|
||||||
|
raise "Entry ID `#{eid}` of `#{title.title}` not found" if entry.nil?
|
||||||
|
|
||||||
|
img = entry.get_thumbnail || entry.read_page 1
|
||||||
|
raise "Failed to get cover of `#{title.title}/#{entry.title}`" \
|
||||||
|
if img.nil?
|
||||||
|
|
||||||
|
send_img env, img
|
||||||
|
rescue e
|
||||||
|
@context.error e
|
||||||
|
env.response.status_code = 500
|
||||||
|
e.message
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
get "/api/book/:tid" do |env|
|
get "/api/book/:tid" do |env|
|
||||||
begin
|
begin
|
||||||
tid = env.params.url["tid"]
|
tid = env.params.url["tid"]
|
||||||
@@ -54,6 +76,18 @@ class APIRouter < Router
|
|||||||
}.to_json
|
}.to_json
|
||||||
end
|
end
|
||||||
|
|
||||||
|
get "/api/admin/thumbnail_progress" do |env|
|
||||||
|
send_json env, {
|
||||||
|
"progress" => Library.default.thumbnail_generation_progress,
|
||||||
|
}.to_json
|
||||||
|
end
|
||||||
|
|
||||||
|
post "/api/admin/generate_thumbnails" do |env|
|
||||||
|
spawn do
|
||||||
|
Library.default.generate_thumbnails
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
post "/api/admin/user/delete/:username" do |env|
|
post "/api/admin/user/delete/:username" do |env|
|
||||||
begin
|
begin
|
||||||
username = env.params.url["username"]
|
username = env.params.url["username"]
|
||||||
@@ -97,6 +131,28 @@ class APIRouter < Router
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
post "/api/bulk-progress/:action/:title" do |env|
|
||||||
|
begin
|
||||||
|
username = get_username env
|
||||||
|
title = (@context.library.get_title env.params.url["title"]).not_nil!
|
||||||
|
action = env.params.url["action"]
|
||||||
|
ids = env.params.json["ids"].as(Array).map &.as_s
|
||||||
|
|
||||||
|
unless action.in? ["read", "unread"]
|
||||||
|
raise "Unknow action #{action}"
|
||||||
|
end
|
||||||
|
title.bulk_progress action, ids, username
|
||||||
|
rescue e
|
||||||
|
@context.error e
|
||||||
|
send_json env, {
|
||||||
|
"success" => false,
|
||||||
|
"error" => e.message,
|
||||||
|
}.to_json
|
||||||
|
else
|
||||||
|
send_json env, {"success" => true}.to_json
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
post "/api/admin/display_name/:title/:name" do |env|
|
post "/api/admin/display_name/:title/:name" do |env|
|
||||||
begin
|
begin
|
||||||
title = (@context.library.get_title env.params.url["title"])
|
title = (@context.library.get_title env.params.url["title"])
|
||||||
@@ -310,5 +366,28 @@ class APIRouter < Router
|
|||||||
}.to_json
|
}.to_json
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
get "/api/dimensions/:tid/:eid" do |env|
|
||||||
|
begin
|
||||||
|
tid = env.params.url["tid"]
|
||||||
|
eid = env.params.url["eid"]
|
||||||
|
|
||||||
|
title = @context.library.get_title tid
|
||||||
|
raise "Title ID `#{tid}` not found" if title.nil?
|
||||||
|
entry = title.get_entry eid
|
||||||
|
raise "Entry ID `#{eid}` of `#{title.title}` not found" if entry.nil?
|
||||||
|
|
||||||
|
sizes = entry.page_dimensions
|
||||||
|
send_json env, {
|
||||||
|
"success" => true,
|
||||||
|
"dimensions" => sizes,
|
||||||
|
}.to_json
|
||||||
|
rescue e
|
||||||
|
send_json env, {
|
||||||
|
"success" => false,
|
||||||
|
"error" => e.message,
|
||||||
|
}.to_json
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ class MainRouter < Router
|
|||||||
continue_reading = @context
|
continue_reading = @context
|
||||||
.library.get_continue_reading_entries username
|
.library.get_continue_reading_entries username
|
||||||
recently_added = @context.library.get_recently_added_entries username
|
recently_added = @context.library.get_recently_added_entries username
|
||||||
|
start_reading = @context.library.get_start_reading_titles username
|
||||||
titles = @context.library.titles
|
titles = @context.library.titles
|
||||||
new_user = !titles.any? { |t| t.load_percentage(username) > 0 }
|
new_user = !titles.any? { |t| t.load_percentage(username) > 0 }
|
||||||
empty_library = titles.size == 0
|
empty_library = titles.size == 0
|
||||||
|
|||||||
+5
-21
@@ -12,11 +12,7 @@ class ReaderRouter < Router
|
|||||||
next layout "reader-error" if entry.err_msg
|
next layout "reader-error" if entry.err_msg
|
||||||
|
|
||||||
# load progress
|
# load progress
|
||||||
page = entry.load_progress username
|
page = [1, entry.load_progress username].max
|
||||||
# we go back 2 * `IMGS_PER_PAGE` pages. the infinite scroll
|
|
||||||
# library perloads a few pages in advance, and the user
|
|
||||||
# might not have actually read them
|
|
||||||
page = [page - 2 * IMGS_PER_PAGE, 1].max
|
|
||||||
|
|
||||||
# start from page 1 if the user has finished reading the entry
|
# start from page 1 if the user has finished reading the entry
|
||||||
page = 1 if entry.finished? username
|
page = 1 if entry.finished? username
|
||||||
@@ -32,29 +28,17 @@ class ReaderRouter < Router
|
|||||||
begin
|
begin
|
||||||
base_url = Config.current.base_url
|
base_url = Config.current.base_url
|
||||||
|
|
||||||
|
username = get_username env
|
||||||
|
|
||||||
title = (@context.library.get_title env.params.url["title"]).not_nil!
|
title = (@context.library.get_title env.params.url["title"]).not_nil!
|
||||||
entry = (title.get_entry env.params.url["entry"]).not_nil!
|
entry = (title.get_entry env.params.url["entry"]).not_nil!
|
||||||
page = env.params.url["page"].to_i
|
page = env.params.url["page"].to_i
|
||||||
raise "" if page > entry.pages || page <= 0
|
raise "" if page > entry.pages || page <= 0
|
||||||
|
|
||||||
# save progress
|
|
||||||
username = get_username env
|
|
||||||
entry.save_progress username, page
|
|
||||||
|
|
||||||
pages = (page...[entry.pages + 1, page + IMGS_PER_PAGE].min)
|
|
||||||
urls = pages.map { |idx|
|
|
||||||
"#{base_url}api/page/#{title.id}/#{entry.id}/#{idx}"
|
|
||||||
}
|
|
||||||
reader_urls = pages.map { |idx|
|
|
||||||
"#{base_url}reader/#{title.id}/#{entry.id}/#{idx}"
|
|
||||||
}
|
|
||||||
next_page = page + IMGS_PER_PAGE
|
|
||||||
next_url = next_entry_url = nil
|
|
||||||
exit_url = "#{base_url}book/#{title.id}"
|
exit_url = "#{base_url}book/#{title.id}"
|
||||||
|
|
||||||
|
next_entry_url = nil
|
||||||
next_entry = entry.next_entry username
|
next_entry = entry.next_entry username
|
||||||
unless next_page > entry.pages
|
|
||||||
next_url = "#{base_url}reader/#{title.id}/#{entry.id}/#{next_page}"
|
|
||||||
end
|
|
||||||
unless next_entry.nil?
|
unless next_entry.nil?
|
||||||
next_entry_url = "#{base_url}reader/#{title.id}/#{next_entry.id}"
|
next_entry_url = "#{base_url}reader/#{title.id}/#{next_entry.id}"
|
||||||
end
|
end
|
||||||
|
|||||||
+176
-94
@@ -32,38 +32,42 @@ class Storage
|
|||||||
"Attepmting to create it"
|
"Attepmting to create it"
|
||||||
Dir.mkdir_p dir
|
Dir.mkdir_p dir
|
||||||
end
|
end
|
||||||
DB.open "sqlite3://#{@path}" do |db|
|
MainFiber.run do
|
||||||
begin
|
DB.open "sqlite3://#{@path}" do |db|
|
||||||
# We create the `ids` table first. even if the uses has an
|
begin
|
||||||
# early version installed and has the `user` table only,
|
db.exec "create table thumbnails " \
|
||||||
# we will still be able to create `ids`
|
"(id text, data blob, filename text, " \
|
||||||
db.exec "create table ids" \
|
"mime text, size integer)"
|
||||||
"(path text, id text, is_title integer)"
|
db.exec "create unique index tn_index on thumbnails (id)"
|
||||||
db.exec "create unique index path_idx on ids (path)"
|
|
||||||
db.exec "create unique index id_idx on ids (id)"
|
|
||||||
|
|
||||||
db.exec "create table users" \
|
db.exec "create table ids" \
|
||||||
"(username text, password text, token text, admin integer)"
|
"(path text, id text, is_title integer)"
|
||||||
rescue e
|
db.exec "create unique index path_idx on ids (path)"
|
||||||
unless e.message.not_nil!.ends_with? "already exists"
|
db.exec "create unique index id_idx on ids (id)"
|
||||||
Logger.fatal "Error when checking tables in DB: #{e}"
|
|
||||||
raise e
|
db.exec "create table users" \
|
||||||
|
"(username text, password text, token text, admin integer)"
|
||||||
|
rescue e
|
||||||
|
unless e.message.not_nil!.ends_with? "already exists"
|
||||||
|
Logger.fatal "Error when checking tables in DB: #{e}"
|
||||||
|
raise e
|
||||||
|
end
|
||||||
|
|
||||||
|
# If the DB is initialized through CLI but no user is added, we need
|
||||||
|
# to create the admin user when first starting the app
|
||||||
|
user_count = db.query_one "select count(*) from users", as: Int32
|
||||||
|
init_admin if init_user && user_count == 0
|
||||||
|
else
|
||||||
|
Logger.debug "Creating DB file at #{@path}"
|
||||||
|
db.exec "create unique index username_idx on users (username)"
|
||||||
|
db.exec "create unique index token_idx on users (token)"
|
||||||
|
|
||||||
|
init_admin if init_user
|
||||||
end
|
end
|
||||||
|
|
||||||
# If the DB is initialized through CLI but no user is added, we need
|
|
||||||
# to create the admin user when first starting the app
|
|
||||||
user_count = db.query_one "select count(*) from users", as: Int32
|
|
||||||
init_admin if init_user && user_count == 0
|
|
||||||
else
|
|
||||||
Logger.debug "Creating DB file at #{@path}"
|
|
||||||
db.exec "create unique index username_idx on users (username)"
|
|
||||||
db.exec "create unique index token_idx on users (token)"
|
|
||||||
|
|
||||||
init_admin if init_user
|
|
||||||
end
|
end
|
||||||
end
|
unless @auto_close
|
||||||
unless @auto_close
|
@db = DB.open "sqlite3://#{@path}"
|
||||||
@db = DB.open "sqlite3://#{@path}"
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -87,37 +91,45 @@ class Storage
|
|||||||
end
|
end
|
||||||
|
|
||||||
def verify_user(username, password)
|
def verify_user(username, password)
|
||||||
get_db do |db|
|
out_token = nil
|
||||||
begin
|
MainFiber.run do
|
||||||
hash, token = db.query_one "select password, token from " \
|
get_db do |db|
|
||||||
"users where username = (?)",
|
begin
|
||||||
username, as: {String, String?}
|
hash, token = db.query_one "select password, token from " \
|
||||||
unless verify_password hash, password
|
"users where username = (?)",
|
||||||
Logger.debug "Password does not match the hash"
|
username, as: {String, String?}
|
||||||
return nil
|
unless verify_password hash, password
|
||||||
|
Logger.debug "Password does not match the hash"
|
||||||
|
next
|
||||||
|
end
|
||||||
|
Logger.debug "User #{username} verified"
|
||||||
|
if token
|
||||||
|
out_token = token
|
||||||
|
next
|
||||||
|
end
|
||||||
|
token = random_str
|
||||||
|
Logger.debug "Updating token for #{username}"
|
||||||
|
db.exec "update users set token = (?) where username = (?)",
|
||||||
|
token, username
|
||||||
|
out_token = token
|
||||||
|
rescue e
|
||||||
|
Logger.error "Error when verifying user #{username}: #{e}"
|
||||||
end
|
end
|
||||||
Logger.debug "User #{username} verified"
|
|
||||||
return token if token
|
|
||||||
token = random_str
|
|
||||||
Logger.debug "Updating token for #{username}"
|
|
||||||
db.exec "update users set token = (?) where username = (?)",
|
|
||||||
token, username
|
|
||||||
return token
|
|
||||||
rescue e
|
|
||||||
Logger.error "Error when verifying user #{username}: #{e}"
|
|
||||||
return nil
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
out_token
|
||||||
end
|
end
|
||||||
|
|
||||||
def verify_token(token)
|
def verify_token(token)
|
||||||
username = nil
|
username = nil
|
||||||
get_db do |db|
|
MainFiber.run do
|
||||||
begin
|
get_db do |db|
|
||||||
username = db.query_one "select username from users where " \
|
begin
|
||||||
"token = (?)", token, as: String
|
username = db.query_one "select username from users where " \
|
||||||
rescue e
|
"token = (?)", token, as: String
|
||||||
Logger.debug "Unable to verify token"
|
rescue e
|
||||||
|
Logger.debug "Unable to verify token"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
username
|
username
|
||||||
@@ -125,12 +137,14 @@ class Storage
|
|||||||
|
|
||||||
def verify_admin(token)
|
def verify_admin(token)
|
||||||
is_admin = false
|
is_admin = false
|
||||||
get_db do |db|
|
MainFiber.run do
|
||||||
begin
|
get_db do |db|
|
||||||
is_admin = db.query_one "select admin from users where " \
|
begin
|
||||||
"token = (?)", token, as: Bool
|
is_admin = db.query_one "select admin from users where " \
|
||||||
rescue e
|
"token = (?)", token, as: Bool
|
||||||
Logger.debug "Unable to verify user as admin"
|
rescue e
|
||||||
|
Logger.debug "Unable to verify user as admin"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
is_admin
|
is_admin
|
||||||
@@ -138,10 +152,12 @@ class Storage
|
|||||||
|
|
||||||
def list_users
|
def list_users
|
||||||
results = Array(Tuple(String, Bool)).new
|
results = Array(Tuple(String, Bool)).new
|
||||||
get_db do |db|
|
MainFiber.run do
|
||||||
db.query "select username, admin from users" do |rs|
|
get_db do |db|
|
||||||
rs.each do
|
db.query "select username, admin from users" do |rs|
|
||||||
results << {rs.read(String), rs.read(Bool)}
|
rs.each do
|
||||||
|
results << {rs.read(String), rs.read(Bool)}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -152,10 +168,12 @@ class Storage
|
|||||||
validate_username username
|
validate_username username
|
||||||
validate_password password
|
validate_password password
|
||||||
admin = (admin ? 1 : 0)
|
admin = (admin ? 1 : 0)
|
||||||
get_db do |db|
|
MainFiber.run do
|
||||||
hash = hash_password password
|
get_db do |db|
|
||||||
db.exec "insert into users values (?, ?, ?, ?)",
|
hash = hash_password password
|
||||||
username, hash, nil, admin
|
db.exec "insert into users values (?, ?, ?, ?)",
|
||||||
|
username, hash, nil, admin
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -163,40 +181,48 @@ class Storage
|
|||||||
admin = (admin ? 1 : 0)
|
admin = (admin ? 1 : 0)
|
||||||
validate_username username
|
validate_username username
|
||||||
validate_password password unless password.empty?
|
validate_password password unless password.empty?
|
||||||
get_db do |db|
|
MainFiber.run do
|
||||||
if password.empty?
|
get_db do |db|
|
||||||
db.exec "update users set username = (?), admin = (?) " \
|
if password.empty?
|
||||||
"where username = (?)",
|
db.exec "update users set username = (?), admin = (?) " \
|
||||||
username, admin, original_username
|
"where username = (?)",
|
||||||
else
|
username, admin, original_username
|
||||||
hash = hash_password password
|
else
|
||||||
db.exec "update users set username = (?), admin = (?)," \
|
hash = hash_password password
|
||||||
"password = (?) where username = (?)",
|
db.exec "update users set username = (?), admin = (?)," \
|
||||||
username, admin, hash, original_username
|
"password = (?) where username = (?)",
|
||||||
|
username, admin, hash, original_username
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete_user(username)
|
def delete_user(username)
|
||||||
get_db do |db|
|
MainFiber.run do
|
||||||
db.exec "delete from users where username = (?)", username
|
get_db do |db|
|
||||||
|
db.exec "delete from users where username = (?)", username
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def logout(token)
|
def logout(token)
|
||||||
get_db do |db|
|
MainFiber.run do
|
||||||
begin
|
get_db do |db|
|
||||||
db.exec "update users set token = (?) where token = (?)", nil, token
|
begin
|
||||||
rescue
|
db.exec "update users set token = (?) where token = (?)", nil, token
|
||||||
|
rescue
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_id(path, is_title)
|
def get_id(path, is_title)
|
||||||
id = nil
|
id = nil
|
||||||
get_db do |db|
|
MainFiber.run do
|
||||||
id = db.query_one? "select id from ids where path = (?)", path,
|
get_db do |db|
|
||||||
as: {String}
|
id = db.query_one? "select id from ids where path = (?)", path,
|
||||||
|
as: {String}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
id
|
id
|
||||||
end
|
end
|
||||||
@@ -206,20 +232,76 @@ class Storage
|
|||||||
end
|
end
|
||||||
|
|
||||||
def bulk_insert_ids
|
def bulk_insert_ids
|
||||||
get_db do |db|
|
MainFiber.run do
|
||||||
db.transaction do |tx|
|
get_db do |db|
|
||||||
@insert_ids.each do |tp|
|
db.transaction do |tx|
|
||||||
tx.connection.exec "insert into ids values (?, ?, ?)", tp[:path],
|
@insert_ids.each do |tp|
|
||||||
tp[:id], tp[:is_title] ? 1 : 0
|
tx.connection.exec "insert into ids values (?, ?, ?)", tp[:path],
|
||||||
|
tp[:id], tp[:is_title] ? 1 : 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@insert_ids.clear
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def save_thumbnail(id : String, img : Image)
|
||||||
|
MainFiber.run do
|
||||||
|
get_db do |db|
|
||||||
|
db.exec "insert into thumbnails values (?, ?, ?, ?, ?)", id, img.data,
|
||||||
|
img.filename, img.mime, img.size
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_thumbnail(id : String) : Image?
|
||||||
|
img = nil
|
||||||
|
MainFiber.run do
|
||||||
|
get_db do |db|
|
||||||
|
db.query_one? "select * from thumbnails where id = (?)", id do |res|
|
||||||
|
img = Image.from_db res
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@insert_ids.clear
|
img
|
||||||
|
end
|
||||||
|
|
||||||
|
def optimize
|
||||||
|
MainFiber.run do
|
||||||
|
Logger.info "Starting DB optimization"
|
||||||
|
get_db do |db|
|
||||||
|
trash_ids = [] of String
|
||||||
|
db.query "select path, id from ids" do |rs|
|
||||||
|
rs.each do
|
||||||
|
path = rs.read String
|
||||||
|
trash_ids << rs.read String unless File.exists? path
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Delete dangling IDs
|
||||||
|
db.exec "delete from ids where id in " \
|
||||||
|
"(#{trash_ids.map { |i| "'#{i}'" }.join ","})"
|
||||||
|
Logger.debug "#{trash_ids.size} dangling IDs deleted" \
|
||||||
|
if trash_ids.size > 0
|
||||||
|
|
||||||
|
# Delete dangling thumbnails
|
||||||
|
trash_thumbnails_count = db.query_one "select count(*) from " \
|
||||||
|
"thumbnails where id not in " \
|
||||||
|
"(select id from ids)", as: Int32
|
||||||
|
if trash_thumbnails_count > 0
|
||||||
|
db.exec "delete from thumbnails where id not in (select id from ids)"
|
||||||
|
Logger.info "#{trash_thumbnails_count} dangling thumbnails deleted"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Logger.info "DB optimization finished"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def close
|
def close
|
||||||
unless @db.nil?
|
MainFiber.run do
|
||||||
@db.not_nil!.close
|
unless @db.nil?
|
||||||
|
@db.not_nil!.close
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
require "http_proxy"
|
||||||
|
|
||||||
|
# Monkey-patch `HTTP::Client` to make it respect the `*_PROXY`
|
||||||
|
# environment variables
|
||||||
|
module HTTP
|
||||||
|
class Client
|
||||||
|
private def self.exec(uri : URI, tls : TLSContext = nil)
|
||||||
|
Logger.debug "Setting proxy"
|
||||||
|
previous_def uri, tls do |client, path|
|
||||||
|
client.set_proxy get_proxy uri
|
||||||
|
yield client, path
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private def get_proxy(uri : URI) : HTTP::Proxy::Client?
|
||||||
|
no_proxy = ENV["no_proxy"]? || ENV["NO_PROXY"]?
|
||||||
|
return if no_proxy &&
|
||||||
|
no_proxy.split(",").any? &.== uri.hostname
|
||||||
|
|
||||||
|
case uri.scheme
|
||||||
|
when "http"
|
||||||
|
env_to_proxy "http_proxy"
|
||||||
|
when "https"
|
||||||
|
env_to_proxy "https_proxy"
|
||||||
|
else
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private def env_to_proxy(key : String) : HTTP::Proxy::Client?
|
||||||
|
val = ENV[key.downcase]? || ENV[key.upcase]?
|
||||||
|
return if val.nil?
|
||||||
|
|
||||||
|
begin
|
||||||
|
uri = URI.parse val
|
||||||
|
HTTP::Proxy::Client.new uri.hostname.not_nil!, uri.port.not_nil!
|
||||||
|
rescue
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
end
|
||||||
+4
-3
@@ -1,6 +1,7 @@
|
|||||||
IMGS_PER_PAGE = 5
|
IMGS_PER_PAGE = 5
|
||||||
UPLOAD_URL_PREFIX = "/uploads"
|
ENTRIES_IN_HOME_SECTIONS = 8
|
||||||
STATIC_DIRS = ["/css", "/js", "/img", "/favicon.ico"]
|
UPLOAD_URL_PREFIX = "/uploads"
|
||||||
|
STATIC_DIRS = ["/css", "/js", "/img", "/favicon.ico"]
|
||||||
|
|
||||||
def random_str
|
def random_str
|
||||||
UUID.random.to_s.gsub "-", ""
|
UUID.random.to_s.gsub "-", ""
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ def validate_username(username)
|
|||||||
if username.size < 3
|
if username.size < 3
|
||||||
raise "Username should contain at least 3 characters"
|
raise "Username should contain at least 3 characters"
|
||||||
end
|
end
|
||||||
if (username =~ /^[A-Za-z0-9_]+$/).nil?
|
if (username =~ /^[a-zA-Z_][a-zA-Z0-9_\-]*$/).nil?
|
||||||
raise "Username should contain alphanumeric characters " \
|
raise "Username can only contain alphanumeric characters, " \
|
||||||
"and underscores only"
|
"underscores, and hyphens"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -81,3 +81,15 @@ macro get_sort_opt
|
|||||||
sort_opt = SortOptions.new sort_method, is_ascending
|
sort_opt = SortOptions.new sort_method, is_ascending
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
module HTTP
|
||||||
|
class Client
|
||||||
|
private def self.exec(uri : URI, tls : TLSContext = nil)
|
||||||
|
Logger.debug "Setting read timeout"
|
||||||
|
previous_def uri, tls do |client, path|
|
||||||
|
client.read_timeout = Config.current.download_timeout_seconds.seconds
|
||||||
|
yield client, path
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|||||||
@@ -1,11 +1,17 @@
|
|||||||
<ul class="uk-list uk-list-large uk-list-divider">
|
<ul class="uk-list uk-list-large uk-list-divider" id="root" x-data="{progress : 1.0, generating : false, scanTitles: 0, scanMs: -1, scanning : false}">
|
||||||
<li data-url="<%= base_url %>admin/user">User Managerment</li>
|
<li @click="location.href = '<%= base_url %>admin/user'">User Managerment</li>
|
||||||
<li onclick="if(!scanning){scan()}">
|
<li :class="{'nopointer' : scanning}" @click="scan()">
|
||||||
<span id="scan">Scan Library Files</span>
|
<span :style="`${scanning ? 'color:grey' : ''}`">Scan Library Files</span>
|
||||||
<span id="scan-status" class="uk-align-right">
|
<div class="uk-align-right">
|
||||||
<div uk-spinner hidden></div>
|
<div uk-spinner x-show="scanning"></div>
|
||||||
<span hidden></span>
|
<span x-show="!scanning && scanMs > 0" x-text="`Scan ${scanTitles} titles in ${scanMs}ms`"></span>
|
||||||
</span>
|
</div>
|
||||||
|
</li>
|
||||||
|
<li :class="{'nopointer' : generating}" @click="generateThumbnails()">
|
||||||
|
<span :style="`${generating ? 'color:grey' : ''}`">Generate Thumbnails</span>
|
||||||
|
<div class="uk-align-right">
|
||||||
|
<span x-show="generating && progress > 0" x-text="`${(progress * 100).toFixed(2)}%`"></span>
|
||||||
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li class="nopointer">
|
<li class="nopointer">
|
||||||
<span>Theme</span>
|
<span>Theme</span>
|
||||||
|
|||||||
@@ -35,12 +35,20 @@
|
|||||||
onclick="location='<%= base_url %>book/<%= item.id %>'"
|
onclick="location='<%= base_url %>book/<%= item.id %>'"
|
||||||
<% end %>>
|
<% end %>>
|
||||||
|
|
||||||
<div class="uk-card uk-card-default">
|
<div class="uk-card uk-card-default" x-data="{selected: false, hover: false, disabled: true}" :class="{selected: selected}"
|
||||||
<div class="uk-card-media-top">
|
<% if page == "title" && item.is_a?(Entry) && item.err_msg.nil? %>
|
||||||
<img data-src="<%= item.cover_url %>" data-width data-height alt="" uk-img
|
x-init="disabled = false"
|
||||||
|
<% end %>>
|
||||||
|
<div class="uk-card-media-top uk-inline" @mouseenter="hover = true" @mouseleave="hover = false">
|
||||||
|
<img data-src="<%= item.cover_url %>" width="100%" height="100%" alt="" uk-img
|
||||||
<% if item.is_a? Entry && item.err_msg %>
|
<% if item.is_a? Entry && item.err_msg %>
|
||||||
class="grayscale"
|
class="grayscale"
|
||||||
<% end %>>
|
<% end %>>
|
||||||
|
<div class="uk-overlay-primary uk-position-cover" x-show="!disabled && (selected || hover)">
|
||||||
|
<div class="uk-position-center">
|
||||||
|
<span class="fas fa-check-circle fa-3x" @click.stop="selected = !selected; $dispatch(selected ? 'add' : 'remove')" :style="`color:${selected && 'orange'};`"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="uk-card-body">
|
<div class="uk-card-body">
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jQuery.dotdotdot/4.0.11/dotdotdot.js"></script>
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/protonet-jquery.inview/1.1.2/jquery.inview.min.js"></script>
|
||||||
|
<script src="<%= base_url %>js/dots.js"></script>
|
||||||
@@ -7,8 +7,12 @@
|
|||||||
<link rel="stylesheet" href="<%= base_url %>css/uikit.css" />
|
<link rel="stylesheet" href="<%= base_url %>css/uikit.css" />
|
||||||
<link rel="stylesheet" href="<%= base_url %>css/mango.css" />
|
<link rel="stylesheet" href="<%= base_url %>css/mango.css" />
|
||||||
<link rel="icon" href="<%= base_url %>favicon.ico">
|
<link rel="icon" href="<%= base_url %>favicon.ico">
|
||||||
|
|
||||||
|
<script src="https://polyfill.io/v3/polyfill.min.js?features=matchMedia%2Cdefault&flags=gated"></script>
|
||||||
<script defer src="<%= base_url %>js/fontawesome.min.js"></script>
|
<script defer src="<%= base_url %>js/fontawesome.min.js"></script>
|
||||||
<script defer src="<%= base_url %>js/solid.min.js"></script>
|
<script defer src="<%= base_url %>js/solid.min.js"></script>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
|
||||||
|
<script type="module" src="https://cdn.jsdelivr.net/gh/alpinejs/alpine@v2.5.0/dist/alpine.min.js"></script>
|
||||||
|
<script nomodule src="https://cdn.jsdelivr.net/gh/alpinejs/alpine@v2.5.0/dist/alpine-ie11.min.js" defer></script>
|
||||||
<script src="<%= base_url %>js/theme.js"></script>
|
<script src="<%= base_url %>js/theme.js"></script>
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
+15
-5
@@ -11,7 +11,7 @@
|
|||||||
<dd>Update <code>config.yml</code> located at: <code><%= Config.current.path %></code></dd>
|
<dd>Update <code>config.yml</code> located at: <code><%= Config.current.path %></code></dd>
|
||||||
<dt style="font-weight: 500;">Can't see your files yet?</dt>
|
<dt style="font-weight: 500;">Can't see your files yet?</dt>
|
||||||
<dd>
|
<dd>
|
||||||
You must wait <%= Config.current.scan_interval %> minutes for the library scan to complete
|
You must wait <%= Config.current.scan_interval_minutes %> minutes for the library scan to complete
|
||||||
<% if is_admin %>
|
<% if is_admin %>
|
||||||
, or manually re-scan from <a href="<%= base_url %>admin">Admin</a>
|
, or manually re-scan from <a href="<%= base_url %>admin">Admin</a>
|
||||||
<% end %>.
|
<% end %>.
|
||||||
@@ -41,7 +41,7 @@
|
|||||||
|
|
||||||
<%- unless continue_reading.empty? -%>
|
<%- unless continue_reading.empty? -%>
|
||||||
<h2 class="uk-title home-headings">Continue Reading</h2>
|
<h2 class="uk-title home-headings">Continue Reading</h2>
|
||||||
<div id="item-container-continue" class="uk-child-width-1-4@m uk-child-width-1-2" uk-grid>
|
<div class="uk-child-width-1-4@m uk-child-width-1-2" uk-grid>
|
||||||
<%- continue_reading.each do |cr| -%>
|
<%- continue_reading.each do |cr| -%>
|
||||||
<% item = cr[:entry] %>
|
<% item = cr[:entry] %>
|
||||||
<% progress = cr[:percentage] %>
|
<% progress = cr[:percentage] %>
|
||||||
@@ -50,9 +50,20 @@
|
|||||||
</div>
|
</div>
|
||||||
<%- end -%>
|
<%- end -%>
|
||||||
|
|
||||||
|
<%- unless start_reading.empty? -%>
|
||||||
|
<h2 class="uk-title home-headings">Start Reading</h2>
|
||||||
|
<div class="uk-child-width-1-4@m uk-child-width-1-2" uk-grid>
|
||||||
|
<%- start_reading.each do |t| -%>
|
||||||
|
<% item = t %>
|
||||||
|
<% progress = 0.0 %>
|
||||||
|
<%= render_component "card" %>
|
||||||
|
<%- end -%>
|
||||||
|
</div>
|
||||||
|
<%- end -%>
|
||||||
|
|
||||||
<%- unless recently_added.empty? -%>
|
<%- unless recently_added.empty? -%>
|
||||||
<h2 class="uk-title home-headings">Recently Added</h2>
|
<h2 class="uk-title home-headings">Recently Added</h2>
|
||||||
<div id="item-container-continue" class="uk-child-width-1-4@m uk-child-width-1-2" uk-grid>
|
<div class="uk-child-width-1-4@m uk-child-width-1-2" uk-grid>
|
||||||
<%- recently_added.each do |ra| -%>
|
<%- recently_added.each do |ra| -%>
|
||||||
<% item = ra %>
|
<% item = ra %>
|
||||||
<% progress = ra[:percentage] %>
|
<% progress = ra[:percentage] %>
|
||||||
@@ -66,8 +77,7 @@
|
|||||||
<%- end -%>
|
<%- end -%>
|
||||||
|
|
||||||
<% content_for "script" do %>
|
<% content_for "script" do %>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jQuery.dotdotdot/4.0.11/dotdotdot.js"></script>
|
<%= render_component "dots-scripts" %>
|
||||||
<script src="<%= base_url %>js/dots.js"></script>
|
|
||||||
<script src="<%= base_url %>js/alert.js"></script>
|
<script src="<%= base_url %>js/alert.js"></script>
|
||||||
<script src="<%= base_url %>js/title.js"></script>
|
<script src="<%= base_url %>js/title.js"></script>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -67,10 +67,13 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="uk-section uk-section-small">
|
<div class="uk-section uk-section-small">
|
||||||
</div>
|
</div>
|
||||||
<div class="uk-section uk-section-small">
|
<div class="uk-section uk-section-small" id="main-section">
|
||||||
<div class="uk-container uk-container-small">
|
<div class="uk-container uk-container-small">
|
||||||
<div id="alert"></div>
|
<div id="alert"></div>
|
||||||
<%= content %>
|
<%= content %>
|
||||||
|
<div class="uk-visible@m" id="totop-wrapper" x-data="{}" x-show="$('body').height() > 1.5 * $(window).height()">
|
||||||
|
<a href="#" uk-totop uk-scroll></a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
<%= render_component "sort-form" %>
|
<%= render_component "sort-form" %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="item-container" class="uk-child-width-1-4@m uk-child-width-1-2" uk-grid>
|
<div class="uk-child-width-1-4@m uk-child-width-1-2" uk-grid>
|
||||||
<% titles.each_with_index do |item, i| %>
|
<% titles.each_with_index do |item, i| %>
|
||||||
<% progress = percentage[i] %>
|
<% progress = percentage[i] %>
|
||||||
<%= render_component "card" %>
|
<%= render_component "card" %>
|
||||||
@@ -24,8 +24,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% content_for "script" do %>
|
<% content_for "script" do %>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jQuery.dotdotdot/4.0.11/dotdotdot.js"></script>
|
<%= render_component "dots-scripts" %>
|
||||||
<script src="<%= base_url %>js/dots.js"></script>
|
|
||||||
<script src="<%= base_url %>js/search.js"></script>
|
<script src="<%= base_url %>js/search.js"></script>
|
||||||
<script src="<%= base_url %>js/sort-items.js"></script>
|
<script src="<%= base_url %>js/sort-items.js"></script>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -21,18 +21,18 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% title.entries.each do |e| %>
|
<% title.entries.each do |e| %>
|
||||||
<entry>
|
<% next if e.err_msg %>
|
||||||
<title><%= HTML.escape(e.display_name) %></title>
|
<entry>
|
||||||
<id>urn:mango:<%= e.id %></id>
|
<title><%= HTML.escape(e.display_name) %></title>
|
||||||
|
<id>urn:mango:<%= e.id %></id>
|
||||||
|
|
||||||
<link rel="http://opds-spec.org/image" href="<%= e.cover_url %>" />
|
<link rel="http://opds-spec.org/image" href="<%= e.cover_url %>" />
|
||||||
<link rel="http://opds-spec.org/image/thumbnail" href="<%= e.cover_url %>" />
|
<link rel="http://opds-spec.org/image/thumbnail" href="<%= e.cover_url %>" />
|
||||||
|
|
||||||
<link rel="http://opds-spec.org/acquisition" href="<%= base_url %>opds/download/<%= e.book.id %>/<%= e.id %>" title="Read" type="<%= MIME.from_filename e.zip_path %>" />
|
<link rel="http://opds-spec.org/acquisition" href="<%= base_url %>opds/download/<%= e.book.id %>/<%= e.id %>" title="Read" type="<%= MIME.from_filename e.zip_path %>" />
|
||||||
|
|
||||||
<link type="text/html" rel="alternate" title="Read in Mango" href="<%= base_url %>reader/<%= e.book.id %>/<%= e.id %>" />
|
<link type="text/html" rel="alternate" title="Read in Mango" href="<%= base_url %>reader/<%= e.book.id %>/<%= e.id %>" />
|
||||||
<link type="text/html" rel="alternate" title="Open in Mango" href="<%= base_url %>book/<%= e.book.id %>" />
|
<link type="text/html" rel="alternate" title="Open in Mango" href="<%= base_url %>book/<%= e.book.id %>" />
|
||||||
</entry>
|
</entry>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
</feed>
|
||||||
</feed>
|
|
||||||
|
|||||||
+85
-21
@@ -3,24 +3,70 @@
|
|||||||
|
|
||||||
<%= render_component "head" %>
|
<%= render_component "head" %>
|
||||||
|
|
||||||
<body>
|
<body style="position:relative;">
|
||||||
<div class="uk-section uk-section-default uk-section-small reader-bg">
|
<div class="uk-section uk-section-default uk-section-small reader-bg"
|
||||||
<div class="uk-container uk-container-small">
|
id="root"
|
||||||
<%- urls.each_with_index do |url, i| -%>
|
:style="mode === 'continuous' ? '' : 'padding:0'"
|
||||||
<img class="uk-align-center" data-src="<%= url %>" src="<%= base_url %>img/loading.gif" data-width data-height uk-img id="<%= reader_urls[i] %>" onclick="showControl(<%= pages.to_a[i] %>);">
|
x-data="{
|
||||||
<%- end -%>
|
loading: true,
|
||||||
<%- if next_url -%>
|
mode: 'continuous', // can be 'continuous', 'height' or 'width'
|
||||||
<a class="next-url" href="<%= next_url %>"></a>
|
msg: 'Loading the web reader. Please wait...',
|
||||||
<%- end -%>
|
alertClass: 'uk-alert-primary',
|
||||||
</div>
|
items: [],
|
||||||
<%- if next_entry_url -%>
|
curItem: {},
|
||||||
<button id="next-btn" class="uk-align-center uk-button uk-button-primary" hidden onclick="redirect('<%= next_entry_url %>')">Next Entry</button>
|
flipAnimation: null
|
||||||
<%- else -%>
|
}">
|
||||||
<button id="next-btn" class="uk-align-center uk-button uk-button-primary" hidden onclick="redirect('<%= exit_url %>')">Exit Reader</button>
|
|
||||||
<%- end -%>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="hidden" hidden></div>
|
<div @keydown.window.debounce="keyHandler($event)"></div>
|
||||||
|
|
||||||
|
<div class="uk-container uk-container-small">
|
||||||
|
<div id="alert"></div>
|
||||||
|
<div x-show="loading">
|
||||||
|
<div :class="alertClass" x-show="msg" uk-alert>
|
||||||
|
<p x-text="msg"></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
:class="{'uk-container': true, 'uk-container-small': mode === 'continuous', 'uk-container-expand': mode !== 'continuous'}">
|
||||||
|
<div x-show="!loading && mode === 'continuous'" x-cloak>
|
||||||
|
<template x-for="item in items">
|
||||||
|
<img
|
||||||
|
uk-img
|
||||||
|
class="uk-align-center"
|
||||||
|
:data-src="item.url"
|
||||||
|
:width="item.width"
|
||||||
|
:height="item.height"
|
||||||
|
:id="item.id"
|
||||||
|
@click="showControl($event)"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<%- if next_entry_url -%>
|
||||||
|
<button id="next-btn" class="uk-align-center uk-button uk-button-primary" @click="nextEntry('<%= next_entry_url %>')">Next Entry</button>
|
||||||
|
<%- else -%>
|
||||||
|
<button id="next-btn" class="uk-align-center uk-button uk-button-primary" @click="redirect('<%= exit_url %>')">Exit Reader</button>
|
||||||
|
<%- end -%>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div x-cloak x-show="!loading && mode !== 'continuous'" class="uk-flex uk-flex-middle" style="height:100vh">
|
||||||
|
|
||||||
|
<img uk-img :class="{
|
||||||
|
'uk-align-center': true,
|
||||||
|
'uk-animation-slide-left': flipAnimation === 'left',
|
||||||
|
'uk-animation-slide-right': flipAnimation === 'right'
|
||||||
|
}" :data-src="curItem.url" :width="curItem.width" :height="curItem.height" :id="curItem.id" @click="showControl($event)" :style="`
|
||||||
|
width:${mode === 'width' ? '100vw' : 'auto'};
|
||||||
|
height:${mode === 'height' ? '100vh' : 'auto'};
|
||||||
|
margin-bottom:0;
|
||||||
|
`" />
|
||||||
|
|
||||||
|
<div style="position:absolute;z-index:1; top:0;left:0; width:30%;height:100%;" @click="flipPage(false)"></div>
|
||||||
|
<div style="position:absolute;z-index:1; top:0;right:0; width:30%;height:100%;" @click="flipPage(true)"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="modal-sections" class="uk-flex-top" uk-modal>
|
<div id="modal-sections" class="uk-flex-top" uk-modal>
|
||||||
<div class="uk-modal-dialog uk-margin-auto-vertical">
|
<div class="uk-modal-dialog uk-margin-auto-vertical">
|
||||||
@@ -34,7 +80,7 @@
|
|||||||
<p id="progress-label"></p>
|
<p id="progress-label"></p>
|
||||||
</div>
|
</div>
|
||||||
<div class="uk-margin">
|
<div class="uk-margin">
|
||||||
<label class="uk-form-label" for="form-stacked-select">Jump to page</label>
|
<label class="uk-form-label" for="page-select">Jump to page</label>
|
||||||
<div class="uk-form-controls">
|
<div class="uk-form-controls">
|
||||||
<select id="page-select" class="uk-select">
|
<select id="page-select" class="uk-select">
|
||||||
<%- (1..entry.pages).each do |p| -%>
|
<%- (1..entry.pages).each do |p| -%>
|
||||||
@@ -43,20 +89,38 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="uk-margin">
|
||||||
|
<label class="uk-form-label" for="mode-select">Mode</label>
|
||||||
|
<div class="uk-form-controls">
|
||||||
|
<select id="mode-select" class="uk-select">
|
||||||
|
<option value="continuous">Continuous</option>
|
||||||
|
<option value="paged">Paged</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="uk-modal-footer uk-text-right">
|
<div class="uk-modal-footer uk-text-right">
|
||||||
<button class="uk-button uk-button-danger" type="button" onclick="redirect('<%= exit_url %>')">Exit Reader</button>
|
<button class="uk-button uk-button-danger" type="button" onclick="redirect('<%= exit_url %>')">Exit Reader</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const base_url = "<%= base_url %>"
|
const base_url = "<%= base_url %>";
|
||||||
|
const page = <%= page %>;
|
||||||
|
const tid = "<%= title.id %>";
|
||||||
|
const eid = "<%= entry.id %>";
|
||||||
</script>
|
</script>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/protonet-jquery.inview/1.1.2/jquery.inview.min.js"></script>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.7/ScrollMagic.min.js"></script>
|
<script src="<%= base_url %>js/alert.js"></script>
|
||||||
<script src="<%= base_url %>js/uikit.min.js"></script>
|
<script src="<%= base_url %>js/uikit.min.js"></script>
|
||||||
<script src="<%= base_url %>js/uikit-icons.min.js"></script>
|
<script src="<%= base_url %>js/uikit-icons.min.js"></script>
|
||||||
<script src="<%= base_url %>js/reader.js"></script>
|
<script src="<%= base_url %>js/reader.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
img[data-src][src*='data:image'] { background: white; }
|
||||||
|
#root img { width: 100%; }
|
||||||
|
</style>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,4 +1,23 @@
|
|||||||
<div>
|
<div>
|
||||||
|
<div id="select-bar" class="uk-card uk-card-body uk-card-default uk-margin-bottom" uk-sticky="offset:10" x-data="{count: 0}" @add.window="count++" @remove.window="count--" x-show="count > 0" style="border:orange;border-style:solid;" x-cloak data-id="<%= title.id %>">
|
||||||
|
<div class="uk-child-width-1-3" uk-grid>
|
||||||
|
<div>
|
||||||
|
<p x-text="count + ' items selected'" style="color:orange"></p>
|
||||||
|
</div>
|
||||||
|
<div class="uk-text-center" id="select-bar-controls">
|
||||||
|
<a class="uk-icon uk-margin-right" uk-tooltip="title: Mark selected as read" href="" @click.prevent="bulkProgress('read', $el)">
|
||||||
|
<i class="fas fa-check-circle"></i>
|
||||||
|
</a>
|
||||||
|
<a class="uk-icon" uk-tooltip="title: Mark selected as unread" href="" @click.prevent="bulkProgress('unread', $el)">
|
||||||
|
<i class="fas fa-times-circle"></i>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="uk-text-right">
|
||||||
|
<a @click="selectAll()" uk-tooltip="title: Select all"><i class="fas fa-check-double uk-margin-small-right"></i></a>
|
||||||
|
<a @click="deselectAll();" uk-tooltip="title: Deselect all"><i class="fas fa-times"></i></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<h2 class=uk-title><span><%= title.display_name %></span>
|
<h2 class=uk-title><span><%= title.display_name %></span>
|
||||||
|
|
||||||
<% if is_admin %>
|
<% if is_admin %>
|
||||||
@@ -32,11 +51,14 @@
|
|||||||
<%= render_component "sort-form" %>
|
<%= render_component "sort-form" %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="item-container" class="uk-child-width-1-4@m uk-child-width-1-2" uk-grid>
|
|
||||||
|
<div class="uk-child-width-1-4@m uk-child-width-1-2" uk-grid>
|
||||||
<% title.titles.each_with_index do |item, i| %>
|
<% title.titles.each_with_index do |item, i| %>
|
||||||
<% progress = title_percentage[i] %>
|
<% progress = title_percentage[i] %>
|
||||||
<%= render_component "card" %>
|
<%= render_component "card" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<div class="uk-child-width-1-4@m uk-child-width-1-2" uk-grid>
|
||||||
<% entries.each_with_index do |item, i| %>
|
<% entries.each_with_index do |item, i| %>
|
||||||
<% progress = percentage[i] %>
|
<% progress = percentage[i] %>
|
||||||
<%= render_component "card" %>
|
<%= render_component "card" %>
|
||||||
@@ -95,8 +117,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% content_for "script" do %>
|
<% content_for "script" do %>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jQuery.dotdotdot/4.0.11/dotdotdot.js"></script>
|
<%= render_component "dots-scripts" %>
|
||||||
<script src="<%= base_url %>js/dots.js"></script>
|
|
||||||
<script src="<%= base_url %>js/alert.js"></script>
|
<script src="<%= base_url %>js/alert.js"></script>
|
||||||
<script src="<%= base_url %>js/title.js"></script>
|
<script src="<%= base_url %>js/title.js"></script>
|
||||||
<script src="<%= base_url %>js/search.js"></script>
|
<script src="<%= base_url %>js/search.js"></script>
|
||||||
|
|||||||
Reference in New Issue
Block a user