Compare commits

...

11 Commits

Author SHA1 Message Date
renovate[bot]
4d6cc5f29b Update dependency io.ktor:ktor-client-cio to v3.4.1 2026-03-03 13:41:09 +00:00
Julien Lengrand-Lambert
89dbda55b8 Moves up to next version, and fixes demo-remote 2025-10-26 00:00:32 +01:00
julien Lengrand-Lambert
d982bc94cb Adding retro Java 17 compatibility
* Moving back to Java 17 compatibility. I'll change demo-remote a little later, because otherwise I have to break the project for some time.

* Prepares version 0.1.3
2025-10-26 00:43:04 +02:00
Julien Lengrand-Lambert
f829d56a43 Update publishing plugin to 0.34 2025-10-19 03:21:52 +02:00
renovate[bot]
0364ab5d0c Update plugin org.jetbrains.kotlinx.kover to v0.9.3 (#44)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-10-19 03:18:31 +02:00
Julien Lengrand-Lambert
389f16fe1c Update contributing file 2025-10-19 03:17:21 +02:00
Julien Lengrand-Lambert
f2cbbe048d First version of contributing.md 2025-10-19 03:13:08 +02:00
Julien Lengrand-Lambert
4333d077c3 Updates remote demo 2025-10-19 03:09:01 +02:00
Julien Lengrand-Lambert
20dfc326c7 Prepares 0.1.3 2025-10-19 02:59:19 +02:00
Julien Lengrand-Lambert
3ec5410f94 Creates 0.1.2 2025-10-19 02:51:32 +02:00
julien Lengrand-Lambert
12de34aa60 Feat/updates 10 25 (#42)
* Update dependency com.fleeksoft.ksoup:ksoup-network to v0.2.5 (#40)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Update whole ksoup to 0.2.5

* Update dependency gradle to v8.14.3 (#37)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Update dependency org.junit:junit-bom to v5.14.0 (#36)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Update dependency gradle to v8.14.3 (#43)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Update plugin org.jetbrains.kotlin.jvm to v2.2.20 (#35)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Update ktor from scraper

* Update settings

* Update settings

* Update gradle/actions action to v4.4.4 (#31)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Adds claude init

* Upgrades to Java 24

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-10-19 02:48:47 +02:00
13 changed files with 273 additions and 29 deletions

View File

@@ -34,7 +34,7 @@ jobs:
# Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies.
# See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md
- name: Setup Gradle
uses: gradle/actions/setup-gradle@8379f6a1328ee0e06e2bb424dadb7b159856a326 # v4.4.0
uses: gradle/actions/setup-gradle@748248ddd2a24f49513d8f472f81c3a07d4d50e1 # v4.4.4
- name: Build with Gradle Wrapper
run: ./gradlew build
@@ -57,7 +57,7 @@ jobs:
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@8379f6a1328ee0e06e2bb424dadb7b159856a326 # v4.4.0
uses: gradle/actions/setup-gradle@748248ddd2a24f49513d8f472f81c3a07d4d50e1 # v4.4.4
- name: Build with Gradle Wrapper
run: ./gradlew koverXmlReport
@@ -88,5 +88,5 @@ jobs:
# Generates and submits a dependency graph, enabling Dependabot Alerts for all project dependencies.
# See: https://github.com/gradle/actions/blob/main/dependency-submission/README.md
- name: Generate and submit dependency graph
uses: gradle/actions/dependency-submission@8379f6a1328ee0e06e2bb424dadb7b159856a326 # v4.4.0
uses: gradle/actions/dependency-submission@748248ddd2a24f49513d8f472f81c3a07d4d50e1 # v4.4.4

6
.idea/AndroidProjectSystem.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AndroidProjectSystem">
<option name="providerId" value="com.android.tools.idea.GradleProjectSystem" />
</component>
</project>

2
.idea/kotlinc.xml generated
View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="KotlinJpsPluginSettings">
<option name="version" value="2.1.21" />
<option name="version" value="2.2.20" />
</component>
</project>

2
.idea/misc.xml generated
View File

@@ -4,7 +4,7 @@
<component name="FrameworkDetectionExcludesConfiguration">
<file type="web" url="file://$PROJECT_DIR$" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="temurin-21" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="temurin-21" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

74
CLAUDE.md Normal file
View File

@@ -0,0 +1,74 @@
# CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## Project Overview
OpenGraphKt is a minimalist Kotlin multiplatform library for parsing Open Graph protocol tags from HTML. It wraps Ksoup (a Kotlin port of JSoup) to extract and structure Open Graph metadata.
**Current Status**: Pre-alpha - Protocol implementation is complete for `og:` tags, but type system needs refinement.
## Project Structure
This is a multi-module Gradle project:
- `opengraphkt/` - Core library module (published to Maven Central as `fr.lengrand:opengraphkt`)
- `demo/` - Local file parsing examples
- `demo-remote/` - Remote URL parsing examples (see Main.kt for usage)
- `scrape-test/` - Testing/scraping utilities
## Common Commands
### Build and Test
```bash
./gradlew build # Build all modules
./gradlew test # Run all tests
./gradlew :opengraphkt:test # Run tests for core library only
```
### Code Coverage
```bash
./gradlew koverXmlReport # Generate XML coverage report
./gradlew koverVerify # Verify coverage meets 70% minimum threshold
```
### Publishing
```bash
./gradlew publishToMavenLocal # Publish to local Maven repo for testing
```
## Architecture
### Core Components
**Parser (`Parser.kt`)**: Main entry point that accepts multiple input types:
- `parse(url: URL)` - Fetches and parses remote HTML
- `parse(html: String)` - Parses raw HTML string
- `parse(file: File)` - Parses local HTML file
- `parse(document: Document)` - Parses Ksoup Document
The parser extracts `meta[property^=og:]` tags and builds structured data models.
**Data Models (`Models.kt`)**: Type-safe representations of Open Graph data:
- `Data` - Main container with `isValid()` method checking required fields (title, type, image, url)
- Base types: `Image`, `Video`, `Audio`
- Content-specific types: `Article`, `Book`, `Profile`
- Music types: `MusicSong`, `MusicAlbum`, `MusicPlaylist`, `MusicRadioStation`
- Video types: `VideoMovie`, `VideoEpisode`
### Key Implementation Details
**Tag Grouping**: Tags are grouped by namespace (prefix before first colon) to handle structured properties like `og:image:width`, `og:image:height` that belong to the preceding `og:image` tag.
**Date Handling**: ISO 8601 datetime parsing with fallback for date-only formats (appends `T00:00:00Z`).
**Structured Property Association**: Images/Videos/Audio with their metadata (width, height, type, etc.) are associated by parsing sequential tags - each base tag (`og:image`) is paired with following attribute tags (`og:image:width`) until the next base tag.
## Development Notes
- **JVM Toolchain**: Java 17 (see `jvmToolchain(17)` in build files)
- **Minimum Java Version**: Java 17 (required by Ksoup dependency)
- **Testing**: CI matrix tests on Java 17 and 23 via GitHub Actions
- **Dependencies**: Core library uses Ksoup (v0.2.5) for HTML parsing and network requests
- **Maven Coordinates**: Group `fr.lengrand`, artifact `opengraphkt`, currently at `0.1.2-SNAPSHOT`
- **Code Coverage**: Kover plugin enforces 70% minimum coverage threshold

158
CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,158 @@
# Contributing to OpenGraphKt
Thank you for your interest in contributing to OpenGraphKt! This document provides guidelines and instructions for contributing to the project.
## Development Setup
### Prerequisites
- Java 17 or later (JVM toolchain configured for Java 17)
- Gradle 8.14.3+ (wrapper included)
- Git
### Getting Started
1. Clone the repository:
```bash
git clone https://github.com/jlengrand/OpenGraphKt.git
cd OpenGraphKt
```
2. Build the project:
```bash
./gradlew build
```
3. Run tests:
```bash
./gradlew test
```
4. Check code coverage:
```bash
./gradlew koverXmlReport
./gradlew koverVerify # Enforces 70% minimum coverage
```
## Project Structure
- `opengraphkt/` - Core library module (published to Maven Central)
- `demo/` - Local file parsing examples
- `demo-remote/` - Remote URL parsing examples using published artifact
- `scrape-test/` - Testing/scraping utilities
## Making Changes
### Code Style
- Follow Kotlin coding conventions
- Use meaningful variable and function names
- Add KDoc comments for public APIs
### Testing
- Write tests for all new functionality
- Maintain minimum 70% code coverage (enforced by Kover)
- Run tests locally before submitting PR: `./gradlew test`
### Commits
- Write clear, concise commit messages
- Reference issue numbers when applicable
- Keep commits focused and atomic
## Submitting Changes
1. Fork the repository
2. Create a feature branch: `git checkout -b feature/your-feature-name`
3. Make your changes
4. Run tests and ensure coverage: `./gradlew test koverVerify`
5. Commit your changes
6. Push to your fork
7. Submit a Pull Request
## Publishing New Versions
This section is for maintainers only.
### Version Numbering
OpenGraphKt follows [Semantic Versioning](https://semver.org/):
- **MAJOR** version for incompatible API changes
- **MINOR** version for backwards-compatible functionality additions
- **PATCH** version for backwards-compatible bug fixes
### Pre-Release Checklist
1. **Update version number** in `opengraphkt/build.gradle.kts`:
```kotlin
version = "0.1.3-SNAPSHOT" // Change to "0.1.3" for release
```
2. **Update demo-remote dependency** in `demo-remote/build.gradle.kts`:
```kotlin
dependencies {
implementation("fr.lengrand:opengraphkt:0.1.3") // Match release version
}
```
3. **Run full test suite**:
```bash
./gradlew clean build test koverVerify
```
4. **Test demo applications**:
```bash
./gradlew :demo:run
./gradlew :demo-remote:run
```
### Publishing to Maven Central
The project uses the `com.vanniktech.maven.publish` plugin for publishing. Publishing is automated through GitHub Actions.
1. **Bump version ** in `opengraphkt/build.gradle.kts`:
```kotlin
version = "0.1.4"
```
2. **Publish to local Maven for testing** (optional):
```bash
./gradlew publishToMavenLocal
```
3. **Create GitHub release** (this triggers the publishing workflow):
- Go to GitHub repository → Releases → "Draft a new release"
- Click "Choose a tag" and create a new tag (e.g., `v0.1.3`)
- Set the release title (e.g., `v0.1.3`)
- Add release notes describing changes
- Click "Publish release"
4. **GitHub Actions will automatically**:
- Build the project
- Run tests
- Publish to Maven Central
- The workflow is triggered automatically when you create a new release
5. After a few minutes, you will see the new version in [Maven Central](https://mvnrepository.com/artifact/fr.lengrand/opengraphkt). You can also directly check the real-time status on [Central Sonartype](https://central.sonatype.com/publishing/deployments).
### Post-Release Steps
1. **Bump version to next SNAPSHOT** in `opengraphkt/build.gradle.kts`:
```kotlin
version = "0.1.5-SNAPSHOT"
```
2. **Commit version bump**:
```bash
git commit -am "Bump version to 0.1.5-SNAPSHOT"
git push
```
## Questions?
If you have questions or need help, please:
- Open an issue on GitHub
- Check existing issues and discussions
Thank you for contributing to OpenGraphKt!

View File

@@ -1,3 +1,3 @@
plugins {
kotlin("jvm") version "2.1.21" apply false
kotlin("jvm") version "2.2.20" apply false
}

View File

@@ -10,7 +10,7 @@ repositories {
}
dependencies {
implementation("fr.lengrand:opengraphkt:0.1.0")
implementation("fr.lengrand:opengraphkt:0.1.3")
testImplementation(kotlin("test"))
}
@@ -19,9 +19,9 @@ tasks.test {
}
kotlin {
jvmToolchain(23)
jvmToolchain(17)
}
application {
mainClass = "fr.lengrand.opengraphkt.MainKt"
mainClass = "fr.lengrand.opengraphktremote.MainKt"
}

View File

@@ -12,9 +12,9 @@ repositories {
}
dependencies {
implementation("com.fleeksoft.ksoup:ksoup:0.2.4")
implementation("com.fleeksoft.ksoup:ksoup-kotlinx:0.2.4")
implementation("com.fleeksoft.ksoup:ksoup-network:0.2.4")
implementation("com.fleeksoft.ksoup:ksoup:0.2.5")
implementation("com.fleeksoft.ksoup:ksoup-kotlinx:0.2.5")
implementation("com.fleeksoft.ksoup:ksoup-network:0.2.5")
implementation(project(":opengraphkt"))
testImplementation(kotlin("test"))
}
@@ -24,7 +24,7 @@ tasks.test {
}
kotlin {
jvmToolchain(23)
jvmToolchain(17)
}
application {

View File

@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME

View File

@@ -1,22 +1,20 @@
import com.vanniktech.maven.publish.SonatypeHost
plugins {
kotlin("jvm")
id("com.vanniktech.maven.publish") version "0.32.0"
id("org.jetbrains.kotlinx.kover") version "0.9.1"
id("com.vanniktech.maven.publish") version "0.34.0"
id("org.jetbrains.kotlinx.kover") version "0.9.3"
}
group = "fr.lengrand"
version = "0.1.2-SNAPSHOT"
version = "0.1.4-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
implementation("com.fleeksoft.ksoup:ksoup:0.2.4")
implementation("com.fleeksoft.ksoup:ksoup-kotlinx:0.2.4")
implementation("com.fleeksoft.ksoup:ksoup-network:0.2.4")
implementation("com.fleeksoft.ksoup:ksoup:0.2.5")
implementation("com.fleeksoft.ksoup:ksoup-kotlinx:0.2.5")
implementation("com.fleeksoft.ksoup:ksoup-network:0.2.5")
testImplementation(kotlin("test"))
}
@@ -35,12 +33,20 @@ tasks.jar {
}
}
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlin {
jvmToolchain(23)
jvmToolchain(17)
compilerOptions {
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17)
}
}
mavenPublishing {
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
publishToMavenCentral()
signAllPublications()

View File

@@ -11,18 +11,18 @@ repositories {
}
dependencies {
testImplementation(platform("org.junit:junit-bom:5.13.1"))
testImplementation(platform("org.junit:junit-bom:5.14.0"))
testImplementation("org.junit.jupiter:junit-jupiter")
implementation(kotlin("stdlib-jdk8"))
implementation(project(":opengraphkt"))
implementation("io.ktor:ktor-client-core:3.1.3")
implementation("io.ktor:ktor-client-cio:3.1.3")
implementation("io.ktor:ktor-client-core:3.3.1")
implementation("io.ktor:ktor-client-cio:3.4.1")
}
tasks.test {
useJUnitPlatform()
}
kotlin {
jvmToolchain(23)
jvmToolchain(17)
}

View File

@@ -1,6 +1,6 @@
pluginManagement {
plugins {
kotlin("jvm") version "2.1.21"
kotlin("jvm") version "2.2.20"
}
}
plugins {