mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-05 03:44:36 -05:00
Compare commits
1 Commits
v0.6.4
...
token-auth
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
53c3ac5676 |
12
.github/workflows/build_pull_request.yml
vendored
12
.github/workflows/build_pull_request.yml
vendored
@@ -10,7 +10,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Clone repo
|
- name: Clone repo
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Validate Gradle Wrapper
|
- name: Validate Gradle Wrapper
|
||||||
uses: gradle/wrapper-validation-action@v1
|
uses: gradle/wrapper-validation-action@v1
|
||||||
@@ -23,7 +23,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Cancel previous runs
|
- name: Cancel previous runs
|
||||||
uses: styfle/cancel-workflow-action@0.10.0
|
uses: styfle/cancel-workflow-action@0.9.0
|
||||||
with:
|
with:
|
||||||
access_token: ${{ github.token }}
|
access_token: ${{ github.token }}
|
||||||
|
|
||||||
@@ -45,9 +45,13 @@ jobs:
|
|||||||
mkdir -p ~/.gradle
|
mkdir -p ~/.gradle
|
||||||
cp .github/runner-files/ci-gradle.properties ~/.gradle/gradle.properties
|
cp .github/runner-files/ci-gradle.properties ~/.gradle/gradle.properties
|
||||||
|
|
||||||
|
|
||||||
- name: Build Jar
|
- name: Build Jar
|
||||||
uses: gradle/gradle-build-action@v2
|
uses: eskatos/gradle-command-action@v1
|
||||||
with:
|
with:
|
||||||
build-root-directory: master
|
build-root-directory: master
|
||||||
|
wrapper-directory: master
|
||||||
arguments: :server:shadowJar --stacktrace
|
arguments: :server:shadowJar --stacktrace
|
||||||
|
wrapper-cache-enabled: true
|
||||||
|
dependencies-cache-enabled: true
|
||||||
|
configuration-cache-enabled: true
|
||||||
164
.github/workflows/build_push.yml
vendored
164
.github/workflows/build_push.yml
vendored
@@ -9,26 +9,28 @@ jobs:
|
|||||||
check_wrapper:
|
check_wrapper:
|
||||||
name: Validate Gradle Wrapper
|
name: Validate Gradle Wrapper
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Clone repo
|
- name: Clone repo
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Validate Gradle Wrapper
|
- name: Validate Gradle Wrapper
|
||||||
uses: gradle/wrapper-validation-action@v1
|
uses: gradle/wrapper-validation-action@v1
|
||||||
|
|
||||||
build:
|
build:
|
||||||
name: Build Jar
|
name: Build artifacts and deploy preview
|
||||||
needs: check_wrapper
|
needs: check_wrapper
|
||||||
if: "!startsWith(github.event.head_commit.message, '[SKIP CI]')"
|
if: "!startsWith(github.event.head_commit.message, '[SKIP CI]')"
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Cancel previous runs
|
- name: Cancel previous runs
|
||||||
uses: styfle/cancel-workflow-action@0.10.0
|
uses: styfle/cancel-workflow-action@0.9.0
|
||||||
with:
|
with:
|
||||||
access_token: ${{ github.token }}
|
access_token: ${{ github.token }}
|
||||||
|
|
||||||
- name: Checkout master branch
|
- name: Checkout master branch
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
ref: master
|
ref: master
|
||||||
path: master
|
path: master
|
||||||
@@ -46,136 +48,43 @@ jobs:
|
|||||||
cp .github/runner-files/ci-gradle.properties ~/.gradle/gradle.properties
|
cp .github/runner-files/ci-gradle.properties ~/.gradle/gradle.properties
|
||||||
|
|
||||||
- name: Build Jar
|
- name: Build Jar
|
||||||
uses: gradle/gradle-build-action@v2
|
uses: eskatos/gradle-command-action@v1
|
||||||
env:
|
env:
|
||||||
ProductBuildType: "Preview"
|
ProductBuildType: "Preview"
|
||||||
with:
|
with:
|
||||||
build-root-directory: master
|
build-root-directory: master
|
||||||
|
wrapper-directory: master
|
||||||
arguments: :server:shadowJar --stacktrace
|
arguments: :server:shadowJar --stacktrace
|
||||||
|
wrapper-cache-enabled: true
|
||||||
- name: Upload Jar
|
dependencies-cache-enabled: true
|
||||||
uses: actions/upload-artifact@v3
|
configuration-cache-enabled: true
|
||||||
with:
|
|
||||||
name: jar
|
|
||||||
path: master/server/build/*.jar
|
|
||||||
if-no-files-found: error
|
|
||||||
|
|
||||||
- name: Upload icons
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: icon
|
|
||||||
path: master/server/src/main/resources/icon
|
|
||||||
if-no-files-found: error
|
|
||||||
|
|
||||||
- name: Tar scripts dir to maintain file permissions
|
|
||||||
run: tar -cvzf scripts.tar.gz -C master/ scripts/
|
|
||||||
- name: Upload scripts.tar.gz
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: scripts
|
|
||||||
path: scripts.tar.gz
|
|
||||||
if-no-files-found: error
|
|
||||||
|
|
||||||
bundle:
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
os:
|
|
||||||
- debian-all
|
|
||||||
- linux-assets
|
|
||||||
- linux-x64
|
|
||||||
- macOS-x64
|
|
||||||
- macOS-arm64
|
|
||||||
- windows-x64
|
|
||||||
- windows-x86
|
|
||||||
|
|
||||||
name: Make ${{ matrix.os }} release
|
|
||||||
needs: build
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Download Jar
|
|
||||||
uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: jar
|
|
||||||
path: server/build
|
|
||||||
|
|
||||||
- name: Download icons
|
|
||||||
uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: icon
|
|
||||||
path: server/src/main/resources/icon
|
|
||||||
|
|
||||||
- name: Download scripts.tar.gz
|
|
||||||
uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: scripts
|
|
||||||
|
|
||||||
- name: Make ${{ matrix.os }} release
|
|
||||||
run: |
|
|
||||||
mkdir upload
|
|
||||||
tar -xvpf scripts.tar.gz
|
|
||||||
scripts/bundler.sh -o upload/ ${{ matrix.os }}
|
|
||||||
|
|
||||||
- name: Upload ${{ matrix.os }} release
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: ${{ matrix.os }}
|
|
||||||
path: upload/*
|
|
||||||
if-no-files-found: error
|
|
||||||
|
|
||||||
release:
|
|
||||||
needs: bundle
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: jar
|
|
||||||
path: release
|
|
||||||
- uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: debian-all
|
|
||||||
path: release
|
|
||||||
- uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: linux-assets
|
|
||||||
path: release
|
|
||||||
- uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: linux-x64
|
|
||||||
path: release
|
|
||||||
- uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: macOS-x64
|
|
||||||
path: release
|
|
||||||
- uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: macOS-arm64
|
|
||||||
path: release
|
|
||||||
- uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: windows-x64
|
|
||||||
path: release
|
|
||||||
- uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: windows-x86
|
|
||||||
path: release
|
|
||||||
|
|
||||||
- name: Checkout Preview branch
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
repository: "Suwayomi/Tachidesk-Server-preview"
|
|
||||||
ref: main
|
|
||||||
path: preview
|
|
||||||
token: ${{ secrets.DEPLOY_PREVIEW_TOKEN }}
|
|
||||||
|
|
||||||
- name: Generate Tag Name
|
- name: Generate Tag Name
|
||||||
id: GenTagName
|
id: GenTagName
|
||||||
run: |
|
run: |
|
||||||
cd release
|
cd master/server/build
|
||||||
genTag=$(ls *.jar | sed -e's/Tachidesk-Server-\|.jar//g')
|
genTag=$(ls *.jar | sed -e's/Tachidesk-Server-\|.jar//g')
|
||||||
echo "$genTag"
|
echo "$genTag"
|
||||||
echo "::set-output name=value::$genTag"
|
echo "::set-output name=value::$genTag"
|
||||||
|
|
||||||
|
- name: make bundle packages
|
||||||
|
run: |
|
||||||
|
cd master/scripts
|
||||||
|
./windows-bundler.sh win32
|
||||||
|
./windows-bundler.sh win64
|
||||||
|
./unix-bundler.sh linux-x64
|
||||||
|
./debian-packager.sh
|
||||||
|
./unix-bundler.sh macOS-x64
|
||||||
|
./unix-bundler.sh macOS-arm64
|
||||||
|
|
||||||
|
- name: Checkout preview branch
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
repository: 'Suwayomi/Tachidesk-Server-preview'
|
||||||
|
ref: main
|
||||||
|
path: preview
|
||||||
|
token: ${{ secrets.DEPLOY_PREVIEW_TOKEN }}
|
||||||
|
|
||||||
- name: Create Tag
|
- name: Create Tag
|
||||||
run: |
|
run: |
|
||||||
TAG="${{ steps.GenTagName.outputs.value }}"
|
TAG="${{ steps.GenTagName.outputs.value }}"
|
||||||
@@ -183,8 +92,7 @@ jobs:
|
|||||||
cd preview
|
cd preview
|
||||||
echo "{ \"latest\": \"$TAG\" }" > index.json
|
echo "{ \"latest\": \"$TAG\" }" > index.json
|
||||||
git add index.json
|
git add index.json
|
||||||
git config --global user.email \
|
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
"github-actions[bot]@users.noreply.github.com"
|
|
||||||
git config --global user.name "github-actions[bot]"
|
git config --global user.name "github-actions[bot]"
|
||||||
git commit -m "Updated to $TAG"
|
git commit -m "Updated to $TAG"
|
||||||
git push origin main
|
git push origin main
|
||||||
@@ -193,10 +101,10 @@ jobs:
|
|||||||
git push origin $TAG
|
git push origin $TAG
|
||||||
|
|
||||||
- name: Upload Preview Release
|
- name: Upload Preview Release
|
||||||
uses: softprops/action-gh-release@v1
|
uses: ncipollo/release-action@v1
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.DEPLOY_PREVIEW_TOKEN }}
|
token: ${{ secrets.DEPLOY_PREVIEW_TOKEN }}
|
||||||
repository: "Suwayomi/Tachidesk-Server-preview"
|
artifacts: "master/server/build/*.jar,master/server/build/*.msi,master/server/build/*.zip,master/server/build/*.tar.gz,master/server/build/*.deb"
|
||||||
tag_name: ${{ steps.GenTagName.outputs.value }}
|
owner: "Suwayomi"
|
||||||
files: release/*
|
repo: "Tachidesk-Server-preview"
|
||||||
|
tag: ${{ steps.GenTagName.outputs.value }}
|
||||||
|
|||||||
148
.github/workflows/publish.yml
vendored
148
.github/workflows/publish.yml
vendored
@@ -1,7 +1,6 @@
|
|||||||
name: CI Publish
|
name: CI Publish
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- "v*"
|
- "v*"
|
||||||
@@ -10,25 +9,27 @@ jobs:
|
|||||||
check_wrapper:
|
check_wrapper:
|
||||||
name: Validate Gradle Wrapper
|
name: Validate Gradle Wrapper
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Clone repo
|
- name: Clone repo
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Validate Gradle Wrapper
|
- name: Validate Gradle Wrapper
|
||||||
uses: gradle/wrapper-validation-action@v1
|
uses: gradle/wrapper-validation-action@v1
|
||||||
|
|
||||||
build:
|
build:
|
||||||
name: Build Jar
|
name: Build artifacts and release
|
||||||
needs: check_wrapper
|
needs: check_wrapper
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Cancel previous runs
|
- name: Cancel previous runs
|
||||||
uses: styfle/cancel-workflow-action@0.10.0
|
uses: styfle/cancel-workflow-action@0.9.0
|
||||||
with:
|
with:
|
||||||
access_token: ${{ github.token }}
|
access_token: ${{ github.token }}
|
||||||
|
|
||||||
- name: Checkout ${{ github.ref }}
|
- name: Checkout ${{ github.ref }}
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
ref: ${{ github.ref }}
|
ref: ${{ github.ref }}
|
||||||
path: master
|
path: master
|
||||||
@@ -43,131 +44,36 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
cd master
|
cd master
|
||||||
mkdir -p ~/.gradle
|
mkdir -p ~/.gradle
|
||||||
cp .github/runner-files/ci-gradle.properties \
|
cp .github/runner-files/ci-gradle.properties ~/.gradle/gradle.properties
|
||||||
~/.gradle/gradle.properties
|
|
||||||
|
|
||||||
- name: Build and copy webUI, Build Jar
|
- name: Build and copy webUI, Build Jar
|
||||||
uses: gradle/gradle-build-action@v2
|
uses: eskatos/gradle-command-action@v1
|
||||||
env:
|
env:
|
||||||
ProductBuildType: "Stable"
|
ProductBuildType: "Stable"
|
||||||
with:
|
with:
|
||||||
build-root-directory: master
|
build-root-directory: master
|
||||||
|
wrapper-directory: master
|
||||||
arguments: :server:downloadWebUI :server:shadowJar --stacktrace
|
arguments: :server:downloadWebUI :server:shadowJar --stacktrace
|
||||||
|
wrapper-cache-enabled: true
|
||||||
|
dependencies-cache-enabled: true
|
||||||
|
configuration-cache-enabled: true
|
||||||
|
|
||||||
- name: Upload Jar
|
- name: Make bundle packages
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: jar
|
|
||||||
path: master/server/build/*.jar
|
|
||||||
if-no-files-found: error
|
|
||||||
|
|
||||||
- name: Upload icons
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: icon
|
|
||||||
path: master/server/src/main/resources/icon
|
|
||||||
if-no-files-found: error
|
|
||||||
|
|
||||||
- name: Tar scripts dir to maintain file permissions
|
|
||||||
run: tar -cvzf scripts.tar.gz -C master/ scripts/
|
|
||||||
- name: Upload scripts.tar.gz
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: scripts
|
|
||||||
path: scripts.tar.gz
|
|
||||||
if-no-files-found: error
|
|
||||||
|
|
||||||
bundle:
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
os:
|
|
||||||
- debian-all
|
|
||||||
- linux-assets
|
|
||||||
- linux-x64
|
|
||||||
- macOS-x64
|
|
||||||
- macOS-arm64
|
|
||||||
- windows-x64
|
|
||||||
- windows-x86
|
|
||||||
|
|
||||||
name: Make ${{ matrix.os }} release
|
|
||||||
needs: build
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Download Jar
|
|
||||||
uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: jar
|
|
||||||
path: server/build
|
|
||||||
|
|
||||||
- name: Download icons
|
|
||||||
uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: icon
|
|
||||||
path: server/src/main/resources/icon
|
|
||||||
|
|
||||||
- name: Download scripts.tar.gz
|
|
||||||
uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: scripts
|
|
||||||
|
|
||||||
- name: Make ${{ matrix.os }} release
|
|
||||||
run: |
|
run: |
|
||||||
mkdir upload/
|
cd master/scripts
|
||||||
tar -xvpf scripts.tar.gz
|
./windows-bundler.sh win32
|
||||||
scripts/bundler.sh -o upload/ ${{ matrix.os }}
|
./windows-bundler.sh win64
|
||||||
|
./unix-bundler.sh linux-x64
|
||||||
|
./debian-packager.sh
|
||||||
|
./unix-bundler.sh macOS-x64
|
||||||
|
./unix-bundler.sh macOS-arm64
|
||||||
|
|
||||||
- name: Upload ${{ matrix.os }} files
|
- name: Upload Release
|
||||||
uses: actions/upload-artifact@v3
|
uses: xresloader/upload-to-github-release@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
with:
|
||||||
name: ${{ matrix.os }}
|
file: "master/server/build/*.jar;master/server/build/*.msi;master/server/build/*.zip;master/server/build/*.tar.gz;master/server/build/*.deb"
|
||||||
path: upload/*
|
tags: true
|
||||||
if-no-files-found: error
|
|
||||||
|
|
||||||
release:
|
|
||||||
if: startsWith(github.ref, 'refs/tags/v')
|
|
||||||
needs: bundle
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: jar
|
|
||||||
path: release
|
|
||||||
- uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: debian-all
|
|
||||||
path: release
|
|
||||||
- uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: linux-assets
|
|
||||||
path: release
|
|
||||||
- uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: linux-x64
|
|
||||||
path: release
|
|
||||||
- uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: macOS-x64
|
|
||||||
path: release
|
|
||||||
- uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: macOS-arm64
|
|
||||||
path: release
|
|
||||||
- uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: windows-x64
|
|
||||||
path: release
|
|
||||||
- uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: windows-x86
|
|
||||||
path: release
|
|
||||||
|
|
||||||
- name: Generate checksums
|
|
||||||
run: cd release && sha256sum * > Checksums.sha256
|
|
||||||
|
|
||||||
- name: Release
|
|
||||||
uses: softprops/action-gh-release@v1
|
|
||||||
with:
|
|
||||||
token: ${{ secrets.WINGET_PUBLISH_PAT }}
|
|
||||||
draft: true
|
draft: true
|
||||||
files: release/*
|
verbose: true
|
||||||
|
|||||||
12
.github/workflows/winget.yml
vendored
12
.github/workflows/winget.yml
vendored
@@ -1,12 +0,0 @@
|
|||||||
name: Publish to WinGet
|
|
||||||
on:
|
|
||||||
release:
|
|
||||||
types: [released]
|
|
||||||
jobs:
|
|
||||||
publish:
|
|
||||||
runs-on: windows-latest # action can only be run on windows
|
|
||||||
steps:
|
|
||||||
- uses: vedantmgoyal2009/winget-releaser@latest
|
|
||||||
with:
|
|
||||||
identifier: Suwayomi.Tachidesk-Server
|
|
||||||
token: ${{ secrets.WINGET_PUBLISH_PAT }}
|
|
||||||
42
CHANGELOG.md
42
CHANGELOG.md
@@ -1,45 +1,3 @@
|
|||||||
# Server: v0.6.4 + WebUI: r946
|
|
||||||
## TL;DR
|
|
||||||
- No new major features
|
|
||||||
- Bug fixes and changes for packaging
|
|
||||||
- Documentation changes
|
|
||||||
|
|
||||||
## Tachidesk-Server Changelog
|
|
||||||
- (r1087) v0.6.3 (by @AriaMoradi)
|
|
||||||
- (r1088) Save categories when manga is unfavorited ([#335](https://github.com/Suwayomi/Tachidesk-Server/pull/335) by @Syer10)
|
|
||||||
- (r1089) handle solid RAR archives ([#339](https://github.com/Suwayomi/Tachidesk-Server/pull/339)) cfso100@gmail.com
|
|
||||||
- (r1090) add support for changing downloads dir ([#343](https://github.com/Suwayomi/Tachidesk-Server/pull/343) by @AriaMoradi)
|
|
||||||
- (r1091) fix Applications dir dependency ([#344](https://github.com/Suwayomi/Tachidesk-Server/pull/344) by @AriaMoradi)
|
|
||||||
- (r1092) add support for alternative web interfaces ([#342](https://github.com/Suwayomi/Tachidesk-Server/pull/342) by @AriaMoradi)
|
|
||||||
- (r1093) Add displayValues json field for select filter ([#347](https://github.com/Suwayomi/Tachidesk-Server/pull/347) by @Syer10)
|
|
||||||
- (r1094) document manga endpoints ([#348](https://github.com/Suwayomi/Tachidesk-Server/pull/348) by @Syer10)
|
|
||||||
- (r1095) add ChapterCount to manga object in categoryMangas endpoint ([#349](https://github.com/Suwayomi/Tachidesk-Server/pull/349) by @abhijeetChawla)
|
|
||||||
- (r1096) document all endpoints ([#350](https://github.com/Suwayomi/Tachidesk-Server/pull/350) by @Syer10)
|
|
||||||
- (r1097) fix copymanga ([#354](https://github.com/Suwayomi/Tachidesk-Server/pull/354) by @AriaMoradi)
|
|
||||||
- (r1098) fix formatting by kotlinter (by @AriaMoradi)
|
|
||||||
- (r1099) bump WebUI (by @AriaMoradi)
|
|
||||||
- (r1100) fix WebUI release name (by @AriaMoradi)
|
|
||||||
- (r1101) Fix documentation errors ([#358](https://github.com/Suwayomi/scripts/pull/358) by @Syer10)
|
|
||||||
- (r1102) Docs improvements ([#359](https://github.com/Suwayomi/scripts/pull/359) by @Syer10)
|
|
||||||
- (r1103) Add linux-all.tar.gz & systemd service ([#366](https://github.com/Suwayomi/scripts/pull/366)) mahor1221@pm.me
|
|
||||||
- (r1104) Publish to Windows Package Managar (WinGet [#369](https://github.com/Suwayomi/scripts/pull/369)) 83997633+vedantmgoyal2009@users.noreply.github.com
|
|
||||||
- (r1105) Refactor scripts ([#370](https://github.com/Suwayomi/scripts/pull/370)) mahor1221@pm.me
|
|
||||||
- (r1106) Run workflow jobs toghether ([#371](https://github.com/Suwayomi/scripts/pull/371)) mahor1221@pm.me
|
|
||||||
- (r1107) Update gradle action ([#372](https://github.com/Suwayomi/scripts/pull/372)) mahor1221@pm.me
|
|
||||||
- (r1108) Improve DocumentationDsl, bugfix default values and add queryParams ([#378](https://github.com/Suwayomi/scripts/pull/378) by @Syer10)
|
|
||||||
- (r1109) Tidy up bundler script ([#380](https://github.com/Suwayomi/scripts/pull/380)) mahor1221@pm.me
|
|
||||||
- (r1110) Replace linux-all with linux-assets ([#381](https://github.com/Suwayomi/scripts/pull/381)) mahor1221@pm.me
|
|
||||||
- (r1111) Rename every instance of Tachidesk jar to Tachdidesk-Server.jar ([#384](https://github.com/Suwayomi/scripts/pull/384) by @AriaMoradi)
|
|
||||||
- (r1112) Fix mistakes from #384 ([#385](https://github.com/Suwayomi/scripts/pull/385) by @AriaMoradi)
|
|
||||||
|
|
||||||
## Tachidesk-WebUI Changelog
|
|
||||||
- (r943) fix default width ([#171](https://github.com/Suwayomi/Tachidesk-WebUI/pull/171) by @Robonau)
|
|
||||||
- (r944) added an update checker button for library ([#172](https://github.com/Suwayomi/Tachidesk-WebUI/pull/172) by @infix)
|
|
||||||
- (r945) fix download queue delete button ([#176](https://github.com/Suwayomi/Tachidesk-WebUI/pull/176) by @Kreach37)
|
|
||||||
- (r946) fix mangadex filters ([#177](https://github.com/Suwayomi/Tachidesk-WebUI/pull/177) by @Robonau)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Server: v0.6.3 + WebUI: r942
|
# Server: v0.6.3 + WebUI: r942
|
||||||
## TL;DR
|
## TL;DR
|
||||||
- Changes in Server
|
- Changes in Server
|
||||||
|
|||||||
@@ -12,10 +12,9 @@ const val kotlinVersion = "1.6.10"
|
|||||||
const val MainClass = "suwayomi.tachidesk.MainKt"
|
const val MainClass = "suwayomi.tachidesk.MainKt"
|
||||||
|
|
||||||
// should be bumped with each stable release
|
// should be bumped with each stable release
|
||||||
val tachideskVersion = System.getenv("ProductVersion") ?: "v0.6.4"
|
val tachideskVersion = System.getenv("ProductVersion") ?: "v0.6.3"
|
||||||
|
|
||||||
val webUIRevisionTag = System.getenv("WebUIRevision") ?: "r946"
|
val webUIRevisionTag = System.getenv("WebUIRevision") ?: "r942"
|
||||||
val sorayomiRevisionTag = System.getenv("SorayomiRevision") ?: "0.1.5"
|
|
||||||
|
|
||||||
// counts commits on the master branch
|
// counts commits on the master branch
|
||||||
val tachideskRevision = runCatching {
|
val tachideskRevision = runCatching {
|
||||||
|
|||||||
@@ -1,292 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Copyright (C) Contributors to the Suwayomi project
|
|
||||||
#
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
main() {
|
|
||||||
POSITIONAL_ARGS=()
|
|
||||||
OUTPUT_DIR=.
|
|
||||||
while [ "$#" -gt 0 ]; do
|
|
||||||
case "$1" in
|
|
||||||
-o|--output-dir)
|
|
||||||
OUTPUT_DIR="$(readlink -e "$2" || exit 1)"
|
|
||||||
shift
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
POSITIONAL_ARGS+=("$1")
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
# restore positional parameters
|
|
||||||
set -- "${POSITIONAL_ARGS[@]}"
|
|
||||||
|
|
||||||
OS="$1"
|
|
||||||
JAR="$(ls server/build/*.jar | tail -n1)"
|
|
||||||
RELEASE_NAME="$(echo "${JAR%.*}" | xargs basename)-$OS"
|
|
||||||
RELEASE_VERSION="$(tmp="${JAR%-*}"; echo "${tmp##*-}" | tr -d v)"
|
|
||||||
#RELEASE_REVISION_NUMBER="$(tmp="${JAR%.*}" && echo "${tmp##*-}" | tr -d r)"
|
|
||||||
local electron_version="v14.0.0"
|
|
||||||
|
|
||||||
# clean temporary directory on function return
|
|
||||||
trap "rm -rf $RELEASE_NAME/" RETURN
|
|
||||||
mkdir "$RELEASE_NAME/"
|
|
||||||
|
|
||||||
case "$OS" in
|
|
||||||
debian-all)
|
|
||||||
RELEASE="$RELEASE_NAME.deb"
|
|
||||||
make_deb_package
|
|
||||||
move_release_to_output_dir
|
|
||||||
;;
|
|
||||||
linux-assets)
|
|
||||||
RELEASE="$RELEASE_NAME.tar.gz"
|
|
||||||
copy_linux_package_assets_to "$RELEASE_NAME/"
|
|
||||||
tar -I "gzip -9" -cvf "$RELEASE" "$RELEASE_NAME/"
|
|
||||||
move_release_to_output_dir
|
|
||||||
;;
|
|
||||||
linux-x64)
|
|
||||||
JRE="OpenJDK8U-jre_x64_linux_hotspot_8u302b08.tar.gz"
|
|
||||||
JRE_URL="https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u302-b08/$JRE"
|
|
||||||
ELECTRON="electron-$electron_version-linux-x64.zip"
|
|
||||||
ELECTRON_URL="https://github.com/electron/electron/releases/download/$electron_version/$ELECTRON"
|
|
||||||
download_jre_and_electron
|
|
||||||
|
|
||||||
RELEASE="$RELEASE_NAME.tar.gz"
|
|
||||||
make_linux_bundle
|
|
||||||
move_release_to_output_dir
|
|
||||||
;;
|
|
||||||
macOS-x64)
|
|
||||||
JRE="OpenJDK8U-jre_x64_mac_hotspot_8u302b08.tar.gz"
|
|
||||||
JRE_URL="https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u302-b08/$JRE"
|
|
||||||
ELECTRON="electron-$electron_version-darwin-x64.zip"
|
|
||||||
ELECTRON_URL="https://github.com/electron/electron/releases/download/$electron_version/$ELECTRON"
|
|
||||||
download_jre_and_electron
|
|
||||||
|
|
||||||
RELEASE="$RELEASE_NAME.zip"
|
|
||||||
make_macos_bundle
|
|
||||||
move_release_to_output_dir
|
|
||||||
;;
|
|
||||||
macOS-arm64)
|
|
||||||
JRE="zulu8.56.0.23-ca-jre8.0.302-macosx_aarch64.tar.gz"
|
|
||||||
JRE_URL="https://cdn.azul.com/zulu/bin/$JRE"
|
|
||||||
ELECTRON="electron-$electron_version-darwin-arm64.zip"
|
|
||||||
ELECTRON_URL="https://github.com/electron/electron/releases/download/$electron_version/$ELECTRON"
|
|
||||||
download_jre_and_electron
|
|
||||||
|
|
||||||
RELEASE="$RELEASE_NAME.zip"
|
|
||||||
make_macos_bundle
|
|
||||||
move_release_to_output_dir
|
|
||||||
;;
|
|
||||||
windows-x86)
|
|
||||||
JRE="OpenJDK8U-jre_x86-32_windows_hotspot_8u292b10.zip"
|
|
||||||
JRE_URL="https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u292-b10/$JRE"
|
|
||||||
ELECTRON="electron-$electron_version-win32-ia32.zip"
|
|
||||||
ELECTRON_URL="https://github.com/electron/electron/releases/download/$electron_version/$ELECTRON"
|
|
||||||
download_jre_and_electron
|
|
||||||
|
|
||||||
RELEASE="$RELEASE_NAME.zip"
|
|
||||||
make_windows_bundle
|
|
||||||
move_release_to_output_dir
|
|
||||||
|
|
||||||
RELEASE="$RELEASE_NAME.msi"
|
|
||||||
make_windows_package
|
|
||||||
move_release_to_output_dir
|
|
||||||
;;
|
|
||||||
windows-x64)
|
|
||||||
JRE="OpenJDK8U-jre_x64_windows_hotspot_8u302b08.zip"
|
|
||||||
JRE_URL="https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u302-b08/$JRE"
|
|
||||||
ELECTRON="electron-$electron_version-win32-x64.zip"
|
|
||||||
ELECTRON_URL="https://github.com/electron/electron/releases/download/$electron_version/$ELECTRON"
|
|
||||||
download_jre_and_electron
|
|
||||||
|
|
||||||
RELEASE="$RELEASE_NAME.zip"
|
|
||||||
make_windows_bundle
|
|
||||||
move_release_to_output_dir
|
|
||||||
|
|
||||||
RELEASE="$RELEASE_NAME.msi"
|
|
||||||
make_windows_package
|
|
||||||
move_release_to_output_dir
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
error $LINENO "Unsupported operating system: $OS" 2
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
move_release_to_output_dir() {
|
|
||||||
# clean up from possible previous runs
|
|
||||||
if [ -f "$OUTPUT_DIR/$RELEASE" ]; then
|
|
||||||
rm "$OUTPUT_DIR/$RELEASE"
|
|
||||||
fi
|
|
||||||
mv "$RELEASE" "$OUTPUT_DIR/"
|
|
||||||
}
|
|
||||||
|
|
||||||
download_jre_and_electron() {
|
|
||||||
if [ ! -f "$JRE" ]; then
|
|
||||||
curl -L "$JRE_URL" -o "$JRE"
|
|
||||||
fi
|
|
||||||
if [ ! -f "$ELECTRON" ]; then
|
|
||||||
curl -L "$ELECTRON_URL" -o "$ELECTRON"
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -p "$RELEASE_NAME/jre/"
|
|
||||||
local ext="${JRE##*.}"
|
|
||||||
local jre_dir
|
|
||||||
if [ "$ext" = "zip" ]; then
|
|
||||||
jre_dir="$(unzip "$JRE" | sed -n '2p' | cut -d: -f2 | xargs basename)"
|
|
||||||
mv "$jre_dir" "$RELEASE_NAME/jre"
|
|
||||||
else
|
|
||||||
# --strip-components=1: untar an archive without the root folder
|
|
||||||
tar xvf "$JRE" --strip-components=1 -C "$RELEASE_NAME/jre/"
|
|
||||||
fi
|
|
||||||
unzip "$ELECTRON" -d "$RELEASE_NAME/electron/"
|
|
||||||
}
|
|
||||||
|
|
||||||
copy_linux_package_assets_to() {
|
|
||||||
local output_dir
|
|
||||||
output_dir="$(readlink -e "$1" || exit 1)"
|
|
||||||
|
|
||||||
cp "scripts/resources/pkg/tachidesk-server-browser-launcher.sh" "$output_dir/"
|
|
||||||
cp "scripts/resources/pkg/tachidesk-server-debug-launcher.sh" "$output_dir/"
|
|
||||||
cp "scripts/resources/pkg/tachidesk-server-electron-launcher.sh" "$output_dir/"
|
|
||||||
cp "scripts/resources/pkg/tachidesk-server.desktop" "$output_dir/"
|
|
||||||
cp "scripts/resources/pkg/systemd"/* "$output_dir/"
|
|
||||||
cp "server/src/main/resources/icon/faviconlogo.png" \
|
|
||||||
"$output_dir/tachidesk-server.png"
|
|
||||||
}
|
|
||||||
|
|
||||||
make_linux_bundle() {
|
|
||||||
cp "$JAR" "$RELEASE_NAME/Tachidesk-Server.jar"
|
|
||||||
cp "scripts/resources/tachidesk-server-browser-launcher.sh" "$RELEASE_NAME/"
|
|
||||||
cp "scripts/resources/tachidesk-server-debug-launcher.sh" "$RELEASE_NAME/"
|
|
||||||
cp "scripts/resources/tachidesk-server-electron-launcher.sh" "$RELEASE_NAME/"
|
|
||||||
|
|
||||||
tar -I "gzip -9" -cvf "$RELEASE" "$RELEASE_NAME/"
|
|
||||||
}
|
|
||||||
|
|
||||||
make_macos_bundle() {
|
|
||||||
cp "$JAR" "$RELEASE_NAME/Tachidesk-Server.jar"
|
|
||||||
cp "scripts/resources/Tachidesk Browser Launcher.command" "$RELEASE_NAME/"
|
|
||||||
cp "scripts/resources/Tachidesk Debug Launcher.command" "$RELEASE_NAME/"
|
|
||||||
cp "scripts/resources/Tachidesk Electron Launcher.command" "$RELEASE_NAME/"
|
|
||||||
|
|
||||||
zip -9 -r "$RELEASE" "$RELEASE_NAME/"
|
|
||||||
}
|
|
||||||
|
|
||||||
# https://wiki.debian.org/SimplePackagingTutorial
|
|
||||||
# https://www.debian.org/doc/manuals/packaging-tutorial/packaging-tutorial.pdf
|
|
||||||
make_deb_package() {
|
|
||||||
local temp_dir
|
|
||||||
temp_dir="$(mktemp -d)"
|
|
||||||
trap "rm -rf $temp_dir" RETURN
|
|
||||||
|
|
||||||
cp "$JAR" "$RELEASE_NAME/Tachidesk-Server.jar"
|
|
||||||
tar -I "gzip" -cvf "$RELEASE_NAME.tar.gz" "$RELEASE_NAME/"
|
|
||||||
#behind $RELEASE_VERSION is underscore "_"
|
|
||||||
local upstream_source="tachidesk-server_$RELEASE_VERSION.orig.tar.gz"
|
|
||||||
mv "$RELEASE_NAME.tar.gz" "$temp_dir/$upstream_source"
|
|
||||||
|
|
||||||
cp -r "scripts/resources/deb/" "$RELEASE_NAME/debian/"
|
|
||||||
copy_linux_package_assets_to "$RELEASE_NAME/debian/"
|
|
||||||
sed -i "s/\$pkgver/$RELEASE_VERSION/" "$RELEASE_NAME/debian/changelog"
|
|
||||||
sed -i "s/\$pkgrel/1/" "$RELEASE_NAME/debian/changelog"
|
|
||||||
#behind $RELEASE_VERSION is hyphen "-"
|
|
||||||
local source_dir="tachidesk-server-$RELEASE_VERSION"
|
|
||||||
mv "$RELEASE_NAME/" "$temp_dir/$source_dir/"
|
|
||||||
|
|
||||||
sudo apt install devscripts build-essential dh-exec
|
|
||||||
cd "$temp_dir/$source_dir/"
|
|
||||||
dpkg-buildpackage --no-sign --build=all
|
|
||||||
cd -
|
|
||||||
|
|
||||||
local deb="tachidesk-server_$RELEASE_VERSION-1_all.deb"
|
|
||||||
mv "$temp_dir/$deb" "$RELEASE"
|
|
||||||
}
|
|
||||||
|
|
||||||
make_windows_bundle() {
|
|
||||||
## I disabled this section until someone find a solution to this error:
|
|
||||||
##E: Unable to correct problems, you have held broken packages.
|
|
||||||
##./bundler.sh: line 250: wine: command not found
|
|
||||||
|
|
||||||
## check if running under github actions
|
|
||||||
#if [ "$CI" = true ]; then
|
|
||||||
## change electron executable's icon
|
|
||||||
#sudo dpkg --add-architecture i386
|
|
||||||
#wget -qO - https://dl.winehq.org/wine-builds/winehq.key \
|
|
||||||
#| sudo apt-key add -
|
|
||||||
#sudo add-apt-repository ppa:cybermax-dexter/sdl2-backport
|
|
||||||
#sudo apt-add-repository "deb https://dl.winehq.org/wine-builds/ubuntu \
|
|
||||||
#$(lsb_release -cs) main"
|
|
||||||
#sudo apt install --install-recommends winehq-stable
|
|
||||||
#fi
|
|
||||||
## this script assumes that wine is installed here on out
|
|
||||||
|
|
||||||
#local rcedit="rcedit-x85.exe"
|
|
||||||
#local rcedit_url="https://github.com/electron/rcedit/releases/download/v0.1.1/$rcedit"
|
|
||||||
## change electron's icon
|
|
||||||
#if [ ! -f "$rcedit" ]; then
|
|
||||||
#curl -L "$rcedit_url" -o "$rcedit"
|
|
||||||
#fi
|
|
||||||
|
|
||||||
#local icon="server/src/main/resources/icon/faviconlogo.ico"
|
|
||||||
#WINEARCH=win32 wine "$rcedit" "$RELEASE_NAME/electron/electron.exe" \
|
|
||||||
# --set-icon "$icon"
|
|
||||||
|
|
||||||
cp "$JAR" "$RELEASE_NAME/Tachidesk-Server.jar"
|
|
||||||
cp "scripts/resources/Tachidesk Browser Launcher.bat" "$RELEASE_NAME"
|
|
||||||
cp "scripts/resources/Tachidesk Debug Launcher.bat" "$RELEASE_NAME"
|
|
||||||
cp "scripts/resources/Tachidesk Electron Launcher.bat" "$RELEASE_NAME"
|
|
||||||
|
|
||||||
zip -9 -r "$RELEASE" "$RELEASE_NAME"
|
|
||||||
}
|
|
||||||
|
|
||||||
make_windows_package() {
|
|
||||||
if [ "$CI" = true ]; then
|
|
||||||
sudo apt install -y wixl
|
|
||||||
fi
|
|
||||||
|
|
||||||
find "$RELEASE_NAME/jre" \
|
|
||||||
| wixl-heat --var var.SourceDir -p "$RELEASE_NAME/" \
|
|
||||||
--directory-ref jre --component-group jre >"$RELEASE_NAME/jre.wxs"
|
|
||||||
find "$RELEASE_NAME/electron" \
|
|
||||||
| wixl-heat --var var.SourceDir -p "$RELEASE_NAME/" \
|
|
||||||
--directory-ref electron --component-group electron >"$RELEASE_NAME/electron.wxs"
|
|
||||||
|
|
||||||
local icon="server/src/main/resources/icon/faviconlogo.ico"
|
|
||||||
local arch=${OS##*-}
|
|
||||||
|
|
||||||
wixl -D ProductVersion="$RELEASE_VERSION" -D SourceDir="$RELEASE_NAME" \
|
|
||||||
-D Icon="$icon" --arch "$arch" "scripts/resources/msi/tachidesk-server-$arch.wxs" \
|
|
||||||
"$RELEASE_NAME/jre.wxs" "$RELEASE_NAME/electron.wxs" -o "$RELEASE"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Error handler
|
|
||||||
# set -u: Treat unset variables as an error when substituting.
|
|
||||||
# set -o pipefail: Prevents errors in pipeline from being masked.
|
|
||||||
# set -e: Immediatly exit if any command has a non-zero exit status.
|
|
||||||
# set -E: Inherit the trap ERR function before exiting by set.
|
|
||||||
#
|
|
||||||
# set -e is not recommended and unpredictable.
|
|
||||||
# see https://stackoverflow.com/questions/64786/error-handling-in-bash
|
|
||||||
# and http://mywiki.wooledge.org/BashFAO/105
|
|
||||||
set -uo pipefail
|
|
||||||
error() {
|
|
||||||
local parent_lineno="$1"
|
|
||||||
local message="$2"
|
|
||||||
local code="${3:-1}"
|
|
||||||
if [ -z "$message" ]; then
|
|
||||||
echo "$0: line $parent_lineno: exiting with status $code"
|
|
||||||
else
|
|
||||||
echo "$0: line $parent_lineno: $message: exiting with status $code"
|
|
||||||
fi
|
|
||||||
exit "$code"
|
|
||||||
}
|
|
||||||
trap 'error $LINENO ""' ERR
|
|
||||||
|
|
||||||
main "$@"; exit
|
|
||||||
|
|
||||||
|
|
||||||
51
scripts/debian-packager.sh
Executable file
51
scripts/debian-packager.sh
Executable file
@@ -0,0 +1,51 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Copyright (C) Contributors to the Suwayomi project
|
||||||
|
#
|
||||||
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
echo "Creating DEB Package"
|
||||||
|
pkgname="tachidesk-server"
|
||||||
|
PkgName="Tachidesk-Server"
|
||||||
|
jar=$(ls ../server/build/*.jar | tail -n1)
|
||||||
|
pkgver="$(tmp="${jar%-*}" && echo "${tmp##*-}" | tr -d v)"
|
||||||
|
pkgrel=1
|
||||||
|
|
||||||
|
srcdir="$pkgname-$pkgver" # uses hyphen "-"
|
||||||
|
srctgz="${pkgname}_$pkgver.orig.tar.gz" # uses underscore "_"
|
||||||
|
deb="${pkgname}_$pkgver-${pkgrel}_all.deb"
|
||||||
|
Deb="${PkgName}_$pkgver-${pkgrel}_all.deb"
|
||||||
|
|
||||||
|
# Prepare
|
||||||
|
mkdir "$srcdir/"
|
||||||
|
cp "$jar" "$srcdir/$pkgname.jar"
|
||||||
|
cp "resources/$pkgname-browser-launcher.sh" "$srcdir/"
|
||||||
|
cp "resources/$pkgname-debug-launcher.sh" "$srcdir/"
|
||||||
|
cp "resources/$pkgname-electron-launcher-debian.sh" "$srcdir/$pkgname-electron-launcher.sh"
|
||||||
|
cp "resources/$pkgname.desktop" "$srcdir/"
|
||||||
|
cp "../server/src/main/resources/icon/faviconlogo.png" "$srcdir/$pkgname.png"
|
||||||
|
|
||||||
|
GZIP=-9 tar -cvzf "$srctgz" "$srcdir/"
|
||||||
|
|
||||||
|
cp -r "resources/debian" "$srcdir/"
|
||||||
|
sed -i "s/\${pkgver}/$pkgver/" "$srcdir/debian/changelog"
|
||||||
|
sed -i "s/\${pkgrel}/$pkgrel/" "$srcdir/debian/changelog"
|
||||||
|
|
||||||
|
# Build
|
||||||
|
mkdir "debuild/"
|
||||||
|
mv "$srctgz" "$srcdir/" "debuild/"
|
||||||
|
sudo apt install devscripts build-essential dh-exec
|
||||||
|
# --lintian-opts --profile are for building Debian packages on Ubuntu
|
||||||
|
cd "debuild/$srcdir/debian"
|
||||||
|
debuild -uc -us --lintian-opts --profile debian
|
||||||
|
cd -
|
||||||
|
|
||||||
|
# clean up from possible previous runs
|
||||||
|
if [ -f "../server/build/$Deb" ]; then
|
||||||
|
rm "../server/build/$Deb"
|
||||||
|
fi
|
||||||
|
|
||||||
|
mv "debuild/$deb" "../server/build/$Deb"
|
||||||
|
rm -rf "debuild/"
|
||||||
@@ -1 +1 @@
|
|||||||
start "" jre/bin/javaw -jar Tachidesk-Server.jar
|
start "" jre/bin/javaw -jar Tachidesk.jar
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
cd "`dirname "$0"`"
|
cd "`dirname "$0"`"
|
||||||
|
|
||||||
./jre/Contents/Home/bin/java -jar Tachidesk-Server.jar
|
./jre/Contents/Home/bin/java -jar Tachidesk.jar
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
:: cleaner output
|
:: cleaner output
|
||||||
@echo off
|
@echo off
|
||||||
|
|
||||||
jre\bin\java -Dsuwayomi.tachidesk.config.server.debugLogsEnabled=true -jar Tachidesk-Server.jar
|
jre\bin\java -Dsuwayomi.tachidesk.config.server.debugLogsEnabled=true -jar Tachidesk.jar
|
||||||
|
|
||||||
:: Prevent cmd from closing when Tachidesk crashes
|
:: Prevent cmd from closing when Tachidesk crashes
|
||||||
pause
|
pause
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
cd "`dirname "$0"`"
|
cd "`dirname "$0"`"
|
||||||
|
|
||||||
./jre/Contents/Home/bin/java -Dsuwayomi.tachidesk.config.server.debugLogsEnabled=true -jar Tachidesk-Server.jar
|
./jre/Contents/Home/bin/java -Dsuwayomi.tachidesk.config.server.debugLogsEnabled=true -jar Tachidesk.jar
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
jre\bin\javaw "-Dsuwayomi.tachidesk.config.server.webUIInterface=electron" "-Dsuwayomi.tachidesk.config.server.electronPath=electron/electron.exe" -jar Tachidesk-Server.jar
|
jre\bin\javaw "-Dsuwayomi.tachidesk.config.server.webUIInterface=electron" "-Dsuwayomi.tachidesk.config.server.electronPath=electron/electron.exe" -jar Tachidesk.jar
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
cd "`dirname "$0"`"
|
cd "`dirname "$0"`"
|
||||||
|
|
||||||
./jre/Contents/Home/bin/java "-Dsuwayomi.tachidesk.config.server.webUIInterface=electron" "-Dsuwayomi.tachidesk.config.server.electronPath=electron/Electron.app/Contents/MacOS/Electron" -jar Tachidesk-Server.jar
|
./jre/Contents/Home/bin/java "-Dsuwayomi.tachidesk.config.server.webUIInterface=electron" "-Dsuwayomi.tachidesk.config.server.electronPath=electron/Electron.app/Contents/MacOS/Electron" -jar Tachidesk.jar
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
tachidesk-server ($pkgver-$pkgrel) unstable; urgency=medium
|
|
||||||
|
|
||||||
* See CHANGELOG.md on https://github.com/Suwayomi/Tachidesk-Server
|
|
||||||
|
|
||||||
-- Mahor1221 <mahor1221@pm.me> Fri, 14 Jan 2022 00:00:00 +0000
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
#!/usr/bin/dh-exec
|
|
||||||
|
|
||||||
Tachidesk-Server.jar usr/share/java/tachidesk-server/
|
|
||||||
debian/tachidesk-server.png usr/share/pixmaps/
|
|
||||||
debian/tachidesk-server.desktop usr/share/applications/
|
|
||||||
debian/tachidesk-server.service usr/lib/systemd/system/
|
|
||||||
debian/tachidesk-server.sysusers => usr/lib/sysusers.d/tachidesk-server.conf
|
|
||||||
debian/tachidesk-server.tmpfiles => usr/lib/tmpfiles.d/tachidesk-server.conf
|
|
||||||
debian/tachidesk-server.conf => etc/tachidesk/server.conf
|
|
||||||
debian/tachidesk-server-browser-launcher.sh => usr/bin/tachidesk-server-browser
|
|
||||||
debian/tachidesk-server-debug-launcher.sh => usr/bin/tachidesk-server-debug
|
|
||||||
debian/tachidesk-server-electron-launcher.sh => usr/bin/tachidesk-server-electron
|
|
||||||
5
scripts/resources/debian/changelog
Normal file
5
scripts/resources/debian/changelog
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
tachidesk-server (${pkgver}-${pkgrel}) unstable; urgency=medium
|
||||||
|
|
||||||
|
* See CHANGELOG.md on https://github.com/Suwayomi/Tachidesk-Server
|
||||||
|
|
||||||
|
-- Mahor Foruzesh <mahorforuzesh@pm.me> Fri, 14 Jan 2022 00:00:00 +0000
|
||||||
2
scripts/resources/deb/control → scripts/resources/debian/control
Normal file → Executable file
2
scripts/resources/deb/control → scripts/resources/debian/control
Normal file → Executable file
@@ -1,7 +1,7 @@
|
|||||||
Source: tachidesk-server
|
Source: tachidesk-server
|
||||||
Section: web
|
Section: web
|
||||||
Priority: optional
|
Priority: optional
|
||||||
Maintainer: Mahor1221 <mahor1221@pm.me>
|
Maintainer: Mahor Foruzesh <mahorforuzesh@pm.me>
|
||||||
Build-Depends: debhelper-compat (= 12), dh-exec
|
Build-Depends: debhelper-compat (= 12), dh-exec
|
||||||
Standards-Version: 4.5.1
|
Standards-Version: 4.5.1
|
||||||
Homepage: https://github.com/Suwayomi/Tachidesk-Server
|
Homepage: https://github.com/Suwayomi/Tachidesk-Server
|
||||||
0
scripts/resources/deb/copyright → scripts/resources/debian/copyright
Normal file → Executable file
0
scripts/resources/deb/copyright → scripts/resources/debian/copyright
Normal file → Executable file
8
scripts/resources/debian/install
Executable file
8
scripts/resources/debian/install
Executable file
@@ -0,0 +1,8 @@
|
|||||||
|
#!/usr/bin/dh-exec
|
||||||
|
|
||||||
|
tachidesk-server-browser-launcher.sh => usr/bin/tachidesk-server-browser
|
||||||
|
tachidesk-server-debug-launcher.sh => usr/bin/tachidesk-server-debug
|
||||||
|
tachidesk-server-electron-launcher.sh => usr/bin/tachidesk-server-electron
|
||||||
|
tachidesk-server.jar usr/share/java/tachidesk-server/
|
||||||
|
tachidesk-server.png usr/share/pixmaps/
|
||||||
|
tachidesk-server.desktop usr/share/applications/
|
||||||
0
scripts/resources/deb/source/format → scripts/resources/debian/source/format
Normal file → Executable file
0
scripts/resources/deb/source/format → scripts/resources/debian/source/format
Normal file → Executable file
0
scripts/resources/deb/source/include-binaries → scripts/resources/debian/source/include-binaries
Normal file → Executable file
0
scripts/resources/deb/source/include-binaries → scripts/resources/debian/source/include-binaries
Normal file → Executable file
@@ -31,7 +31,7 @@
|
|||||||
<!-- Component -->
|
<!-- Component -->
|
||||||
<DirectoryRef Id="INSTALLDIR">
|
<DirectoryRef Id="INSTALLDIR">
|
||||||
<Component Id="TachideskJAR" Guid="*" Win64="yes">
|
<Component Id="TachideskJAR" Guid="*" Win64="yes">
|
||||||
<File Id="Tachidesk-Server.jar" Source="$(var.SourceDir)/Tachidesk-Server.jar" KeyPath="yes" />
|
<File Id="Tachidesk.jar" Source="$(var.SourceDir)/Tachidesk.jar" KeyPath="yes" />
|
||||||
</Component>
|
</Component>
|
||||||
|
|
||||||
<Component Id="TachideskBrowserBAT" Guid="*" Win64="yes">
|
<Component Id="TachideskBrowserBAT" Guid="*" Win64="yes">
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
<!-- Component -->
|
<!-- Component -->
|
||||||
<DirectoryRef Id="INSTALLDIR">
|
<DirectoryRef Id="INSTALLDIR">
|
||||||
<Component Id="TachideskJAR" Guid="*">
|
<Component Id="TachideskJAR" Guid="*">
|
||||||
<File Id="Tachidesk-Server.jar" Source="$(var.SourceDir)/Tachidesk-Server.jar" KeyPath="yes" />
|
<File Id="Tachidesk.jar" Source="$(var.SourceDir)/Tachidesk.jar" KeyPath="yes" />
|
||||||
</Component>
|
</Component>
|
||||||
|
|
||||||
<Component Id="TachideskBrowserBAT" Guid="*">
|
<Component Id="TachideskBrowserBAT" Guid="*">
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
TACHIDESK_ROOT_DIR="/var/lib/tachidesk"
|
|
||||||
|
|
||||||
# Extra arguments passed to the java command
|
|
||||||
# The default value disables the system tray icon, and launching a browser on service start.
|
|
||||||
JAVA_ARGS=-Dsuwayomi.tachidesk.config.server.initialOpenInBrowserEnabled=false -Dsuwayomi.tachidesk.config.server.systemTrayEnabled=false
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=A free and open source manga reader server that runs extensions built for Tachiyomi.
|
|
||||||
Wants=network-online.target
|
|
||||||
After=network-online.target
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=simple
|
|
||||||
User=tachidesk
|
|
||||||
Group=tachidesk
|
|
||||||
SyslogIdentifier=tachidesk
|
|
||||||
|
|
||||||
EnvironmentFile=/etc/tachidesk/server.conf
|
|
||||||
ExecStart=/usr/bin/java $JAVA_ARGS -Dsuwayomi.tachidesk.config.server.rootDir="${TACHIDESK_ROOT_DIR}" -jar /usr/share/java/tachidesk-server/Tachidesk-Server.jar
|
|
||||||
Restart=on-failure
|
|
||||||
|
|
||||||
ProtectSystem=full
|
|
||||||
ProtectHome=true
|
|
||||||
PrivateTmp=yes
|
|
||||||
PrivateDevices=yes
|
|
||||||
ProtectClock=yes
|
|
||||||
ProtectKernelTunables=yes
|
|
||||||
ProtectKernelModules=yes
|
|
||||||
ProtectKernelLogs=yes
|
|
||||||
ProtectControlGroups=yes
|
|
||||||
RestrictSUIDSGID=yes
|
|
||||||
RestrictRealtime=yes
|
|
||||||
RestrictNamespaces=yes
|
|
||||||
NoNewPrivileges=yes
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
#Type Name ID GECOS Home directory Shell
|
|
||||||
u tachidesk - "Tachidesk Manga Server" /var/lib/tachidesk
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
#Type Path Mode User Group Age Argument
|
|
||||||
d /var/lib/tachidesk 0755 tachidesk tachidesk
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
exec /usr/bin/java -jar /usr/share/java/tachidesk-server/Tachidesk-Server.jar
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
exec /usr/bin/java \
|
|
||||||
-Dsuwayomi.tachidesk.config.server.debugLogsEnabled=true \
|
|
||||||
-jar /usr/share/java/tachidesk-server/Tachidesk-Server.jar
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
if [ ! -f /usr/bin/electron ]; then
|
|
||||||
echo "Electron executable was not found!
|
|
||||||
In order to run this launcher, you need Electron installed."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
exec /usr/bin/java \
|
|
||||||
-Dsuwayomi.tachidesk.config.server.webUIInterface=electron \
|
|
||||||
-Dsuwayomi.tachidesk.config.server.electronPath=/usr/bin/electron \
|
|
||||||
-jar /usr/share/java/tachidesk-server/Tachidesk-Server.jar
|
|
||||||
@@ -1,3 +1,2 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
exec /usr/bin/java -jar /usr/share/java/tachidesk-server/tachidesk-server.jar
|
||||||
exec ./jre/bin/java -jar ./Tachidesk-Server.jar
|
|
||||||
|
|||||||
@@ -1,5 +1,2 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
exec /usr/bin/java -Dsuwayomi.tachidesk.config.server.debugLogsEnabled=true -jar /usr/share/java/tachidesk-server/tachidesk-server.jar
|
||||||
exec ./jre/bin/java \
|
|
||||||
-Dsuwayomi.tachidesk.config.server.debugLogsEnabled=true \
|
|
||||||
-jar ./Tachidesk-Server.jar
|
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
if [ ! -f /usr/bin/electron ]; then
|
||||||
|
echo "Electron executable was not found
|
||||||
|
In order to run this launcher, you need Electron installed.
|
||||||
|
|
||||||
|
You can install it with these commands:
|
||||||
|
sudo apt install npm
|
||||||
|
sudo npm install electron -g"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec /usr/bin/java -Dsuwayomi.tachidesk.config.server.webUIInterface=electron -Dsuwayomi.tachidesk.config.server.electronPath=/usr/bin/electron -jar /usr/share/java/tachidesk-server/tachidesk-server.jar
|
||||||
@@ -1,6 +1,3 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
exec ./jre/bin/java \
|
exec /usr/bin/java -Dsuwayomi.tachidesk.config.server.webUIInterface=electron -Dsuwayomi.tachidesk.config.server.electronPath=/usr/bin/electron -jar /usr/share/java/tachidesk-server/tachidesk-server.jar
|
||||||
-Dsuwayomi.tachidesk.config.server.webUIInterface=electron \
|
|
||||||
-Dsuwayomi.tachidesk.config.server.electronPath=./electron/electron \
|
|
||||||
-jar ./Tachidesk-Server.jar
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
Type=Application
|
Type=Application
|
||||||
Name=Tachidesk-Server
|
Name=Tachidesk-Server
|
||||||
Comment=Manga Reader
|
Comment=Manga Reader
|
||||||
Exec=/usr/bin/java -jar /usr/share/java/tachidesk-server/Tachidesk-Server.jar "\\$@"
|
Exec=/usr/bin/java -jar /usr/share/java/tachidesk-server/tachidesk-server.jar "\\$@"
|
||||||
Icon=tachidesk-server
|
Icon=tachidesk-server
|
||||||
Terminal=false
|
Terminal=false
|
||||||
Categories=Network;
|
Categories=Network;
|
||||||
87
scripts/unix-bundler.sh
Executable file
87
scripts/unix-bundler.sh
Executable file
@@ -0,0 +1,87 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Copyright (C) Contributors to the Suwayomi project
|
||||||
|
#
|
||||||
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
electron_version="v14.0.0"
|
||||||
|
|
||||||
|
if [ $1 = "linux-x64" ]; then
|
||||||
|
jre="OpenJDK8U-jre_x64_linux_hotspot_8u302b08.tar.gz"
|
||||||
|
jre_release="jdk8u302-b08"
|
||||||
|
jre_url="https://github.com/adoptium/temurin8-binaries/releases/download/$jre_release/$jre"
|
||||||
|
jre_dir="$jre_release-jre"
|
||||||
|
electron="electron-$electron_version-linux-x64.zip"
|
||||||
|
elif [ $1 = "macOS-x64" ]; then
|
||||||
|
jre="OpenJDK8U-jre_x64_mac_hotspot_8u302b08.tar.gz"
|
||||||
|
jre_release="jdk8u302-b08"
|
||||||
|
jre_url="https://github.com/adoptium/temurin8-binaries/releases/download/$jre_release/$jre"
|
||||||
|
jre_dir="$jre_release-jre"
|
||||||
|
electron="electron-$electron_version-darwin-x64.zip"
|
||||||
|
elif [ $1 = "macOS-arm64" ]; then
|
||||||
|
jre="zulu8.56.0.23-ca-jre8.0.302-macosx_aarch64.tar.gz"
|
||||||
|
jre_release="zulu8.56.0.23-ca-jre8.0.302-macosx_aarch64"
|
||||||
|
jre_url="https://cdn.azul.com/zulu/bin/$jre"
|
||||||
|
jre_dir="$jre_release/zulu-8.jre"
|
||||||
|
electron="electron-$electron_version-darwin-arm64.zip"
|
||||||
|
else
|
||||||
|
echo "Unsupported arch value: $1"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
arch="$1"
|
||||||
|
os=$(echo $arch | cut -d '-' -f1)
|
||||||
|
|
||||||
|
echo "creating $arch bundle"
|
||||||
|
|
||||||
|
jar=$(ls ../server/build/*.jar | tail -n1)
|
||||||
|
jar_name=$(echo $jar | cut -d'/' -f4)
|
||||||
|
release_name=$(echo $jar_name | sed 's/.jar//')-$arch
|
||||||
|
|
||||||
|
# make release dir
|
||||||
|
mkdir $release_name
|
||||||
|
|
||||||
|
echo "Dealing with jre..."
|
||||||
|
if [ ! -f $jre ]; then
|
||||||
|
curl -L $jre_url -o $jre
|
||||||
|
fi
|
||||||
|
tar xvf $jre
|
||||||
|
mv $jre_dir $release_name/jre
|
||||||
|
|
||||||
|
echo "Dealing with electron"
|
||||||
|
if [ ! -f $electron ]; then
|
||||||
|
curl -L "https://github.com/electron/electron/releases/download/$electron_version/$electron" -o $electron
|
||||||
|
fi
|
||||||
|
unzip $electron -d $release_name/electron
|
||||||
|
|
||||||
|
# copy artifacts
|
||||||
|
cp $jar $release_name/Tachidesk-Server.jar
|
||||||
|
if [ $os = linux ]; then
|
||||||
|
cp "resources/tachidesk-server-browser-launcher.sh" $release_name
|
||||||
|
cp "resources/tachidesk-server-debug-launcher.sh" $release_name
|
||||||
|
cp "resources/tachidesk-server-electron-launcher.sh" $release_name
|
||||||
|
elif [ $os = macOS ]; then
|
||||||
|
cp "resources/Tachidesk Browser Launcher.command" $release_name
|
||||||
|
cp "resources/Tachidesk Debug Launcher.command" $release_name
|
||||||
|
cp "resources/Tachidesk Electron Launcher.command" $release_name
|
||||||
|
fi
|
||||||
|
|
||||||
|
archive_name=""
|
||||||
|
if [ $os = linux ]; then
|
||||||
|
archive_name=$release_name.tar.gz
|
||||||
|
GZIP=-9 tar cvzf $archive_name $release_name
|
||||||
|
elif [ $os = macOS ]; then
|
||||||
|
archive_name=$release_name.zip
|
||||||
|
zip -9 -r $archive_name $release_name
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -rf $release_name
|
||||||
|
|
||||||
|
# clean up from possible previous runs
|
||||||
|
if [ -f ../server/build/$archive_name ]; then
|
||||||
|
rm ../server/build/$archive_name
|
||||||
|
fi
|
||||||
|
|
||||||
|
mv $archive_name ../server/build/
|
||||||
104
scripts/windows-bundler.sh
Executable file
104
scripts/windows-bundler.sh
Executable file
@@ -0,0 +1,104 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Copyright (C) Contributors to the Suwayomi project
|
||||||
|
#
|
||||||
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
electron_version="v14.0.0"
|
||||||
|
arch=$1
|
||||||
|
if [ $arch = "win32" ]; then
|
||||||
|
jre="OpenJDK8U-jre_x86-32_windows_hotspot_8u292b10.zip"
|
||||||
|
jre_release="jdk8u292-b10"
|
||||||
|
jre_url="https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/$jre_release/$jre"
|
||||||
|
arch="windows-x86"
|
||||||
|
electron="electron-$electron_version-win32-ia32.zip"
|
||||||
|
else
|
||||||
|
jre="OpenJDK8U-jre_x64_windows_hotspot_8u302b08.zip"
|
||||||
|
jre_release="jdk8u302-b08"
|
||||||
|
jre_url="https://github.com/adoptium/temurin8-binaries/releases/download/$jre_release/$jre"
|
||||||
|
arch="windows-x64"
|
||||||
|
electron="electron-$electron_version-win32-x64.zip"
|
||||||
|
fi
|
||||||
|
|
||||||
|
jre_dir="$jre_release-jre"
|
||||||
|
|
||||||
|
echo "creating windows bundle"
|
||||||
|
|
||||||
|
jar=$(ls ../server/build/*.jar | tail -n1)
|
||||||
|
jar_name=$(echo $jar | cut -d'/' -f4)
|
||||||
|
release_name=$(echo $jar_name | sed 's/.jar//')-$arch
|
||||||
|
|
||||||
|
# make release dir
|
||||||
|
mkdir $release_name
|
||||||
|
|
||||||
|
echo "Dealing with jre..."
|
||||||
|
if [ ! -f $jre ]; then
|
||||||
|
curl -L $jre_url -o $jre
|
||||||
|
fi
|
||||||
|
unzip $jre
|
||||||
|
mv $jre_dir $release_name/jre
|
||||||
|
|
||||||
|
echo "Dealing with electron"
|
||||||
|
if [ ! -f $electron ]; then
|
||||||
|
curl -L "https://github.com/electron/electron/releases/download/$electron_version/$electron" -o $electron
|
||||||
|
fi
|
||||||
|
unzip $electron -d $release_name/electron
|
||||||
|
|
||||||
|
# change electron's icon
|
||||||
|
rcedit="rcedit-x86.exe"
|
||||||
|
if [ ! -f $rcedit ]; then
|
||||||
|
curl -L "https://github.com/electron/rcedit/releases/download/v1.1.1/$rcedit" -o $rcedit
|
||||||
|
fi
|
||||||
|
|
||||||
|
# check if running under github actions
|
||||||
|
if [ $CI = true ]; then
|
||||||
|
# change electron executable's icon
|
||||||
|
sudo dpkg --add-architecture i386
|
||||||
|
wget -qO - https://dl.winehq.org/wine-builds/winehq.key | sudo apt-key add -
|
||||||
|
sudo add-apt-repository ppa:cybermax-dexter/sdl2-backport
|
||||||
|
sudo apt-add-repository "deb https://dl.winehq.org/wine-builds/ubuntu $(lsb_release -cs) main"
|
||||||
|
sudo apt install --install-recommends winehq-stable
|
||||||
|
sudo apt install -y wixl
|
||||||
|
fi
|
||||||
|
# this script assumes that wine is installed here on out
|
||||||
|
|
||||||
|
WINEARCH=win32 wine $rcedit $release_name/electron/electron.exe --set-icon ../server/src/main/resources/icon/faviconlogo.ico
|
||||||
|
|
||||||
|
# copy artifacts
|
||||||
|
cp $jar $release_name/Tachidesk.jar
|
||||||
|
cp "resources/Tachidesk Browser Launcher.bat" $release_name
|
||||||
|
cp "resources/Tachidesk Debug Launcher.bat" $release_name
|
||||||
|
cp "resources/Tachidesk Electron Launcher.bat" $release_name
|
||||||
|
|
||||||
|
zip_name=$release_name.zip
|
||||||
|
zip -9 -r $zip_name $release_name
|
||||||
|
|
||||||
|
# create msi package
|
||||||
|
msi_name=$release_name.msi
|
||||||
|
release_ver=$(tmp=${jar%-*} && echo ${tmp##*-} | tr -d v)
|
||||||
|
icon="../server/src/main/resources/icon/faviconlogo.ico"
|
||||||
|
|
||||||
|
find $release_name/jre | wixl-heat --var var.SourceDir -p $release_name/ --directory-ref jre --component-group jre >jre.wxs
|
||||||
|
find $release_name/electron | wixl-heat --var var.SourceDir -p $release_name/ --directory-ref electron --component-group electron >electron.wxs
|
||||||
|
if [ $arch = "win32" ]; then
|
||||||
|
wixl -D ProductVersion=$release_ver -D SourceDir=$release_name -D Icon=$icon \
|
||||||
|
--arch x86 resources/msi/tachidesk-server-x86.wxs jre.wxs electron.wxs -o $msi_name
|
||||||
|
else
|
||||||
|
wixl -D ProductVersion=$release_ver -D SourceDir=$release_name -D Icon=$icon \
|
||||||
|
--arch x64 resources/msi/tachidesk-server-x64.wxs jre.wxs electron.wxs -o $msi_name
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -rf $release_name
|
||||||
|
|
||||||
|
# clean up from possible previous runs
|
||||||
|
if [ -f ../server/build/$zip_name ]; then
|
||||||
|
rm ../server/build/$zip_name
|
||||||
|
fi
|
||||||
|
if [ -f ../server/build/$msi_name ]; then
|
||||||
|
rm ../server/build/$msi_name
|
||||||
|
fi
|
||||||
|
|
||||||
|
mv $zip_name ../server/build/
|
||||||
|
mv $msi_name ../server/build/
|
||||||
@@ -54,14 +54,11 @@ dependencies {
|
|||||||
|
|
||||||
// Disk & File
|
// Disk & File
|
||||||
implementation("net.lingala.zip4j:zip4j:2.9.1")
|
implementation("net.lingala.zip4j:zip4j:2.9.1")
|
||||||
implementation("com.github.junrar:junrar:7.5.0")
|
implementation("com.github.junrar:junrar:7.4.0")
|
||||||
|
|
||||||
// CloudflareInterceptor
|
// CloudflareInterceptor
|
||||||
implementation("net.sourceforge.htmlunit:htmlunit:2.56.0")
|
implementation("net.sourceforge.htmlunit:htmlunit:2.56.0")
|
||||||
|
|
||||||
// AES/CBC/PKCS7Padding Cypher provider for zh.copymanga
|
|
||||||
implementation("org.bouncycastle:bcprov-jdk18on:1.71")
|
|
||||||
|
|
||||||
// Source models and interfaces from Tachiyomi 1.x
|
// Source models and interfaces from Tachiyomi 1.x
|
||||||
// using source class from tachiyomi commit 9493577de27c40ce8b2b6122cc447d025e34c477 to not depend on tachiyomi.sourceapi
|
// using source class from tachiyomi commit 9493577de27c40ce8b2b6122cc447d025e34c477 to not depend on tachiyomi.sourceapi
|
||||||
// implementation("tachiyomi.sourceapi:source-api:1.1")
|
// implementation("tachiyomi.sourceapi:source-api:1.1")
|
||||||
@@ -78,9 +75,6 @@ dependencies {
|
|||||||
}
|
}
|
||||||
|
|
||||||
application {
|
application {
|
||||||
applicationDefaultJvmArgs = listOf(
|
|
||||||
"-Djunrar.extractor.thread-keep-alive-seconds=30"
|
|
||||||
)
|
|
||||||
mainClass.set(MainClass)
|
mainClass.set(MainClass)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,9 +104,6 @@ buildConfig {
|
|||||||
buildConfigField("String", "WEBUI_REPO", quoteWrap("https://github.com/Suwayomi/Tachidesk-WebUI-preview"))
|
buildConfigField("String", "WEBUI_REPO", quoteWrap("https://github.com/Suwayomi/Tachidesk-WebUI-preview"))
|
||||||
buildConfigField("String", "WEBUI_TAG", quoteWrap(webUIRevisionTag))
|
buildConfigField("String", "WEBUI_TAG", quoteWrap(webUIRevisionTag))
|
||||||
|
|
||||||
buildConfigField("String", "SORAYOMI_REPO", quoteWrap("https://github.com/Suwayomi/Tachidesk-Sorayomi"))
|
|
||||||
buildConfigField("String", "SORAYOMI_TAG", quoteWrap(sorayomiRevisionTag))
|
|
||||||
|
|
||||||
|
|
||||||
buildConfigField("String", "GITHUB", quoteWrap("https://github.com/Suwayomi/Tachidesk-Server"))
|
buildConfigField("String", "GITHUB", quoteWrap("https://github.com/Suwayomi/Tachidesk-Server"))
|
||||||
buildConfigField("String", "DISCORD", quoteWrap("https://discord.gg/DDZdqZWaHA"))
|
buildConfigField("String", "DISCORD", quoteWrap("https://discord.gg/DDZdqZWaHA"))
|
||||||
|
|||||||
@@ -5,10 +5,11 @@ import com.github.junrar.rarfile.FileHeader
|
|||||||
import eu.kanade.tachiyomi.source.model.Page
|
import eu.kanade.tachiyomi.source.model.Page
|
||||||
import eu.kanade.tachiyomi.util.lang.compareToCaseInsensitiveNaturalOrder
|
import eu.kanade.tachiyomi.util.lang.compareToCaseInsensitiveNaturalOrder
|
||||||
import suwayomi.tachidesk.manga.impl.util.storage.ImageUtil
|
import suwayomi.tachidesk.manga.impl.util.storage.ImageUtil
|
||||||
import java.io.ByteArrayInputStream
|
|
||||||
import java.io.ByteArrayOutputStream
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
|
import java.io.PipedInputStream
|
||||||
|
import java.io.PipedOutputStream
|
||||||
|
import java.util.concurrent.Executors
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loader used to load a chapter from a .rar or .cbr file.
|
* Loader used to load a chapter from a .rar or .cbr file.
|
||||||
@@ -21,40 +22,20 @@ class RarPageLoader(file: File) : PageLoader {
|
|||||||
private val archive = Archive(file)
|
private val archive = Archive(file)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The fully uncompressed files, to be used in case archive is solid.
|
* Pool for copying compressed files to an input stream.
|
||||||
*/
|
*/
|
||||||
private var archiveMap = mutableMapOf<FileHeader, InputStream>()
|
private val pool = Executors.newFixedThreadPool(1)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an observable containing the pages found on this rar archive ordered with a natural
|
* Returns an observable containing the pages found on this rar archive ordered with a natural
|
||||||
* comparator.
|
* comparator.
|
||||||
*/
|
*/
|
||||||
override fun getPages(): List<ReaderPage> {
|
override fun getPages(): List<ReaderPage> {
|
||||||
if (archive.mainHeader.isSolid) {
|
|
||||||
// Solid means that we need to read all the file sequentially
|
|
||||||
for (header in archive.fileHeaders) {
|
|
||||||
val baos = ByteArrayOutputStream()
|
|
||||||
archive.extractFile(header, baos)
|
|
||||||
archiveMap[header] = ByteArrayInputStream(baos.toByteArray())
|
|
||||||
}
|
|
||||||
// After reading the full archive, proceed to filter and transform
|
|
||||||
return archive.fileHeaders
|
|
||||||
.filter { !it.isDirectory && ImageUtil.isImage(it.fileName) { archiveMap.getValue(it) } }
|
|
||||||
.sortedWith { f1, f2 -> f1.fileName.compareToCaseInsensitiveNaturalOrder(f2.fileName) }
|
|
||||||
.mapIndexed { i, header ->
|
|
||||||
val streamFn = { archiveMap.getValue(header) }
|
|
||||||
|
|
||||||
ReaderPage(i).apply {
|
|
||||||
stream = streamFn
|
|
||||||
status = Page.READY
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return archive.fileHeaders
|
return archive.fileHeaders
|
||||||
.filter { !it.isDirectory && ImageUtil.isImage(it.fileName) { archive.getInputStream(it) } }
|
.filter { !it.isDirectory && ImageUtil.isImage(it.fileName) { archive.getInputStream(it) } }
|
||||||
.sortedWith { f1, f2 -> f1.fileName.compareToCaseInsensitiveNaturalOrder(f2.fileName) }
|
.sortedWith { f1, f2 -> f1.fileName.compareToCaseInsensitiveNaturalOrder(f2.fileName) }
|
||||||
.mapIndexed { i, header ->
|
.mapIndexed { i, header ->
|
||||||
val streamFn = { archive.getInputStream(header) }
|
val streamFn = { getStream(header) }
|
||||||
|
|
||||||
ReaderPage(i).apply {
|
ReaderPage(i).apply {
|
||||||
stream = streamFn
|
stream = streamFn
|
||||||
@@ -62,4 +43,21 @@ class RarPageLoader(file: File) : PageLoader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an input stream for the given [header].
|
||||||
|
*/
|
||||||
|
private fun getStream(header: FileHeader): InputStream {
|
||||||
|
val pipeIn = PipedInputStream()
|
||||||
|
val pipeOut = PipedOutputStream(pipeIn)
|
||||||
|
pool.execute {
|
||||||
|
try {
|
||||||
|
pipeOut.use {
|
||||||
|
archive.extractFile(header, it)
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return pipeIn
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,9 +5,7 @@ package eu.kanade.tachiyomi.source.model
|
|||||||
open class Filter<T>(val name: String, var state: T) {
|
open class Filter<T>(val name: String, var state: T) {
|
||||||
open class Header(name: String) : Filter<Any>(name, 0)
|
open class Header(name: String) : Filter<Any>(name, 0)
|
||||||
open class Separator(name: String = "") : Filter<Any>(name, 0)
|
open class Separator(name: String = "") : Filter<Any>(name, 0)
|
||||||
abstract class Select<V>(name: String, val values: Array<V>, state: Int = 0) : Filter<Int>(name, state) {
|
abstract class Select<V>(name: String, val values: Array<V>, state: Int = 0) : Filter<Int>(name, state)
|
||||||
val displayValues get() = values.map { it.toString() }
|
|
||||||
}
|
|
||||||
abstract class Text(name: String, state: String = "") : Filter<String>(name, state)
|
abstract class Text(name: String, state: String = "") : Filter<String>(name, state)
|
||||||
abstract class CheckBox(name: String, state: Boolean = false) : Filter<Boolean>(name, state)
|
abstract class CheckBox(name: String, state: Boolean = false) : Filter<Boolean>(name, state)
|
||||||
abstract class TriState(name: String, state: Int = STATE_IGNORE) : Filter<Int>(name, state) {
|
abstract class TriState(name: String, state: Int = STATE_IGNORE) : Filter<Int>(name, state) {
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ import suwayomi.tachidesk.global.controller.SettingsController
|
|||||||
object GlobalAPI {
|
object GlobalAPI {
|
||||||
fun defineEndpoints() {
|
fun defineEndpoints() {
|
||||||
path("settings") {
|
path("settings") {
|
||||||
get("about", SettingsController.about)
|
get("about", SettingsController::about)
|
||||||
get("check-update", SettingsController.checkUpdate)
|
get("check-update", SettingsController::checkUpdate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,48 +7,22 @@ package suwayomi.tachidesk.global.controller
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
import io.javalin.http.HttpCode
|
import io.javalin.http.Context
|
||||||
import suwayomi.tachidesk.global.impl.About
|
import suwayomi.tachidesk.global.impl.About
|
||||||
import suwayomi.tachidesk.global.impl.AboutDataClass
|
|
||||||
import suwayomi.tachidesk.global.impl.AppUpdate
|
import suwayomi.tachidesk.global.impl.AppUpdate
|
||||||
import suwayomi.tachidesk.global.impl.UpdateDataClass
|
|
||||||
import suwayomi.tachidesk.server.JavalinSetup.future
|
import suwayomi.tachidesk.server.JavalinSetup.future
|
||||||
import suwayomi.tachidesk.server.util.handler
|
|
||||||
import suwayomi.tachidesk.server.util.withOperation
|
|
||||||
|
|
||||||
/** Settings Page/Screen */
|
/** Settings Page/Screen */
|
||||||
object SettingsController {
|
object SettingsController {
|
||||||
/** returns some static info about the current app build */
|
/** returns some static info about the current app build */
|
||||||
val about = handler(
|
fun about(ctx: Context) {
|
||||||
documentWith = {
|
ctx.json(About.getAbout())
|
||||||
withOperation {
|
}
|
||||||
summary("About Tachidesk")
|
|
||||||
description("Returns some static info about the current app build")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
behaviorOf = { ctx ->
|
|
||||||
ctx.json(About.getAbout())
|
|
||||||
},
|
|
||||||
withResults = {
|
|
||||||
json<AboutDataClass>(HttpCode.OK)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
/** check for app updates */
|
/** check for app updates */
|
||||||
val checkUpdate = handler(
|
fun checkUpdate(ctx: Context) {
|
||||||
documentWith = {
|
ctx.json(
|
||||||
withOperation {
|
future { AppUpdate.checkUpdate() }
|
||||||
summary("Tachidesk update check")
|
)
|
||||||
description("Check for app updates")
|
}
|
||||||
}
|
|
||||||
},
|
|
||||||
behaviorOf = { ctx ->
|
|
||||||
ctx.json(
|
|
||||||
future { AppUpdate.checkUpdate() }
|
|
||||||
)
|
|
||||||
},
|
|
||||||
withResults = {
|
|
||||||
json<UpdateDataClass>(HttpCode.OK)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,98 +24,98 @@ import suwayomi.tachidesk.manga.controller.UpdateController
|
|||||||
object MangaAPI {
|
object MangaAPI {
|
||||||
fun defineEndpoints() {
|
fun defineEndpoints() {
|
||||||
path("extension") {
|
path("extension") {
|
||||||
get("list", ExtensionController.list)
|
get("list", ExtensionController::list)
|
||||||
|
|
||||||
get("install/{pkgName}", ExtensionController.install)
|
get("install/{pkgName}", ExtensionController::install)
|
||||||
post("install", ExtensionController.installFile)
|
post("install", ExtensionController::installFile)
|
||||||
get("update/{pkgName}", ExtensionController.update)
|
get("update/{pkgName}", ExtensionController::update)
|
||||||
get("uninstall/{pkgName}", ExtensionController.uninstall)
|
get("uninstall/{pkgName}", ExtensionController::uninstall)
|
||||||
|
|
||||||
get("icon/{apkName}", ExtensionController.icon)
|
get("icon/{apkName}", ExtensionController::icon)
|
||||||
}
|
}
|
||||||
|
|
||||||
path("source") {
|
path("source") {
|
||||||
get("list", SourceController.list)
|
get("list", SourceController::list)
|
||||||
get("{sourceId}", SourceController.retrieve)
|
get("{sourceId}", SourceController::retrieve)
|
||||||
|
|
||||||
get("{sourceId}/popular/{pageNum}", SourceController.popular)
|
get("{sourceId}/popular/{pageNum}", SourceController::popular)
|
||||||
get("{sourceId}/latest/{pageNum}", SourceController.latest)
|
get("{sourceId}/latest/{pageNum}", SourceController::latest)
|
||||||
|
|
||||||
get("{sourceId}/preferences", SourceController.getPreferences)
|
get("{sourceId}/preferences", SourceController::getPreferences)
|
||||||
post("{sourceId}/preferences", SourceController.setPreference)
|
post("{sourceId}/preferences", SourceController::setPreference)
|
||||||
|
|
||||||
get("{sourceId}/filters", SourceController.getFilters)
|
get("{sourceId}/filters", SourceController::getFilters)
|
||||||
post("{sourceId}/filters", SourceController.setFilters)
|
post("{sourceId}/filters", SourceController::setFilters)
|
||||||
|
|
||||||
get("{sourceId}/search", SourceController.searchSingle)
|
get("{sourceId}/search", SourceController::searchSingle)
|
||||||
// get("all/search", SourceController.searchGlobal) // TODO
|
// get("all/search", SourceController::searchGlobal) // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
path("manga") {
|
path("manga") {
|
||||||
get("{mangaId}", MangaController.retrieve)
|
get("{mangaId}", MangaController.retrieve)
|
||||||
get("{mangaId}/thumbnail", MangaController.thumbnail)
|
get("{mangaId}/thumbnail", MangaController::thumbnail)
|
||||||
|
|
||||||
get("{mangaId}/category", MangaController.categoryList)
|
get("{mangaId}/category", MangaController::categoryList)
|
||||||
get("{mangaId}/category/{categoryId}", MangaController.addToCategory)
|
get("{mangaId}/category/{categoryId}", MangaController::addToCategory)
|
||||||
delete("{mangaId}/category/{categoryId}", MangaController.removeFromCategory)
|
delete("{mangaId}/category/{categoryId}", MangaController::removeFromCategory)
|
||||||
|
|
||||||
get("{mangaId}/library", MangaController.addToLibrary)
|
get("{mangaId}/library", MangaController::addToLibrary)
|
||||||
delete("{mangaId}/library", MangaController.removeFromLibrary)
|
delete("{mangaId}/library", MangaController::removeFromLibrary)
|
||||||
|
|
||||||
patch("{mangaId}/meta", MangaController.meta)
|
patch("{mangaId}/meta", MangaController::meta)
|
||||||
|
|
||||||
get("{mangaId}/chapters", MangaController.chapterList)
|
get("{mangaId}/chapters", MangaController::chapterList)
|
||||||
get("{mangaId}/chapter/{chapterIndex}", MangaController.chapterRetrieve)
|
get("{mangaId}/chapter/{chapterIndex}", MangaController::chapterRetrieve)
|
||||||
patch("{mangaId}/chapter/{chapterIndex}", MangaController.chapterModify)
|
patch("{mangaId}/chapter/{chapterIndex}", MangaController::chapterModify)
|
||||||
delete("{mangaId}/chapter/{chapterIndex}", MangaController.chapterDelete)
|
delete("{mangaId}/chapter/{chapterIndex}", MangaController::chapterDelete)
|
||||||
|
|
||||||
patch("{mangaId}/chapter/{chapterIndex}/meta", MangaController.chapterMeta)
|
patch("{mangaId}/chapter/{chapterIndex}/meta", MangaController::chapterMeta)
|
||||||
|
|
||||||
get("{mangaId}/chapter/{chapterIndex}/page/{index}", MangaController.pageRetrieve)
|
get("{mangaId}/chapter/{chapterIndex}/page/{index}", MangaController::pageRetrieve)
|
||||||
}
|
}
|
||||||
|
|
||||||
path("category") {
|
path("category") {
|
||||||
get("", CategoryController.categoryList)
|
get("", CategoryController::categoryList)
|
||||||
post("", CategoryController.categoryCreate)
|
post("", CategoryController::categoryCreate)
|
||||||
|
|
||||||
// The order here is important {categoryId} needs to be applied last
|
// The order here is important {categoryId} needs to be applied last
|
||||||
// or throws a NumberFormatException
|
// or throws a NumberFormatException
|
||||||
patch("reorder", CategoryController.categoryReorder)
|
patch("reorder", CategoryController::categoryReorder)
|
||||||
|
|
||||||
get("{categoryId}", CategoryController.categoryMangas)
|
get("{categoryId}", CategoryController::categoryMangas)
|
||||||
patch("{categoryId}", CategoryController.categoryModify)
|
patch("{categoryId}", CategoryController::categoryModify)
|
||||||
delete("{categoryId}", CategoryController.categoryDelete)
|
delete("{categoryId}", CategoryController::categoryDelete)
|
||||||
}
|
}
|
||||||
|
|
||||||
path("backup") {
|
path("backup") {
|
||||||
post("import", BackupController.protobufImport)
|
post("import", BackupController::protobufImport)
|
||||||
post("import/file", BackupController.protobufImportFile)
|
post("import/file", BackupController::protobufImportFile)
|
||||||
|
|
||||||
post("validate", BackupController.protobufValidate)
|
post("validate", BackupController::protobufValidate)
|
||||||
post("validate/file", BackupController.protobufValidateFile)
|
post("validate/file", BackupController::protobufValidateFile)
|
||||||
|
|
||||||
get("export", BackupController.protobufExport)
|
get("export", BackupController::protobufExport)
|
||||||
get("export/file", BackupController.protobufExportFile)
|
get("export/file", BackupController::protobufExportFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
path("downloads") {
|
path("downloads") {
|
||||||
ws("", DownloadController::downloadsWS)
|
ws("", DownloadController::downloadsWS)
|
||||||
|
|
||||||
get("start", DownloadController.start)
|
get("start", DownloadController::start)
|
||||||
get("stop", DownloadController.stop)
|
get("stop", DownloadController::stop)
|
||||||
get("clear", DownloadController.stop)
|
get("clear", DownloadController::stop)
|
||||||
}
|
}
|
||||||
|
|
||||||
path("download") {
|
path("download") {
|
||||||
get("{mangaId}/chapter/{chapterIndex}", DownloadController.queueChapter)
|
get("{mangaId}/chapter/{chapterIndex}", DownloadController::queueChapter)
|
||||||
delete("{mangaId}/chapter/{chapterIndex}", DownloadController.unqueueChapter)
|
delete("{mangaId}/chapter/{chapterIndex}", DownloadController::unqueueChapter)
|
||||||
}
|
}
|
||||||
|
|
||||||
path("update") {
|
path("update") {
|
||||||
get("recentChapters/{pageNum}", UpdateController.recentChapters)
|
get("recentChapters/{pageNum}", UpdateController::recentChapters)
|
||||||
post("fetch", UpdateController.categoryUpdate)
|
post("fetch", UpdateController::categoryUpdate)
|
||||||
post("reset", UpdateController.reset)
|
post("reset", UpdateController.reset)
|
||||||
get("summary", UpdateController.updateSummary)
|
get("summary", UpdateController::updateSummary)
|
||||||
ws("", UpdateController::categoryUpdateWS)
|
ws("", UpdateController::categoryUpdateWS)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,11 @@
|
|||||||
package suwayomi.tachidesk.manga.controller
|
package suwayomi.tachidesk.manga.controller
|
||||||
|
|
||||||
import io.javalin.http.HttpCode
|
import io.javalin.http.Context
|
||||||
import suwayomi.tachidesk.manga.impl.backup.AbstractBackupValidator
|
|
||||||
import suwayomi.tachidesk.manga.impl.backup.BackupFlags
|
import suwayomi.tachidesk.manga.impl.backup.BackupFlags
|
||||||
import suwayomi.tachidesk.manga.impl.backup.proto.ProtoBackupExport
|
import suwayomi.tachidesk.manga.impl.backup.proto.ProtoBackupExport
|
||||||
import suwayomi.tachidesk.manga.impl.backup.proto.ProtoBackupImport
|
import suwayomi.tachidesk.manga.impl.backup.proto.ProtoBackupImport
|
||||||
import suwayomi.tachidesk.manga.impl.backup.proto.ProtoBackupValidator
|
import suwayomi.tachidesk.manga.impl.backup.proto.ProtoBackupValidator
|
||||||
import suwayomi.tachidesk.server.JavalinSetup.future
|
import suwayomi.tachidesk.server.JavalinSetup.future
|
||||||
import suwayomi.tachidesk.server.util.handler
|
|
||||||
import suwayomi.tachidesk.server.util.withOperation
|
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
|
|
||||||
@@ -22,153 +19,78 @@ import java.util.Date
|
|||||||
object BackupController {
|
object BackupController {
|
||||||
|
|
||||||
/** expects a Tachiyomi protobuf backup in the body */
|
/** expects a Tachiyomi protobuf backup in the body */
|
||||||
val protobufImport = handler(
|
fun protobufImport(ctx: Context) {
|
||||||
documentWith = {
|
ctx.future(
|
||||||
withOperation {
|
future {
|
||||||
summary("Restore a backup")
|
ProtoBackupImport.performRestore(ctx.bodyAsInputStream())
|
||||||
description("Expects a Tachiyomi protobuf backup in the body")
|
|
||||||
}
|
}
|
||||||
},
|
)
|
||||||
behaviorOf = { ctx ->
|
}
|
||||||
ctx.future(
|
|
||||||
future {
|
|
||||||
ProtoBackupImport.performRestore(ctx.bodyAsInputStream())
|
|
||||||
}
|
|
||||||
)
|
|
||||||
},
|
|
||||||
withResults = {
|
|
||||||
httpCode(HttpCode.OK)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
/** expects a Tachiyomi protobuf backup as a file upload, the file must be named "backup.proto.gz" */
|
/** expects a Tachiyomi protobuf backup as a file upload, the file must be named "backup.proto.gz" */
|
||||||
val protobufImportFile = handler(
|
fun protobufImportFile(ctx: Context) {
|
||||||
documentWith = {
|
// TODO: rewrite this with ctx.uploadedFiles(), don't call the multipart field "backup.proto.gz"
|
||||||
withOperation {
|
ctx.future(
|
||||||
summary("Restore a backup file")
|
future {
|
||||||
description("Expects a Tachiyomi protobuf backup as a file upload, the file must be named \"backup.proto.gz\"")
|
ProtoBackupImport.performRestore(ctx.uploadedFile("backup.proto.gz")!!.content)
|
||||||
}
|
}
|
||||||
uploadedFile("backup.proto.gz") {
|
)
|
||||||
it.description("Protobuf backup")
|
}
|
||||||
it.required(true)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
behaviorOf = { ctx ->
|
|
||||||
// TODO: rewrite this with ctx.uploadedFiles(), don't call the multipart field "backup.proto.gz"
|
|
||||||
ctx.future(
|
|
||||||
future {
|
|
||||||
ProtoBackupImport.performRestore(ctx.uploadedFile("backup.proto.gz")!!.content)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
},
|
|
||||||
withResults = {
|
|
||||||
httpCode(HttpCode.OK)
|
|
||||||
httpCode(HttpCode.NOT_FOUND)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
/** returns a Tachiyomi protobuf backup created from the current database as a body */
|
/** returns a Tachiyomi protobuf backup created from the current database as a body */
|
||||||
val protobufExport = handler(
|
fun protobufExport(ctx: Context) {
|
||||||
documentWith = {
|
ctx.contentType("application/octet-stream")
|
||||||
withOperation {
|
ctx.future(
|
||||||
summary("Create a backup")
|
future {
|
||||||
description("Returns a Tachiyomi protobuf backup created from the current database as a body")
|
ProtoBackupExport.createBackup(
|
||||||
}
|
BackupFlags(
|
||||||
},
|
includeManga = true,
|
||||||
behaviorOf = { ctx ->
|
includeCategories = true,
|
||||||
ctx.contentType("application/octet-stream")
|
includeChapters = true,
|
||||||
ctx.future(
|
includeTracking = true,
|
||||||
future {
|
includeHistory = true,
|
||||||
ProtoBackupExport.createBackup(
|
|
||||||
BackupFlags(
|
|
||||||
includeManga = true,
|
|
||||||
includeCategories = true,
|
|
||||||
includeChapters = true,
|
|
||||||
includeTracking = true,
|
|
||||||
includeHistory = true,
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
}
|
)
|
||||||
)
|
}
|
||||||
},
|
)
|
||||||
withResults = {
|
}
|
||||||
mime(HttpCode.OK, "application/octet-stream")
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
/** returns a Tachiyomi protobuf backup created from the current database as a file */
|
/** returns a Tachiyomi protobuf backup created from the current database as a file */
|
||||||
val protobufExportFile = handler(
|
fun protobufExportFile(ctx: Context) {
|
||||||
documentWith = {
|
ctx.contentType("application/octet-stream")
|
||||||
withOperation {
|
val currentDate = SimpleDateFormat("yyyy-MM-dd_HH-mm").format(Date())
|
||||||
summary("Create a backup file")
|
|
||||||
description("Returns a Tachiyomi protobuf backup created from the current database as a file")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
behaviorOf = { ctx ->
|
|
||||||
ctx.contentType("application/octet-stream")
|
|
||||||
val currentDate = SimpleDateFormat("yyyy-MM-dd_HH-mm").format(Date())
|
|
||||||
|
|
||||||
ctx.header("Content-Disposition", """attachment; filename="tachidesk_$currentDate.proto.gz"""")
|
ctx.header("Content-Disposition", """attachment; filename="tachidesk_$currentDate.proto.gz"""")
|
||||||
ctx.future(
|
ctx.future(
|
||||||
future {
|
future {
|
||||||
ProtoBackupExport.createBackup(
|
ProtoBackupExport.createBackup(
|
||||||
BackupFlags(
|
BackupFlags(
|
||||||
includeManga = true,
|
includeManga = true,
|
||||||
includeCategories = true,
|
includeCategories = true,
|
||||||
includeChapters = true,
|
includeChapters = true,
|
||||||
includeTracking = true,
|
includeTracking = true,
|
||||||
includeHistory = true,
|
includeHistory = true,
|
||||||
)
|
|
||||||
)
|
)
|
||||||
}
|
)
|
||||||
)
|
}
|
||||||
},
|
)
|
||||||
withResults = {
|
}
|
||||||
mime(HttpCode.OK, "application/octet-stream")
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
/** Reports missing sources and trackers, expects a Tachiyomi protobuf backup in the body */
|
/** Reports missing sources and trackers, expects a Tachiyomi protobuf backup in the body */
|
||||||
val protobufValidate = handler(
|
fun protobufValidate(ctx: Context) {
|
||||||
documentWith = {
|
ctx.future(
|
||||||
withOperation {
|
future {
|
||||||
summary("Validate a backup")
|
ProtoBackupValidator.validate(ctx.bodyAsInputStream())
|
||||||
description("Reports missing sources and trackers, expects a Tachiyomi protobuf backup in the body")
|
|
||||||
}
|
}
|
||||||
},
|
)
|
||||||
behaviorOf = { ctx ->
|
}
|
||||||
ctx.future(
|
|
||||||
future {
|
|
||||||
ProtoBackupValidator.validate(ctx.bodyAsInputStream())
|
|
||||||
}
|
|
||||||
)
|
|
||||||
},
|
|
||||||
withResults = {
|
|
||||||
json<AbstractBackupValidator.ValidationResult>(HttpCode.OK)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
/** Reports missing sources and trackers, expects a Tachiyomi protobuf backup as a file upload, the file must be named "backup.proto.gz" */
|
/** Reports missing sources and trackers, expects a Tachiyomi protobuf backup as a file upload, the file must be named "backup.proto.gz" */
|
||||||
val protobufValidateFile = handler(
|
fun protobufValidateFile(ctx: Context) {
|
||||||
documentWith = {
|
ctx.future(
|
||||||
withOperation {
|
future {
|
||||||
summary("Validate a backup file")
|
ProtoBackupValidator.validate(ctx.uploadedFile("backup.proto.gz")!!.content)
|
||||||
description("Reports missing sources and trackers, expects a Tachiyomi protobuf backup as a file upload, the file must be named \"backup.proto.gz\"")
|
|
||||||
}
|
}
|
||||||
uploadedFile("backup.proto.gz") {
|
)
|
||||||
it.description("Protobuf backup")
|
}
|
||||||
it.required(true)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
behaviorOf = { ctx ->
|
|
||||||
ctx.future(
|
|
||||||
future {
|
|
||||||
ProtoBackupValidator.validate(ctx.uploadedFile("backup.proto.gz")!!.content)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
},
|
|
||||||
withResults = {
|
|
||||||
json<AbstractBackupValidator.ValidationResult>(HttpCode.OK)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,126 +7,50 @@ package suwayomi.tachidesk.manga.controller
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
import io.javalin.http.HttpCode
|
import io.javalin.http.Context
|
||||||
import suwayomi.tachidesk.manga.impl.Category
|
import suwayomi.tachidesk.manga.impl.Category
|
||||||
import suwayomi.tachidesk.manga.impl.CategoryManga
|
import suwayomi.tachidesk.manga.impl.CategoryManga
|
||||||
import suwayomi.tachidesk.manga.model.dataclass.CategoryDataClass
|
|
||||||
import suwayomi.tachidesk.manga.model.dataclass.MangaDataClass
|
|
||||||
import suwayomi.tachidesk.server.util.formParam
|
|
||||||
import suwayomi.tachidesk.server.util.handler
|
|
||||||
import suwayomi.tachidesk.server.util.pathParam
|
|
||||||
import suwayomi.tachidesk.server.util.withOperation
|
|
||||||
|
|
||||||
object CategoryController {
|
object CategoryController {
|
||||||
/** category list */
|
/** category list */
|
||||||
val categoryList = handler(
|
fun categoryList(ctx: Context) {
|
||||||
documentWith = {
|
ctx.json(Category.getCategoryList())
|
||||||
withOperation {
|
}
|
||||||
summary("Category list")
|
|
||||||
description("get a list of categories")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
behaviorOf = { ctx ->
|
|
||||||
ctx.json(Category.getCategoryList())
|
|
||||||
},
|
|
||||||
withResults = {
|
|
||||||
json<Array<CategoryDataClass>>(HttpCode.OK)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
/** category create */
|
/** category create */
|
||||||
val categoryCreate = handler(
|
fun categoryCreate(ctx: Context) {
|
||||||
formParam<String>("name"),
|
val name = ctx.formParam("name")!!
|
||||||
documentWith = {
|
Category.createCategory(name)
|
||||||
withOperation {
|
ctx.status(200)
|
||||||
summary("Category create")
|
}
|
||||||
description("Create a category")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
behaviorOf = { ctx, name ->
|
|
||||||
if (Category.createCategory(name) != -1) {
|
|
||||||
ctx.status(200)
|
|
||||||
} else {
|
|
||||||
ctx.status(HttpCode.BAD_REQUEST)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
withResults = {
|
|
||||||
httpCode(HttpCode.OK)
|
|
||||||
httpCode(HttpCode.BAD_REQUEST)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
/** category modification */
|
/** category modification */
|
||||||
val categoryModify = handler(
|
fun categoryModify(ctx: Context) {
|
||||||
pathParam<Int>("categoryId"),
|
val categoryId = ctx.pathParam("categoryId").toInt()
|
||||||
formParam<String?>("name"),
|
val name = ctx.formParam("name")
|
||||||
formParam<Boolean?>("default"),
|
val isDefault = ctx.formParam("default")?.toBoolean()
|
||||||
documentWith = {
|
Category.updateCategory(categoryId, name, isDefault)
|
||||||
withOperation {
|
ctx.status(200)
|
||||||
summary("Category modify")
|
}
|
||||||
description("Modify a category")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
behaviorOf = { ctx, categoryId, name, isDefault ->
|
|
||||||
Category.updateCategory(categoryId, name, isDefault)
|
|
||||||
ctx.status(200)
|
|
||||||
},
|
|
||||||
withResults = {
|
|
||||||
httpCode(HttpCode.OK)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
/** category delete */
|
/** category delete */
|
||||||
val categoryDelete = handler(
|
fun categoryDelete(ctx: Context) {
|
||||||
pathParam<Int>("categoryId"),
|
val categoryId = ctx.pathParam("categoryId").toInt()
|
||||||
documentWith = {
|
Category.removeCategory(categoryId)
|
||||||
withOperation {
|
ctx.status(200)
|
||||||
summary("Category delete")
|
}
|
||||||
description("Delete a category")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
behaviorOf = { ctx, categoryId ->
|
|
||||||
Category.removeCategory(categoryId)
|
|
||||||
ctx.status(200)
|
|
||||||
},
|
|
||||||
withResults = {
|
|
||||||
httpCode(HttpCode.OK)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
/** returns the manga list associated with a category */
|
/** returns the manga list associated with a category */
|
||||||
val categoryMangas = handler(
|
fun categoryMangas(ctx: Context) {
|
||||||
pathParam<Int>("categoryId"),
|
val categoryId = ctx.pathParam("categoryId").toInt()
|
||||||
documentWith = {
|
ctx.json(CategoryManga.getCategoryMangaList(categoryId))
|
||||||
withOperation {
|
}
|
||||||
summary("Category manga")
|
|
||||||
description("Returns the manga list associated with a category")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
behaviorOf = { ctx, categoryId ->
|
|
||||||
ctx.json(CategoryManga.getCategoryMangaList(categoryId))
|
|
||||||
},
|
|
||||||
withResults = {
|
|
||||||
json<Array<MangaDataClass>>(HttpCode.OK)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
/** category re-ordering */
|
/** category re-ordering */
|
||||||
val categoryReorder = handler(
|
fun categoryReorder(ctx: Context) {
|
||||||
formParam<Int>("from"),
|
val from = ctx.formParam("from")!!.toInt()
|
||||||
formParam<Int>("to"),
|
val to = ctx.formParam("to")!!.toInt()
|
||||||
documentWith = {
|
Category.reorderCategory(from, to)
|
||||||
withOperation {
|
ctx.status(200)
|
||||||
summary("Category re-ordering")
|
}
|
||||||
description("Re-order a category")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
behaviorOf = { ctx, from, to ->
|
|
||||||
Category.reorderCategory(from, to)
|
|
||||||
ctx.status(200)
|
|
||||||
},
|
|
||||||
withResults = {
|
|
||||||
httpCode(HttpCode.OK)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,13 +7,10 @@ package suwayomi.tachidesk.manga.controller
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
import io.javalin.http.HttpCode
|
import io.javalin.http.Context
|
||||||
import io.javalin.websocket.WsConfig
|
import io.javalin.websocket.WsConfig
|
||||||
import suwayomi.tachidesk.manga.impl.download.DownloadManager
|
import suwayomi.tachidesk.manga.impl.download.DownloadManager
|
||||||
import suwayomi.tachidesk.server.JavalinSetup.future
|
import suwayomi.tachidesk.server.JavalinSetup.future
|
||||||
import suwayomi.tachidesk.server.util.handler
|
|
||||||
import suwayomi.tachidesk.server.util.pathParam
|
|
||||||
import suwayomi.tachidesk.server.util.withOperation
|
|
||||||
|
|
||||||
object DownloadController {
|
object DownloadController {
|
||||||
/** Download queue stats */
|
/** Download queue stats */
|
||||||
@@ -31,99 +28,45 @@ object DownloadController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Start the downloader */
|
/** Start the downloader */
|
||||||
val start = handler(
|
fun start(ctx: Context) {
|
||||||
documentWith = {
|
DownloadManager.start()
|
||||||
withOperation {
|
|
||||||
summary("Downloader start")
|
|
||||||
description("Start the downloader")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
behaviorOf = { ctx ->
|
|
||||||
DownloadManager.start()
|
|
||||||
|
|
||||||
ctx.status(200)
|
ctx.status(200)
|
||||||
},
|
}
|
||||||
withResults = {
|
|
||||||
httpCode(HttpCode.OK)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
/** Stop the downloader */
|
/** Stop the downloader */
|
||||||
val stop = handler(
|
fun stop(ctx: Context) {
|
||||||
documentWith = {
|
DownloadManager.stop()
|
||||||
withOperation {
|
|
||||||
summary("Downloader stop")
|
|
||||||
description("Stop the downloader")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
behaviorOf = { ctx ->
|
|
||||||
DownloadManager.stop()
|
|
||||||
|
|
||||||
ctx.status(200)
|
ctx.status(200)
|
||||||
},
|
}
|
||||||
withResults = {
|
|
||||||
httpCode(HttpCode.OK)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
/** clear download queue */
|
/** clear download queue */
|
||||||
val clear = handler(
|
fun clear(ctx: Context) {
|
||||||
documentWith = {
|
DownloadManager.clear()
|
||||||
withOperation {
|
|
||||||
summary("Downloader clear")
|
|
||||||
description("Clear download queue")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
behaviorOf = { ctx ->
|
|
||||||
DownloadManager.clear()
|
|
||||||
|
|
||||||
ctx.status(200)
|
ctx.status(200)
|
||||||
},
|
}
|
||||||
withResults = {
|
|
||||||
httpCode(HttpCode.OK)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
/** Queue chapter for download */
|
/** Queue chapter for download */
|
||||||
val queueChapter = handler(
|
fun queueChapter(ctx: Context) {
|
||||||
pathParam<Int>("chapterIndex"),
|
val chapterIndex = ctx.pathParam("chapterIndex").toInt()
|
||||||
pathParam<Int>("mangaId"),
|
val mangaId = ctx.pathParam("mangaId").toInt()
|
||||||
documentWith = {
|
|
||||||
withOperation {
|
ctx.future(
|
||||||
summary("Downloader add chapter")
|
future {
|
||||||
description("Queue chapter for download")
|
DownloadManager.enqueue(chapterIndex, mangaId)
|
||||||
}
|
}
|
||||||
},
|
)
|
||||||
behaviorOf = { ctx, chapterIndex, mangaId ->
|
}
|
||||||
ctx.future(
|
|
||||||
future {
|
|
||||||
DownloadManager.enqueue(chapterIndex, mangaId)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
},
|
|
||||||
withResults = {
|
|
||||||
httpCode(HttpCode.OK)
|
|
||||||
httpCode(HttpCode.NOT_FOUND)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
/** delete chapter from download queue */
|
/** delete chapter from download queue */
|
||||||
val unqueueChapter = handler(
|
fun unqueueChapter(ctx: Context) {
|
||||||
pathParam<Int>("chapterIndex"),
|
val chapterIndex = ctx.pathParam("chapterIndex").toInt()
|
||||||
pathParam<Int>("mangaId"),
|
val mangaId = ctx.pathParam("mangaId").toInt()
|
||||||
documentWith = {
|
|
||||||
withOperation {
|
|
||||||
summary("Downloader remove chapter")
|
|
||||||
description("Delete chapter from download queue")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
behaviorOf = { ctx, chapterIndex, mangaId ->
|
|
||||||
DownloadManager.unqueue(chapterIndex, mangaId)
|
|
||||||
|
|
||||||
ctx.status(200)
|
DownloadManager.unqueue(chapterIndex, mangaId)
|
||||||
},
|
|
||||||
withResults = {
|
ctx.status(200)
|
||||||
httpCode(HttpCode.OK)
|
}
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,159 +7,78 @@ package suwayomi.tachidesk.manga.controller
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
import io.javalin.http.HttpCode
|
import io.javalin.http.Context
|
||||||
import mu.KotlinLogging
|
import mu.KotlinLogging
|
||||||
import suwayomi.tachidesk.manga.impl.extension.Extension
|
import suwayomi.tachidesk.manga.impl.extension.Extension
|
||||||
import suwayomi.tachidesk.manga.impl.extension.ExtensionsList
|
import suwayomi.tachidesk.manga.impl.extension.ExtensionsList
|
||||||
import suwayomi.tachidesk.manga.model.dataclass.ExtensionDataClass
|
|
||||||
import suwayomi.tachidesk.server.JavalinSetup.future
|
import suwayomi.tachidesk.server.JavalinSetup.future
|
||||||
import suwayomi.tachidesk.server.util.handler
|
|
||||||
import suwayomi.tachidesk.server.util.pathParam
|
|
||||||
import suwayomi.tachidesk.server.util.queryParam
|
|
||||||
import suwayomi.tachidesk.server.util.withOperation
|
|
||||||
|
|
||||||
object ExtensionController {
|
object ExtensionController {
|
||||||
private val logger = KotlinLogging.logger {}
|
private val logger = KotlinLogging.logger {}
|
||||||
|
|
||||||
/** list all extensions */
|
/** list all extensions */
|
||||||
val list = handler(
|
fun list(ctx: Context) {
|
||||||
documentWith = {
|
ctx.future(
|
||||||
withOperation {
|
future {
|
||||||
summary("Extension list")
|
ExtensionsList.getExtensionList()
|
||||||
description("List all extensions")
|
|
||||||
}
|
}
|
||||||
},
|
)
|
||||||
behaviorOf = { ctx ->
|
}
|
||||||
ctx.future(
|
|
||||||
future {
|
|
||||||
ExtensionsList.getExtensionList()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
},
|
|
||||||
withResults = {
|
|
||||||
json<Array<ExtensionDataClass>>(HttpCode.OK)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
/** install extension identified with "pkgName" */
|
/** install extension identified with "pkgName" */
|
||||||
val install = handler(
|
fun install(ctx: Context) {
|
||||||
pathParam<String>("pkgName"),
|
val pkgName = ctx.pathParam("pkgName")
|
||||||
documentWith = {
|
|
||||||
withOperation {
|
ctx.future(
|
||||||
summary("Extension install")
|
future {
|
||||||
description("install extension identified with \"pkgName\"")
|
Extension.installExtension(pkgName)
|
||||||
}
|
}
|
||||||
},
|
)
|
||||||
behaviorOf = { ctx, pkgName ->
|
}
|
||||||
ctx.future(
|
|
||||||
future {
|
|
||||||
Extension.installExtension(pkgName)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
},
|
|
||||||
withResults = {
|
|
||||||
httpCode(HttpCode.CREATED)
|
|
||||||
httpCode(HttpCode.FOUND)
|
|
||||||
httpCode(HttpCode.INTERNAL_SERVER_ERROR)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
/** install the uploaded apk file */
|
/** install the uploaded apk file */
|
||||||
val installFile = handler(
|
fun installFile(ctx: Context) {
|
||||||
documentWith = {
|
|
||||||
withOperation {
|
|
||||||
summary("Extension install apk")
|
|
||||||
description("Install the uploaded apk file")
|
|
||||||
}
|
|
||||||
uploadedFile("file") {
|
|
||||||
it.description("Extension apk")
|
|
||||||
it.required(true)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
behaviorOf = { ctx ->
|
|
||||||
val uploadedFile = ctx.uploadedFile("file")!!
|
|
||||||
logger.debug { "Uploaded extension file name: " + uploadedFile.filename }
|
|
||||||
|
|
||||||
ctx.future(
|
val uploadedFile = ctx.uploadedFile("file")!!
|
||||||
future {
|
logger.debug { "Uploaded extension file name: " + uploadedFile.filename }
|
||||||
Extension.installExternalExtension(uploadedFile.content, uploadedFile.filename)
|
|
||||||
}
|
ctx.future(
|
||||||
)
|
future {
|
||||||
},
|
Extension.installExternalExtension(uploadedFile.content, uploadedFile.filename)
|
||||||
withResults = {
|
}
|
||||||
httpCode(HttpCode.CREATED)
|
)
|
||||||
httpCode(HttpCode.FOUND)
|
}
|
||||||
httpCode(HttpCode.INTERNAL_SERVER_ERROR)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
/** update extension identified with "pkgName" */
|
/** update extension identified with "pkgName" */
|
||||||
val update = handler(
|
fun update(ctx: Context) {
|
||||||
pathParam<String>("pkgName"),
|
val pkgName = ctx.pathParam("pkgName")
|
||||||
documentWith = {
|
|
||||||
withOperation {
|
ctx.future(
|
||||||
summary("Extension update")
|
future {
|
||||||
description("Update extension identified with \"pkgName\"")
|
Extension.updateExtension(pkgName)
|
||||||
}
|
}
|
||||||
},
|
)
|
||||||
behaviorOf = { ctx, pkgName ->
|
}
|
||||||
ctx.future(
|
|
||||||
future {
|
|
||||||
Extension.updateExtension(pkgName)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
},
|
|
||||||
withResults = {
|
|
||||||
httpCode(HttpCode.CREATED)
|
|
||||||
httpCode(HttpCode.FOUND)
|
|
||||||
httpCode(HttpCode.NOT_FOUND)
|
|
||||||
httpCode(HttpCode.INTERNAL_SERVER_ERROR)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
/** uninstall extension identified with "pkgName" */
|
/** uninstall extension identified with "pkgName" */
|
||||||
val uninstall = handler(
|
fun uninstall(ctx: Context) {
|
||||||
pathParam<String>("pkgName"),
|
val pkgName = ctx.pathParam("pkgName")
|
||||||
documentWith = {
|
|
||||||
withOperation {
|
Extension.uninstallExtension(pkgName)
|
||||||
summary("Extension uninstall")
|
ctx.status(200)
|
||||||
description("Uninstall extension identified with \"pkgName\"")
|
}
|
||||||
}
|
|
||||||
},
|
|
||||||
behaviorOf = { ctx, pkgName ->
|
|
||||||
Extension.uninstallExtension(pkgName)
|
|
||||||
ctx.status(200)
|
|
||||||
},
|
|
||||||
withResults = {
|
|
||||||
httpCode(HttpCode.CREATED)
|
|
||||||
httpCode(HttpCode.FOUND)
|
|
||||||
httpCode(HttpCode.NOT_FOUND)
|
|
||||||
httpCode(HttpCode.INTERNAL_SERVER_ERROR)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
/** icon for extension named `apkName` */
|
/** icon for extension named `apkName` */
|
||||||
val icon = handler(
|
fun icon(ctx: Context) {
|
||||||
pathParam<String>("apkName"),
|
val apkName = ctx.pathParam("apkName")
|
||||||
queryParam("useCache", true),
|
val useCache = ctx.queryParam("useCache")?.toBoolean() ?: true
|
||||||
documentWith = {
|
|
||||||
withOperation {
|
ctx.future(
|
||||||
summary("Extension icon")
|
future { Extension.getExtensionIcon(apkName, useCache) }
|
||||||
description("Icon for extension named `apkName`")
|
.thenApply {
|
||||||
}
|
ctx.header("content-type", it.second)
|
||||||
},
|
it.first
|
||||||
behaviorOf = { ctx, apkName, useCache ->
|
}
|
||||||
ctx.future(
|
)
|
||||||
future { Extension.getExtensionIcon(apkName, useCache) }
|
}
|
||||||
.thenApply {
|
|
||||||
ctx.header("content-type", it.second)
|
|
||||||
it.first
|
|
||||||
}
|
|
||||||
)
|
|
||||||
},
|
|
||||||
withResults = {
|
|
||||||
httpCode(HttpCode.OK)
|
|
||||||
httpCode(HttpCode.NOT_FOUND)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ package suwayomi.tachidesk.manga.controller
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
import io.javalin.http.Context
|
||||||
import io.javalin.http.HttpCode
|
import io.javalin.http.HttpCode
|
||||||
import suwayomi.tachidesk.manga.impl.CategoryManga
|
import suwayomi.tachidesk.manga.impl.CategoryManga
|
||||||
import suwayomi.tachidesk.manga.impl.Chapter
|
import suwayomi.tachidesk.manga.impl.Chapter
|
||||||
@@ -14,11 +15,8 @@ import suwayomi.tachidesk.manga.impl.Library
|
|||||||
import suwayomi.tachidesk.manga.impl.Manga
|
import suwayomi.tachidesk.manga.impl.Manga
|
||||||
import suwayomi.tachidesk.manga.impl.Page
|
import suwayomi.tachidesk.manga.impl.Page
|
||||||
import suwayomi.tachidesk.manga.impl.chapter.getChapterDownloadReady
|
import suwayomi.tachidesk.manga.impl.chapter.getChapterDownloadReady
|
||||||
import suwayomi.tachidesk.manga.model.dataclass.CategoryDataClass
|
|
||||||
import suwayomi.tachidesk.manga.model.dataclass.ChapterDataClass
|
|
||||||
import suwayomi.tachidesk.manga.model.dataclass.MangaDataClass
|
import suwayomi.tachidesk.manga.model.dataclass.MangaDataClass
|
||||||
import suwayomi.tachidesk.server.JavalinSetup.future
|
import suwayomi.tachidesk.server.JavalinSetup.future
|
||||||
import suwayomi.tachidesk.server.util.formParam
|
|
||||||
import suwayomi.tachidesk.server.util.handler
|
import suwayomi.tachidesk.server.util.handler
|
||||||
import suwayomi.tachidesk.server.util.pathParam
|
import suwayomi.tachidesk.server.util.pathParam
|
||||||
import suwayomi.tachidesk.server.util.queryParam
|
import suwayomi.tachidesk.server.util.queryParam
|
||||||
@@ -32,7 +30,7 @@ object MangaController {
|
|||||||
documentWith = {
|
documentWith = {
|
||||||
withOperation {
|
withOperation {
|
||||||
summary("Get a manga")
|
summary("Get a manga")
|
||||||
description("Get a manga from the database using a specific id.")
|
description("Get a manga from the database using a specific id")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
behaviorOf = { ctx, mangaId, onlineFetch ->
|
behaviorOf = { ctx, mangaId, onlineFetch ->
|
||||||
@@ -49,278 +47,140 @@ object MangaController {
|
|||||||
)
|
)
|
||||||
|
|
||||||
/** manga thumbnail */
|
/** manga thumbnail */
|
||||||
val thumbnail = handler(
|
fun thumbnail(ctx: Context) {
|
||||||
pathParam<Int>("mangaId"),
|
val mangaId = ctx.pathParam("mangaId").toInt()
|
||||||
queryParam("useCache", true),
|
val useCache = ctx.queryParam("useCache")?.toBoolean() ?: true
|
||||||
documentWith = {
|
|
||||||
withOperation {
|
ctx.future(
|
||||||
summary("Get a manga thumbnail")
|
future { Manga.getMangaThumbnail(mangaId, useCache) }
|
||||||
description("Get a manga thumbnail from the source or the cache.")
|
.thenApply {
|
||||||
}
|
ctx.header("content-type", it.second)
|
||||||
},
|
val httpCacheSeconds = 60 * 60 * 24
|
||||||
behaviorOf = { ctx, mangaId, useCache ->
|
ctx.header("cache-control", "max-age=$httpCacheSeconds")
|
||||||
ctx.future(
|
it.first
|
||||||
future { Manga.getMangaThumbnail(mangaId, useCache) }
|
}
|
||||||
.thenApply {
|
)
|
||||||
ctx.header("content-type", it.second)
|
}
|
||||||
val httpCacheSeconds = 60 * 60 * 24
|
|
||||||
ctx.header("cache-control", "max-age=$httpCacheSeconds")
|
|
||||||
it.first
|
|
||||||
}
|
|
||||||
)
|
|
||||||
},
|
|
||||||
withResults = {
|
|
||||||
mime(HttpCode.OK, "image/*")
|
|
||||||
httpCode(HttpCode.NOT_FOUND)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
/** adds the manga to library */
|
/** adds the manga to library */
|
||||||
val addToLibrary = handler(
|
fun addToLibrary(ctx: Context) {
|
||||||
pathParam<Int>("mangaId"),
|
val mangaId = ctx.pathParam("mangaId").toInt()
|
||||||
documentWith = {
|
|
||||||
withOperation {
|
ctx.future(
|
||||||
summary("Add manga to library")
|
future { Library.addMangaToLibrary(mangaId) }
|
||||||
description("Use a manga id to add the manga to your library.\nWill do nothing if manga is already in your library.")
|
)
|
||||||
}
|
}
|
||||||
},
|
|
||||||
behaviorOf = { ctx, mangaId ->
|
|
||||||
ctx.future(
|
|
||||||
future { Library.addMangaToLibrary(mangaId) }
|
|
||||||
)
|
|
||||||
},
|
|
||||||
withResults = {
|
|
||||||
httpCode(HttpCode.OK)
|
|
||||||
httpCode(HttpCode.NOT_FOUND)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
/** removes the manga from the library */
|
/** removes the manga from the library */
|
||||||
val removeFromLibrary = handler(
|
fun removeFromLibrary(ctx: Context) {
|
||||||
pathParam<Int>("mangaId"),
|
val mangaId = ctx.pathParam("mangaId").toInt()
|
||||||
documentWith = {
|
|
||||||
withOperation {
|
ctx.future(
|
||||||
summary("Remove manga to library")
|
future { Library.removeMangaFromLibrary(mangaId) }
|
||||||
description("Use a manga id to remove the manga to your library.\nWill do nothing if manga not in your library.")
|
)
|
||||||
}
|
}
|
||||||
},
|
|
||||||
behaviorOf = { ctx, mangaId ->
|
|
||||||
ctx.future(
|
|
||||||
future { Library.removeMangaFromLibrary(mangaId) }
|
|
||||||
)
|
|
||||||
},
|
|
||||||
withResults = {
|
|
||||||
httpCode(HttpCode.OK)
|
|
||||||
httpCode(HttpCode.NOT_FOUND)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
/** list manga's categories */
|
/** list manga's categories */
|
||||||
val categoryList = handler(
|
fun categoryList(ctx: Context) {
|
||||||
pathParam<Int>("mangaId"),
|
val mangaId = ctx.pathParam("mangaId").toInt()
|
||||||
documentWith = {
|
ctx.json(CategoryManga.getMangaCategories(mangaId))
|
||||||
withOperation {
|
}
|
||||||
summary("Get a manga's categories")
|
|
||||||
description("Get the list of categories for this manga")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
behaviorOf = { ctx, mangaId ->
|
|
||||||
ctx.json(CategoryManga.getMangaCategories(mangaId))
|
|
||||||
},
|
|
||||||
withResults = {
|
|
||||||
json<Array<CategoryDataClass>>(HttpCode.OK)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
/** adds the manga to category */
|
/** adds the manga to category */
|
||||||
val addToCategory = handler(
|
fun addToCategory(ctx: Context) {
|
||||||
pathParam<Int>("mangaId"),
|
val mangaId = ctx.pathParam("mangaId").toInt()
|
||||||
pathParam<Int>("categoryId"),
|
val categoryId = ctx.pathParam("categoryId").toInt()
|
||||||
documentWith = {
|
CategoryManga.addMangaToCategory(mangaId, categoryId)
|
||||||
withOperation {
|
ctx.status(200)
|
||||||
summary("Add manga to category")
|
}
|
||||||
description("Add a manga to a category using their ids.")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
behaviorOf = { ctx, mangaId, categoryId ->
|
|
||||||
CategoryManga.addMangaToCategory(mangaId, categoryId)
|
|
||||||
ctx.status(200)
|
|
||||||
},
|
|
||||||
withResults = {
|
|
||||||
httpCode(HttpCode.OK)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
/** removes the manga from the category */
|
/** removes the manga from the category */
|
||||||
val removeFromCategory = handler(
|
fun removeFromCategory(ctx: Context) {
|
||||||
pathParam<Int>("mangaId"),
|
val mangaId = ctx.pathParam("mangaId").toInt()
|
||||||
pathParam<Int>("categoryId"),
|
val categoryId = ctx.pathParam("categoryId").toInt()
|
||||||
documentWith = {
|
CategoryManga.removeMangaFromCategory(mangaId, categoryId)
|
||||||
withOperation {
|
ctx.status(200)
|
||||||
summary("Remove manga from category")
|
}
|
||||||
description("Remove a manga from a category using their ids.")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
behaviorOf = { ctx, mangaId, categoryId ->
|
|
||||||
CategoryManga.removeMangaFromCategory(mangaId, categoryId)
|
|
||||||
ctx.status(200)
|
|
||||||
},
|
|
||||||
withResults = {
|
|
||||||
httpCode(HttpCode.OK)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
/** used to modify a manga's meta parameters */
|
/** used to modify a manga's meta parameters */
|
||||||
val meta = handler(
|
fun meta(ctx: Context) {
|
||||||
pathParam<Int>("mangaId"),
|
val mangaId = ctx.pathParam("mangaId").toInt()
|
||||||
formParam<String>("key"),
|
|
||||||
formParam<String>("value"),
|
val key = ctx.formParam("key")!!
|
||||||
documentWith = {
|
val value = ctx.formParam("value")!!
|
||||||
withOperation {
|
|
||||||
summary("Add data to manga")
|
Manga.modifyMangaMeta(mangaId, key, value)
|
||||||
description("A simple Key-Value storage in the manga object, you can set values for whatever you want inside it.")
|
|
||||||
}
|
ctx.status(200)
|
||||||
},
|
}
|
||||||
behaviorOf = { ctx, mangaId, key, value ->
|
|
||||||
Manga.modifyMangaMeta(mangaId, key, value)
|
|
||||||
ctx.status(200)
|
|
||||||
},
|
|
||||||
withResults = {
|
|
||||||
httpCode(HttpCode.OK)
|
|
||||||
httpCode(HttpCode.NOT_FOUND)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
/** get chapter list when showing a manga */
|
/** get chapter list when showing a manga */
|
||||||
val chapterList = handler(
|
fun chapterList(ctx: Context) {
|
||||||
pathParam<Int>("mangaId"),
|
val mangaId = ctx.pathParam("mangaId").toInt()
|
||||||
queryParam("onlineFetch", false),
|
|
||||||
documentWith = {
|
val onlineFetch = ctx.queryParam("onlineFetch")?.toBoolean() ?: false
|
||||||
withOperation {
|
|
||||||
summary("Get manga chapter list")
|
ctx.future(future { Chapter.getChapterList(mangaId, onlineFetch) })
|
||||||
description("Get the manga chapter list from the database or online. If there is no chapters in the database it fetches the chapters online. Use onlineFetch to update chapter list.")
|
}
|
||||||
}
|
|
||||||
},
|
|
||||||
behaviorOf = { ctx, mangaId, onlineFetch ->
|
|
||||||
ctx.future(future { Chapter.getChapterList(mangaId, onlineFetch) })
|
|
||||||
},
|
|
||||||
withResults = {
|
|
||||||
json<Array<ChapterDataClass>>(HttpCode.OK)
|
|
||||||
httpCode(HttpCode.NOT_FOUND)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
/** used to display a chapter, get a chapter in order to show its pages */
|
/** used to display a chapter, get a chapter in order to show its pages */
|
||||||
val chapterRetrieve = handler(
|
fun chapterRetrieve(ctx: Context) {
|
||||||
pathParam<Int>("mangaId"),
|
val chapterIndex = ctx.pathParam("chapterIndex").toInt()
|
||||||
pathParam<Int>("chapterIndex"),
|
val mangaId = ctx.pathParam("mangaId").toInt()
|
||||||
documentWith = {
|
ctx.future(future { getChapterDownloadReady(chapterIndex, mangaId) })
|
||||||
withOperation {
|
}
|
||||||
summary("Get a chapter")
|
|
||||||
description("Get the chapter from the manga id and chapter index. It will also retrieve the pages for this chapter.")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
behaviorOf = { ctx, mangaId, chapterIndex ->
|
|
||||||
ctx.future(future { getChapterDownloadReady(chapterIndex, mangaId) })
|
|
||||||
},
|
|
||||||
withResults = {
|
|
||||||
json<ChapterDataClass>(HttpCode.OK)
|
|
||||||
httpCode(HttpCode.NOT_FOUND)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
/** used to modify a chapter's parameters */
|
/** used to modify a chapter's parameters */
|
||||||
val chapterModify = handler(
|
fun chapterModify(ctx: Context) {
|
||||||
pathParam<Int>("mangaId"),
|
val chapterIndex = ctx.pathParam("chapterIndex").toInt()
|
||||||
pathParam<Int>("chapterIndex"),
|
val mangaId = ctx.pathParam("mangaId").toInt()
|
||||||
formParam<Boolean?>("read"),
|
|
||||||
formParam<Boolean?>("bookmarked"),
|
|
||||||
formParam<Boolean?>("markPrevRead"),
|
|
||||||
formParam<Int?>("lastPageRead"),
|
|
||||||
documentWith = {
|
|
||||||
withOperation {
|
|
||||||
summary("Modify a chapter")
|
|
||||||
description("Update user info for a given chapter, such as read status, bookmarked, and more.")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
behaviorOf = { ctx, mangaId, chapterIndex, read, bookmarked, markPrevRead, lastPageRead ->
|
|
||||||
Chapter.modifyChapter(mangaId, chapterIndex, read, bookmarked, markPrevRead, lastPageRead)
|
|
||||||
|
|
||||||
ctx.status(200)
|
val read = ctx.formParam("read")?.toBoolean()
|
||||||
},
|
val bookmarked = ctx.formParam("bookmarked")?.toBoolean()
|
||||||
withResults = {
|
val markPrevRead = ctx.formParam("markPrevRead")?.toBoolean()
|
||||||
httpCode(HttpCode.OK)
|
val lastPageRead = ctx.formParam("lastPageRead")?.toInt()
|
||||||
}
|
|
||||||
)
|
Chapter.modifyChapter(mangaId, chapterIndex, read, bookmarked, markPrevRead, lastPageRead)
|
||||||
|
|
||||||
|
ctx.status(200)
|
||||||
|
}
|
||||||
|
|
||||||
/** delete a downloaded chapter */
|
/** delete a downloaded chapter */
|
||||||
val chapterDelete = handler(
|
fun chapterDelete(ctx: Context) {
|
||||||
pathParam<Int>("mangaId"),
|
val chapterIndex = ctx.pathParam("chapterIndex").toInt()
|
||||||
pathParam<Int>("chapterIndex"),
|
val mangaId = ctx.pathParam("mangaId").toInt()
|
||||||
documentWith = {
|
|
||||||
withOperation {
|
|
||||||
summary("Delete a chapter download")
|
|
||||||
description("Delete the downloaded chapter and its files.")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
behaviorOf = { ctx, mangaId, chapterIndex ->
|
|
||||||
Chapter.deleteChapter(mangaId, chapterIndex)
|
|
||||||
|
|
||||||
ctx.status(200)
|
Chapter.deleteChapter(mangaId, chapterIndex)
|
||||||
},
|
|
||||||
withResults = {
|
ctx.status(200)
|
||||||
httpCode(HttpCode.OK)
|
}
|
||||||
httpCode(HttpCode.NOT_FOUND)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
/** used to modify a chapter's meta parameters */
|
/** used to modify a chapter's meta parameters */
|
||||||
val chapterMeta = handler(
|
fun chapterMeta(ctx: Context) {
|
||||||
pathParam<Int>("mangaId"),
|
val chapterIndex = ctx.pathParam("chapterIndex").toInt()
|
||||||
pathParam<Int>("chapterIndex"),
|
val mangaId = ctx.pathParam("mangaId").toInt()
|
||||||
formParam<String>("key"),
|
|
||||||
formParam<String>("value"),
|
|
||||||
documentWith = {
|
|
||||||
withOperation {
|
|
||||||
summary("Add data to chapter")
|
|
||||||
description("A simple Key-Value storage in the chapter object, you can set values for whatever you want inside it.")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
behaviorOf = { ctx, mangaId, chapterIndex, key, value ->
|
|
||||||
Chapter.modifyChapterMeta(mangaId, chapterIndex, key, value)
|
|
||||||
|
|
||||||
ctx.status(200)
|
val key = ctx.formParam("key")!!
|
||||||
},
|
val value = ctx.formParam("value")!!
|
||||||
withResults = {
|
|
||||||
httpCode(HttpCode.OK)
|
Chapter.modifyChapterMeta(mangaId, chapterIndex, key, value)
|
||||||
httpCode(HttpCode.NOT_FOUND)
|
|
||||||
}
|
ctx.status(200)
|
||||||
)
|
}
|
||||||
|
|
||||||
/** get page at index "index" */
|
/** get page at index "index" */
|
||||||
val pageRetrieve = handler(
|
fun pageRetrieve(ctx: Context) {
|
||||||
pathParam<Int>("mangaId"),
|
val mangaId = ctx.pathParam("mangaId").toInt()
|
||||||
pathParam<Int>("chapterIndex"),
|
val chapterIndex = ctx.pathParam("chapterIndex").toInt()
|
||||||
pathParam<Int>("index"),
|
val index = ctx.pathParam("index").toInt()
|
||||||
queryParam("useCache", true),
|
val useCache = ctx.queryParam("useCache")?.toBoolean() ?: true
|
||||||
documentWith = {
|
|
||||||
withOperation {
|
ctx.future(
|
||||||
summary("Get a chapter page")
|
future { Page.getPageImage(mangaId, chapterIndex, index, useCache) }
|
||||||
description("Get a chapter page for a given index. Cache use can be disabled so it only retrieves it directly from the source.")
|
.thenApply {
|
||||||
}
|
ctx.header("content-type", it.second)
|
||||||
},
|
it.first
|
||||||
behaviorOf = { ctx, mangaId, chapterIndex, index, useCache ->
|
}
|
||||||
ctx.future(
|
)
|
||||||
future { Page.getPageImage(mangaId, chapterIndex, index, useCache) }
|
}
|
||||||
.thenApply {
|
|
||||||
ctx.header("content-type", it.second)
|
|
||||||
it.first
|
|
||||||
}
|
|
||||||
)
|
|
||||||
},
|
|
||||||
withResults = {
|
|
||||||
mime(HttpCode.OK, "image/*")
|
|
||||||
httpCode(HttpCode.NOT_FOUND)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ package suwayomi.tachidesk.manga.controller
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
import io.javalin.http.HttpCode
|
import io.javalin.http.Context
|
||||||
import kotlinx.serialization.decodeFromString
|
import kotlinx.serialization.decodeFromString
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import org.kodein.di.DI
|
import org.kodein.di.DI
|
||||||
@@ -18,204 +18,87 @@ import suwayomi.tachidesk.manga.impl.Search
|
|||||||
import suwayomi.tachidesk.manga.impl.Search.FilterChange
|
import suwayomi.tachidesk.manga.impl.Search.FilterChange
|
||||||
import suwayomi.tachidesk.manga.impl.Source
|
import suwayomi.tachidesk.manga.impl.Source
|
||||||
import suwayomi.tachidesk.manga.impl.Source.SourcePreferenceChange
|
import suwayomi.tachidesk.manga.impl.Source.SourcePreferenceChange
|
||||||
import suwayomi.tachidesk.manga.model.dataclass.PagedMangaListDataClass
|
|
||||||
import suwayomi.tachidesk.manga.model.dataclass.SourceDataClass
|
|
||||||
import suwayomi.tachidesk.server.JavalinSetup.future
|
import suwayomi.tachidesk.server.JavalinSetup.future
|
||||||
import suwayomi.tachidesk.server.util.handler
|
|
||||||
import suwayomi.tachidesk.server.util.pathParam
|
|
||||||
import suwayomi.tachidesk.server.util.queryParam
|
|
||||||
import suwayomi.tachidesk.server.util.withOperation
|
|
||||||
|
|
||||||
object SourceController {
|
object SourceController {
|
||||||
/** list of sources */
|
/** list of sources */
|
||||||
val list = handler(
|
fun list(ctx: Context) {
|
||||||
documentWith = {
|
ctx.json(Source.getSourceList())
|
||||||
withOperation {
|
}
|
||||||
summary("Sources list")
|
|
||||||
description("List of sources")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
behaviorOf = { ctx ->
|
|
||||||
ctx.json(Source.getSourceList())
|
|
||||||
},
|
|
||||||
withResults = {
|
|
||||||
json<Array<SourceDataClass>>(HttpCode.OK)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
/** fetch source with id `sourceId` */
|
/** fetch source with id `sourceId` */
|
||||||
val retrieve = handler(
|
fun retrieve(ctx: Context) {
|
||||||
pathParam<Long>("sourceId"),
|
val sourceId = ctx.pathParam("sourceId").toLong()
|
||||||
documentWith = {
|
ctx.json(Source.getSource(sourceId)!!)
|
||||||
withOperation {
|
}
|
||||||
summary("Source fetch")
|
|
||||||
description("Fetch source with id `sourceId`")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
behaviorOf = { ctx, sourceId ->
|
|
||||||
ctx.json(Source.getSource(sourceId)!!)
|
|
||||||
},
|
|
||||||
withResults = {
|
|
||||||
json<SourceDataClass>(HttpCode.OK)
|
|
||||||
httpCode(HttpCode.NOT_FOUND)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
/** popular mangas from source with id `sourceId` */
|
/** popular mangas from source with id `sourceId` */
|
||||||
val popular = handler(
|
fun popular(ctx: Context) {
|
||||||
pathParam<Long>("sourceId"),
|
val sourceId = ctx.pathParam("sourceId").toLong()
|
||||||
pathParam<Int>("pageNum"),
|
val pageNum = ctx.pathParam("pageNum").toInt()
|
||||||
documentWith = {
|
ctx.future(
|
||||||
withOperation {
|
future {
|
||||||
summary("Source popular manga")
|
MangaList.getMangaList(sourceId, pageNum, popular = true)
|
||||||
description("Popular mangas from source with id `sourceId`")
|
|
||||||
}
|
}
|
||||||
},
|
)
|
||||||
behaviorOf = { ctx, sourceId, pageNum ->
|
}
|
||||||
ctx.future(
|
|
||||||
future {
|
|
||||||
MangaList.getMangaList(sourceId, pageNum, popular = true)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
},
|
|
||||||
withResults = {
|
|
||||||
json<PagedMangaListDataClass>(HttpCode.OK)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
/** latest mangas from source with id `sourceId` */
|
/** latest mangas from source with id `sourceId` */
|
||||||
val latest = handler(
|
fun latest(ctx: Context) {
|
||||||
pathParam<Long>("sourceId"),
|
val sourceId = ctx.pathParam("sourceId").toLong()
|
||||||
pathParam<Int>("pageNum"),
|
val pageNum = ctx.pathParam("pageNum").toInt()
|
||||||
documentWith = {
|
ctx.future(
|
||||||
withOperation {
|
future {
|
||||||
summary("Source latest manga")
|
MangaList.getMangaList(sourceId, pageNum, popular = false)
|
||||||
description("Latest mangas from source with id `sourceId`")
|
|
||||||
}
|
}
|
||||||
},
|
)
|
||||||
behaviorOf = { ctx, sourceId, pageNum ->
|
}
|
||||||
ctx.future(
|
|
||||||
future {
|
|
||||||
MangaList.getMangaList(sourceId, pageNum, popular = false)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
},
|
|
||||||
withResults = {
|
|
||||||
json<PagedMangaListDataClass>(HttpCode.OK)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
/** fetch preferences of source with id `sourceId` */
|
/** fetch preferences of source with id `sourceId` */
|
||||||
val getPreferences = handler(
|
fun getPreferences(ctx: Context) {
|
||||||
pathParam<Long>("sourceId"),
|
val sourceId = ctx.pathParam("sourceId").toLong()
|
||||||
documentWith = {
|
ctx.json(Source.getSourcePreferences(sourceId))
|
||||||
withOperation {
|
}
|
||||||
summary("Source preferences")
|
|
||||||
description("Fetch preferences of source with id `sourceId`")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
behaviorOf = { ctx, sourceId ->
|
|
||||||
ctx.json(Source.getSourcePreferences(sourceId))
|
|
||||||
},
|
|
||||||
withResults = {
|
|
||||||
json<Array<Source.PreferenceObject>>(HttpCode.OK)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
/** set one preference of source with id `sourceId` */
|
/** set one preference of source with id `sourceId` */
|
||||||
val setPreference = handler(
|
fun setPreference(ctx: Context) {
|
||||||
pathParam<Long>("sourceId"),
|
val sourceId = ctx.pathParam("sourceId").toLong()
|
||||||
documentWith = {
|
val preferenceChange = ctx.bodyAsClass(SourcePreferenceChange::class.java)
|
||||||
withOperation {
|
ctx.json(Source.setSourcePreference(sourceId, preferenceChange))
|
||||||
summary("Source preference set")
|
}
|
||||||
description("Set one preference of source with id `sourceId`")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
behaviorOf = { ctx, sourceId ->
|
|
||||||
val preferenceChange = ctx.bodyAsClass(SourcePreferenceChange::class.java)
|
|
||||||
ctx.json(Source.setSourcePreference(sourceId, preferenceChange))
|
|
||||||
},
|
|
||||||
withResults = {
|
|
||||||
httpCode(HttpCode.OK)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
/** fetch filters of source with id `sourceId` */
|
/** fetch filters of source with id `sourceId` */
|
||||||
val getFilters = handler(
|
fun getFilters(ctx: Context) {
|
||||||
pathParam<Long>("sourceId"),
|
val sourceId = ctx.pathParam("sourceId").toLong()
|
||||||
queryParam("reset", false),
|
val reset = ctx.queryParam("reset")?.toBoolean() ?: false
|
||||||
documentWith = {
|
ctx.json(Search.getFilterList(sourceId, reset))
|
||||||
withOperation {
|
}
|
||||||
summary("Source filters")
|
|
||||||
description("Fetch filters of source with id `sourceId`")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
behaviorOf = { ctx, sourceId, reset ->
|
|
||||||
ctx.json(Search.getFilterList(sourceId, reset))
|
|
||||||
},
|
|
||||||
withResults = {
|
|
||||||
json<Array<Search.FilterObject>>(HttpCode.OK)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
private val json by DI.global.instance<Json>()
|
private val json by DI.global.instance<Json>()
|
||||||
|
|
||||||
/** change filters of source with id `sourceId` */
|
/** change filters of source with id `sourceId` */
|
||||||
val setFilters = handler(
|
fun setFilters(ctx: Context) {
|
||||||
pathParam<Long>("sourceId"),
|
val sourceId = ctx.pathParam("sourceId").toLong()
|
||||||
documentWith = {
|
val filterChange = try {
|
||||||
withOperation {
|
json.decodeFromString<List<FilterChange>>(ctx.body())
|
||||||
summary("Source filters set")
|
} catch (e: Exception) {
|
||||||
description("Change filters of source with id `sourceId`")
|
listOf(json.decodeFromString<FilterChange>(ctx.body()))
|
||||||
}
|
|
||||||
},
|
|
||||||
behaviorOf = { ctx, sourceId ->
|
|
||||||
val filterChange = try {
|
|
||||||
json.decodeFromString<List<FilterChange>>(ctx.body())
|
|
||||||
} catch (e: Exception) {
|
|
||||||
listOf(json.decodeFromString<FilterChange>(ctx.body()))
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.json(Search.setFilter(sourceId, filterChange))
|
|
||||||
},
|
|
||||||
withResults = {
|
|
||||||
httpCode(HttpCode.OK)
|
|
||||||
}
|
}
|
||||||
)
|
|
||||||
|
ctx.json(Search.setFilter(sourceId, filterChange))
|
||||||
|
}
|
||||||
|
|
||||||
/** single source search */
|
/** single source search */
|
||||||
val searchSingle = handler(
|
fun searchSingle(ctx: Context) {
|
||||||
pathParam<Long>("sourceId"),
|
val sourceId = ctx.pathParam("sourceId").toLong()
|
||||||
queryParam("searchTerm", ""),
|
val searchTerm = ctx.queryParam("searchTerm") ?: ""
|
||||||
queryParam("pageNum", 1),
|
val pageNum = ctx.queryParam("pageNum")?.toInt() ?: 1
|
||||||
documentWith = {
|
ctx.future(future { Search.sourceSearch(sourceId, searchTerm, pageNum) })
|
||||||
withOperation {
|
}
|
||||||
summary("Source search")
|
|
||||||
description("Single source search")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
behaviorOf = { ctx, sourceId, searchTerm, pageNum ->
|
|
||||||
ctx.future(future { Search.sourceSearch(sourceId, searchTerm, pageNum) })
|
|
||||||
},
|
|
||||||
withResults = {
|
|
||||||
json<PagedMangaListDataClass>(HttpCode.OK)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
/** all source search */
|
/** all source search */
|
||||||
val searchAll = handler(
|
fun searchAll(ctx: Context) { // TODO
|
||||||
pathParam<String>("searchTerm"),
|
val searchTerm = ctx.pathParam("searchTerm")
|
||||||
documentWith = {
|
ctx.json(Search.sourceGlobalSearch(searchTerm))
|
||||||
withOperation {
|
}
|
||||||
summary("Source global search")
|
|
||||||
description("All source search")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
behaviorOf = { ctx, searchTerm -> // TODO
|
|
||||||
ctx.json(Search.sourceGlobalSearch(searchTerm))
|
|
||||||
},
|
|
||||||
withResults = {
|
|
||||||
httpCode(HttpCode.OK)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package suwayomi.tachidesk.manga.controller
|
package suwayomi.tachidesk.manga.controller
|
||||||
|
|
||||||
|
import io.javalin.http.Context
|
||||||
import io.javalin.http.HttpCode
|
import io.javalin.http.HttpCode
|
||||||
import io.javalin.websocket.WsConfig
|
import io.javalin.websocket.WsConfig
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
@@ -11,15 +12,10 @@ import suwayomi.tachidesk.manga.impl.Category
|
|||||||
import suwayomi.tachidesk.manga.impl.CategoryManga
|
import suwayomi.tachidesk.manga.impl.CategoryManga
|
||||||
import suwayomi.tachidesk.manga.impl.Chapter
|
import suwayomi.tachidesk.manga.impl.Chapter
|
||||||
import suwayomi.tachidesk.manga.impl.update.IUpdater
|
import suwayomi.tachidesk.manga.impl.update.IUpdater
|
||||||
import suwayomi.tachidesk.manga.impl.update.UpdateStatus
|
|
||||||
import suwayomi.tachidesk.manga.impl.update.UpdaterSocket
|
import suwayomi.tachidesk.manga.impl.update.UpdaterSocket
|
||||||
import suwayomi.tachidesk.manga.model.dataclass.CategoryDataClass
|
import suwayomi.tachidesk.manga.model.dataclass.CategoryDataClass
|
||||||
import suwayomi.tachidesk.manga.model.dataclass.MangaChapterDataClass
|
|
||||||
import suwayomi.tachidesk.manga.model.dataclass.PaginatedList
|
|
||||||
import suwayomi.tachidesk.server.JavalinSetup.future
|
import suwayomi.tachidesk.server.JavalinSetup.future
|
||||||
import suwayomi.tachidesk.server.util.formParam
|
|
||||||
import suwayomi.tachidesk.server.util.handler
|
import suwayomi.tachidesk.server.util.handler
|
||||||
import suwayomi.tachidesk.server.util.pathParam
|
|
||||||
import suwayomi.tachidesk.server.util.withOperation
|
import suwayomi.tachidesk.server.util.withOperation
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -33,63 +29,35 @@ object UpdateController {
|
|||||||
private val logger = KotlinLogging.logger { }
|
private val logger = KotlinLogging.logger { }
|
||||||
|
|
||||||
/** get recently updated manga chapters */
|
/** get recently updated manga chapters */
|
||||||
val recentChapters = handler(
|
fun recentChapters(ctx: Context) {
|
||||||
pathParam<Int>("pageNum"),
|
val pageNum = ctx.pathParam("pageNum").toInt()
|
||||||
documentWith = {
|
|
||||||
withOperation {
|
|
||||||
summary("Updates fetch")
|
|
||||||
description("Get recently updated manga chapters")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
behaviorOf = { ctx, pageNum ->
|
|
||||||
ctx.future(
|
|
||||||
future {
|
|
||||||
Chapter.getRecentChapters(pageNum)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
},
|
|
||||||
withResults = {
|
|
||||||
json<PagedMangaChapterListDataClass>(HttpCode.OK)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
ctx.future(
|
||||||
* Class made for handling return type in the documentation for [recentChapters],
|
future {
|
||||||
* since OpenApi cannot handle runtime generics.
|
Chapter.getRecentChapters(pageNum)
|
||||||
*/
|
|
||||||
private class PagedMangaChapterListDataClass : PaginatedList<MangaChapterDataClass>(emptyList(), false)
|
|
||||||
|
|
||||||
val categoryUpdate = handler(
|
|
||||||
formParam<Int?>("categoryId"),
|
|
||||||
documentWith = {
|
|
||||||
withOperation {
|
|
||||||
summary("Updater start")
|
|
||||||
description("Starts the updater")
|
|
||||||
}
|
}
|
||||||
},
|
)
|
||||||
behaviorOf = { ctx, categoryId ->
|
}
|
||||||
val categoriesForUpdate = ArrayList<CategoryDataClass>()
|
|
||||||
if (categoryId == null) {
|
fun categoryUpdate(ctx: Context) {
|
||||||
logger.info { "Adding Library to Update Queue" }
|
val categoryId = ctx.formParam("category")?.toIntOrNull()
|
||||||
categoriesForUpdate.addAll(Category.getCategoryList())
|
val categoriesForUpdate = ArrayList<CategoryDataClass>()
|
||||||
|
if (categoryId == null) {
|
||||||
|
logger.info { "Adding Library to Update Queue" }
|
||||||
|
categoriesForUpdate.addAll(Category.getCategoryList())
|
||||||
|
} else {
|
||||||
|
val category = Category.getCategoryById(categoryId)
|
||||||
|
if (category != null) {
|
||||||
|
categoriesForUpdate.add(category)
|
||||||
} else {
|
} else {
|
||||||
val category = Category.getCategoryById(categoryId)
|
logger.info { "No Category found" }
|
||||||
if (category != null) {
|
ctx.status(HttpCode.BAD_REQUEST)
|
||||||
categoriesForUpdate.add(category)
|
return
|
||||||
} else {
|
|
||||||
logger.info { "No Category found" }
|
|
||||||
ctx.status(HttpCode.BAD_REQUEST)
|
|
||||||
return@handler
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
addCategoriesToUpdateQueue(categoriesForUpdate, true)
|
|
||||||
ctx.status(HttpCode.OK)
|
|
||||||
},
|
|
||||||
withResults = {
|
|
||||||
httpCode(HttpCode.OK)
|
|
||||||
httpCode(HttpCode.BAD_REQUEST)
|
|
||||||
}
|
}
|
||||||
)
|
addCategoriesToUpdateQueue(categoriesForUpdate, true)
|
||||||
|
ctx.status(HttpCode.OK)
|
||||||
|
}
|
||||||
|
|
||||||
private fun addCategoriesToUpdateQueue(categories: List<CategoryDataClass>, clear: Boolean = false) {
|
private fun addCategoriesToUpdateQueue(categories: List<CategoryDataClass>, clear: Boolean = false) {
|
||||||
val updater by DI.global.instance<IUpdater>()
|
val updater by DI.global.instance<IUpdater>()
|
||||||
@@ -116,27 +84,15 @@ object UpdateController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val updateSummary = handler(
|
fun updateSummary(ctx: Context) {
|
||||||
documentWith = {
|
val updater by DI.global.instance<IUpdater>()
|
||||||
withOperation {
|
ctx.json(updater.getStatus().value.getJsonSummary())
|
||||||
summary("Updater summary")
|
}
|
||||||
description("Gets the latest updater summary")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
behaviorOf = { ctx ->
|
|
||||||
val updater by DI.global.instance<IUpdater>()
|
|
||||||
ctx.json(updater.getStatus().value.getJsonSummary())
|
|
||||||
},
|
|
||||||
withResults = {
|
|
||||||
json<UpdateStatus>(HttpCode.OK)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
val reset = handler(
|
val reset = handler(
|
||||||
documentWith = {
|
documentWith = {
|
||||||
withOperation {
|
withOperation {
|
||||||
summary("Updater reset")
|
summary("Stops and resets the Updater")
|
||||||
description("Stops and resets the Updater")
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
behaviorOf = { ctx ->
|
behaviorOf = { ctx ->
|
||||||
|
|||||||
@@ -70,19 +70,12 @@ object CategoryManga {
|
|||||||
.slice(ChapterTable.id.count())
|
.slice(ChapterTable.id.count())
|
||||||
.select { (MangaTable.id eq ChapterTable.manga) and (ChapterTable.isDownloaded eq true) }
|
.select { (MangaTable.id eq ChapterTable.manga) and (ChapterTable.isDownloaded eq true) }
|
||||||
)
|
)
|
||||||
val chapterCountExpression = wrapAsExpression<Long>(
|
|
||||||
ChapterTable
|
|
||||||
.slice(ChapterTable.id.count())
|
|
||||||
.select { (MangaTable.id eq ChapterTable.manga) }
|
|
||||||
)
|
|
||||||
|
|
||||||
val selectedColumns = MangaTable.columns + unreadExpression + downloadExpression + chapterCountExpression
|
|
||||||
|
|
||||||
|
val selectedColumns = MangaTable.columns + unreadExpression + downloadExpression
|
||||||
val transform: (ResultRow) -> MangaDataClass = {
|
val transform: (ResultRow) -> MangaDataClass = {
|
||||||
val dataClass = MangaTable.toDataClass(it)
|
val dataClass = MangaTable.toDataClass(it)
|
||||||
dataClass.unreadCount = it[unreadExpression]?.toInt()
|
dataClass.unreadCount = it[unreadExpression]?.toInt()
|
||||||
dataClass.downloadCount = it[downloadExpression]?.toInt()
|
dataClass.downloadCount = it[downloadExpression]?.toInt()
|
||||||
dataClass.chapterCount = it[chapterCountExpression]?.toInt()
|
|
||||||
dataClass
|
dataClass
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,7 +90,7 @@ object CategoryManga {
|
|||||||
return transaction {
|
return transaction {
|
||||||
CategoryMangaTable.innerJoin(MangaTable)
|
CategoryMangaTable.innerJoin(MangaTable)
|
||||||
.slice(selectedColumns)
|
.slice(selectedColumns)
|
||||||
.select { (MangaTable.inLibrary eq true) and (CategoryMangaTable.category eq categoryId) }
|
.select { CategoryMangaTable.category eq categoryId }
|
||||||
.map(transform)
|
.map(transform)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ package suwayomi.tachidesk.manga.impl
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
import org.jetbrains.exposed.sql.deleteWhere
|
||||||
import org.jetbrains.exposed.sql.insert
|
import org.jetbrains.exposed.sql.insert
|
||||||
import org.jetbrains.exposed.sql.select
|
import org.jetbrains.exposed.sql.select
|
||||||
import org.jetbrains.exposed.sql.transactions.transaction
|
import org.jetbrains.exposed.sql.transactions.transaction
|
||||||
@@ -23,20 +24,17 @@ object Library {
|
|||||||
if (!manga.inLibrary) {
|
if (!manga.inLibrary) {
|
||||||
transaction {
|
transaction {
|
||||||
val defaultCategories = CategoryTable.select { CategoryTable.isDefault eq true }.toList()
|
val defaultCategories = CategoryTable.select { CategoryTable.isDefault eq true }.toList()
|
||||||
val existingCategories = CategoryMangaTable.select { CategoryMangaTable.manga eq mangaId }.toList()
|
|
||||||
|
|
||||||
MangaTable.update({ MangaTable.id eq manga.id }) {
|
MangaTable.update({ MangaTable.id eq manga.id }) {
|
||||||
it[inLibrary] = true
|
it[inLibrary] = true
|
||||||
it[inLibraryAt] = Instant.now().epochSecond
|
it[inLibraryAt] = Instant.now().epochSecond
|
||||||
it[defaultCategory] = defaultCategories.isEmpty() && existingCategories.isEmpty()
|
it[defaultCategory] = defaultCategories.isEmpty()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (existingCategories.isEmpty()) {
|
defaultCategories.forEach { category ->
|
||||||
defaultCategories.forEach { category ->
|
CategoryMangaTable.insert {
|
||||||
CategoryMangaTable.insert {
|
it[CategoryMangaTable.category] = category[CategoryTable.id].value
|
||||||
it[CategoryMangaTable.category] = category[CategoryTable.id].value
|
it[CategoryMangaTable.manga] = mangaId
|
||||||
it[CategoryMangaTable.manga] = mangaId
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -49,7 +47,9 @@ object Library {
|
|||||||
transaction {
|
transaction {
|
||||||
MangaTable.update({ MangaTable.id eq manga.id }) {
|
MangaTable.update({ MangaTable.id eq manga.id }) {
|
||||||
it[inLibrary] = false
|
it[inLibrary] = false
|
||||||
|
it[defaultCategory] = true
|
||||||
}
|
}
|
||||||
|
CategoryMangaTable.deleteWhere { CategoryMangaTable.manga eq mangaId }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,8 +36,7 @@ data class MangaDataClass(
|
|||||||
|
|
||||||
val freshData: Boolean = false,
|
val freshData: Boolean = false,
|
||||||
var unreadCount: Int? = null,
|
var unreadCount: Int? = null,
|
||||||
var downloadCount: Int? = null,
|
var downloadCount: Int? = null
|
||||||
var chapterCount: Int? = null
|
|
||||||
)
|
)
|
||||||
|
|
||||||
data class PagedMangaListDataClass(
|
data class PagedMangaListDataClass(
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ package suwayomi.tachidesk.manga.model.dataclass
|
|||||||
|
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
|
|
||||||
open class PaginatedList<T>(
|
data class PaginatedList<T>(
|
||||||
val page: List<T>,
|
val page: List<T>,
|
||||||
val hasNextPage: Boolean,
|
val hasNextPage: Boolean,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import org.kodein.di.instance
|
|||||||
import suwayomi.tachidesk.global.GlobalAPI
|
import suwayomi.tachidesk.global.GlobalAPI
|
||||||
import suwayomi.tachidesk.manga.MangaAPI
|
import suwayomi.tachidesk.manga.MangaAPI
|
||||||
import suwayomi.tachidesk.server.util.Browser
|
import suwayomi.tachidesk.server.util.Browser
|
||||||
import suwayomi.tachidesk.server.util.setupWebInterface
|
import suwayomi.tachidesk.server.util.setupWebUI
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.util.concurrent.CompletableFuture
|
import java.util.concurrent.CompletableFuture
|
||||||
import kotlin.concurrent.thread
|
import kotlin.concurrent.thread
|
||||||
@@ -45,9 +45,9 @@ object JavalinSetup {
|
|||||||
fun javalinSetup() {
|
fun javalinSetup() {
|
||||||
val app = Javalin.create { config ->
|
val app = Javalin.create { config ->
|
||||||
if (serverConfig.webUIEnabled) {
|
if (serverConfig.webUIEnabled) {
|
||||||
setupWebInterface()
|
setupWebUI()
|
||||||
|
|
||||||
logger.info { "Serving web static files for ${serverConfig.webUIFlavor}" }
|
logger.info { "Serving webUI static files" }
|
||||||
config.addStaticFiles(applicationDirs.webUIRoot, Location.EXTERNAL)
|
config.addStaticFiles(applicationDirs.webUIRoot, Location.EXTERNAL)
|
||||||
config.addSinglePageRoot("/", applicationDirs.webUIRoot + "/index.html", Location.EXTERNAL)
|
config.addSinglePageRoot("/", applicationDirs.webUIRoot + "/index.html", Location.EXTERNAL)
|
||||||
config.registerPlugin(OpenApiPlugin(getOpenApiOptions()))
|
config.registerPlugin(OpenApiPlugin(getOpenApiOptions()))
|
||||||
@@ -56,14 +56,16 @@ object JavalinSetup {
|
|||||||
config.enableCorsForAllOrigins()
|
config.enableCorsForAllOrigins()
|
||||||
|
|
||||||
config.accessManager { handler, ctx, _ ->
|
config.accessManager { handler, ctx, _ ->
|
||||||
fun credentialsValid(): Boolean {
|
fun basicAuthCredentialsValid(): Boolean {
|
||||||
val (username, password) = ctx.basicAuthCredentials()
|
val (username, password) = ctx.basicAuthCredentials()
|
||||||
return username == serverConfig.basicAuthUsername && password == serverConfig.basicAuthPassword
|
return username == serverConfig.basicAuthUsername && password == serverConfig.basicAuthPassword
|
||||||
}
|
}
|
||||||
|
|
||||||
if (serverConfig.basicAuthEnabled && !(ctx.basicAuthCredentialsExist() && credentialsValid())) {
|
if (serverConfig.authType != "none") {
|
||||||
ctx.header("WWW-Authenticate", "Basic")
|
if (serverConfig.authType == "basicAuth" && !(ctx.basicAuthCredentialsExist() && basicAuthCredentialsValid())) {
|
||||||
ctx.status(401).json("Unauthorized")
|
ctx.header("WWW-Authenticate", "Basic")
|
||||||
|
ctx.status(401).json("Unauthorized")
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
handler.handle(ctx)
|
handler.handle(ctx)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import com.typesafe.config.Config
|
|||||||
import xyz.nulldev.ts.config.GlobalConfigManager
|
import xyz.nulldev.ts.config.GlobalConfigManager
|
||||||
import xyz.nulldev.ts.config.SystemPropertyOverridableConfigModule
|
import xyz.nulldev.ts.config.SystemPropertyOverridableConfigModule
|
||||||
import xyz.nulldev.ts.config.debugLogsEnabled
|
import xyz.nulldev.ts.config.debugLogsEnabled
|
||||||
|
import kotlin.reflect.KProperty
|
||||||
|
|
||||||
private const val MODULE_NAME = "server"
|
private const val MODULE_NAME = "server"
|
||||||
class ServerConfig(config: Config, moduleName: String = MODULE_NAME) : SystemPropertyOverridableConfigModule(config, moduleName) {
|
class ServerConfig(config: Config, moduleName: String = MODULE_NAME) : SystemPropertyOverridableConfigModule(config, moduleName) {
|
||||||
@@ -26,16 +27,23 @@ class ServerConfig(config: Config, moduleName: String = MODULE_NAME) : SystemPro
|
|||||||
// misc
|
// misc
|
||||||
val debugLogsEnabled: Boolean = debugLogsEnabled(GlobalConfigManager.config)
|
val debugLogsEnabled: Boolean = debugLogsEnabled(GlobalConfigManager.config)
|
||||||
val systemTrayEnabled: Boolean by overridableConfig
|
val systemTrayEnabled: Boolean by overridableConfig
|
||||||
val downloadsPath: String by overridableConfig
|
|
||||||
|
|
||||||
// webUI
|
// webUI
|
||||||
val webUIEnabled: Boolean by overridableConfig
|
val webUIEnabled: Boolean by overridableConfig
|
||||||
val webUIFlavor: String by overridableConfig
|
|
||||||
val initialOpenInBrowserEnabled: Boolean by overridableConfig
|
val initialOpenInBrowserEnabled: Boolean by overridableConfig
|
||||||
val webUIInterface: String by overridableConfig
|
val webUIInterface: String by overridableConfig
|
||||||
val electronPath: String by overridableConfig
|
val electronPath: String by overridableConfig
|
||||||
|
|
||||||
// Authentication
|
// Authentication
|
||||||
|
val authType: String by object {
|
||||||
|
operator fun <R> getValue(thisRef: R, property: KProperty<*>): String {
|
||||||
|
val propValue: String = overridableConfig.getValue(thisRef, property)
|
||||||
|
if (basicAuthEnabled) {
|
||||||
|
return "basicAuth"
|
||||||
|
}
|
||||||
|
return propValue
|
||||||
|
}
|
||||||
|
}
|
||||||
val basicAuthEnabled: Boolean by overridableConfig
|
val basicAuthEnabled: Boolean by overridableConfig
|
||||||
val basicAuthUsername: String by overridableConfig
|
val basicAuthUsername: String by overridableConfig
|
||||||
val basicAuthPassword: String by overridableConfig
|
val basicAuthPassword: String by overridableConfig
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import io.javalin.plugin.json.JavalinJackson
|
|||||||
import io.javalin.plugin.json.JsonMapper
|
import io.javalin.plugin.json.JsonMapper
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import mu.KotlinLogging
|
import mu.KotlinLogging
|
||||||
import org.bouncycastle.jce.provider.BouncyCastleProvider
|
|
||||||
import org.kodein.di.DI
|
import org.kodein.di.DI
|
||||||
import org.kodein.di.bind
|
import org.kodein.di.bind
|
||||||
import org.kodein.di.conf.global
|
import org.kodein.di.conf.global
|
||||||
@@ -30,7 +29,6 @@ import xyz.nulldev.ts.config.ApplicationRootDir
|
|||||||
import xyz.nulldev.ts.config.ConfigKodeinModule
|
import xyz.nulldev.ts.config.ConfigKodeinModule
|
||||||
import xyz.nulldev.ts.config.GlobalConfigManager
|
import xyz.nulldev.ts.config.GlobalConfigManager
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.security.Security
|
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
|
||||||
private val logger = KotlinLogging.logger {}
|
private val logger = KotlinLogging.logger {}
|
||||||
@@ -40,7 +38,7 @@ class ApplicationDirs(
|
|||||||
) {
|
) {
|
||||||
val extensionsRoot = "$dataRoot/extensions"
|
val extensionsRoot = "$dataRoot/extensions"
|
||||||
val thumbnailsRoot = "$dataRoot/thumbnails"
|
val thumbnailsRoot = "$dataRoot/thumbnails"
|
||||||
val mangaDownloadsRoot = serverConfig.downloadsPath.ifBlank { "$dataRoot/downloads" }
|
val mangaDownloadsRoot = "$dataRoot/downloads"
|
||||||
val localMangaRoot = "$dataRoot/local"
|
val localMangaRoot = "$dataRoot/local"
|
||||||
val webUIRoot = "$dataRoot/webUI"
|
val webUIRoot = "$dataRoot/webUI"
|
||||||
}
|
}
|
||||||
@@ -54,11 +52,6 @@ val androidCompat by lazy { AndroidCompat() }
|
|||||||
fun applicationSetup() {
|
fun applicationSetup() {
|
||||||
logger.info("Running Tachidesk ${BuildConfig.VERSION} revision ${BuildConfig.REVISION}")
|
logger.info("Running Tachidesk ${BuildConfig.VERSION} revision ${BuildConfig.REVISION}")
|
||||||
|
|
||||||
// register Tachidesk's config which is dubbed "ServerConfig"
|
|
||||||
GlobalConfigManager.registerModule(
|
|
||||||
ServerConfig.register(GlobalConfigManager.config)
|
|
||||||
)
|
|
||||||
|
|
||||||
// Application dirs
|
// Application dirs
|
||||||
val applicationDirs = ApplicationDirs()
|
val applicationDirs = ApplicationDirs()
|
||||||
|
|
||||||
@@ -76,6 +69,7 @@ fun applicationSetup() {
|
|||||||
// Migrate Directories from old versions
|
// Migrate Directories from old versions
|
||||||
File("$ApplicationRootDir/manga-thumbnails").renameTo(applicationDirs.thumbnailsRoot)
|
File("$ApplicationRootDir/manga-thumbnails").renameTo(applicationDirs.thumbnailsRoot)
|
||||||
File("$ApplicationRootDir/manga-local").renameTo(applicationDirs.localMangaRoot)
|
File("$ApplicationRootDir/manga-local").renameTo(applicationDirs.localMangaRoot)
|
||||||
|
File("$ApplicationRootDir/manga").renameTo(applicationDirs.mangaDownloadsRoot)
|
||||||
File("$ApplicationRootDir/anime-thumbnails").delete()
|
File("$ApplicationRootDir/anime-thumbnails").delete()
|
||||||
|
|
||||||
// make dirs we need
|
// make dirs we need
|
||||||
@@ -90,6 +84,11 @@ fun applicationSetup() {
|
|||||||
File(it).mkdirs()
|
File(it).mkdirs()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// register Tachidesk's config which is dubbed "ServerConfig"
|
||||||
|
GlobalConfigManager.registerModule(
|
||||||
|
ServerConfig.register(GlobalConfigManager.config)
|
||||||
|
)
|
||||||
|
|
||||||
// Make sure only one instance of the app is running
|
// Make sure only one instance of the app is running
|
||||||
handleAppMutex()
|
handleAppMutex()
|
||||||
|
|
||||||
@@ -155,7 +154,4 @@ fun applicationSetup() {
|
|||||||
System.getProperties()["socksProxyPort"] = serverConfig.socksProxyPort
|
System.getProperties()["socksProxyPort"] = serverConfig.socksProxyPort
|
||||||
logger.info("Socks Proxy is enabled to ${serverConfig.socksProxyHost}:${serverConfig.socksProxyPort}")
|
logger.info("Socks Proxy is enabled to ${serverConfig.socksProxyHost}:${serverConfig.socksProxyPort}")
|
||||||
}
|
}
|
||||||
|
|
||||||
// AES/CBC/PKCS7Padding Cypher provider for zh.copymanga
|
|
||||||
Security.addProvider(BouncyCastleProvider())
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,44 +12,23 @@ fun <T> getSimpleParamItem(ctx: Context, param: Param<T>): String? {
|
|||||||
is Param.FormParam -> ctx.formParam(param.key)
|
is Param.FormParam -> ctx.formParam(param.key)
|
||||||
is Param.PathParam -> ctx.pathParam(param.key)
|
is Param.PathParam -> ctx.pathParam(param.key)
|
||||||
is Param.QueryParam -> ctx.queryParam(param.key)
|
is Param.QueryParam -> ctx.queryParam(param.key)
|
||||||
else -> throw IllegalStateException("Invalid param")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
fun <T> getParam(ctx: Context, param: Param<T>): T {
|
fun <T> getParam(ctx: Context, param: Param<T>): T {
|
||||||
if (param is Param.QueryParams<*, *>) {
|
val typedItem: Any? = when (param.clazz) {
|
||||||
val item = ctx.queryParams(param.key).filter(String::isNotBlank)
|
String::class.java -> getSimpleParamItem(ctx, param)
|
||||||
val typedItem: List<Any?> = when (param.clazz) {
|
Int::class.java -> getSimpleParamItem(ctx, param)?.toIntOrNull()
|
||||||
String::class.java, java.lang.String::class.java -> item
|
Long::class.java -> getSimpleParamItem(ctx, param)?.toLongOrNull()
|
||||||
Int::class.java, java.lang.Integer::class.java -> item.map { it.toIntOrNull() }
|
Boolean::class.java -> getSimpleParamItem(ctx, param)?.toBoolean()
|
||||||
Long::class.java, java.lang.Long::class.java -> item.map { it.toLongOrNull() }
|
Float::class.java -> getSimpleParamItem(ctx, param)?.toFloatOrNull()
|
||||||
Boolean::class.java, java.lang.Boolean::class.java -> item.map { it.toBoolean() }
|
Double::class.java -> getSimpleParamItem(ctx, param)?.toDoubleOrNull()
|
||||||
Float::class.java, java.lang.Float::class.java -> item.map { it.toFloatOrNull() }
|
|
||||||
Double::class.java, java.lang.Double::class.java -> item.map { it.toDoubleOrNull() }
|
|
||||||
else -> throw IllegalStateException("Unknown class ${param.clazz.simpleName}")
|
|
||||||
}.let {
|
|
||||||
if (param.nullable) {
|
|
||||||
it
|
|
||||||
} else {
|
|
||||||
it.filterNotNull()
|
|
||||||
}
|
|
||||||
}.ifEmpty { param.defaultValue }
|
|
||||||
return typedItem as T
|
|
||||||
}
|
|
||||||
val typedItem: Any? = when (val clazz = param.clazz as Class<T>) {
|
|
||||||
String::class.java, java.lang.String::class.java -> getSimpleParamItem(ctx, param) ?: param.defaultValue
|
|
||||||
Int::class.java, java.lang.Integer::class.java -> getSimpleParamItem(ctx, param)?.toIntOrNull() ?: param.defaultValue
|
|
||||||
Long::class.java, java.lang.Long::class.java -> getSimpleParamItem(ctx, param)?.toLongOrNull() ?: param.defaultValue
|
|
||||||
Boolean::class.java, java.lang.Boolean::class.java -> getSimpleParamItem(ctx, param)?.toBoolean() ?: param.defaultValue
|
|
||||||
Float::class.java, java.lang.Float::class.java -> getSimpleParamItem(ctx, param)?.toFloatOrNull() ?: param.defaultValue
|
|
||||||
Double::class.java, java.lang.Double::class.java -> getSimpleParamItem(ctx, param)?.toDoubleOrNull() ?: param.defaultValue
|
|
||||||
else -> {
|
else -> {
|
||||||
when (param) {
|
when (param) {
|
||||||
is Param.FormParam -> ctx.formParamAsClass(param.key, clazz)
|
is Param.FormParam -> ctx.formParamAsClass(param.key, param.clazz)
|
||||||
is Param.PathParam -> ctx.pathParamAsClass(param.key, clazz)
|
is Param.PathParam -> ctx.pathParamAsClass(param.key, param.clazz)
|
||||||
is Param.QueryParam -> ctx.queryParamAsClass(param.key, clazz)
|
is Param.QueryParam -> ctx.queryParamAsClass(param.key, param.clazz)
|
||||||
else -> throw IllegalStateException("Invalid param")
|
|
||||||
}.let {
|
}.let {
|
||||||
if (param.nullable) {
|
if (param.nullable) {
|
||||||
it.allowNullable().get() ?: param.defaultValue
|
it.allowNullable().get() ?: param.defaultValue
|
||||||
@@ -82,8 +61,7 @@ inline fun getDocumentation(
|
|||||||
when (it) {
|
when (it) {
|
||||||
is Param.FormParam -> formParam(it.key, it.clazz, !it.nullable && it.defaultValue == null)
|
is Param.FormParam -> formParam(it.key, it.clazz, !it.nullable && it.defaultValue == null)
|
||||||
is Param.PathParam -> pathParam(it.key, it.clazz)
|
is Param.PathParam -> pathParam(it.key, it.clazz)
|
||||||
is Param.QueryParam -> queryParam(it.key, it.clazz)
|
is Param.QueryParam -> queryParam(it.key, it.clazz,)
|
||||||
is Param.QueryParams<*, *> -> queryParam(it.key, it.clazz, isRepeatable = true)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -105,46 +83,37 @@ inline fun <reified T> formParam(key: String, defaultValue: T? = null): Param.Fo
|
|||||||
inline fun <reified T> queryParam(key: String, defaultValue: T? = null): Param.QueryParam<T> {
|
inline fun <reified T> queryParam(key: String, defaultValue: T? = null): Param.QueryParam<T> {
|
||||||
return Param.QueryParam(key, T::class.java, defaultValue, null is T)
|
return Param.QueryParam(key, T::class.java, defaultValue, null is T)
|
||||||
}
|
}
|
||||||
inline fun <reified T> queryParams(key: String, defaultValue: List<T> = emptyList()): Param.QueryParams<T, List<T>> {
|
|
||||||
return Param.QueryParams(key, T::class.java, defaultValue, null is T)
|
|
||||||
}
|
|
||||||
inline fun <reified T> pathParam(key: String): Param.PathParam<T> {
|
inline fun <reified T> pathParam(key: String): Param.PathParam<T> {
|
||||||
return Param.PathParam(key, T::class.java, null, false)
|
return Param.PathParam(key, T::class.java, null, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
sealed class Param<T> {
|
sealed class Param<T> {
|
||||||
abstract val key: String
|
abstract val key: String
|
||||||
abstract val clazz: Class<*>
|
abstract val clazz: Class<T>
|
||||||
abstract val defaultValue: T?
|
abstract val defaultValue: T?
|
||||||
abstract val nullable: Boolean
|
abstract val nullable: Boolean
|
||||||
data class FormParam<T>(
|
data class FormParam<T>(
|
||||||
override val key: String,
|
override val key: String,
|
||||||
override val clazz: Class<*>,
|
override val clazz: Class<T>,
|
||||||
override val defaultValue: T?,
|
override val defaultValue: T?,
|
||||||
override val nullable: Boolean
|
override val nullable: Boolean
|
||||||
) : Param<T>()
|
) : Param<T>()
|
||||||
data class QueryParam<T>(
|
data class QueryParam<T>(
|
||||||
override val key: String,
|
override val key: String,
|
||||||
override val clazz: Class<*>,
|
override val clazz: Class<T>,
|
||||||
override val defaultValue: T?,
|
override val defaultValue: T?,
|
||||||
override val nullable: Boolean
|
override val nullable: Boolean
|
||||||
) : Param<T>()
|
) : Param<T>()
|
||||||
data class QueryParams<R, T : List<R>>(
|
|
||||||
override val key: String,
|
|
||||||
override val clazz: Class<R>,
|
|
||||||
override val defaultValue: T,
|
|
||||||
override val nullable: Boolean
|
|
||||||
) : Param<T>()
|
|
||||||
data class PathParam<T>(
|
data class PathParam<T>(
|
||||||
override val key: String,
|
override val key: String,
|
||||||
override val clazz: Class<*>,
|
override val clazz: Class<T>,
|
||||||
override val defaultValue: T?,
|
override val defaultValue: T?,
|
||||||
override val nullable: Boolean
|
override val nullable: Boolean
|
||||||
) : Param<T>()
|
) : Param<T>()
|
||||||
}
|
}
|
||||||
|
|
||||||
class ResultsBuilder {
|
class ResultsBuilder {
|
||||||
val results = mutableListOf<ResultType>()
|
val results = mutableListOf<ResultType<*>>()
|
||||||
|
|
||||||
inline fun <reified T> json(code: HttpCode) {
|
inline fun <reified T> json(code: HttpCode) {
|
||||||
results += ResultType.MimeType(code, "application/json", T::class.java)
|
results += ResultType.MimeType(code, "application/json", T::class.java)
|
||||||
@@ -152,22 +121,19 @@ class ResultsBuilder {
|
|||||||
fun plainText(code: HttpCode) {
|
fun plainText(code: HttpCode) {
|
||||||
results += ResultType.MimeType(code, "text/plain", String::class.java)
|
results += ResultType.MimeType(code, "text/plain", String::class.java)
|
||||||
}
|
}
|
||||||
fun mime(code: HttpCode, mime: String) {
|
|
||||||
results += ResultType.MimeType(code, mime, null)
|
|
||||||
}
|
|
||||||
fun httpCode(code: HttpCode) {
|
fun httpCode(code: HttpCode) {
|
||||||
results += ResultType.StatusCode(code)
|
results += ResultType.StatusCode(code)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sealed class ResultType {
|
sealed class ResultType <T> {
|
||||||
abstract fun applyTo(documentation: OpenApiDocumentation)
|
abstract fun applyTo(documentation: OpenApiDocumentation)
|
||||||
data class MimeType(val code: HttpCode, val mime: String, private val clazz: Class<*>?) : ResultType() {
|
data class MimeType<T>(val code: HttpCode, val mime: String, private val clazz: Class<T>) : ResultType<T>() {
|
||||||
override fun applyTo(documentation: OpenApiDocumentation) {
|
override fun applyTo(documentation: OpenApiDocumentation) {
|
||||||
documentation.result(code.status.toString(), clazz)
|
documentation.result(code.status.toString(), clazz)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
data class StatusCode(val code: HttpCode) : ResultType() {
|
data class StatusCode(val code: HttpCode) : ResultType<Unit>() {
|
||||||
override fun applyTo(documentation: OpenApiDocumentation) {
|
override fun applyTo(documentation: OpenApiDocumentation) {
|
||||||
documentation.result<Unit>(code.status.toString())
|
documentation.result<Unit>(code.status.toString())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,6 @@ package suwayomi.tachidesk.server.util
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
import kotlinx.serialization.json.Json
|
|
||||||
import kotlinx.serialization.json.jsonObject
|
|
||||||
import kotlinx.serialization.json.jsonPrimitive
|
|
||||||
import mu.KotlinLogging
|
import mu.KotlinLogging
|
||||||
import net.lingala.zip4j.ZipFile
|
import net.lingala.zip4j.ZipFile
|
||||||
import org.kodein.di.DI
|
import org.kodein.di.DI
|
||||||
@@ -17,8 +14,6 @@ import org.kodein.di.conf.global
|
|||||||
import org.kodein.di.instance
|
import org.kodein.di.instance
|
||||||
import suwayomi.tachidesk.server.ApplicationDirs
|
import suwayomi.tachidesk.server.ApplicationDirs
|
||||||
import suwayomi.tachidesk.server.BuildConfig
|
import suwayomi.tachidesk.server.BuildConfig
|
||||||
import suwayomi.tachidesk.server.serverConfig
|
|
||||||
import uy.kohesive.injekt.injectLazy
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
import java.net.HttpURLConnection
|
import java.net.HttpURLConnection
|
||||||
@@ -28,7 +23,6 @@ import java.security.MessageDigest
|
|||||||
|
|
||||||
private val logger = KotlinLogging.logger {}
|
private val logger = KotlinLogging.logger {}
|
||||||
private val applicationDirs by DI.global.instance<ApplicationDirs>()
|
private val applicationDirs by DI.global.instance<ApplicationDirs>()
|
||||||
private val json: Json by injectLazy()
|
|
||||||
private val tmpDir = System.getProperty("java.io.tmpdir")
|
private val tmpDir = System.getProperty("java.io.tmpdir")
|
||||||
|
|
||||||
private fun ByteArray.toHex(): String = joinToString(separator = "") { eachByte -> "%02x".format(eachByte) }
|
private fun ByteArray.toHex(): String = joinToString(separator = "") { eachByte -> "%02x".format(eachByte) }
|
||||||
@@ -50,19 +44,6 @@ private fun directoryMD5(fileDir: String): String {
|
|||||||
return digest.toHex()
|
return digest.toHex()
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Make sure a valid web interface installation is available */
|
|
||||||
fun setupWebInterface() {
|
|
||||||
when (serverConfig.webUIFlavor) {
|
|
||||||
"WebUI" -> setupWebUI()
|
|
||||||
"Sorayomi" -> setupSorayomi()
|
|
||||||
"Custom" -> {
|
|
||||||
/* do nothing */
|
|
||||||
}
|
|
||||||
else -> setupWebUI()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Make sure a valid copy of WebUI is available */
|
|
||||||
fun setupWebUI() {
|
fun setupWebUI() {
|
||||||
// check if we have webUI installed and is correct version
|
// check if we have webUI installed and is correct version
|
||||||
val webUIRevisionFile = File(applicationDirs.webUIRoot + "/revision")
|
val webUIRevisionFile = File(applicationDirs.webUIRoot + "/revision")
|
||||||
@@ -136,63 +117,3 @@ fun setupWebUI() {
|
|||||||
logger.info { "Extracting WebUI zip Done." }
|
logger.info { "Extracting WebUI zip Done." }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Make sure a valid copy of Sorayomi is available */
|
|
||||||
fun setupSorayomi() {
|
|
||||||
// check if we have Sorayomi installed and is correct version
|
|
||||||
val sorayomiVersionFile = File(applicationDirs.webUIRoot + "/version.json")
|
|
||||||
if (sorayomiVersionFile.exists() && json.parseToJsonElement(
|
|
||||||
sorayomiVersionFile.readText()
|
|
||||||
).jsonObject["version"]!!.jsonPrimitive.content == BuildConfig.SORAYOMI_TAG
|
|
||||||
) {
|
|
||||||
logger.info { "Sorayomi Static files exists and is the correct revision" }
|
|
||||||
logger.info { "Verifying Sorayomi Static files..." }
|
|
||||||
logger.info { "md5: " + directoryMD5(applicationDirs.webUIRoot) }
|
|
||||||
} else {
|
|
||||||
File(applicationDirs.webUIRoot).deleteRecursively()
|
|
||||||
|
|
||||||
val sorayomiZip = "tachidesk-sorayomi-${BuildConfig.SORAYOMI_TAG}-web.zip"
|
|
||||||
val sorayomiZipPath = "$tmpDir/$sorayomiZip"
|
|
||||||
val sorayomiZipFile = File(sorayomiZipPath)
|
|
||||||
|
|
||||||
// download sorayomi zip
|
|
||||||
val sorayomiZipURL = "${BuildConfig.SORAYOMI_REPO}/releases/download/${BuildConfig.SORAYOMI_TAG}/$sorayomiZip"
|
|
||||||
sorayomiZipFile.delete()
|
|
||||||
|
|
||||||
logger.info { "Downloading Sorayomi zip from the Internet..." }
|
|
||||||
val data = ByteArray(1024)
|
|
||||||
|
|
||||||
sorayomiZipFile.outputStream().use { sorayomiZipFileOut ->
|
|
||||||
|
|
||||||
val connection = URL(sorayomiZipURL).openConnection() as HttpURLConnection
|
|
||||||
connection.connect()
|
|
||||||
val contentLength = connection.contentLength
|
|
||||||
|
|
||||||
connection.inputStream.buffered().use { inp ->
|
|
||||||
var totalCount = 0
|
|
||||||
|
|
||||||
print("Download progress: % 00")
|
|
||||||
while (true) {
|
|
||||||
val count = inp.read(data, 0, 1024)
|
|
||||||
|
|
||||||
if (count == -1)
|
|
||||||
break
|
|
||||||
|
|
||||||
totalCount += count
|
|
||||||
val percentage = (totalCount.toFloat() / contentLength * 100).toInt().toString().padStart(2, '0')
|
|
||||||
print("\b\b$percentage")
|
|
||||||
|
|
||||||
sorayomiZipFileOut.write(data, 0, count)
|
|
||||||
}
|
|
||||||
println()
|
|
||||||
logger.info { "Downloading Sorayomi Done." }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// extract Sorayomi zip
|
|
||||||
logger.info { "Extracting Sorayomi zip..." }
|
|
||||||
File(applicationDirs.webUIRoot).mkdirs()
|
|
||||||
ZipFile(sorayomiZipPath).extractAll(applicationDirs.webUIRoot)
|
|
||||||
logger.info { "Extracting Sorayomi zip Done." }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,17 +9,16 @@ server.socksProxyPort = ""
|
|||||||
|
|
||||||
# webUI
|
# webUI
|
||||||
server.webUIEnabled = true
|
server.webUIEnabled = true
|
||||||
server.webUIFlavor = "WebUI" # "WebUI" or "Sorayomi" or "Custom"
|
|
||||||
server.initialOpenInBrowserEnabled = true
|
server.initialOpenInBrowserEnabled = true
|
||||||
server.webUIInterface = "browser" # "browser" or "electron"
|
server.webUIInterface = "browser" # "browser" or "electron"
|
||||||
server.electronPath = ""
|
server.electronPath = ""
|
||||||
|
|
||||||
# Authentication
|
# Authentication
|
||||||
server.basicAuthEnabled = false
|
server.authType = "none" # "none" or "basicAuth" or "token"
|
||||||
|
server.basicAuthEnabled = false # This is deprecated, use server.authType
|
||||||
server.basicAuthUsername = ""
|
server.basicAuthUsername = ""
|
||||||
server.basicAuthPassword = ""
|
server.basicAuthPassword = ""
|
||||||
|
|
||||||
# misc
|
# misc
|
||||||
server.debugLogsEnabled = false
|
server.debugLogsEnabled = false
|
||||||
server.systemTrayEnabled = true
|
server.systemTrayEnabled = true
|
||||||
server.downloadsPath = ""
|
|
||||||
|
|||||||
Reference in New Issue
Block a user