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

Commit 264d221

Browse files
committed
officially Kweb not KWeb
1 parent 5e5859d commit 264d221

File tree

18 files changed

+55
-56
lines changed

18 files changed

+55
-56
lines changed

README.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
## KWeb
1+
## Kweb
22

33
[![experimental](http://badges.github.io/stability-badges/dist/experimental.svg)](http://github.com/badges/stability-badges) [![](https://jitpack.io/v/sanity/kweb.svg)](https://jitpack.io/#sanity/kweb) [![Build Status](https://travis-ci.org/sanity/kweb.svg?branch=master)](https://travis-ci.org/sanity/kweb)
44

55

6-
KWeb is an experimental [Kotlin](http://kotlinlang.org/) library for building rich interactive web applications in pure Kotlin in a way
6+
Kweb is an experimental [Kotlin](http://kotlinlang.org/) library for building rich interactive web applications in pure Kotlin in a way
77
that makes the distinction between web browser and server largely invisible to the programmer.
88

99
In particular, it can use the new [coroutines](https://github.com/Kotlin/kotlinx.coroutines) mechanism in
@@ -17,10 +17,10 @@ Building rich webapps normally requires navigating the
1717
choosing between a vast multitude of tools, transpilers, minifiers, state maintainers, and so on, most of which will
1818
be obsolete in 6 months. Then you're faced with handling interaction between client and server which is a whole other world of pain.
1919

20-
KWeb intends to solve this.
20+
Kweb intends to solve this.
2121

2222
### How does it work?
23-
KWeb treats the web browser as a fairly dumb robot, keeping most of the intelligence server-side,
23+
Kweb treats the web browser as a fairly dumb robot, keeping most of the intelligence server-side,
2424
relaying instructions to the client via a websocket, and receiving responses from the client. Instructions to the server
2525
are simple JavaScript snippets which the browser immediately executes, returning the result to the server if requested.
2626

@@ -32,17 +32,17 @@ transparently keeping server and client state in sync, motivated largely by the
3232
to HTML in the event that the browser doesn't support JavaScript. This requirement is a lot less relevant today than it
3333
was a decade ago.
3434

35-
Uniquely, KWeb takes advantage of the new coroutines functionality in the upcoming Kotlin 1.1 to handle
36-
asynchronously waiting for responses from the client in a way that's almost transparent to the user of KWeb, without tying up threads (a definite no-no if you plan on having more than a handful of people visiting your website at a delay).
35+
Uniquely, Kweb takes advantage of the new coroutines functionality in the upcoming Kotlin 1.1 to handle
36+
asynchronously waiting for responses from the client in a way that's almost transparent to the user of Kweb, without tying up threads (a definite no-no if you plan on having more than a handful of people visiting your website at a delay).
3737

3838
#### News
3939
##### 2017-01-09: Plugins
40-
KWeb now has a simple but flexible plugin mechanism, allowing the addition of support for 3rd party JavaScript libraries.
40+
Kweb now has a simple but flexible plugin mechanism, allowing the addition of support for 3rd party JavaScript libraries.
4141

4242
As an example, here is a [demo](https://github.com/sanity/kweb/blob/master/src/main/kotlin/com/github/sanity/kweb/demos/jquery/jquery.kt) of a rudimentary JQuery plugin being used, and [here](https://github.com/sanity/kweb/blob/master/src/main/kotlin/com/github/sanity/kweb/plugins/jqueryCore/JQueryCorePlugin.kt) you can see its implementation. Currently it only supports .remove() - but you should get a feel for how easy it will be to flesh out other functionality.
4343

4444
##### 2017-01-08: Initial announcement
45-
KWeb is currently very experimental, at this stage more of a proof-of-concept and playground for ideas than anything
45+
Kweb is currently very experimental, at this stage more of a proof-of-concept and playground for ideas than anything
4646
even close to being useful in production.
4747

4848
The DOM DSL only covers a tiny subset of its eventual functionality, just barely more than is required for the TODO
@@ -54,7 +54,7 @@ Have questions, ideas, or otherwise want to contribute?
5454
Join our Slack channel [#kweb on kotlinlang](https://kotlinlang.slack.com/messages/kweb/)! You may need to [sign up for kotlinlang](http://kotlinslackin.herokuapp.com/) first.
5555

5656
Take a look at our [open issues](https://github.com/sanity/kweb/issues), some of them should be quite easy to tackle, even
57-
for someone new to KWeb. I will do my best to review and merge any suitable pull requests promptly.
57+
for someone new to Kweb. I will do my best to review and merge any suitable pull requests promptly.
5858

5959
#### Getting started
6060
1. Ensure you are using the "Early Access Preview 1.1" Kotlin plugin in IDEA, see "How to Try It" section at the
@@ -72,18 +72,18 @@ This is way longer than it needs to be due to the extensive comments, it may als
7272
[here](https://github.com/sanity/kweb/blob/master/src/main/kotlin/com/github/sanity/kweb/demos/todo/todo.kt).
7373

7474
```kotlin
75-
import com.github.sanity.kweb.KWeb
75+
import com.github.sanity.kweb.Kweb
7676
import com.github.sanity.kweb.dom.to.Element
7777
import com.github.sanity.kweb.dom.to.Element.InputType.setText
7878
import kotlinx.coroutines.async
7979
import kotlinx.coroutines.await
8080

8181
fun main(args: Array<String>) {
8282
// Starts a web server listening on port 8091
83-
KWeb(8091) {
83+
Kweb(8091) {
8484
doc.body.apply {
8585
// Add a header to to the body, along with some simple instructions.
86-
h1("Simple KWeb demo - a to-do list")
86+
h1("Simple Kweb demo - a to-do list")
8787
p("Edit the setText box below and click the button to add the item. Click an item to remove it.")
8888

8989
// If you're unfamiliar with the `apply` function, read this:

build.gradle

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
group 'com.github.sanity'
2-
version '0.0.33'
2+
version '0.0.34'
33

44
buildscript {
55
ext.kotlin_version = '1.1.0'
@@ -61,7 +61,6 @@ dependencies {
6161
compile('org.wasabifx:wasabi:0.3.120') {
6262
exclude module: "slf4j-simple"
6363
}
64-
//compile 'org.jetbrains.kotlinx:vertx3-lang-kotlin:0.0.+'
6564
compile 'com.github.salomonbrys.kotson:kotson:2.3.0'
6665
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.0'
6766
compile group: 'commons-io', name: 'commons-io', version: '2.5'

docs/_posts/2017-03-03-getting-started.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ js:
1313

1414
### What you should know
1515

16-
KWeb is built on [Kotlin 1.1](http://kotlinlang.org/), you should have some familiarity with Kotlin
16+
Kweb is built on [Kotlin 1.1](http://kotlinlang.org/), you should have some familiarity with Kotlin
1717
and the Java ecosystem on which it's built.
1818

19-
### Adding a KWeb dependency
19+
### Adding a Kweb dependency
2020

21-
The KWeb library is distributed via [JitPack](https://jitpack.io/#sanity/kweb), it can be added
21+
The Kweb library is distributed via [JitPack](https://jitpack.io/#sanity/kweb), it can be added
2222
easily to any Kotlin project:
2323

2424
#### Gradle

docs/_posts/2017-03-08-your-first-kwebsite.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Add a file like the following to your project:
1010

1111
```kotlin
1212
fun main(args: Array<String>) {
13-
KWeb(port = 7823) {
13+
Kweb(port = 7823) {
1414
doc.body.h1().setText("Hello World!")
1515
}
1616
}
@@ -24,7 +24,7 @@ Let's edit the file to do something more interesting:
2424

2525
```kotlin
2626
fun main(args: Array<String>) {
27-
KWeb(port = 7823) {
27+
Kweb(port = 7823) {
2828
var counter = 0
2929
val h1 = doc.body.h1()
3030
h1.setText("Hello World!")
@@ -42,7 +42,7 @@ we've assigned the header element to a variable called `h1`, and then we use the
4242
Next we create a click event listener on the header element, once clicked we set the text of the element to the value
4343
of the variable `counter`, and increase the value of `counter`.
4444

45-
Kill KWeb if it is still running, and run this new version. Try clicking on the text.
45+
Kill Kweb if it is still running, and run this new version. Try clicking on the text.
4646

4747
**Troubleshooting**: If you get an error like `Exception in thread "main" java.net.BindException: Address already in use` it means
4848
that the previous version is still running and therefore the new version is unable to listen on port 7823, make

docs/_posts/2017-03-09-live-coding.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ error, but this bug in HotSwapAgent has been reported and may be fixed by now.
5151

5252
#### Step 4 : Configure Kweb to refresh webpages automatically
5353

54-
Set the `refreshPageOnHotswap` KWeb constructor parameter to `true`:
54+
Set the `refreshPageOnHotswap` Kweb constructor parameter to `true`:
5555

5656
```kotlin
57-
KWeb(port = 1234, refreshPageOnHotswap = true) {
57+
Kweb(port = 1234, refreshPageOnHotswap = true) {
5858
```
5959

6060
#### Step 5 : Run your code
@@ -63,13 +63,13 @@ Now run your project in debug mode (the button with the green bug), you should s
6363

6464
```
6565
HOTSWAP AGENT: 19:01:57.851 INFO (org.hotswap.agent.HotswapAgent) - Loading Hotswap agent {1.1.0-SNAPSHOT} - unlimited runtime class redefinition.
66-
HOTSWAP AGENT: 19:01:58.178 INFO (org.hotswap.agent.config.PluginRegistry) - Discovered plugins: [KWebHotswapPlugin]
66+
HOTSWAP AGENT: 19:01:58.178 INFO (org.hotswap.agent.config.PluginRegistry) - Discovered plugins: [KwebHotswapPlugin]
6767
HOTSWAP AGENT: 19:01:59.145 INFO (org.hotswap.agent.config.PluginRegistry) - Discovered plugins: [Hotswapper, WatchResources, ClassInitPlugin, Hibernate, Hibernate3JPA, Hibernate3, Spring, Jersey1, Jersey2, Jetty, Tomcat, ZK, Logback, Log4j2, MyFaces, Mojarra, Seam, ELResolver, WildFlyELResolver, OsgiEquinox, Owb, Proxy, WebObjects, Weld, JBossModules, ResteasyRegistry, Deltaspike, JavaBeans]
6868
HOTSWAP AGENT: 19:01:59.231 INFO (org.hotswap.agent.config.PluginRegistry) - Discovered plugins: []
6969
HOTSWAP AGENT: 19:02:00.009 INFO (org.hotswap.agent.config.PluginRegistry) - Plugin 'org.hotswap.agent.plugin.logback.LogbackPlugin' initialized in ClassLoader 'sun.misc.Launcher$AppClassLoader@18b4aac2'.
7070
```
7171

72-
This indicates that HotSwapAgent is working, and in particular look out for `Discovered plugins: [KWebHotswapPlugin]` as this will indicate
72+
This indicates that HotSwapAgent is working, and in particular look out for `Discovered plugins: [KwebHotswapPlugin]` as this will indicate
7373
that Kweb is aware of HotSwapAgent (this is necessary for the automatic refresh).
7474

7575
#### Step 6 : Try it!
@@ -79,4 +79,4 @@ modified (Shift+Command+F9 on a Mac), in a few seconds the browser window should
7979
the change.
8080
8181
Note that HotSwapAgent doesn't work with every code modification, for example if you make a change to the configuration
82-
of your KWeb object it will not pick this up.
82+
of your Kweb object it will not pick this up.

docs/index.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ title: "Introduction to Kweb"
66
1. TOC
77
{:toc}
88

9-
#### What is KWeb?
9+
#### What is Kweb?
1010

1111
Kweb is a library for building rich web applications in the [Kotlin](http://kotlinlang.org/)
1212
programming language. You can think of it as a powerful Kotlin DSL that allows you to remote-control
@@ -69,7 +69,7 @@ supports.
6969
be organized
7070

7171
#### How does it work?
72-
KWeb keeps all of the logic server-side, and uses websockets to communicate with web browsers.
72+
Kweb keeps all of the logic server-side, and uses websockets to communicate with web browsers.
7373
We also take advantage of Kotlin's powerful new coroutines mechanism to efficiently handle
7474
asynchronicity largely invisible to the programmer.
7575

@@ -79,9 +79,9 @@ Here we create a simple "todo" list app:
7979

8080
```kotlin
8181
fun main(args: Array<String>) {
82-
KWeb(8091, debug = true) {
82+
Kweb(8091, debug = true) {
8383
doc.body.apply {
84-
h1().addText("Simple KWeb demo - a to-do list")
84+
h1().addText("Simple Kweb demo - a to-do list")
8585
p().addText("Edit the text box below and click the button to add the item. Click an item to remove it.")
8686

8787
val ul = ul().apply {

src/main/kotlin/com/github/sanity/kweb/KWeb.kt src/main/kotlin/com/github/sanity/kweb/Kweb.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ wont be happy. But I thought for your use case it would enable you to move thing
2828
at your end till its properly configurable
2929
*/
3030

31-
class KWeb(val port: Int,
31+
class Kweb(val port: Int,
3232
val debug: Boolean = true,
3333
val refreshPageOnHotswap : Boolean = false,
3434
val plugins: List<KWebPlugin> = Collections.emptyList(),
@@ -80,10 +80,10 @@ class KWeb(val port: Int,
8080
val logStatement = logStatementBuilder.toString()
8181
logger.warn { logStatement }
8282
}) {
83-
buildPage(RootReceiver(newClientId, httpRequestInfo, this@KWeb))
83+
buildPage(RootReceiver(newClientId, httpRequestInfo, this@Kweb))
8484
}
8585
} else {
86-
buildPage(RootReceiver(newClientId, httpRequestInfo, this@KWeb))
86+
buildPage(RootReceiver(newClientId, httpRequestInfo, this@Kweb))
8787
}
8888
for (plugin in plugins) {
8989
execute(newClientId, plugin.executeAfterPageCreation())
@@ -103,7 +103,7 @@ class KWeb(val port: Int,
103103
}
104104
}
105105
server.start(wait = false)
106-
logger.info {"KWeb is listening on port $port"}
106+
logger.info {"Kweb is listening on port $port"}
107107
}
108108

109109
private fun handleInboundMessage(ctx: ChannelHandlerContext, message: C2SWebsocketMessage) {

src/main/kotlin/com/github/sanity/kweb/RootReceiver.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import java.util.concurrent.CompletableFuture
66
import kotlin.reflect.KClass
77
import kotlin.reflect.jvm.jvmName
88

9-
class RootReceiver(private val clientId: String, val httpRequestInfo: HttpRequestInfo, internal val cc: KWeb, val response: String? = null) {
9+
class RootReceiver(private val clientId: String, val httpRequestInfo: HttpRequestInfo, internal val cc: Kweb, val response: String? = null) {
1010
private val plugins: Map<KClass<out KWebPlugin>, KWebPlugin> by lazy {
1111
cc.appliedPlugins.map { it::class to it }.toMap()
1212
}
@@ -22,7 +22,7 @@ class RootReceiver(private val clientId: String, val httpRequestInfo: HttpReques
2222
if (!plugins.contains(requiredPlugin)) missing.add(requiredPlugin.simpleName ?: requiredPlugin.jvmName)
2323
}
2424
if (missing.isNotEmpty()) {
25-
throw RuntimeException("Plugin(s) ${missing.joinToString(separator = ", ")} required but not passed to KWeb constructor")
25+
throw RuntimeException("Plugin(s) ${missing.joinToString(separator = ", ")} required but not passed to Kweb constructor")
2626
}
2727
}
2828

src/main/kotlin/com/github/sanity/kweb/demos/async/async.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.github.sanity.kweb.demos.async
22

3-
import com.github.sanity.kweb.KWeb
3+
import com.github.sanity.kweb.Kweb
44
import com.github.sanity.kweb.dom.element.creation.createElement
55
import com.github.sanity.kweb.dom.element.modification.setAttribute
66
import com.github.sanity.kweb.dom.element.modification.addText
@@ -13,7 +13,7 @@ import kotlinx.coroutines.experimental.future.future
1313
*/
1414
fun main(args: Array<String>) {
1515
println("Visit http://127.0.0.1:8091/ in your browser...")
16-
KWeb(8091) {
16+
Kweb(8091) {
1717
doc.body.apply {
1818
val p1 = createElement("p").setAttribute("id", 1).addText("one")
1919
val p2 = createElement("p").setAttribute("id", 2).addText("two")

src/main/kotlin/com/github/sanity/kweb/demos/errorDetection/buildPageTime/buildPageTime.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package com.github.sanity.kweb.demos.errorDetection.buildPageTime
22

3-
import com.github.sanity.kweb.KWeb
3+
import com.github.sanity.kweb.Kweb
44

55
/**
66
* Created by ian on 3/10/17.
77
*/
88

99
fun main(args: Array<String>) {
10-
KWeb(port = 1234, debug = true) {
10+
Kweb(port = 1234, debug = true) {
1111
Thread.sleep(1000)
1212
}
1313
Thread.sleep(2000)

src/main/kotlin/com/github/sanity/kweb/demos/event/event.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.github.sanity.kweb.demos.event
22

3-
import com.github.sanity.kweb.KWeb
3+
import com.github.sanity.kweb.Kweb
44
import com.github.sanity.kweb.dom.element.creation.input
55
import com.github.sanity.kweb.dom.element.events.on
66

@@ -9,7 +9,7 @@ import com.github.sanity.kweb.dom.element.events.on
99
*/
1010

1111
fun main(args: Array<String>) {
12-
KWeb(4682) {
12+
Kweb(4682) {
1313
doc.body.apply {
1414
input().on.keydown { e ->
1515
println("Received: '${e}'")

src/main/kotlin/com/github/sanity/kweb/demos/materialDesignLite/materialDesignLite.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.github.sanity.kweb.demos.materialDesignLite
22

3-
import com.github.sanity.kweb.KWeb
3+
import com.github.sanity.kweb.Kweb
44
import com.github.sanity.kweb.dom.element.creation.a
55
import com.github.sanity.kweb.dom.element.creation.span
66
import com.github.sanity.kweb.dom.element.events.on
@@ -16,7 +16,7 @@ import com.github.sanity.kweb.plugins.materialdesignlite.table.table
1616

1717
fun main(args: Array<String>) {
1818
println("Visit http://127.0.0.1:8091/ in your browser...")
19-
KWeb(port = 8091, plugins = listOf(materialDesignLite)) {
19+
Kweb(port = 8091, plugins = listOf(materialDesignLite)) {
2020
doc.body.apply {
2121
mdl.layout(fixedHeader = true).apply {
2222
addHeader()

src/main/kotlin/com/github/sanity/kweb/demos/plugins/bootstrap4/bootstrap4.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.github.sanity.kweb.demos.plugins.bootstrap4
22

3-
import com.github.sanity.kweb.KWeb
3+
import com.github.sanity.kweb.Kweb
44
import com.github.sanity.kweb.dom.element.creation.*
55
import com.github.sanity.kweb.dom.element.creation.createElement
66
import com.github.sanity.kweb.dom.element.creation.div
@@ -40,11 +40,11 @@ From http://v4-alpha.getbootstrap.com/components/forms/#textual-inputs
4040

4141
fun main(args: Array<String>) {
4242
println("Visit http://127.0.0.1:8091/ in your browser...")
43-
KWeb(port = 8091, plugins = listOf(bootstrap4)) {
43+
Kweb(port = 8091, plugins = listOf(bootstrap4)) {
4444
doc.body.apply {
4545
div().apply {
4646
container().apply {
47-
h1().addText("KWeb Bootstrap4 demo")
47+
h1().addText("Kweb Bootstrap4 demo")
4848

4949
p().addText("The following is a simple setText field which does nothing")
5050
}

src/main/kotlin/com/github/sanity/kweb/demos/plugins/jquery/jquery.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.github.sanity.kweb.demos.plugins.jquery
22

3-
import com.github.sanity.kweb.KWeb
3+
import com.github.sanity.kweb.Kweb
44
import com.github.sanity.kweb.dom.attributes.attr
55
import com.github.sanity.kweb.dom.attributes.classes
66
import com.github.sanity.kweb.dom.element.creation.h1
@@ -14,7 +14,7 @@ import com.github.sanity.kweb.plugins.jqueryCore.jqueryCore
1414
*/
1515

1616
fun main(args: Array<String>) {
17-
KWeb(port = 8091, plugins = listOf(jqueryCore)) {
17+
Kweb(port = 8091, plugins = listOf(jqueryCore)) {
1818
doc.body.apply {
1919
h1(attr.classes("test")).addText("Simple Demo of JQuery plugin").apply {
2020
jquery(".test").apply {

src/main/kotlin/com/github/sanity/kweb/demos/plugins/select2/select2demo.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.github.sanity.kweb.demos.plugins.select2
22

3-
import com.github.sanity.kweb.KWeb
3+
import com.github.sanity.kweb.Kweb
44
import com.github.sanity.kweb.dom.element.creation.select
55
import com.github.sanity.kweb.plugins.select2.Item
66
import com.github.sanity.kweb.plugins.select2.Suggestions
@@ -11,7 +11,7 @@ import com.github.sanity.kweb.plugins.select2.select2
1111
*/
1212

1313
fun main(args: Array<String>) {
14-
KWeb(5461, plugins = listOf(select2)) {
14+
Kweb(5461, plugins = listOf(select2)) {
1515
doc.body.apply {
1616
val select = select()
1717
select.select2(suggestions = { Suggestions(results = listOf(Item("1", "One"), Item("2", "Two"))) }).on.select {

src/main/kotlin/com/github/sanity/kweb/demos/todo/todo.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.github.sanity.kweb.demos.todo
22

3-
import com.github.sanity.kweb.KWeb
3+
import com.github.sanity.kweb.Kweb
44
import com.github.sanity.kweb.dom.element.creation.*
55
import com.github.sanity.kweb.dom.element.events.on
66
import com.github.sanity.kweb.dom.element.modification.addText
@@ -10,10 +10,10 @@ import kotlinx.coroutines.experimental.future.future
1010

1111
fun main(args: Array<String>) {
1212
// Starts a web server listening on port 8091
13-
KWeb(8091, debug = true) {
13+
Kweb(8091, debug = true) {
1414
doc.body.apply {
1515
// Add a header parent to the body, along with some simple instructions.
16-
h1().addText("Simple KWeb demo - a to-do list")
16+
h1().addText("Simple Kweb demo - a to-do list")
1717
p().addText("Edit the text box below and click the button to add the item. Click an item to remove it.")
1818

1919
// If you're unfamiliar with the `apply` function, read this:

0 commit comments

Comments
 (0)