diff --git a/example/presentation/TestPresentation.reveal.kts b/example/presentation/TestPresentation.reveal.kts index b482e29..4aa40a5 100644 --- a/example/presentation/TestPresentation.reveal.kts +++ b/example/presentation/TestPresentation.reveal.kts @@ -1,3 +1,4 @@ +import dev.limebeck.revealkt.core.RevealKt import qrcode.color.Colors title = "Hello from my presentation" @@ -5,6 +6,83 @@ title = "Hello from my presentation" configuration { controls = false progress = false + theme = RevealKt.Configuration.Theme.Predefined.BLACK + additionalCssStyle = """ + + .hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + background: #3f3f3f; + color: #dcdcdc; + } + + .hljs-keyword, + .hljs-selector-tag, + .hljs-tag { + color: #e3ceab; + } + + .hljs-template-tag { + color: #dcdcdc; + } + + .hljs-number { + color: #8cd0d3; + } + + .hljs-variable, + .hljs-template-variable, + .hljs-attribute { + color: #efdcbc; + } + + .hljs-literal { + color: #efefaf; + } + + .hljs-subst { + color: #8f8f8f; + } + + .hljs-title, + .hljs-name, + .hljs-selector-id, + .hljs-selector-class, + .hljs-section, + .hljs-type { + color: #efef8f; + } + + .hljs-symbol, + .hljs-bullet, + .hljs-link { + color: #dca3a3; + } + + .hljs-deletion, + .hljs-string, + .hljs-built_in, + .hljs-builtin-name { + color: #cc9393; + } + + .hljs-addition, + .hljs-comment, + .hljs-quote, + .hljs-meta { + color: #7f9f7f; + } + + + .hljs-emphasis { + font-style: italic; + } + + .hljs-strong { + font-weight: bold; + } + """.trimIndent() } slides { @@ -40,15 +118,91 @@ slides { } } slide { + //language=XML + val jsonCode = """ + + + + 4.0.0 + + org.example + maven-module + 1.0-SNAPSHOT + jar + + org.example maven-module + + + UTF-8 + 1.6.10 + official + 4.12 + + + + + org.jetbrains.kotlin + kotlin-stdlib + \${'$'}{kotlin.version} + + + org.jetbrains.kotlin + kotlin-test-junit + \${'$'}{kotlin.version} + test + + + junit + junit + \${'$'}{junit.version} + test + + + + + src/main/kotlin + src/test/kotlin + + + + org.jetbrains.kotlin + kotlin-maven-plugin + \${'$'}{kotlin.version} + + + compile + compile + + compile + + + + test-compile + test-compile + + test-compile + + + + + + + + """.trimIndent() autoanimate = true +title - +code { - //language=JSON - """ - { - "string": "some string" - } - """.trimIndent() +// +code( +// trim = false +// ) { +// jsonCode +// } + +code( + lines = "1|12|30", + trim = false + ) { + jsonCode } } slide { diff --git a/gradle.properties b/gradle.properties index 2f58a77..9f70563 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ yarn.ignoreScripts = false kotlinVersion=1.9.20 -revealKtVersion=0.2.3 +revealKtVersion=0.2.4 kotlinCoroutinesVersion=1.8.0 ktorVersion=2.1.3 diff --git a/reveal-kt/app/build.gradle.kts b/reveal-kt/app/build.gradle.kts index 1486724..37f5e9e 100644 --- a/reveal-kt/app/build.gradle.kts +++ b/reveal-kt/app/build.gradle.kts @@ -85,7 +85,7 @@ kotlin { implementation(kotlin("stdlib-js")) implementation("org.jetbrains.kotlin-wrappers:kotlin-extensions:1.0.1-pre.346") - implementation(npm("reveal.js", "5.0.2")) + implementation(npm("reveal.js", "5.0.5")) } } val jsTest by getting diff --git a/reveal-kt/app/src/jsMain/kotlin/Main.kt b/reveal-kt/app/src/jsMain/kotlin/Main.kt index 42480d1..1486099 100644 --- a/reveal-kt/app/src/jsMain/kotlin/Main.kt +++ b/reveal-kt/app/src/jsMain/kotlin/Main.kt @@ -41,7 +41,12 @@ fun main() { } } - is ConfigurationDto.Theme.Custom -> kotlinext.js.require(configuration.theme.cssLink) + is ConfigurationDto.Theme.Custom -> { + val style = document.createElement("style").apply { + this.setAttribute("href", configuration.theme.cssLink) + } + document.head?.appendChild(style) + } } kotlinext.js.require("reveal.js/plugin/highlight/monokai.css") diff --git a/reveal-kt/app/src/jvmMain/kotlin/server/Rendering.kt b/reveal-kt/app/src/jvmMain/kotlin/server/Rendering.kt index 80b8122..8f98c17 100644 --- a/reveal-kt/app/src/jvmMain/kotlin/server/Rendering.kt +++ b/reveal-kt/app/src/jvmMain/kotlin/server/Rendering.kt @@ -10,10 +10,10 @@ import kotlinx.html.stream.createHTML import kotlinx.serialization.encodeToString fun renderLoadResult(loadResult: RevealKtScriptLoader.LoadResult): String { - return when (loadResult) { + return "" + when (loadResult) { is RevealKtScriptLoader.LoadResult.Success -> { val presentation = loadResult.value.build() - createHTML(prettyPrint = true).apply { + createHTML(prettyPrint = true, xhtmlCompatible = true).apply { html { render(presentation) } @@ -21,7 +21,7 @@ fun renderLoadResult(loadResult: RevealKtScriptLoader.LoadResult): String { } is RevealKtScriptLoader.LoadResult.Error -> { - createHTML(prettyPrint = true).apply { + createHTML(prettyPrint = true, xhtmlCompatible = true).apply { html { head { title { +"Render Error" } diff --git a/reveal-kt/app/src/jvmMain/resources/logback.xml b/reveal-kt/app/src/jvmMain/resources/logback.xml index 0d0d6e9..c6aa93c 100644 --- a/reveal-kt/app/src/jvmMain/resources/logback.xml +++ b/reveal-kt/app/src/jvmMain/resources/logback.xml @@ -14,4 +14,5 @@ + diff --git a/reveal-kt/lib-dsl/src/commonMain/kotlin/core/RevealKtElement.kt b/reveal-kt/lib-dsl/src/commonMain/kotlin/core/RevealKtElement.kt index 0d4f51f..92238ee 100644 --- a/reveal-kt/lib-dsl/src/commonMain/kotlin/core/RevealKtElement.kt +++ b/reveal-kt/lib-dsl/src/commonMain/kotlin/core/RevealKtElement.kt @@ -1,11 +1,13 @@ package dev.limebeck.revealkt.core +import dev.limebeck.revealkt.dsl.RevealKtMarker import dev.limebeck.revealkt.utils.ID import kotlinx.html.HtmlBlockTag import kotlinx.html.classes import kotlinx.html.style import kotlin.reflect.KProperty +@RevealKtMarker interface RevealKtElement { val id: ID fun render(tag: HtmlBlockTag) diff --git a/reveal-kt/lib-dsl/src/commonMain/kotlin/core/elements/Code.kt b/reveal-kt/lib-dsl/src/commonMain/kotlin/core/elements/Code.kt index 18be66d..d6c9b48 100644 --- a/reveal-kt/lib-dsl/src/commonMain/kotlin/core/elements/Code.kt +++ b/reveal-kt/lib-dsl/src/commonMain/kotlin/core/elements/Code.kt @@ -9,14 +9,14 @@ data class Code( override val id: ID = UuidGenerator.generateId(), val trim: Boolean = true, val lang: String? = null, - val lines: String = "", + val lines: String? = null, val code: String, ) : RevealKtElement { constructor( id: ID = UuidGenerator.generateId(), - trim: Boolean = true, + trim: Boolean = false, lang: String? = null, - lines: String = "", + lines: String? = null, codeProvider: () -> String, ) : this(id, trim, lang, lines, codeProvider()) @@ -29,9 +29,8 @@ data class Code( code { conditionalAttribute("data-trim", ::trim) - conditionalAttribute("data-line-numbers", lines) { lines.isNotBlank() && lines.isNotEmpty() } + conditionalAttribute("data-line-numbers", lines ?: "") { lines != null } - style = "line-height: normal; padding: 0 3px; overflow-wrap:normal" script("text/template") { unsafe { +this@Code.code diff --git a/reveal-kt/lib-dsl/src/commonMain/kotlin/dsl/SlidesHolder.kt b/reveal-kt/lib-dsl/src/commonMain/kotlin/dsl/SlidesHolder.kt index 716df20..a7fa258 100644 --- a/reveal-kt/lib-dsl/src/commonMain/kotlin/dsl/SlidesHolder.kt +++ b/reveal-kt/lib-dsl/src/commonMain/kotlin/dsl/SlidesHolder.kt @@ -2,6 +2,7 @@ package dev.limebeck.revealkt.dsl import dev.limebeck.revealkt.elements.slides.Slide +@RevealKtMarker interface SlidesHolder { val slides: MutableList } \ No newline at end of file diff --git a/reveal-kt/lib-dsl/src/commonMain/kotlin/dsl/slides/RegularSlideBuilder.kt b/reveal-kt/lib-dsl/src/commonMain/kotlin/dsl/slides/RegularSlideBuilder.kt index 82d9c6d..d7c0340 100644 --- a/reveal-kt/lib-dsl/src/commonMain/kotlin/dsl/slides/RegularSlideBuilder.kt +++ b/reveal-kt/lib-dsl/src/commonMain/kotlin/dsl/slides/RegularSlideBuilder.kt @@ -2,10 +2,12 @@ package dev.limebeck.revealkt.dsl.slides import dev.limebeck.revealkt.core.RevealKtElement import dev.limebeck.revealkt.dsl.ElementsHolder +import dev.limebeck.revealkt.dsl.RevealKtMarker import dev.limebeck.revealkt.dsl.SlidesHolder import dev.limebeck.revealkt.elements.slides.RegularSlide import dev.limebeck.revealkt.utils.UuidGenerator +@RevealKtMarker class RegularSlideBuilder : ElementsHolder { var autoanimate: Boolean = true var id = UuidGenerator.generateId() diff --git a/reveal-kt/lib-dsl/src/commonMain/kotlin/dsl/slides/VerticalSlideBuilder.kt b/reveal-kt/lib-dsl/src/commonMain/kotlin/dsl/slides/VerticalSlideBuilder.kt index 50db42c..899b66b 100644 --- a/reveal-kt/lib-dsl/src/commonMain/kotlin/dsl/slides/VerticalSlideBuilder.kt +++ b/reveal-kt/lib-dsl/src/commonMain/kotlin/dsl/slides/VerticalSlideBuilder.kt @@ -1,10 +1,15 @@ package dev.limebeck.revealkt.dsl.slides +import dev.limebeck.revealkt.dsl.RevealKtMarker import dev.limebeck.revealkt.dsl.SlidesHolder import dev.limebeck.revealkt.elements.slides.Slide import dev.limebeck.revealkt.elements.slides.VerticalSlide import dev.limebeck.revealkt.utils.UuidGenerator +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract +@RevealKtMarker class VerticalSlideBuilder : SlidesHolder { var autoanimate: Boolean = false var id = UuidGenerator.generateId() @@ -20,8 +25,12 @@ class VerticalSlideBuilder : SlidesHolder { } } +@OptIn(ExperimentalContracts::class) fun SlidesHolder.verticalSlide( block: VerticalSlideBuilder .() -> Unit ) { + contract { + callsInPlace(block, InvocationKind.EXACTLY_ONCE) + } slides.add(VerticalSlideBuilder().apply(block).build()) } \ No newline at end of file diff --git a/reveal-kt/lib-dsl/src/commonTest/kotlin/CommonTest.kt b/reveal-kt/lib-dsl/src/commonTest/kotlin/CommonTest.kt index d43bf40..9ed52f1 100644 --- a/reveal-kt/lib-dsl/src/commonTest/kotlin/CommonTest.kt +++ b/reveal-kt/lib-dsl/src/commonTest/kotlin/CommonTest.kt @@ -1,12 +1,10 @@ import dev.limebeck.revealkt.core.RevealKt import dev.limebeck.revealkt.core.elements.ListItem import dev.limebeck.revealkt.core.elements.RegularText +import dev.limebeck.revealkt.core.elements.UnorderedList import dev.limebeck.revealkt.dsl.* import dev.limebeck.revealkt.dsl.slides.regularSlide -import dev.limebeck.revealkt.dsl.slides.slide import dev.limebeck.revealkt.dsl.slides.verticalSlide -import dev.limebeck.revealkt.core.elements.Title -import dev.limebeck.revealkt.core.elements.UnorderedList import kotlin.test.Test @@ -48,11 +46,13 @@ class CommonTest { } slides { - regularSlide { - autoanimate = true - +title(fitText = true) { "(Де)мистифицируем" } - +img(src = "gradle-white-primary.png") - +note("Спросить, кто вообще пользовался гредлом") + verticalSlide { + regularSlide { + autoanimate = true + +title(fitText = true) { "(Де)мистифицируем" } + +img(src = "gradle-white-primary.png") + +note("Спросить, кто вообще пользовался гредлом") + } } regularSlide { +smallTitle { "Кто я такой?" }