Your framework looks really cool, I would be happy to see the code and to try it too :)
The template I've done so far did not HTML escape the string, but I saw that in Templates.kt you did some work, so I thought just to wait for string escaping to be working (at least, I presume it's not working now, I didn't understand how to convert a string to a string array to build a StringTemplate instance).
If I correctly understand how Kotlin string works, they are converted to a String at runtime, but how I can access this array?
I need some day to push my code to github, because it include a sample app that use a database from one of my customer, I have to remove sensible data and
create another db containing only the 2 tables I used in the sample.
I’ll also add some comment to explain how I thought to put all my ideas together. Anyway I will be honoured to get your opinion…
Cheers
Andrea
Thank you, but as I said it is just a proof of concepts by now, not really usable for real work.
Anyway, I think I can put it on github within some day, at least to discuss the concepts
and if possible to start together to develop a web framework as discussed in this thread.
I think that the best way to go is to develop a Kotlin layer around the Play Scala core, as they
do with Scala.I don’t want to reinvent the wheel, and I really like Play.
Oh, I didn't remember to say I've also included LESS compiler from Asual
I've submitted my work to https://github.com/parroit/kweb.
It’s really rough for now, I’m in the process of adding comments to explain my ideas
and difficult I’ve found (someone due to my Kotlin inexperience, some due to compiler bugs).
I’ve included Intellij project and modules files, but not all dependencies jar. I think you can deduce it from Intellij project libraries, and in the meantime
I create a pom.
Remember that templates are not escaped in any way, use at your own risk!
I look forward for your comments…
Feel free to contact me by email if you prefer
Really nice (and big) work! It looks pretty cool and comprehensive for a proof of concept. It's really promising, if you need help to add new features on it, I would be happy to help.
Is there a simple way to run the sample app?
Loic
Thank you Loic, I'm happy you appreciate my work :)
To start the sample site, if you’ve managed to resolve all jar dependencies, there is
a main() function in siteswelcomesrcmainkweb-kotlinApp.kt.
It start the netty server and launch your browser on localhost:8080.
I need any kind of help to go on, your collaboration will be precious!
According to you what could be the best way to go on: continue with a new framework,
or to develop some kind of module to integrate in Play?
I think that the first option could attract developers that are not satisfied with Play 2
and its complete Scala rewrite, while the second option could attract all other
Play developers (the ones which like Play2…)
If you look at kw.views.Html.kt, it is all taken from the html builder sample, I think it’s
better to replace that with kool.io templates from James.
I think both of them would be good ways to go on : continue with a play module would be cool because of the big play community (good way to bring people to use kotlin) and because of the number of avalaible play modules. But Play 2 already have dependency on Scala runtime APIs, so maybe adding Koltin runtime would be a bit heavy. Building a new pure Kotlin framework may be really cool to bring new ideas and really make it in the "Koltin way".
By the way, I do not know if the Play-Kotlin project is progressing or if it was set aside…
Maybe Andrey Breslav could give us some hints on the status of play-kotlin? I agree with you that building a new pure Kotlin framework will give us more space to develop new kool ideas...
But there is really a lot of work to be done this way, we have to get more people involved!
Yes it would be better to know the progress on Play before making a decision...
Sure. I'll write a post on a new thread explicitly asking for this. Could I speak of our project?
I’ve see on your Github account Play2-HTML5Tags and I think, if you agree, that it would be great to convert it to Kotlin and use it as part of the framework template.
I think If we take this way and also
- improve KWeb template on the side of intellisense support (It is hard to configure and a bit fragile now)
- improve it on the side of HTML escaping to make it usable at least in beta quality pages with a minimum of security.
- include kool.io template, improved with your html5 input tags and my bootstrap tags
that we could get a great template framework that we could we use both in a completely new web framework and in a Kotlin Play module.
Sure. I'll write a post on a new thread explicitly asking for this. Could I speak of our project?
Of course you can, it' your "child" ;)
I've see on your Github account Play2-HTML5Tags and I think, if you agree, that it would be great to convert it to Kotlin and use it as part of the framework template. I think If we take this way and also
- improve KWeb template on the side of intellisense support (It is hard to configure and a bit fragile now)
- improve it on the side of HTML escaping to make it usable at least in beta quality pages with a minimum of security.
- include kool.io template, improved with your html5 input tags and my bootstrap tags
that we could get a great template framework that we could we use both in a completely new web framework and in a Kotlin Play module.
Great idea, it looks exciting! Another thing we could improve I think is the routes definition (App.kt). If we use a kind of template for this it would be more readable.
Yes the route definition, it's not really readable now. Just post an issue on Kweb project, I will comment on this issue there...
BTW by intellisense did you mean the language injection support in IDEA? If so how did you get it work? :)
It works great for me in Java using the @Language annotation; though it doesn’t seem to work for me in Kotlin though. Did you figure out a way?
I’ve raised http://youtrack.jetbrains.com/issue/KT-2428 to track it in the meantime.
Yes, I mean it. But you cannot inject HTML into Kotlin, at least for now, I hope Jetbrains guys will add support for the language soon. However, what you can do is inject Kotlin into HTML. This is supported and work, except inside strings, but with come caveats. Injection in HTML is done by HTML tag, so you have to choose which html tag will contain Kotlin code. I've configured the <html> tag in Idea, and I get Kotlin completion and error reporting for all code put inside it.
But, if you look at [https://github.com/parroit/kweb/blob/master/sites/welcome/src/main/kweb-kotlin/views/layout.html.kt],
you’ll see that the file is no more a valid Kotlin file, because it start with html tags.
So I have to change the file extension to something other than kt, and compile it by hand in [https://github.com/parroit/kweb/blob/master/src/main/kotlin/kw/server/compile/CompileView.kt].
I basically strip down from the file <doctype> <html> and </html> tags, compile the rest of the source (which is now valid kotlin).
<doctype> <html> and </html> are added by the htmlView fun when it render the output.
This process is a bit fragile by now, but I hope to improve it and make more solid.
A more standard approch like that of Play could be simpler to implement, but I love code completion
and error checking, I think that could be very useful…
I am ready also, i’m familiar with Play framework 2. I would write this module but i don’t know where to start.
Basing this development on the old Play! 1, would be really strange. I’ve worked with Play! 1 and Java and Play! 2 and Scala, and the latter was far better. Actually the design of Play! 1 is a bit strange: for example Play 1 uses exception to achieve a bit more “Ruby on Rails feeling”. And, although Play 1 is still maintained, it is definitely not the future. So, I think the development should definitely be based on Play 2.
Someone doubted that Play 2 is mature enough. It is. I’ve developed a Play 2 application over three years ago and even then was the framework solid. The application is still running without problems.
I wonder what build system should be used. Play 2 is heavily based on SBT, so a Kotlin plug-in for SBT or an alternative build system like Gradle would be necessary.
Is this idea still alive? Is there a project hosted somewhere? As a new Kotlin user who’s written web apps in Java, Rails, and Grails, I’m surprised there’s not much in the way of web frameworks for Kotlin.
spring boot already supports kotlin officially, so one could add kotlin runtime and std lib into an existing java project
After 6 months developing in Play Framework with Kotlin, I have written a blog post talking about it and we have two big projects in production using it, and this is the project example Play framework in kotlin
Thanks guys!