-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
5,791 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<application android:usesCleartextTraffic="true" /> | ||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 8 additions & 17 deletions
25
feedfinder/src/main/java/com/jocmp/feedfinder/DefaultRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,21 @@ | ||
package com.jocmp.feedfinder | ||
|
||
import java.net.HttpURLConnection | ||
import java.net.URL | ||
import java.net.http.HttpClient | ||
import java.net.http.HttpRequest | ||
import java.net.http.HttpResponse | ||
|
||
|
||
internal class DefaultRequest( | ||
private val client: HttpClient = buildClient() | ||
) : Request { | ||
internal class DefaultRequest: Request { | ||
override suspend fun fetch(url: URL): Response { | ||
val request = HttpRequest.newBuilder(url.toURI()) | ||
.GET() | ||
.build() | ||
val parsedURL = URL("https", url.host, url.port, url.file) | ||
val connection = parsedURL.openConnection() as HttpURLConnection | ||
connection.setRequestProperty("User-Agent", USER_AGENT) | ||
|
||
val body = client.send(request, HttpResponse.BodyHandlers.ofString()).body() | ||
val body = connection.inputStream.bufferedReader().readText() | ||
|
||
return Response(body = body) | ||
return Response(url = parsedURL, body = body) | ||
} | ||
|
||
companion object { | ||
fun buildClient(): HttpClient { | ||
return HttpClient | ||
.newBuilder() | ||
.followRedirects(HttpClient.Redirect.ALWAYS) | ||
.build() | ||
} | ||
const val USER_AGENT = "Basil/1.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
feedfinder/src/main/java/com/jocmp/feedfinder/parser/FakeFeed.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
package com.jocmp.feedfinder.parser | ||
|
||
import java.net.URL | ||
|
||
class FakeFeed: Feed { | ||
override fun isValid(): Boolean { | ||
return false | ||
} | ||
|
||
override val feedURL: URL | ||
get() = URL("https://arstechnica.com/feed") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
package com.jocmp.feedfinder.parser | ||
|
||
import java.net.URL | ||
|
||
interface Feed { | ||
fun isValid(): Boolean | ||
|
||
val feedURL: URL | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 0 additions & 9 deletions
9
feedfinder/src/main/java/com/jocmp/feedfinder/sources/BodyLink.kt
This file was deleted.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
feedfinder/src/main/java/com/jocmp/feedfinder/sources/BodyLinkSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.jocmp.feedfinder.sources | ||
|
||
import com.jocmp.feedfinder.parser.Feed | ||
|
||
internal class BodyLinkSource: Source { | ||
override suspend fun find(): List<Feed> { | ||
return emptyList() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 7 additions & 1 deletion
8
feedfinder/src/test/java/com/jocmp/feedfinder/FeedFinderTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
package com.jocmp.feedfinder | ||
|
||
import kotlinx.coroutines.runBlocking | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import kotlin.test.assertEquals | ||
|
||
class FeedFinderTest { | ||
@Test | ||
fun find_returnsASuccess() { | ||
fun find_returnsASuccess() = runBlocking { | ||
val finder = FeedFinder("arstechnica.com") | ||
|
||
finder.find() | ||
|
||
assertEquals("", "") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.