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

View File

@@ -94,9 +94,30 @@ class Main {
val mangaId = ctx.pathParam("mangaId").toInt()
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
}
}
}
}