Skip to content
This repository has been archived by the owner on Aug 10, 2024. It is now read-only.

Commit

Permalink
/static too prone to collisions, change to kweb_static/
Browse files Browse the repository at this point in the history
  • Loading branch information
sanity committed Oct 31, 2022
1 parent f496edd commit 82454b9
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions docs/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
- [URL Routing](routing.md)
- [CSS & Style](style.md)
- [Components](components.md)
- [JavaScript Interop](js.md)
- [Integrations](integrations.md)
- [Frequently Asked Questions](faq.md)
6 changes: 6 additions & 0 deletions docs/src/js.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# JavaScript Interop

While Kweb speaks Kotlin to you, it speaks JavaScript to the browser. Kweb's DOM interaction functionality is
build on top of two functions, [Element.callJsFunction()](https://docs.kweb.io/api/kweb-core/kweb/-element/call-js-function.html),
and [Element.callJsFunctionWithResult()](https://docs.kweb.io/api/kweb-core/kweb/-element/call-js-function-with-result.html).

2 changes: 1 addition & 1 deletion src/main/kotlin/kweb/Kweb.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Kweb private constructor(

// This StaticFilesPlugin is used to serve static files required by Kweb and bundled plugins, it's
// added to the plugin list implicitly.
val plugins = plugins + StaticFilesPlugin(ResourceFolder("kweb.static"), "/static")
val plugins = plugins + StaticFilesPlugin(ResourceFolder("kweb.static"), "/kweb_static")

/**
*
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/kweb/html/HtmlDocumentSupplier.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ internal object HtmlDocumentSupplier {

head.appendElement("link")
.attr("rel", "stylesheet")
.attr("href", "/static/toastify/toastify.min.css")
.attr("href", "/kweb_static/toastify/toastify.min.css")
}

html.appendElement("body").let { body: Element ->
Expand All @@ -55,7 +55,7 @@ internal object HtmlDocumentSupplier {
| This page is built with <a href="https://kweb.io/">Kweb</a>, which
| requires JavaScript to be enabled.""".trimMargin())
body.appendElement("script")
.attr("src", "/static/toastify/toastify.js")
.attr("src", "/kweb_static/toastify/toastify.js")
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/kweb/plugins/fomanticUI/FomanticUIPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ class FomanticUIPlugin : KwebPlugin(dependsOn = setOf(jqueryCore)
doc.head().appendElement("link")
.attr("rel", "stylesheet")
.attr("type", "text/css")
.attr("href", "/static/plugins/fomantic/semantic.min.css")
.attr("href", "/kweb_static/plugins/fomantic/semantic.min.css")

doc.head().appendElement("script")
.attr("src", "/static/plugins/fomantic/semantic.min.js")
.attr("src", "/kweb_static/plugins/fomantic/semantic.min.js")

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import org.jsoup.nodes.Document
class JQueryCorePlugin : KwebPlugin() {
override fun decorate(doc: Document) {
doc.head().appendElement("script")
.attr("src", "/static/plugins/jquery/jquery-3.4.1.min.js")
.attr("src", "/kweb_static/plugins/jquery/jquery-3.4.1.min.js")
.attr("crossorigin", "anonymous")
}
}
Expand Down

0 comments on commit 82454b9

Please sign in to comment.