mirror of
https://github.com/Matte23/circolapp.git
synced 2025-12-06 07:29:10 +00:00
Some syntax changes before resuming project
This commit is contained in:
@@ -31,13 +31,15 @@ actual class SpecificPorporatoServer actual constructor(private val porporatoSer
|
||||
val list = ArrayList<Circular>()
|
||||
|
||||
for (i in 0 until htmlList.size) {
|
||||
list.add(
|
||||
porporatoServer.generateFromString(
|
||||
htmlList[i].text(),
|
||||
htmlList[i].attr("href"),
|
||||
i.toLong()
|
||||
porporatoServer.generateFromString(
|
||||
htmlList[i].text(),
|
||||
htmlList[i].attr("href"),
|
||||
i.toLong()
|
||||
)?.let {
|
||||
list.add(
|
||||
it
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return list
|
||||
|
||||
@@ -67,7 +67,6 @@ class CurieServer(ktorClient: HttpClient) : Server(ktorClient) {
|
||||
return Pair(true, ServerAPI.Companion.Result.SUCCESS)
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalStdlibApi::class)
|
||||
@Throws(IOException::class, CancellationException::class)
|
||||
private suspend fun retrieveDataFromServer(): Response {
|
||||
return ktorClient.get(ENDPOINT_URL)
|
||||
|
||||
@@ -75,7 +75,6 @@ class PorporatoServer(ktorClient: HttpClient) : Server(ktorClient) {
|
||||
return Pair(true, ServerAPI.Companion.Result.SUCCESS)
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalStdlibApi::class)
|
||||
@Throws(IOException::class, CancellationException::class)
|
||||
private suspend fun parsePage(url: String): List<Circular> {
|
||||
val response = retrieveDataFromServer(url)
|
||||
@@ -120,13 +119,12 @@ class PorporatoServer(ktorClient: HttpClient) : Server(ktorClient) {
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalStdlibApi::class)
|
||||
@Throws(IOException::class, CancellationException::class)
|
||||
private suspend fun retrieveDataFromServer(url: String): String {
|
||||
return ktorClient.request<HttpResponse>(url).readText(Charsets.ISO_8859_1)
|
||||
}
|
||||
|
||||
fun generateFromString(string: String, path: String, index: Long): Circular {
|
||||
fun generateFromString(string: String, path: String, index: Long): Circular? {
|
||||
val fullUrl = baseUrl + path
|
||||
var title = string
|
||||
|
||||
@@ -152,7 +150,7 @@ class PorporatoServer(ktorClient: HttpClient) : Server(ktorClient) {
|
||||
title = title.removeRange(dateMatcher.range)
|
||||
.removeSuffix(" (pubb.: )")
|
||||
|
||||
Circular(id, serverID, title, fullUrl, fullUrl, dateMatcher.value.replace("-", "/"))
|
||||
if (title != "") Circular(id, serverID, title, fullUrl, fullUrl, dateMatcher.value.replace("-", "/")) else null
|
||||
} else {
|
||||
Circular(id, serverID, title, fullUrl, fullUrl, "")
|
||||
}
|
||||
|
||||
@@ -59,7 +59,6 @@ abstract class GenericPreverServer(ktorClient: HttpClient) : Server(ktorClient)
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalStdlibApi::class)
|
||||
@Throws(IOException::class, CancellationException::class)
|
||||
private suspend fun parsePage(page: Int): List<Circular> {
|
||||
val posts = retrievePageFromServer(page)
|
||||
@@ -83,7 +82,6 @@ abstract class GenericPreverServer(ktorClient: HttpClient) : Server(ktorClient)
|
||||
return Pair(true, ServerAPI.Companion.Result.SUCCESS)
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalStdlibApi::class)
|
||||
@Throws(IOException::class, CancellationException::class)
|
||||
private suspend fun retrievePageFromServer(page: Int): List<Post> {
|
||||
return try {
|
||||
|
||||
@@ -35,13 +35,15 @@ actual class SpecificPorporatoServer actual constructor(private val porporatoSer
|
||||
return list
|
||||
|
||||
for (i in htmlList.indices) {
|
||||
list.add(
|
||||
porporatoServer.generateFromString(
|
||||
htmlList[i].textContent,
|
||||
htmlList[i].attributes.objectForKey("href").toString(),
|
||||
i.toLong()
|
||||
porporatoServer.generateFromString(
|
||||
htmlList[i].textContent,
|
||||
htmlList[i].attributes.objectForKey("href").toString(),
|
||||
i.toLong()
|
||||
)?.let {
|
||||
list.add(
|
||||
it
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return list
|
||||
|
||||
Reference in New Issue
Block a user