Skip to content
This repository was archived by the owner on Jul 27, 2024. It is now read-only.

Commit f3b1d42

Browse files
feat: rokahon extension x.y.1 (#2)
* feat: impl all core feat * feat: implement all core feat * feat: implement all core feat * uncomment compile * fix: version * fix: rename to default * fix: order * chore: workflows * test: account diff env * test: account diff env
1 parent 425fefe commit f3b1d42

File tree

17 files changed

+234
-167
lines changed

17 files changed

+234
-167
lines changed

.github/workflows/auto-build.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# git tag
2+
# git tag vx.y.z
3+
# git push --tag
4+
5+
on:
6+
push:
7+
tags:
8+
- v*
9+
10+
jobs:
11+
build:
12+
strategy:
13+
matrix:
14+
include:
15+
- os: ubuntu-latest
16+
extension: ""
17+
- os: windows-latest
18+
extension: ".exe"
19+
20+
runs-on: ${{ matrix.os }}
21+
steps:
22+
- name: Setup repo
23+
uses: actions/checkout@v3
24+
- name: Setup Deno
25+
uses: denoland/setup-deno@v1
26+
with:
27+
deno-version: v1.43.6
28+
29+
- name: Building rokahon on ${{ matrix.os }}
30+
run: |
31+
cd rokahon-server
32+
make compile
33+
34+
- name: Archive build for ${{ matrix.os }}
35+
run: |
36+
cd rokahon-server
37+
tar -czvf ../rokahon-${{ github.ref_name }}-${{ matrix.os }}.tar.gz *
38+
39+
- name: Release ${{ matrix.os }}
40+
uses: svenstaro/upload-release-action@v2
41+
with:
42+
tag: ${{ github.ref }}
43+
file: "rokahon-${{ github.ref_name }}-${{ matrix.os }}.tar.gz"
44+
asset_name: "rokahon-${{ github.ref_name }}-${{ matrix.os }}.tar.gz"
45+
overwrite: true

.github/workflows/tests.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: rokahon tests
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
branches: ["main"]
8+
9+
jobs:
10+
test:
11+
strategy:
12+
matrix:
13+
include:
14+
- os: ubuntu-latest
15+
- os: windows-latest
16+
runs-on: ${{ matrix.os }}
17+
steps:
18+
- name: Setup repo
19+
uses: actions/checkout@v3
20+
- name: Setup Deno
21+
uses: denoland/setup-deno@v1
22+
with:
23+
deno-version: v1.43.6
24+
# - name: Verify formatting
25+
# run: deno fmt --check
26+
# - name: Run linter
27+
# run: deno lint
28+
- name: Run rokahon tests
29+
run: |
30+
cd rokahon-server
31+
make test

.gitignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,39 @@ repo/
1313
apk/
1414
gen
1515
generated-src/
16+
17+
# https://raw.githubusercontent.com/github/gitignore/main/Android.gitignore
18+
19+
# Gradle files
20+
.gradle/
21+
build/
22+
23+
# Local configuration file (sdk path, etc)
24+
local.properties
25+
26+
# Log/OS Files
27+
*.log
28+
29+
# Android Studio generated files and folders
30+
captures/
31+
.externalNativeBuild/
32+
.cxx/
33+
*.apk
34+
output.json
35+
36+
# IntelliJ
37+
*.iml
38+
.idea/
39+
misc.xml
40+
deploymentTargetDropDown.xml
41+
render.experimental.xml
42+
43+
# Keystore files
44+
*.jks
45+
*.keystore
46+
47+
# Google Services (e.g. APIs or Firebase)
48+
google-services.json
49+
50+
# Android Profiling
51+
*.hprof

README.md

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,9 @@ Rokahon (or ローカル本) is a simple server for your local gallery, you can
88
browse local files through apps similar to Mihon or just use it as a simple REST
99
endpoint.
1010

11-
## Rokahon Mihon Extension
12-
13-
Rokahon android extension for Mihon or any Tachyomi-like apps.
14-
15-
TODO
16-
1711
## Rokahon server
1812

19-
A very basic server that automatically scans and cache a list of directories.
13+
A very basic server that exposes your local gallery into a functional REST api.
2014

2115
For example, with the configuration..
2216

@@ -37,20 +31,31 @@ Rōkahon will serve any subdirectory that follows the structure
3731
```
3832
path/to/lib1/..
3933
bookTitle
40-
chapter1
34+
chapter2
4135
1.ext
42-
2.ext
4336
..
44-
chapter2
37+
chapter1
4538
1.ext
39+
2.ext
4640
..
4741
4842
other/lib2/..
4943
bookTitle
50-
chapter1
44+
chapter2
5145
a.ext
5246
..
53-
chapter2
47+
chapter1
5448
a.ext
5549
..
5650
```
51+
52+
## Rokahon Mihon Extension
53+
54+
Rokahon android extension for Mihon or any most Tachyomi forks.
55+
56+
Simply launch the server, install the extension, configure the address and you
57+
are done.
58+
59+
<p align="center">
60+
<img src="misc/address_screenshot.bmp">
61+
</p>

misc/address_screenshot.bmp

17.4 KB
Binary file not shown.

rokahon-extension/local.properties

Lines changed: 0 additions & 8 deletions
This file was deleted.

rokahon-extension/settings.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,3 @@ fun loadIndividualExtension(lang: String, name: String) {
3939
fun File.eachDir(block: (File) -> Unit) {
4040
listFiles()?.filter { it.isDirectory }?.forEach { block(it) }
4141
}
42-
include(":extensions:individual:all:rokahhon")

rokahon-extension/src/all/rokahon/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ext {
66
extName = 'Rokahon'
77
pkgNameSuffix = 'all.rokahon'
88
extClass = '.Rokahon'
9-
extVersionCode = 12
9+
extVersionCode = 1
1010
}
1111

1212
apply from: "$rootDir/common.gradle"

rokahon-extension/src/all/rokahon/src/eu/kanade/tachiyomi/extension/all/rokahon/Rokahon.kt

Lines changed: 35 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class Rokahon : ConfigurableSource, UnmeteredSource, HttpSource() {
3737
private const val ADDRESS_TITLE = "Server URL"
3838
private const val ADDRESS_DEFAULT = "http://192.168.1.170:1770"
3939
}
40+
4041
override val baseUrl by lazy { preferences.getString(ADDRESS_TITLE, ADDRESS_DEFAULT)!! }
4142

4243
private val json: Json by injectLazy()
@@ -53,12 +54,11 @@ class Rokahon : ConfigurableSource, UnmeteredSource, HttpSource() {
5354
override fun latestUpdatesRequest(page: Int): Request = throw Exception("Not supported")
5455
override fun latestUpdatesParse(response: Response): MangasPage = throw Exception("Not supported")
5556
override fun imageUrlParse(response: Response): String = throw Exception("Not supported")
56-
override fun pageListParse(response: Response): List<Page> = throw UnsupportedOperationException("Not used")
5757

58-
// MANGA SEARCH + PARSE
58+
// MANGA SEARCH
5959
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
6060
// Response will be available in searchMangaParse
61-
println("searchMangaRequest")
61+
println("FN_CALL searchMangaRequest")
6262
val url = "$baseUrl/search"
6363
.toHttpUrl()
6464
.newBuilder()
@@ -67,8 +67,9 @@ class Rokahon : ConfigurableSource, UnmeteredSource, HttpSource() {
6767
.build()
6868
return GET(url, headers)
6969
}
70+
7071
override fun searchMangaParse(response: Response): MangasPage {
71-
println("searchMangaParse")
72+
println("FN_CALL searchMangaParse")
7273
var rokaResponse = json.decodeFromString<RokahonResponse<List<RokahonSimpBook>>>(response.body.string())
7374
if (rokaResponse.isError) {
7475
val msg = rokaResponse.data.toString()
@@ -83,7 +84,6 @@ class Rokahon : ConfigurableSource, UnmeteredSource, HttpSource() {
8384
title = book.title
8485
url = "$baseUrl/book/" + book.id
8586
thumbnail_url = "$baseUrl/image?id=" + book.cover.id
86-
genre = "sample"
8787
status = SManga.ONGOING
8888
},
8989
)
@@ -92,80 +92,69 @@ class Rokahon : ConfigurableSource, UnmeteredSource, HttpSource() {
9292
return MangasPage(items, false)
9393
}
9494

95-
// POPULAR MANGA REQUEST + PARSE
95+
// POPULAR MANGA
9696
override fun popularMangaRequest(page: Int) = searchMangaRequest(1, "", FilterList())
9797

98-
override fun popularMangaParse(response: Response): MangasPage {
99-
return searchMangaParse(response)
100-
}
98+
override fun popularMangaParse(response: Response) = searchMangaParse(response)
10199

102100
// MANGA DETAILS
103101
override fun fetchMangaDetails(manga: SManga): Observable<SManga> {
104-
println("fetchMangaDetails " + manga.title)
102+
println("FN_CALL fetchMangaDetails " + manga.title + " :: " + manga.url)
105103
return Observable.just(manga)
106104
}
107105

108-
override fun mangaDetailsRequest(manga: SManga): Request {
109-
println("mangaDetailsRequest " + manga.title)
110-
return super.mangaDetailsRequest(manga)
111-
}
112-
113-
override fun mangaDetailsParse(response: Response) = throw UnsupportedOperationException("Not used.")
106+
override fun mangaDetailsParse(response: Response) = throw UnsupportedOperationException("mangaDetailsParse :: Not used")
114107

115-
// CHAPTER LIST + PARSE
116-
// override fun prepareNewChapter(chapter: SChapter, manga: SManga) {
117-
// println("prepareNewChapter " + chapter.url)
118-
// super.prepareNewChapter(chapter, manga)
119-
// }
108+
// CHAPTER LIST
109+
override fun chapterListRequest(manga: SManga): Request {
110+
println("FN_CALL chapterListRequest " + manga.title + " :: " + manga.url)
111+
return GET(manga.url, headers)
112+
}
120113

121-
override fun fetchChapterList(manga: SManga): Observable<List<SChapter>> {
122-
println("fetchChapterList " + manga.title)
123-
var response = GET(manga.url, headers)
124-
val rokaResponse = json.decodeFromString<RokahonResponse<RokahonSimpBook>>(response.body.toString())
114+
override fun chapterListParse(response: Response): List<SChapter> {
115+
println("FN_CALL chapterListParse " + response.request.url)
116+
val rokaResponse = json.decodeFromString<RokahonResponse<RokahonSimpBook>>(response.body.string())
125117
if (rokaResponse.isError) {
126118
val msg = rokaResponse.data.toString()
127119
Log.e("Search", msg)
120+
throw Exception(msg)
128121
}
129122
val book = rokaResponse.data
130-
val chapters = book.chapters.map {
123+
return book.chapters.map {
131124
SChapter.create().apply {
132-
url = "$baseUrl/pages/" + book.id + "/" + it.id
125+
url = "$baseUrl/chapter/" + book.id + "/" + it.id
133126
name = it.title
134127
}
135128
}
136-
return Observable.just(chapters)
137129
}
138130

139-
override fun chapterListRequest(manga: SManga): Request {
140-
println("chapterListRequest " + manga.title + " :: " + manga.url)
141-
return GET(manga.url, headers)
131+
// PAGE
132+
override fun pageListRequest(chapter: SChapter): Request {
133+
println("FN_CALL pageListRequest " + chapter.url)
134+
return GET(chapter.url, headers)
142135
}
143136

144-
override fun chapterListParse(response: Response): List<SChapter> {
145-
println("chapterListParse " + response.request.url)
146-
val rokaResponse = json.decodeFromString<RokahonResponse<RokahonSimpBook>>(response.body.toString())
137+
override fun pageListParse(response: Response): List<Page> {
138+
println("FN_CALL pageListParse " + response.request.url)
139+
val rokaResponse = json.decodeFromString<RokahonResponse<RokahonChapter>>(response.body.string())
147140
if (rokaResponse.isError) {
148141
val msg = rokaResponse.data.toString()
149142
Log.e("Search", msg)
150143
throw Exception(msg)
151144
}
152-
val book = rokaResponse.data
153-
return book.chapters.map {
154-
SChapter.create().apply {
155-
url = "$baseUrl/pages/" + book.id + "/" + it.id
156-
name = it.title
157-
}
145+
val chapter = rokaResponse.data
146+
return chapter.pages.map {
147+
Page(
148+
index = it.number,
149+
imageUrl = "$baseUrl/image?id=" + it.image.id,
150+
)
158151
}
159152
}
160153

161-
override fun pageListRequest(chapter: SChapter): Request {
162-
TODO("page list request")
163-
}
164-
165154
// Settings/UI
166155

167156
override fun setupPreferenceScreen(screen: PreferenceScreen) {
168-
screen.addPreference(screen.editTextPreference(ADDRESS_TITLE, ADDRESS_DEFAULT, baseUrl, false, "i.e. http://192.168.1.115:4567"))
157+
screen.addPreference(screen.editTextPreference(ADDRESS_TITLE, ADDRESS_DEFAULT, baseUrl, false, "http://192.168.1.170:1770"))
169158
}
170159

171160
private val preferences: SharedPreferences by lazy {
@@ -194,7 +183,7 @@ class Rokahon : ConfigurableSource, UnmeteredSource, HttpSource() {
194183
setOnPreferenceChangeListener { _, newValue ->
195184
try {
196185
val res = preferences.edit().putString(title, newValue as String).commit()
197-
Toast.makeText(context, "Restart Tachiyomi to apply new setting.", Toast.LENGTH_LONG).show()
186+
Toast.makeText(context, "Restart application to apply new setting.", Toast.LENGTH_LONG).show()
198187
res
199188
} catch (e: Exception) {
200189
Log.e("Rokahon", "Exception while setting text preference", e)

rokahon-server/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ CONFIG = ./src/deno.json
55
server:
66
deno run -A --config=$(CONFIG) $(MAIN)
77

8-
# compile:
9-
# deno compile -A --output $(BIN) --config=$(CONFIG) $(MAIN) --is_compiled_binary
8+
compile:
9+
deno compile -A --output $(BIN) --config=$(CONFIG) $(MAIN) --is_compiled_binary
1010

1111
cache:
1212
deno cache --config=$(CONFIG) --lock-write $(MAIN)

0 commit comments

Comments
 (0)