Skip to content

Commit

Permalink
Merge pull request #9 from LimeBeck/release/v0.3.0
Browse files Browse the repository at this point in the history
V0.3.0
  • Loading branch information
LimeBeck authored May 4, 2024
2 parents 0e487e6 + 51409aa commit 37272a2
Show file tree
Hide file tree
Showing 30 changed files with 1,155 additions and 227 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.idea
**/build
kotlin-js-store
.kotlin
14 changes: 1 addition & 13 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
plugins {
kotlin("multiplatform")
alias(libs.plugins.kotlin.multiplatform) apply false
alias(libs.plugins.versions)
}

repositories {
mavenCentral()
}

kotlin {
jvm {}
sourceSets {
val commonMain by getting {
dependencies {

}
}
// val jvmMain by getting
}
}
5 changes: 3 additions & 2 deletions example/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
val revealKtVersion = "0.0.2"
val revealKtVersion = "0.3.0"
group = "com.example"
version = "1.0.0-SNAPSHOT"

plugins {
kotlin("jvm") version "1.7.20"
kotlin("jvm") version "2.0.0-RC2"
}

repositories {
mavenLocal()
mavenCentral()
}

Expand Down
14 changes: 14 additions & 0 deletions example/presentation/TestPresentation.reveal.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
@file:DependsOn("dev.limebeck:ko-te-jvm:0.2.5")

import dev.limebeck.revealkt.core.RevealKt
import qrcode.color.Colors

import dev.limebeck.templateEngine.KoTeRenderer
import kotlinx.coroutines.runBlocking

runBlocking {
KoTeRenderer().render(
"""
Test {{ data }}
""".trimIndent(),
data = mapOf("data" to "Test")
).let(::println)
}

title = "Hello from my presentation"

configuration {
Expand Down
9 changes: 1 addition & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@ kotlin.js.generate.executable.default=false
kotlin.js.generate.externals=true
yarn.ignoreScripts = false

kotlinVersion=1.9.20

revealKtVersion=0.2.4

kotlinCoroutinesVersion=1.8.0
ktorVersion=2.1.3
dokkaVersion=1.9.10

revealKtVersion=0.3.0

repo.uri=https://maven.pkg.github.com/LimeBeck/reveal-kt
30 changes: 20 additions & 10 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
[versions]

kotlin = "1.9.0"
kotlin = "2.0.0-RC2"
serialization = "1.6.3"
ktor = "2.1.3"
ktor = "2.3.10"
kxhtml = "0.11.0"
dokka = "1.9.20"
arrow = "1.2.4"

[libraries]
slf4j = { module = "org.slf4j:slf4j-api", version = "2.0.7" }
logback = { module = "ch.qos.logback:logback-classic", version = "1.5.0"}
clikt = { module = "com.github.ajalt.clikt:clikt", version = "4.2.2" }
logback = { module = "ch.qos.logback:logback-classic", version = "1.5.6" }
clikt = { module = "com.github.ajalt.clikt:clikt", version = "4.4.0" }
kxhtml-jvm = { module = "org.jetbrains.kotlinx:kotlinx-html-jvm", version.ref = "kxhtml" }
kxhtml = { module = "org.jetbrains.kotlinx:kotlinx-html", version.ref = "kxhtml" }
uuid = { module = "com.benasher44:uuid", version = "0.8.2" }
uuid = { module = "com.benasher44:uuid", version = "0.8.4" }
qrcode = { module = "io.github.g0dkar:qrcode-kotlin", version = "4.1.1" }
playwright = { module = "com.microsoft.playwright:playwright", version = "1.41.2" }
playwright = { module = "com.microsoft.playwright:playwright", version = "1.43.0" }
kotlin-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.strictly = "1.8.0" }
kotlin-serialization = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "serialization" }
arrow-core = { module = "io.arrow-kt:arrow-core", version.ref = "arrow" }
arrow-ksp = { module = "io.arrow-kt:arrow-optics-ksp-plugin", version.ref = "arrow" }
arrow-optics = { module = "io.arrow-kt:arrow-optics", version.ref = "arrow" }

[plugins]

versions = { id = "com.github.ben-manes.versions", version = "0.51.0" }
dokka = { id = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "kotlin" }
build-config = { id = "dev.limebeck.build-time-config", version = "2.2.0"}
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
build-config = { id = "dev.limebeck.build-time-config", version = "2.2.1" }
ktor = { id = "io.ktor.plugin", version.ref = "ktor" }
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
ksp = { id = "com.google.devtools.ksp", version = "2.0.0-RC2-1.0.20" }
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
17 changes: 9 additions & 8 deletions reveal-kt/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

plugins {
kotlin("multiplatform")
kotlin("plugin.serialization")
alias(libs.plugins.kotlin.multiplatform)
alias(libs.plugins.kotlin.serialization)
application
id("com.github.johnrengelman.shadow") version "8.1.1"
id("maven-publish")
id("signing")
id("org.jetbrains.dokka")
alias(libs.plugins.dokka)
alias(libs.plugins.build.config)
}

Expand All @@ -22,11 +22,12 @@ repositories {

buildTimeConfig {
config {
destination.set(project.buildDir)
destination.set(project.layout.buildDirectory.get().asFile)
objectName.set("RevealkConfig")
packageName.set("dev.limebeck.revealkt")
configProperties {
property<String>("version") set revealKtVersion
val version by string(revealKtVersion)
val kotlinVersion by string(libs.versions.kotlin.get())
}
}
}
Expand Down Expand Up @@ -57,7 +58,7 @@ kotlin {
val commonMain by getting {
dependencies {
implementation(project(":reveal-kt:lib-dsl"))
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:${libs.versions.serialization.get()}")
implementation(libs.kotlin.serialization)
}
}
val commonTest by getting {
Expand Down Expand Up @@ -85,7 +86,7 @@ kotlin {
implementation(kotlin("stdlib-js"))

implementation("org.jetbrains.kotlin-wrappers:kotlin-extensions:1.0.1-pre.346")
implementation(npm("reveal.js", "5.0.5"))
implementation(npm("reveal.js", "5.1.0"))
}
}
val jsTest by getting
Expand All @@ -101,7 +102,7 @@ val jvmProcessResources = tasks.named<Copy>("jvmProcessResources")
val jsCopyTask = tasks.create<Copy>("jsCopyTask") {
val jsBrowserDistribution = tasks.named("jsBrowserDistribution")
from(jsBrowserDistribution)
into(jvmProcessResources.get().destinationDir.resolve("js"))
into(jvmProcessResources.get().destinationDir.resolve("static"))
excludes.add("*.zip")
excludes.add("*.tar")
}
Expand Down
121 changes: 110 additions & 11 deletions reveal-kt/app/src/commonMain/kotlin/ConfigurationDto.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,123 @@ data class ConfigurationDto(
@Contextual
val theme: Theme,
val additionalCssStyle: String?,
val additionalLinks: List<String>,
val controlsTutorial: Boolean,
val controlsLayout: String,
val controlsBackArrows: String,
@Contextual
val slideNumber: SlideNumber,
val showSlideNumber: String,
val hashOneBasedIndex: Boolean,
val hash: Boolean,
val respondToHashChanges: Boolean,
val jumpToSlide: Boolean,
val keyboard: Boolean,
val disableLayout: Boolean,
val overview: Boolean,
val loop: Boolean,
val rtl: Boolean,
val navigationMode: String,
val shuffle: Boolean,
val fragments: Boolean,
val fragmentInURL: Boolean,
val help: Boolean,
val pause: Boolean,
val showNotes: Boolean,
val autoAnimate: Boolean,
val autoAnimateEasing: String,
val autoAnimateUnmatched: Boolean,
val autoSlide: Double,
val autoSlideStoppable: Boolean,
val defaultTiming: Int?,
val mouseWheel: Boolean?,
val previewLinks: Boolean,
val focusBodyOnPageVisibilityChange: Boolean,
val transition: String,
val transitionSpeed: String,
val backgroundTransition: String,
val parallaxBackgroundImage: String,
val parallaxBackgroundSize: String,
val parallaxBackgroundRepeat: String,
val pdfSeparateFragments: Boolean,
val hideInactiveCursor: Boolean,
) {
constructor(configuration: RevealKt.Configuration) : this(
controls = configuration.controls,
progress = configuration.progress,
history = configuration.history,
center = configuration.center,
touch = configuration.touch,
autoAnimateDuration = configuration.autoAnimateDuration,
view = when (configuration.view) {
progress = configuration.appearance.progress,
history = configuration.behavior.history,
center = configuration.appearance.center,
touch = configuration.appearance.touch,
autoAnimateDuration = configuration.animation.autoAnimateDuration,
view = when (configuration.appearance.view) {
RevealKt.Configuration.View.SCROLL -> "scroll"
RevealKt.Configuration.View.REGULAR -> null
},
theme = Theme.of(configuration.theme),
additionalCssStyle = configuration.additionalCssStyle,
additionalLinks = configuration.additionalLinks,
theme = Theme.of(configuration.appearance.theme),
additionalCssStyle = configuration.appearance.additionalCssStyle,
controlsTutorial = configuration.controlsTutorial,
controlsLayout = configuration.controlsLayout.value,
controlsBackArrows = configuration.controlsBackArrows.value,
slideNumber = SlideNumber.of(configuration.appearance.slideNumber),
showSlideNumber = configuration.appearance.showSlideNumber.value,
hashOneBasedIndex = configuration.behavior.hashOneBasedIndex,
hash = configuration.behavior.hash,
respondToHashChanges = configuration.behavior.respondToHashChanges,
jumpToSlide = configuration.behavior.jumpToSlide,
keyboard = configuration.behavior.keyboard,
disableLayout = configuration.appearance.disableLayout,
overview = configuration.appearance.overview,
loop = configuration.behavior.loop,
rtl = configuration.appearance.rtl,
navigationMode = configuration.navigationMode.value,
shuffle = configuration.shuffle,
fragments = configuration.fragments,
fragmentInURL = configuration.fragmentInURL,
help = configuration.help,
pause = configuration.pause,
showNotes = configuration.appearance.showNotes,
autoAnimate = configuration.animation.autoAnimate,
autoAnimateEasing = configuration.animation.autoAnimateEasing,
autoAnimateUnmatched = configuration.animation.autoAnimateUnmatched,
autoSlide = configuration.autoSlide,
autoSlideStoppable = configuration.autoSlideStoppable,
defaultTiming = configuration.defaultTiming,
mouseWheel = configuration.mouseWheel,
previewLinks = configuration.previewLinks,
focusBodyOnPageVisibilityChange = configuration.behavior.focusBodyOnPageVisibilityChange,
transition = configuration.animation.transition.value,
transitionSpeed = configuration.animation.transitionSpeed.value,
backgroundTransition = configuration.animation.backgroundTransition.value,
parallaxBackgroundImage = configuration.animation.parallaxBackgroundImage,
parallaxBackgroundSize = configuration.animation.parallaxBackgroundSize,
parallaxBackgroundRepeat = configuration.animation.parallaxBackgroundRepeat.value,
pdfSeparateFragments = configuration.pdfSeparateFragments,
hideInactiveCursor = configuration.behavior.hideInactiveCursor,
)

@Polymorphic
@Serializable
sealed interface SlideNumber {
companion object {
fun of(slideNumber: RevealKt.Configuration.SlideNumber): SlideNumber = when (slideNumber) {
RevealKt.Configuration.SlideNumber.Enable -> Enable
RevealKt.Configuration.SlideNumber.Disable -> Disable
is RevealKt.Configuration.SlideNumber.Custom -> Custom(slideNumber.format)
}
}

@Serializable
@SerialName("Disable")
data object Disable : SlideNumber

@Serializable
@SerialName("Enable")
data object Enable : SlideNumber

@Serializable
@SerialName("Custom")
data class Custom(val format: String) : SlideNumber
}

@Polymorphic
@Serializable
sealed interface Theme {
Expand Down Expand Up @@ -91,6 +190,6 @@ data class ConfigurationDto(
}
}

val configurationJsomMapper = Json {
val configurationJsonMapper = Json {
useArrayPolymorphism = true
}
17 changes: 14 additions & 3 deletions reveal-kt/app/src/jsMain/kotlin/Main.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import dev.limebeck.revealkt.server.ConfigurationDto
import dev.limebeck.revealkt.server.configurationJsomMapper
import dev.limebeck.revealkt.server.configurationJsonMapper
import kotlinx.browser.document
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.json.decodeFromDynamic
Expand All @@ -10,7 +10,7 @@ external val configurationJson: dynamic

@OptIn(ExperimentalSerializationApi::class)
fun main() {
val configuration = configurationJsomMapper.decodeFromDynamic<ConfigurationDto>(configurationJson)
val configuration = configurationJsonMapper.decodeFromDynamic<ConfigurationDto>(configurationJson)

val defaultPlugins = arrayOf(
kotlinext.js.require("reveal.js/plugin/notes/notes.js"),
Expand Down Expand Up @@ -51,8 +51,19 @@ fun main() {

kotlinext.js.require("reveal.js/plugin/highlight/monokai.css")

val dynamicConfiguration = configurationJsomMapper.encodeToDynamic(configuration)
val dynamicConfiguration = configurationJsonMapper.encodeToDynamic(configuration)
dynamicConfiguration.plugins = defaultPlugins
dynamicConfiguration.slideNumber = when(configuration.slideNumber) {
ConfigurationDto.SlideNumber.Enable -> true
ConfigurationDto.SlideNumber.Disable -> false
is ConfigurationDto.SlideNumber.Custom -> configuration.slideNumber
}

dynamicConfiguration.autoSlide = when {
configuration.autoSlide < 0.0 -> false
else -> configuration.autoSlide
}

Reveal(
dynamicConfiguration
).initialize()
Expand Down
Loading

0 comments on commit 37272a2

Please sign in to comment.