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

Commit

Permalink
rename package to io.kweb
Browse files Browse the repository at this point in the history
  • Loading branch information
sanity committed Apr 8, 2017
1 parent a50985a commit 468b9b2
Show file tree
Hide file tree
Showing 48 changed files with 230 additions and 234 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group 'com.github.sanity'
version '0.1.3'
group 'io.kweb'
version '0.1.4'

buildscript {
ext.kotlin_version = '1.1.1'
Expand Down
20 changes: 0 additions & 20 deletions src/main/kotlin/com/github/sanity/kweb/demos/event/event.kt

This file was deleted.

10 changes: 0 additions & 10 deletions src/main/kotlin/com/github/sanity/kweb/dom/element/events/on.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package com.github.sanity.kweb
package io.kweb

import com.github.sanity.kweb.browserConnection.OutboundChannel
import com.github.sanity.kweb.dev.hotswap.KwebHotswapPlugin
import com.github.sanity.kweb.plugins.KWebPlugin
import io.kweb.browserConnection.OutboundChannel
import io.kweb.dev.hotswap.KwebHotswapPlugin
import io.kweb.plugins.KWebPlugin
import io.mola.galimatias.URL
import kotlinx.coroutines.experimental.CommonPool
import kotlinx.coroutines.experimental.async
import mu.KLogging
import org.apache.commons.io.IOUtils
import org.hotswap.agent.javassist.NotFoundException
import org.jetbrains.ktor.application.ApplicationRequest
Expand All @@ -16,8 +15,6 @@ import org.jetbrains.ktor.features.DefaultHeaders
import org.jetbrains.ktor.features.origin
import org.jetbrains.ktor.http.ContentType
import org.jetbrains.ktor.http.HttpStatusCode
import org.jetbrains.ktor.netty.NettyApplicationHost
import org.jetbrains.ktor.netty.embeddedNettyServer
import org.jetbrains.ktor.request.uri
import org.jetbrains.ktor.response.contentType
import org.jetbrains.ktor.response.respondText
Expand All @@ -29,7 +26,6 @@ import org.jetbrains.ktor.websocket.WebSocket
import org.jetbrains.ktor.websocket.readText
import org.jetbrains.ktor.websocket.webSocket
import java.util.*
import java.util.concurrent.ConcurrentHashMap

/**
* Created by ian on 12/31/16.
Expand Down Expand Up @@ -59,23 +55,23 @@ typealias JavaScriptError = String
class Kweb(val port: Int,
val debug: Boolean = true,
val refreshPageOnHotswap : Boolean = false,
val plugins: List<KWebPlugin> = Collections.emptyList(),
val appServerConfigurator: (Routing) -> Unit = {},
val onError : ((List<StackTraceElement>, JavaScriptError) -> LogError) = { _, _ -> true},
val plugins: List<io.kweb.plugins.KWebPlugin> = java.util.Collections.emptyList(),
val appServerConfigurator: (org.jetbrains.ktor.routing.Routing) -> Unit = {},
val onError : ((List<StackTraceElement>, io.kweb.JavaScriptError) -> io.kweb.LogError) = { _, _ -> true},
val maxPageBuildTimeMS : Long = 200,
val buildPage: WebBrowser.() -> Unit
) {
companion object: KLogging()
companion object: mu.KLogging()

private var server: NettyApplicationHost?
private val clients: MutableMap<String, WSClientData>
private val mutableAppliedPlugins: MutableSet<KWebPlugin> = HashSet()
val appliedPlugins: Set<KWebPlugin> get() = mutableAppliedPlugins
private var server: org.jetbrains.ktor.netty.NettyApplicationHost?
private val clients: MutableMap<String, io.kweb.WSClientData>
private val mutableAppliedPlugins: MutableSet<io.kweb.plugins.KWebPlugin> = java.util.HashSet()
val appliedPlugins: Set<io.kweb.plugins.KWebPlugin> get() = mutableAppliedPlugins

init {

//TODO: Need to do housekeeping to delete old client data
clients = ConcurrentHashMap<String, WSClientData>()
clients = java.util.concurrent.ConcurrentHashMap<String, WSClientData>()

val startHeadBuilder = StringBuilder()
val endHeadBuilder = StringBuilder()
Expand All @@ -84,7 +80,7 @@ class Kweb(val port: Int,
KwebHotswapPlugin.addHotswapReloadListener({refreshAllPages()})
}

server= embeddedNettyServer(port) {
server= org.jetbrains.ktor.netty.embeddedNettyServer(port) {
install(DefaultHeaders)
routing {

Expand All @@ -99,8 +95,8 @@ class Kweb(val port: Int,

val resourceStream = Kweb::class.java.getResourceAsStream("kweb_bootstrap.html")
val bootstrapHtmlTemplate = IOUtils.toString(resourceStream, Charsets.UTF_8)
.replace("<!-- START HEADER PLACEHOLDER -->", startHeadBuilder.toString())
.replace("<!-- END HEADER PLACEHOLDER -->", endHeadBuilder.toString())
.replace("<!-- START HEADER PLACEHOLDER -->", startHeadBuilder.toString())
.replace("<!-- END HEADER PLACEHOLDER -->", endHeadBuilder.toString())

// Setup default KWeb routing.
get("/favicon.ico") {
Expand Down Expand Up @@ -143,18 +139,18 @@ class Kweb(val port: Int,
// TODO replace with ktor type.
call.response.contentType("text/html")
call.respond(bootstrapHtml)
} catch (nfe : NotFoundException) {
} catch (nfe: NotFoundException) {
call.response.status(HttpStatusCode.NotFound)
call.respondText("URL ${call.request.uri} not found.", ContentType.parse("text/plain"))
} catch (e : Exception) {
} catch (e: Exception) {
call.response.status(HttpStatusCode.InternalServerError)
val logToken = random.nextLong().toString(16)
call.respondText("""
Internal Server Error.
Please include code $logToken in any error report to help us track it down.
""".trimIndent())
logger.error(e) {"Exception thrown while rendering page, code $logToken" }
logger.error(e) { "Exception thrown while rendering page, code $logToken" }
}
}
webSocket("/ws") {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.github.sanity.kweb
package io.kweb

import com.github.sanity.kweb.dom.Document
import com.github.sanity.kweb.plugins.KWebPlugin
import io.kweb.dom.Document
import io.kweb.plugins.KWebPlugin
import kotlinx.coroutines.experimental.CommonPool
import kotlinx.coroutines.experimental.launch
import mu.KLogging
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.sanity.kweb.browserConnection
package io.kweb.browserConnection

import kotlinx.coroutines.experimental.runBlocking
import org.jetbrains.ktor.websocket.Frame
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.github.sanity.kweb.demos.async
package io.kweb.demos.async

import com.github.sanity.kweb.Kweb
import com.github.sanity.kweb.dom.element.creation.tags.p
import com.github.sanity.kweb.dom.element.modification.addText
import com.github.sanity.kweb.dom.element.modification.setAttribute
import com.github.sanity.kweb.dom.element.new
import com.github.sanity.kweb.dom.element.read.read
import io.kweb.Kweb
import io.kweb.dom.element.creation.tags.p
import io.kweb.dom.element.modification.addText
import io.kweb.dom.element.modification.setAttribute
import io.kweb.dom.element.new
import io.kweb.dom.element.read.read
import kotlinx.coroutines.experimental.future.await
import kotlinx.coroutines.experimental.future.future
import mu.KotlinLogging
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.github.sanity.kweb.demos.errorDetection.buildPageTime
package io.kweb.demos.errorDetection.buildPageTime

import com.github.sanity.kweb.Kweb
import io.kweb.Kweb

/**
* Created by ian on 3/10/17.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.github.sanity.kweb.demos.errorDetection.jsError
package io.kweb.demos.errorDetection.jsError

import com.github.sanity.kweb.Kweb
import io.kweb.Kweb

/**
* Created by ian on 3/28/17.
Expand Down
20 changes: 20 additions & 0 deletions src/main/kotlin/io/kweb/demos/event/event.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package io.kweb.demos.event

import io.kweb.Kweb
import io.kweb.dom.element.creation.tags.input
import io.kweb.dom.element.events.on
import io.kweb.dom.element.new

/**
* Created by ian on 2/21/17.
*/

fun main(args: Array<String>) {
Kweb(4682) {
doc.body.new {
input().on.keydown { e ->
println("Received: '${e}'")
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.github.sanity.kweb.demos.plugins.jquery
package io.kweb.demos.plugins.jquery

import com.github.sanity.kweb.Kweb
import com.github.sanity.kweb.dom.attributes.attr
import com.github.sanity.kweb.dom.attributes.classes
import com.github.sanity.kweb.dom.element.creation.tags.h1
import com.github.sanity.kweb.dom.element.modification.addText
import com.github.sanity.kweb.dom.element.new
import com.github.sanity.kweb.plugins.jqueryCore.jquery
import com.github.sanity.kweb.plugins.jqueryCore.jqueryCore
import io.kweb.Kweb
import io.kweb.dom.attributes.attr
import io.kweb.dom.attributes.classes
import io.kweb.dom.element.creation.tags.h1
import io.kweb.dom.element.modification.addText
import io.kweb.dom.element.new
import io.kweb.plugins.jqueryCore.jquery
import io.kweb.plugins.jqueryCore.jqueryCore


/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.github.sanity.kweb.demos.todo
package io.kweb.demos.todo

import com.github.sanity.kweb.Kweb
import com.github.sanity.kweb.dom.element.creation.ElementCreator
import com.github.sanity.kweb.dom.element.creation.tags.*
import com.github.sanity.kweb.dom.element.events.on
import com.github.sanity.kweb.dom.element.modification.addText
import com.github.sanity.kweb.dom.element.modification.delete
import com.github.sanity.kweb.dom.element.modification.text
import com.github.sanity.kweb.dom.element.new
import io.kweb.Kweb
import io.kweb.dom.element.creation.ElementCreator
import io.kweb.dom.element.creation.tags.*
import io.kweb.dom.element.events.on
import io.kweb.dom.element.modification.addText
import io.kweb.dom.element.modification.delete
import io.kweb.dom.element.modification.text
import io.kweb.dom.element.new
import kotlinx.coroutines.experimental.future.await
import kotlinx.coroutines.experimental.future.future

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.sanity.kweb.dev.hotswap
package io.kweb.dev.hotswap

import mu.KotlinLogging
import org.hotswap.agent.annotation.LoadEvent
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.github.sanity.kweb.dom
package io.kweb.dom

import com.github.sanity.kweb.Kweb
import com.github.sanity.kweb.WebBrowser
import com.github.sanity.kweb.dom.cookies.CookieReceiver
import com.github.sanity.kweb.dom.element.Element
import com.github.sanity.kweb.dom.element.creation.tags.h1
import com.github.sanity.kweb.dom.element.modification.text
import com.github.sanity.kweb.dom.element.new
import io.kweb.Kweb
import io.kweb.WebBrowser
import io.kweb.dom.cookies.CookieReceiver
import io.kweb.dom.element.Element
import io.kweb.dom.element.creation.tags.h1
import io.kweb.dom.element.modification.text
import io.kweb.dom.element.new

/**
* Represents the in-browser Document Object Model, corresponding to the JavaScript
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.sanity.kweb.dom
package io.kweb.dom

/**
* Created by ian on 4/3/17.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.sanity.kweb.dom.attributes
package io.kweb.dom.attributes

/**
* Created by ian on 1/14/17.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.github.sanity.kweb.dom.cookies
package io.kweb.dom.cookies

import com.github.salomonbrys.kotson.fromJson
import com.github.sanity.kweb.WebBrowser
import com.github.sanity.kweb.dom.element.KWebDSL
import com.github.sanity.kweb.gson
import com.github.sanity.kweb.toJson
import io.kweb.WebBrowser
import io.kweb.dom.element.KWebDSL
import io.kweb.gson
import io.kweb.toJson
import java.time.Duration
import java.util.*
import java.util.concurrent.CompletableFuture
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.github.sanity.kweb.dom.element

import com.github.sanity.kweb.Kweb
import com.github.sanity.kweb.WebBrowser
import com.github.sanity.kweb.dom.element.creation.ElementCreator
import com.github.sanity.kweb.dom.element.creation.tags.h1
import com.github.sanity.kweb.dom.element.modification.removeChildAt
import com.github.sanity.kweb.dom.element.modification.setAttribute
import com.github.sanity.kweb.dom.element.modification.text
import com.github.sanity.kweb.dom.element.read.read
import com.github.sanity.kweb.plugins.KWebPlugin
package io.kweb.dom.element

import io.kweb.Kweb
import io.kweb.WebBrowser
import io.kweb.dom.element.creation.ElementCreator
import io.kweb.dom.element.creation.tags.h1
import io.kweb.dom.element.modification.removeChildAt
import io.kweb.dom.element.modification.setAttribute
import io.kweb.dom.element.modification.text
import io.kweb.dom.element.read.read
import io.kweb.plugins.KWebPlugin
import kotlinx.coroutines.experimental.future.await
import kotlinx.coroutines.experimental.future.future
import java.util.concurrent.CompletableFuture
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.github.sanity.kweb.dom.element.creation
package io.kweb.dom.element.creation

import com.github.sanity.kweb.dom.attributes.attr
import com.github.sanity.kweb.dom.element.Element
import com.github.sanity.kweb.plugins.KWebPlugin
import com.github.sanity.kweb.random
import com.github.sanity.kweb.toJson
import io.kweb.dom.attributes.attr
import io.kweb.dom.element.Element
import io.kweb.plugins.KWebPlugin
import io.kweb.random
import io.kweb.toJson
import mu.KLogging
import java.util.concurrent.ConcurrentHashMap
import kotlin.reflect.KClass
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.github.sanity.kweb.dom.element.creation.tags
package io.kweb.dom.element.creation.tags

import com.github.salomonbrys.kotson.toJson
import com.github.sanity.kweb.dom.attributes.attr
import com.github.sanity.kweb.dom.attributes.set
import com.github.sanity.kweb.dom.element.Element
import com.github.sanity.kweb.dom.element.creation.ElementCreator
import com.github.sanity.kweb.dom.element.modification.setAttribute
import io.kweb.dom.attributes.attr
import io.kweb.dom.attributes.set
import io.kweb.dom.element.Element
import io.kweb.dom.element.creation.ElementCreator
import io.kweb.dom.element.modification.setAttribute
import java.util.concurrent.CompletableFuture

/**
Expand Down
Loading

0 comments on commit 468b9b2

Please sign in to comment.