Skip to content

Commit

Permalink
V0.2.4: Fixed Quircks browser mode. Add FilesWatcher logger configura…
Browse files Browse the repository at this point in the history
…tion. Update reveal-js
  • Loading branch information
LimeBeck committed Apr 7, 2024
1 parent 4b1d79c commit 0e487e6
Show file tree
Hide file tree
Showing 12 changed files with 199 additions and 26 deletions.
168 changes: 161 additions & 7 deletions example/presentation/TestPresentation.reveal.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,88 @@
import dev.limebeck.revealkt.core.RevealKt
import qrcode.color.Colors

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 {
Expand Down Expand Up @@ -40,15 +118,91 @@ slides {
}
}
slide {
//language=XML
val jsonCode = """
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>maven-module</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>org.example maven-module</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<kotlin.version>1.6.10</kotlin.version>
<kotlin.code.style>official</kotlin.code.style>
<junit.version>4.12</junit.version>
</properties>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>\${'$'}{kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test-junit</artifactId>
<version>\${'$'}{kotlin.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>\${'$'}{junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/kotlin</sourceDirectory>
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>\${'$'}{kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
""".trimIndent()
autoanimate = true
+title
+code {
//language=JSON
"""
{
"string": "some string"
}
""".trimIndent()
// +code(
// trim = false
// ) {
// jsonCode
// }
+code(
lines = "1|12|30",
trim = false
) {
jsonCode
}
}
slide {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion reveal-kt/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion reveal-kt/app/src/jsMain/kotlin/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 3 additions & 3 deletions reveal-kt/app/src/jvmMain/kotlin/server/Rendering.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ import kotlinx.html.stream.createHTML
import kotlinx.serialization.encodeToString

fun renderLoadResult(loadResult: RevealKtScriptLoader.LoadResult): String {
return when (loadResult) {
return "<!DOCTYPE html>" + when (loadResult) {
is RevealKtScriptLoader.LoadResult.Success -> {
val presentation = loadResult.value.build()
createHTML(prettyPrint = true).apply {
createHTML(prettyPrint = true, xhtmlCompatible = true).apply {
html {
render(presentation)
}
}.finalize()
}

is RevealKtScriptLoader.LoadResult.Error -> {
createHTML(prettyPrint = true).apply {
createHTML(prettyPrint = true, xhtmlCompatible = true).apply {
html {
head {
title { +"Render Error" }
Expand Down
1 change: 1 addition & 0 deletions reveal-kt/app/src/jvmMain/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
<logger name="ch.qos" level="WARN"/>
<logger name="Application" level="${LOG_LEVEL:-WARN}"/>
<logger name="ServerLogger" level="${LOG_LEVEL:-WARN}"/>
<logger name="FilesWatcher" level="${LOG_LEVEL:-WARN}"/>
</configuration>
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
9 changes: 4 additions & 5 deletions reveal-kt/lib-dsl/src/commonMain/kotlin/core/elements/Code.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package dev.limebeck.revealkt.dsl

import dev.limebeck.revealkt.elements.slides.Slide

@RevealKtMarker
interface SlidesHolder {
val slides: MutableList<Slide>
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -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())
}
16 changes: 8 additions & 8 deletions reveal-kt/lib-dsl/src/commonTest/kotlin/CommonTest.kt
Original file line number Diff line number Diff line change
@@ -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


Expand Down Expand Up @@ -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 { "Кто я такой?" }
Expand Down

0 comments on commit 0e487e6

Please sign in to comment.