Skip to content

Commit

Permalink
Merge pull request #48 from fleeksoft/release-0.1.5
Browse files Browse the repository at this point in the history
Release 0.1.5
  • Loading branch information
itboy87 authored Aug 23, 2024
2 parents 579adab + 1649d27 commit bb49133
Show file tree
Hide file tree
Showing 181 changed files with 9,523 additions and 2,246 deletions.
3 changes: 0 additions & 3 deletions .fleet/settings.json

This file was deleted.

80 changes: 41 additions & 39 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ jobs:
matrix:
config: [
{ target: android, os: ubuntu-latest, tasks: testDebugUnitTest testReleaseUnitTest, continueOnError: false },
{ target: apple, os: macos-latest, tasks: iosX64Test iosSimulatorArm64Test macosX64Test macosArm64Test tvosX64Test tvosSimulatorArm64Test watchosSimulatorArm64Test, continueOnError: false },
{ target: apple, os: macos-latest, tasks: iosX64Test iosSimulatorArm64Test macosX64Test macosArm64Test tvosX64Test tvosSimulatorArm64Test, continueOnError: false },
{ target: js, os: ubuntu-latest, tasks: jsTest wasmTest, continueOnError: false },
{ target: desktop, os: ubuntu-latest, tasks: jvmTest, continueOnError: false },
{ target: windows, os: windows-latest, tasks: mingwX64Test, continueOnError: false },
{ target: linux, os: windows-latest, tasks: linuxX64Test, continueOnError: false },
]
isKorlibs: [ "true", "false" ]
runs-on: ${{ matrix.config.os }}
name: Build ${{ matrix.config.target }}
name: Build ${{ matrix.config.target }} with isKorlibs=${{ matrix.isKorlibs }}
steps:
- uses: actions/checkout@v3
- name: Setup JDK 17
Expand All @@ -32,9 +34,9 @@ jobs:
- name: Setup gradle
uses: gradle/gradle-build-action@v2

- name: Test ${{ matrix.config.target }} targets
- name: Test ${{ matrix.config.target }} targets with isKorlibs=${{ matrix.isKorlibs }}
continue-on-error: ${{ matrix.config.continueOnError }}
run: ./gradlew ${{ matrix.config.tasks }} --info
run: ./gradlew ${{ matrix.config.tasks }} -PisKorlibs=${{ matrix.isKorlibs }} --info
working-directory: ${{ github.workspace }}

# deploy:
Expand Down Expand Up @@ -63,38 +65,38 @@ jobs:
# ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.GPG_KEY_ID }}
# ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_KEY_PASSWORD }}
#
deploy_docs:
if: github.ref == 'refs/heads/release'
runs-on: macos-latest
needs:
- build
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

steps:
- uses: actions/checkout@v3

- name: Setup JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Setup gradle
uses: gradle/gradle-build-action@v2

- name: Setup Pages
uses: actions/configure-pages@v3

- name: Generate docs with dokka
run: ./gradlew dokkaHtmlMultiModule

- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: ${{ github.workspace }}/build/dokka/htmlMultiModule

- name: Release to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
# deploy_docs:
# if: github.ref == 'refs/heads/release'
# runs-on: macos-latest
# needs:
# - build
# environment:
# name: github-pages
# url: ${{ steps.deployment.outputs.page_url }}
#
# steps:
# - uses: actions/checkout@v3
#
# - name: Setup JDK 17
# uses: actions/setup-java@v3
# with:
# java-version: '17'
# distribution: 'temurin'
#
# - name: Setup gradle
# uses: gradle/gradle-build-action@v2
#
# - name: Setup Pages
# uses: actions/configure-pages@v3
#
# - name: Generate docs with dokka
# run: ./gradlew dokkaHtmlMultiModule
#
# - name: Upload artifact
# uses: actions/upload-pages-artifact@v1
# with:
# path: ${{ github.workspace }}/build/dokka/htmlMultiModule
#
# - name: Release to GitHub Pages
# id: deployment
# uses: actions/deploy-pages@v1
84 changes: 62 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

**Ksoup** is a Kotlin Multiplatform library for working with real-world HTML and XML. It's a port of the renowned Java library, **jsoup**, and offers an easy-to-use API for URL fetching, data parsing, extraction, and manipulation using DOM and CSS selectors.

[![Kotlin](https://img.shields.io/badge/Kotlin-2.0.0-blue.svg?style=flat&logo=kotlin)](https://kotlinlang.org)
[![Kotlin](https://img.shields.io/badge/Kotlin-2.0.10-blue.svg?style=flat&logo=kotlin)](https://kotlinlang.org)
[![Apache-2.0](https://img.shields.io/badge/License-Apache%202.0-green.svg)](https://opensource.org/licenses/Apache-2.0)
[![Maven Central](https://img.shields.io/maven-central/v/com.fleeksoft.ksoup/ksoup.svg)](https://central.sonatype.com/artifact/com.fleeksoft.ksoup/ksoup)

![badge-android](http://img.shields.io/badge/platform-android-6EDB8D.svg?style=flat)
![badge-ios](http://img.shields.io/badge/platform-ios-CDCDCD.svg?style=flat)
![badge-mac](http://img.shields.io/badge/platform-macos-111111.svg?style=flat)
![badge-watchos](http://img.shields.io/badge/platform-watchos-C0C0C0.svg?style=flat)
![badge-tvos](http://img.shields.io/badge/platform-tvos-808080.svg?style=flat)
![badge-jvm](http://img.shields.io/badge/platform-jvm-DB413D.svg?style=flat)
![badge-linux](http://img.shields.io/badge/platform-linux-2D3F6C.svg?style=flat)
Expand All @@ -31,17 +30,40 @@ Ksoup is adept at handling all varieties of HTML found in the wild.
## Getting started
### Ksoup is published on Maven Central
Include the dependency in `commonMain`. Latest version [![Maven Central](https://img.shields.io/maven-central/v/com.fleeksoft.ksoup/ksoup.svg)](https://central.sonatype.com/artifact/com.fleeksoft.ksoup/ksoup)
```Kotlin
commonMain.dependencies {
implementation("com.fleeksoft.ksoup:ksoup:<version>")

// Optional: Include only if you need to use network request functions such as
// Ksoup.parseGetRequest, Ksoup.parseSubmitRequest, and Ksoup.parsePostRequest
implementation("com.fleeksoft.ksoup:ksoup-network:<version>")
}
```
Ksoup published in three variants. Pick the one that suits your needs and start building!
1. **This variant built with [kotlinx-io](https://github.com/Kotlin/kotlinx-io) and [Ktor 3.0.0-beta-2](https://github.com/ktorio/ktor)**
```kotlin
implementation("com.fleeksoft.ksoup:ksoup:<version>")

// Optional: Include only if you need to use network request functions such as
// Ksoup.parseGetRequest, Ksoup.parseSubmitRequest, and Ksoup.parsePostRequest
implementation("com.fleeksoft.ksoup:ksoup-network:<version>")
```

2. **This variant built with [kotlinx-io](https://github.com/Kotlin/kotlinx-io) and [Ktor 2.3.12](https://github.com/ktorio/ktor)**
```kotlin
implementation("com.fleeksoft.ksoup:ksoup-ktor2:<version>")

// Optional: Include only if you need to use network request functions such as
// Ksoup.parseGetRequest, Ksoup.parseSubmitRequest, and Ksoup.parsePostRequest
implementation("com.fleeksoft.ksoup:ksoup-network-ktor2:<version>")
```

3. **This variant is built with [korlibs-io](https://github.com/korlibs/korlibs-io)**
```kotlin
implementation("com.fleeksoft.ksoup:ksoup-korlibs:<version>")

// Optional: Include only if you need to use network request functions such as
// Ksoup.parseGetRequest, Ksoup.parseSubmitRequest, and Ksoup.parsePostRequest
implementation("com.fleeksoft.ksoup:ksoup-network-korlibs:<version>")
```

**NOTE:** Variants built with kotlinx do not support gzip files.


### Parsing HTML from a String with Ksoup
For API documentation you can check [Jsoup](https://jsoup.org/). Most of the APIs work without any changes.
```kotlin
val html = "<html><head><title>One</title></head><body>Two</body></html>"
val doc: Document = Ksoup.parse(html = html)
Expand Down Expand Up @@ -69,8 +91,26 @@ headlines.forEach { headline: Element ->
}
```
In this example, `Ksoup.parseGetRequest` fetches and parses HTML content from Wikipedia, extracting and printing news headlines and their corresponding links.

#### For further documentation, please check here: [Ksoup](https://fleeksoft.github.io/ksoup/)
### Ksoup Public functions
- Ksoup.parse
- Ksoup.parseFile
- Ksoup.clean
- Ksoup.isValid

### Ksoup Network Public functions
- Suspend functions
- Ksoup.parseGetRequest
- Ksoup.parseSubmitRequest
- Ksoup.parsePostRequest
- Blocking functions
- Ksoup.parseGetRequestBlocking
- Ksoup.parseSubmitRequestBlocking
- Ksoup.parsePostRequestBlocking

#### For further documentation, please check here: [Jsoup](https://jsoup.org/)

### Ksoup vs. Jsoup Performance: Parsing & Selecting 448KB HTML File [test.tx](https://github.com/fleeksoft/ksoup/blob/develop/ksoup-test/testResources/test.txt)
![Ksoup vs Jsoup](performance.png)

## Open source
Ksoup is an open source project, a Kotlin Multiplatform port of jsoup, distributed under the Apache License, Version 2.0. The source code of Ksoup is available on [GitHub](https://github.com/fleeksoft/ksoup).
Expand All @@ -85,16 +125,16 @@ To report any issues, visit our [GitHub issues](https://github.com/fleeksoft/kso

## Library Status

| Platform | Status | Notes |
|----------------|--------------|-------|
| Android | Stable | |
| JVM | Stable | |
| iOS | Stable | |
| JS | Alpha | |
| WasmJs | Alpha | |
| Native MacOS | Alpha | |
| Linux | Experimental | |
| Native Windows | Experimental | |
| Platform | Status | Notes |
|----------------|--------------|--------------------------|
| Android | Stable | |
| JVM | Stable | |
| iOS | Stable | |
| JS | Alpha | |
| WasmJs | Alpha | not supported with ktor2 |
| Native MacOS | Alpha | |
| Linux | Experimental | |
| Native Windows | Experimental | |



Expand Down
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ kotlin.code.style=official

#Android
android.useAndroidX=true
android.nonTransitiveRClass=true
android.nonTransitiveRClass=true

isKorlibs = false
20 changes: 11 additions & 9 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,42 +1,44 @@
[versions]
agp = "8.2.2" #kmp max gradle support 8.2 right now
#kotlin = "1.9.24"
kotlin = "2.0.0"
kotlin = "2.0.10"
compileSdk = "34"
minSdk = "21"
libraryVersion = "0.1.4"
ktor = "2.3.12"
libraryVersion = "0.1.5"
ktor = "3.0.0-beta-2"
coroutines = "1.8.1"
okio = "3.9.0"
kotlinxDatetime = "0.6.0"
kotlinx-io = "0.3.5"
kotlinxDatetime = "0.6.1"
kotlinx-io = "0.5.3"
codepoints = "0.9.0"
dokka = "1.9.20"

#korlibs = "999.0.0.999" # 999.0.0.999 is local version
korlibs = "6.0.0"
korlibs = "6.0.1"
mavenPublish = "0.29.0"

stately-concurrent = "2.0.7"
jsoup = "1.18.1"

[libraries]
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" }
ktor-io = { module = "io.ktor:ktor-io", version.ref = "ktor" }
ktor-http = { module = "io.ktor:ktor-http", version.ref = "ktor" }
ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
ktor-client-logging = { module = "io.ktor:ktor-client-logging", version.ref = "ktor" }
ktor-client-darwin = { module = "io.ktor:ktor-client-darwin", version.ref = "ktor" }
ktor-client-cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" }
ktor-client-okhttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktor" }
ktor-client-js = { module = "io.ktor:ktor-client-js", version.ref = "ktor" }
ktor-client-win = { module = "io.ktor:ktor-client-winhttp", version.ref = "ktor" }
okio = { module = "com.squareup.okio:okio", version.ref = "okio" }
okio-nodefilesystem = { module = "com.squareup.okio:okio-nodefilesystem", version.ref = "okio" }
kotlinx-datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinxDatetime" }
kotlinx-io = { module = "org.jetbrains.kotlinx:kotlinx-io-core", version.ref = "kotlinx-io" }
codepoints = { module = "de.cketti.unicode:kotlin-codepoints-deluxe", version.ref = "codepoints" }
korlibs-io = { module = "com.soywiz:korlibs-io", version.ref = "korlibs" }
korlibs-io-network-core = { module = "com.soywiz:korlibs-io-network-core", version.ref = "korlibs" }
stately-concurrent = { module = "co.touchlab:stately-concurrent-collections", version.ref = "stately-concurrent" }
jsoup = { module = "org.jsoup:jsoup", version.ref = "jsoup" }

[plugins]
androidLibrary = { id = "com.android.library", version.ref = "agp" }
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
37 changes: 37 additions & 0 deletions ksoup-engine-common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
plugins {
alias(libs.plugins.mavenPublish)
}

group = "com.fleeksoft.ksoup"
version = libs.versions.libraryVersion.get()

val artifactId = "ksoup-engine-common"
mavenPublishing {
coordinates("com.fleeksoft.ksoup", artifactId, libs.versions.libraryVersion.get())
pom {
name.set(artifactId)
description.set("Ksoup is a Kotlin Multiplatform library for working with HTML and XML, and offers an easy-to-use API for URL fetching, data parsing, extraction, and manipulation using DOM and CSS selectors.")
licenses {
license {
name.set("Apache-2.0")
url.set("https://opensource.org/licenses/Apache-2.0")
}
}
url.set("https://github.com/fleeksoft/ksoup")
issueManagement {
system.set("Github")
url.set("https://github.com/fleeksoft/ksoup/issues")
}
scm {
connection.set("https://github.com/fleeksoft/ksoup.git")
url.set("https://github.com/fleeksoft/ksoup")
}
developers {
developer {
name.set("Sabeeh Ul Hussnain Anjum")
email.set("[email protected]")
organization.set("Fleek Soft")
}
}
}
}
8 changes: 8 additions & 0 deletions ksoup-engine-common/module.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
product:
type: lib
platforms: [jvm, js, wasm, android, linuxX64, linuxArm64, tvosArm64, tvosX64, tvosSimulatorArm64, macosX64, macosArm64, iosArm64, iosSimulatorArm64, iosX64, mingwX64]

apply: [ ../common.module-template.yaml ]

aliases:
- jvmAndAndroid: [jvm, android]
19 changes: 19 additions & 0 deletions ksoup-engine-common/src/com/fleeksoft/ksoup/engine/KsoupEngine.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.fleeksoft.ksoup.engine

import com.fleeksoft.ksoup.io.Charset
import com.fleeksoft.ksoup.io.FileSource
import com.fleeksoft.ksoup.io.SourceReader

interface KsoupEngine {
fun urlResolveOrNull(base: String, relUrl: String): String?

fun openSourceReader(content: String, charset: Charset? = null): SourceReader

fun openSourceReader(byteArray: ByteArray): SourceReader

fun getUtf8Charset(): Charset

fun charsetForName(name: String): Charset

fun pathToFileSource(path: String): FileSource
}
Loading

0 comments on commit bb49133

Please sign in to comment.