add build workflow

This commit is contained in:
Aria Moradi 2021-01-21 14:15:05 +03:30
parent c537c1bf29
commit 34a7c24e0b
5 changed files with 173 additions and 2 deletions

14
.github/scripts/commit-repo.sh vendored Executable file
View File

@ -0,0 +1,14 @@
#!/bin/bash
set -e
rsync -a --delete --exclude .git --exclude .gitignore ../master/repo/ .
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git status
if [ -n "$(git status --porcelain)" ]; then
git add .
git commit -m "Update extensions repo"
git push
else
echo "No changes to commit"
fi

6
.github/scripts/create-repo.sh vendored Executable file
View File

@ -0,0 +1,6 @@
#!/bin/bash
set -e
mkdir -p repo/
cp -f server/build/server-1.0-all.jar repo/

71
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,71 @@
name: CI
on:
push:
branches:
- master
pull_request:
jobs:
check_wrapper:
name: Validate Gradle Wrapper
runs-on: ubuntu-latest
steps:
- name: Clone repo
uses: actions/checkout@v2
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
build:
name: Build FatJar
needs: check_wrapper
if: "!startsWith(github.event.head_commit.message, '[SKIP CI]')"
runs-on: ubuntu-latest
steps:
- name: Cancel previous runs
uses: styfle/cancel-workflow-action@0.5.0
with:
access_token: ${{ github.token }}
- name: Checkout master branch
uses: actions/checkout@v2
with:
ref: master
path: master
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Build the Jar
uses: eskatos/gradle-command-action@v1
with:
build-root-directory: master
wrapper-directory: master
arguments: :server:shadowJar
wrapper-cache-enabled: true
dependencies-cache-enabled: true
configuration-cache-enabled: true
- name: Create repo artifacts
if: github.event_name == 'push' && github.repository == 'AriaMoradi/Tachidesk'
run: |
cd master
./.github/scripts/create-repo.sh
- name: Checkout repo branch
if: github.event_name == 'push' && github.repository == 'AriaMoradi/Tachidesk'
uses: actions/checkout@v2
with:
ref: repo
path: repo
- name: Deploy repo
if: github.event_name == 'push' && github.repository == 'AriaMoradi/Tachidesk'
run: |
cd repo
../master/.github/scripts/commit-repo.sh

View File

@ -94,9 +94,30 @@ class Main {
val mangaId = ctx.pathParam("mangaId").toInt() val mangaId = ctx.pathParam("mangaId").toInt()
ctx.json(getPages(chapterId, mangaId)) ctx.json(getPages(chapterId, mangaId))
} }
// global search
app.get("/api/v1/search/:searchTerm") { ctx ->
val searchTerm = ctx.pathParam("searchTerm")
ctx.json(sourceGlobalSearch(searchTerm))
}
// single source search
app.get("/api/v1/source/:sourceId/search/:searchTerm") { ctx ->
val sourceId = ctx.pathParam("sourceId").toLong()
val searchTerm = ctx.pathParam("searchTerm")
ctx.json(sourceSearch(sourceId, searchTerm))
}
// source filter list
app.get("/api/v1/source/:sourceId/filters/") { ctx ->
val sourceId = ctx.pathParam("sourceId").toLong()
ctx.json(sourceFilters(sourceId))
}
} }
} }
} }

View File

@ -0,0 +1,59 @@
package ir.armor.tachidesk.util
import eu.kanade.tachiyomi.source.model.Filter
import eu.kanade.tachiyomi.source.model.FilterList
fun sourceFilters(sourceId: Long) {
val source = getHttpSource(sourceId)
source.getFilterList().toItems()
}
fun sourceSearch(sourceId: Long, searchTerm: String) {
val source = getHttpSource(sourceId)
//source.fetchSearchManga()
}
fun sourceGlobalSearch(searchTerm: String) {
}
data class FilterWrapper(
val type: String,
val filter: Any
)
private fun FilterList.toItems(): List<FilterWrapper> {
return mapNotNull { filter ->
when (filter) {
is Filter.Header -> FilterWrapper("Header",filter)
is Filter.Separator -> FilterWrapper("Separator",filter)
is Filter.CheckBox -> FilterWrapper("CheckBox",filter)
is Filter.TriState -> FilterWrapper("TriState",filter)
is Filter.Text -> FilterWrapper("Text",filter)
is Filter.Select<*> -> FilterWrapper("Select",filter)
is Filter.Group<*> -> {
val group = GroupItem(filter)
val subItems = filter.state.mapNotNull {
when (it) {
is Filter.CheckBox -> FilterWrapper("CheckBox",filter)
is Filter.TriState -> FilterWrapper("TriState",filter)
is Filter.Text -> FilterWrapper("Text",filter)
is Filter.Select<*> -> FilterWrapper("Select",filter)
else -> null
} as? ISectionable<*, *>
}
subItems.forEach { it.header = group }
group.subItems = subItems
group
}
is Filter.Sort -> {
val group = SortGroup(filter)
val subItems = filter.values.map {
SortItem(it, group)
}
group.subItems = subItems
group
}
}
}
}