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>()
|
val list = ArrayList<Circular>()
|
||||||
|
|
||||||
for (i in 0 until htmlList.size) {
|
for (i in 0 until htmlList.size) {
|
||||||
list.add(
|
porporatoServer.generateFromString(
|
||||||
porporatoServer.generateFromString(
|
htmlList[i].text(),
|
||||||
htmlList[i].text(),
|
htmlList[i].attr("href"),
|
||||||
htmlList[i].attr("href"),
|
i.toLong()
|
||||||
i.toLong()
|
)?.let {
|
||||||
|
list.add(
|
||||||
|
it
|
||||||
)
|
)
|
||||||
)
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return list
|
return list
|
||||||
|
|||||||
@@ -67,7 +67,6 @@ class CurieServer(ktorClient: HttpClient) : Server(ktorClient) {
|
|||||||
return Pair(true, ServerAPI.Companion.Result.SUCCESS)
|
return Pair(true, ServerAPI.Companion.Result.SUCCESS)
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalStdlibApi::class)
|
|
||||||
@Throws(IOException::class, CancellationException::class)
|
@Throws(IOException::class, CancellationException::class)
|
||||||
private suspend fun retrieveDataFromServer(): Response {
|
private suspend fun retrieveDataFromServer(): Response {
|
||||||
return ktorClient.get(ENDPOINT_URL)
|
return ktorClient.get(ENDPOINT_URL)
|
||||||
|
|||||||
@@ -75,7 +75,6 @@ class PorporatoServer(ktorClient: HttpClient) : Server(ktorClient) {
|
|||||||
return Pair(true, ServerAPI.Companion.Result.SUCCESS)
|
return Pair(true, ServerAPI.Companion.Result.SUCCESS)
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalStdlibApi::class)
|
|
||||||
@Throws(IOException::class, CancellationException::class)
|
@Throws(IOException::class, CancellationException::class)
|
||||||
private suspend fun parsePage(url: String): List<Circular> {
|
private suspend fun parsePage(url: String): List<Circular> {
|
||||||
val response = retrieveDataFromServer(url)
|
val response = retrieveDataFromServer(url)
|
||||||
@@ -120,13 +119,12 @@ class PorporatoServer(ktorClient: HttpClient) : Server(ktorClient) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalStdlibApi::class)
|
|
||||||
@Throws(IOException::class, CancellationException::class)
|
@Throws(IOException::class, CancellationException::class)
|
||||||
private suspend fun retrieveDataFromServer(url: String): String {
|
private suspend fun retrieveDataFromServer(url: String): String {
|
||||||
return ktorClient.request<HttpResponse>(url).readText(Charsets.ISO_8859_1)
|
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
|
val fullUrl = baseUrl + path
|
||||||
var title = string
|
var title = string
|
||||||
|
|
||||||
@@ -152,7 +150,7 @@ class PorporatoServer(ktorClient: HttpClient) : Server(ktorClient) {
|
|||||||
title = title.removeRange(dateMatcher.range)
|
title = title.removeRange(dateMatcher.range)
|
||||||
.removeSuffix(" (pubb.: )")
|
.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 {
|
} else {
|
||||||
Circular(id, serverID, title, fullUrl, fullUrl, "")
|
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)
|
@Throws(IOException::class, CancellationException::class)
|
||||||
private suspend fun parsePage(page: Int): List<Circular> {
|
private suspend fun parsePage(page: Int): List<Circular> {
|
||||||
val posts = retrievePageFromServer(page)
|
val posts = retrievePageFromServer(page)
|
||||||
@@ -83,7 +82,6 @@ abstract class GenericPreverServer(ktorClient: HttpClient) : Server(ktorClient)
|
|||||||
return Pair(true, ServerAPI.Companion.Result.SUCCESS)
|
return Pair(true, ServerAPI.Companion.Result.SUCCESS)
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalStdlibApi::class)
|
|
||||||
@Throws(IOException::class, CancellationException::class)
|
@Throws(IOException::class, CancellationException::class)
|
||||||
private suspend fun retrievePageFromServer(page: Int): List<Post> {
|
private suspend fun retrievePageFromServer(page: Int): List<Post> {
|
||||||
return try {
|
return try {
|
||||||
|
|||||||
@@ -35,13 +35,15 @@ actual class SpecificPorporatoServer actual constructor(private val porporatoSer
|
|||||||
return list
|
return list
|
||||||
|
|
||||||
for (i in htmlList.indices) {
|
for (i in htmlList.indices) {
|
||||||
list.add(
|
porporatoServer.generateFromString(
|
||||||
porporatoServer.generateFromString(
|
htmlList[i].textContent,
|
||||||
htmlList[i].textContent,
|
htmlList[i].attributes.objectForKey("href").toString(),
|
||||||
htmlList[i].attributes.objectForKey("href").toString(),
|
i.toLong()
|
||||||
i.toLong()
|
)?.let {
|
||||||
|
list.add(
|
||||||
|
it
|
||||||
)
|
)
|
||||||
)
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return list
|
return list
|
||||||
|
|||||||
Reference in New Issue
Block a user