Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of https://github.com/TinyMission/kara

Conflicts:
	src/KaraExec/src/generators/Generator.kt
  • Loading branch information...
commit d56fe51720b2aaa21333cc5806ad66f1259e509a 2 parents 4049d48 + 64728b6
@cheptsov cheptsov authored
View
1  .idea/ant.xml
@@ -9,6 +9,7 @@
<maximumHeapSize value="128" />
<maximumStackSize value="2" />
<properties />
+ <executeOn event="afterCompilation" target="jars" />
</buildFile>
</component>
</project>
View
3  README.md
@@ -13,6 +13,9 @@ Kara is developed by [Tiny Mission](http://tinymission.com). We're a small web a
There's plenty of work left to do to make Kara a first class framework, and we'd welcome contributions. Contact andy at tinymission.com to get involved.
+## Continous integration and Downloads
+CI is set up at [TeamCity](http://teamcity.jetbrains.com/project.html?projectId=project77&tab=projectOverview).
+Download latest successful [build](http://teamcity.jetbrains.com/repository/download/bt432/.lastSuccessful/kara-{build.number}.zip)
## Bugs, Suggestions and Feature Requests
View
4 build.xml
@@ -5,6 +5,10 @@
<property name="build.number" value="SNAPSHOT"/>
<target name="jars">
+ <delete dir="modules" failonerror="false"/>
+ <mkdir dir="modules"/>
+ <mkdir dir="modules/core"/>
+
<jar destfile="modules/KaraExec.jar" update="false">
<fileset dir="out/production/KaraExec">
<exclude name="**/script.kts"/>
View
2  samples/KaraDemo/KaraDemo.iml
@@ -2,7 +2,7 @@
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/bin" />
- <output-test url="file://$MODULE_DIR$/../../out/test/KaraDemo" />
+ <output-test url="file://$KARA_HOME$/out/test/KaraDemo" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
View
2  src/KaraExec/src/Main.kt
@@ -62,7 +62,6 @@ Generators:
Currently supports: 'idea' for IntelliJ IDEA
- update Updates the application's Kara dependency to the latest version
route <name> Generates a new route with the given name.
view <route> <view> Generate a new view for the given route. ('View' will be automatically appended to the name)
@@ -109,7 +108,6 @@ fun main(args: Array<String>) {
"g", "generate" -> runGenerator = true
"d", "dependencies" -> resolveDependencies = true
"h", "help" -> showHelp = true
- "update" -> generatorTask = GeneratorTask.update
"project" -> generatorTask = GeneratorTask.project
"route" -> generatorTask = GeneratorTask.route
"view" -> generatorTask = GeneratorTask.view
View
54 src/KaraExec/src/generators/Generator.kt
@@ -13,7 +13,6 @@ import com.google.common.io.Files
enum class GeneratorTask(val name : String) {
project: GeneratorTask("project")
route: GeneratorTask("route")
- update: GeneratorTask("update")
view: GeneratorTask("view")
fun toString() : String {
return name
@@ -46,7 +45,7 @@ class Generator(val appConfig : AppConfig, val task : GeneratorTask, val args :
var stylesheetName : String = ""
- var ide = ""
+ var ide = "default"
var projectName = ""
@@ -76,9 +75,6 @@ class Generator(val appConfig : AppConfig, val task : GeneratorTask, val args :
for (arg in args)
execRoute(arg)
}
- GeneratorTask.update -> {
- execUpdate()
- }
GeneratorTask.view -> {
// ensure there's a route name and a view name
if (args.size != 2)
@@ -151,17 +147,13 @@ class Generator(val appConfig : AppConfig, val task : GeneratorTask, val args :
createDir("tmp")
createIDEFiles(ide)
- // copy the necessary libraries
- copyFile("lib/kotlin-runtime.jar", "lib/kotlin-runtime.jar")
- copyFile("modules/core/KaraLib.jar", "lib/KaraLib.jar")
// render the templates
- renderTemplate(moduleImlTemplate(this), "${appConfig.appPackage}.iml")
- renderTemplate(buildxmlTemplate(this), "build.xml")
+ renderTemplate(buildxmlTemplate(), "build.xml")
renderTemplate(ivyTemplate(this, projectName), "ivy.xml")
- renderTemplate(appconfigTemplate(this), "config/appconfig.json")
- renderTemplate(appconfigDevelopmentTemplate(this), "config/appconfig.development.json")
- renderTemplate(applicationTemplate(this), "src/$appPackagePath/Application.kt")
+ renderTemplate(appconfigTemplate(), "config/appconfig.json")
+ renderTemplate(appconfigDevelopmentTemplate(), "config/appconfig.development.json")
+ renderTemplate(applicationTemplate(), "src/$appPackagePath/Application.kt")
// make the default routes and view
execRoute("Home")
@@ -179,7 +171,7 @@ class Generator(val appConfig : AppConfig, val task : GeneratorTask, val args :
ensureDir("src/$appPackagePath/routes")
- renderTemplate(routeTemplate(this), "src/$appPackagePath/routes/${routeClassName}.kt")
+ renderTemplate(routeTemplate(), "src/$appPackagePath/routes/${routeClassName}.kt")
execLayout("Default")
execView(routeName, "Index")
}
@@ -193,8 +185,8 @@ class Generator(val appConfig : AppConfig, val task : GeneratorTask, val args :
ensureDir("src/$appPackagePath/views")
ensureDir("src/$appPackagePath/styles")
- renderTemplate(layoutTemplate(this), "src/$appPackagePath/views/${viewName}.kt")
- renderTemplate(stylesheetTemplate(this), "src/$appPackagePath/styles/${stylesheetName}.kt")
+ renderTemplate(layoutTemplate(), "src/$appPackagePath/views/${viewName}.kt")
+ renderTemplate(stylesheetTemplate(), "src/$appPackagePath/styles/${stylesheetName}.kt")
}
@@ -211,13 +203,7 @@ class Generator(val appConfig : AppConfig, val task : GeneratorTask, val args :
val outPath = "src/$appPackagePath/views/$routeSlug/${viewName}.kt"
var isLanding = routeName == "Home" && vName == "Index"
- renderTemplate(viewTemplate(this, outPath, isLanding), outPath)
- }
-
-
- /** Updates the target project's Kara dependency to the latest version. */
- fun execUpdate() {
- copyFile("out/jars/KaraLib.jar", "lib/KaraLib.jar")
+ renderTemplate(viewTemplate(outPath, isLanding), outPath)
}
@@ -266,31 +252,11 @@ class Generator(val appConfig : AppConfig, val task : GeneratorTask, val args :
fun createIDEFiles(ide: String) {
when (ide) {
- "idea" -> createIDEAFiles()
+ "default", "idea" -> createIDEAFiles()
else -> {
throw RuntimeException("$ide not supported")
}
}
}
-
- fun createIDEAFiles() {
- // TODO: .idea works on Windows too?
- ensureDir(".idea")
- ensureDir(".idea/scopes")
- ensureDir(".idea/copyright")
- ensureDir(".idea/libraries")
- renderTemplate(gradleTemplate(this), ".idea/gradle.xml")
- renderTemplate(compilerTemplate(this), ".idea/compiler.xml")
- renderTemplate(encodingsTemplate(this), ".idea/encodings.xml")
- renderTemplate(uiDesignerTemplate(this), ".idea/uiDesigner.xml")
- renderTemplate(vcsTemplate(this), ".idea/vcs.xml")
- renderTemplate(miscTemplate(this), ".idea/misc.xml")
- renderTemplate(scopeTemplate(this), ".idea/scopes/scope_settings.xml")
- renderTemplate(nameTemplate(this), ".idea/.name")
- renderTemplate(copyrightTemplate(this), ".idea/copyright/profile_settings.xml")
- renderTemplate(modulesTemplate(this), ".idea/modules.xml")
- renderTemplate(libraryKaraTemplate(this), ".idea/libraries/KaraLib.xml")
- }
-
}
View
22 src/KaraExec/src/generators/templates/GeneralTemplates.kt
@@ -7,11 +7,11 @@ import kara.generators.Generator
*/
-fun appconfigTemplate(gen : Generator) : String {
+fun Generator.appconfigTemplate() : String {
return """
{
"kara": {
- "appPackage": "${gen.appPackage}",
+ "appPackage": "${appPackage}",
"publicDir": "public",
"stylesheetDir": "stylesheets",
"sessionDir": "tmp/sessions"
@@ -20,7 +20,7 @@ fun appconfigTemplate(gen : Generator) : String {
"""
}
-fun appconfigDevelopmentTemplate(gen : Generator) : String {
+fun Generator.appconfigDevelopmentTemplate() : String {
return """
{
"kara": {
@@ -31,7 +31,7 @@ fun appconfigDevelopmentTemplate(gen : Generator) : String {
}
-fun buildxmlTemplate(gen : Generator) : String {
+fun Generator.buildxmlTemplate() : String {
return """
<project>
<target name="restart">
@@ -44,9 +44,9 @@ fun buildxmlTemplate(gen : Generator) : String {
}
-fun applicationTemplate(gen : Generator) : String {
+fun Generator.applicationTemplate() : String {
return """
-package ${gen.appPackage}
+package ${appPackage}
import kara.config.*
@@ -67,15 +67,15 @@ public class Application(config: AppConfig) : kara.app.Application(config) {
"""
}
-fun routeTemplate(gen : Generator) : String {
+fun Generator.routeTemplate() : String {
return """
-package ${gen.appPackage}.routes
+package ${appPackage}.routes
-import ${gen.appPackage}.views.*
-import ${gen.appPackage}.views.${gen.routeSlug}.*
+import ${appPackage}.views.*
+import ${appPackage}.views.${routeSlug}.*
import kara.controllers.*
-object ${gen.routeClassName} {
+object ${routeClassName} {
val layout = DefaultLayout()
Get("/") class Index() : Request({
IndexView()
View
285 src/KaraExec/src/generators/templates/IDEATemplates.kt
@@ -3,255 +3,90 @@ package generators.templates
import kara.generators.Generator
import java.util.UUID
-
-fun gradleTemplate(gen: Generator): String {
- val USER_HOME = "\$USER_HOME"
- return """<?xml version="1.0" encoding="UTF-8"?>
- <project version="4">
- <component name="GradleSettings">
- <option name="gradleHome" value="$USER_HOME$/frameworks/gradle-1.0" />
- </component>
- </project>
- """
-}
-
-fun compilerTemplate(gen: Generator): String {
-
- return """<?xml version="1.0" encoding="UTF-8"?>
- <project version="4">
- <component name="CompilerConfiguration">
- <option name="DEFAULT_COMPILER" value="Javac" />
- <resourceExtensions />
- <wildcardResourcePatterns>
- <entry name="!?*.java" />
- <entry name="!?*.form" />
- <entry name="!?*.class" />
- <entry name="!?*.groovy" />
- <entry name="!?*.scala" />
- <entry name="!?*.flex" />
- <entry name="!?*.kt" />
- <entry name="!?*.clj" />
- </wildcardResourcePatterns>
- <annotationProcessing>
- <profile default="true" name="Default" enabled="false">
- <processorPath useClasspath="true" />
- </profile>
- </annotationProcessing>
- </component>
- </project>
- """
-}
-
-fun encodingsTemplate(gen: Generator): String {
- return """<?xml version="1.0" encoding="UTF-8"?>
- <project version="4">
- <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
- </project>
- """
-}
-
-fun uiDesignerTemplate(gen: Generator): String {
- val Separator = "\$Separator"
- return """<?xml version="1.0" encoding="UTF-8"?>
- <project version="4">
- <component name="Palette2">
- <group name="Swing">
- <item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
- <default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
- </item>
- <item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
- <default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
- </item>
- <item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
- <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
- </item>
- <item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
- <default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
- </item>
- <item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
- <default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
- <initial-values>
- <property name="text" value="Button" />
- </initial-values>
- </item>
- <item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
- <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
- <initial-values>
- <property name="text" value="RadioButton" />
- </initial-values>
- </item>
- <item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
- <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
- <initial-values>
- <property name="text" value="CheckBox" />
- </initial-values>
- </item>
- <item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
- <default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
- <initial-values>
- <property name="text" value="Label" />
- </initial-values>
- </item>
- <item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
- <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
- <preferred-size width="150" height="-1" />
- </default-constraints>
- </item>
- <item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
- <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
- <preferred-size width="150" height="-1" />
- </default-constraints>
- </item>
- <item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
- <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
- <preferred-size width="150" height="-1" />
- </default-constraints>
- </item>
- <item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
- <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
- <preferred-size width="150" height="50" />
- </default-constraints>
- </item>
- <item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
- <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
- <preferred-size width="150" height="50" />
- </default-constraints>
- </item>
- <item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
- <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
- <preferred-size width="150" height="50" />
- </default-constraints>
- </item>
- <item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
- <default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
- </item>
- <item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
- <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
- <preferred-size width="150" height="50" />
- </default-constraints>
- </item>
- <item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
- <default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
- <preferred-size width="150" height="50" />
- </default-constraints>
- </item>
- <item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
- <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
- <preferred-size width="150" height="50" />
- </default-constraints>
- </item>
- <item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
- <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
- <preferred-size width="200" height="200" />
- </default-constraints>
- </item>
- <item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
- <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
- <preferred-size width="200" height="200" />
- </default-constraints>
- </item>
- <item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
- <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
- </item>
- <item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
- <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
- </item>
- <item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
- <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
- </item>
- <item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
- <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
- </item>
- <item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
- <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
- <preferred-size width="-1" height="20" />
- </default-constraints>
- </item>
- <item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
- <default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
- </item>
- <item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
- <default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
- </item>
- </group>
- </component>
- </project>
- """
-
-}
-
-fun vcsTemplate(gen: Generator): String {
- return """<?xml version="1.0" encoding="UTF-8"?>
- <project version="4">
- <component name="VcsDirectoryMappings">
- <mapping directory="" vcs="" />
- </component>
- </project>
- """
-
-
-}
-
-fun miscTemplate(gen: Generator): String {
- val PROJECT_DIR = "\$PROJECT_DIR"
- val guid = UUID.randomUUID().toString().replace("-","")
- return """<?xml version="1.0" encoding="UTF-8"?>
- <project version="4">
- <component name="IdProvider" IDEtalkID="$guid" />
- <component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true">
- <output url="file://$PROJECT_DIR$/out" />
- </component>
- </project>
-"""
+fun Generator.createIDEAFiles() {
+ ensureDir(".idea")
+ ensureDir(".idea/libraries")
+ renderTemplate(nameTemplate(), ".idea/.name")
+ renderTemplate(modulesTemplate(), ".idea/modules.xml")
+ renderTemplate(misc(), ".idea/misc.xml")
+ renderTemplate(libraryKaraTemplate(), ".idea/libraries/KaraLib.xml")
+ renderTemplate(libraryKotlinRuntime(), ".idea/libraries/KotlinRuntime.xml")
+ renderTemplate(moduleImlTemplate(), "${appConfig.appPackage}.iml")
}
-fun modulesTemplate(gen: Generator): String {
+fun Generator.modulesTemplate(): String {
val PROJECT_DIR = "\$PROJECT_DIR"
return """<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
- <module fileurl="file://$PROJECT_DIR$/${gen.appPackage}.iml" filepath="$PROJECT_DIR$/${gen.appPackage}.iml" />
+ <module fileurl="file://$PROJECT_DIR$/${appPackage}.iml" filepath="$PROJECT_DIR$/${appPackage}.iml" />
</modules>
</component>
</project>
"""
-
-}
-fun scopeTemplate(gen: Generator): String {
- return """<component name="DependencyValidationManager">
- <state>
- <option name="SKIP_IMPORT_STATEMENTS" value="false" />
- </state>
- </component>
- """
}
-fun nameTemplate(gen: Generator): String {
- return """${gen.projectName}"""
+fun Generator.nameTemplate(): String {
+ return """${projectName}"""
}
-fun copyrightTemplate(gen: Generator): String {
- return """<component name="CopyrightManager">
- <settings default="">
- <module2copyright />
- </settings>
- </component>
+fun Generator.libraryKaraTemplate(): String {
+ val KARA_HOME = "\$KARA_HOME"
+ return """<component name="libraryTable">
+ <library name="KaraLib">
+ <CLASSES>
+ <root url="jar://$KARA_HOME$/modules/core/KaraLib.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES>
+ <root url="jar://$KARA_HOME$/modules/core/KaraLib-sources.zip!/" />
+ </SOURCES>
+ </library>
+</component>
"""
}
-fun libraryKaraTemplate(gen: Generator): String {
- val PROJECT_DIR = "\$PROJECT_DIR"
+fun Generator.libraryKotlinRuntime() : String {
+ val KARA_HOME = "\$KARA_HOME"
return """<component name="libraryTable">
- <library name="KaraLib">
+ <library name="KotlinRuntime">
<CLASSES>
- <root url="jar://$PROJECT_DIR$/lib/KaraLib.jar!/" />
+ <root url="jar://$KARA_HOME$/lib/kotlin-runtime.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
- <root url="jar://$PROJECT_DIR$/lib/KaraLib.jar!/" />
+ <root url="jar://$KARA_HOME/lib/kotlin-runtime.jar!/src" />
</SOURCES>
</library>
</component>
"""
-}
+}
+
+fun Generator.misc() : String {
+ return """<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" assert-keyword="true" jdk-15="true" project-jdk-name="1.7" project-jdk-type="JavaSDK" />
+</project>
+"""
+}
+
+fun Generator.moduleImlTemplate() : String {
+ val MODULE_DIR = "\$MODULE_DIR"
+ return """<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+ <component name="NewModuleRootManager" inherit-compiler-output="false">
+ <output url="file://$MODULE_DIR$/bin" />
+ <output-test url="file://$MODULE_DIR$/bin/test" />
+ <exclude-output />
+ <content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
+ </content>
+ <orderEntry type="jdk" jdkName="1.7" jdkType="JavaSDK" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="library" name="KotlinRuntime" level="project" />
+ <orderEntry type="library" name="KaraLib" level="project" />
+ </component>
+</module>
+"""
+}
View
28 src/KaraExec/src/generators/templates/ProjectTemplates.kt
@@ -1,28 +0,0 @@
-package generators.templates
-
-import kara.generators.Generator
-
-/**
- * Templates for project generation.
- */
-
-val MODULE_DIR = "\$MODULE_DIR"
-
-fun moduleImlTemplate(gen : Generator) : String {
- return """<?xml version="1.0" encoding="UTF-8"?>
-<module type="JAVA_MODULE" version="4">
- <component name="NewModuleRootManager" inherit-compiler-output="false">
- <output url="file://$MODULE_DIR$/bin" />
- <output-test url="file://$MODULE_DIR$/bin/test" />
- <exclude-output />
- <content url="file://$MODULE_DIR$">
- <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
- </content>
- <orderEntry type="jdk" jdkName="1.7" jdkType="JavaSDK" />
- <orderEntry type="sourceFolder" forTests="false" />
- <orderEntry type="library" name="KotlinRuntime" level="project" />
- <orderEntry type="library" name="KaraLib" level="project" />
- </component>
-</module>
-"""
-}
View
22 src/KaraExec/src/generators/templates/ViewTemplates.kt
@@ -21,13 +21,13 @@ p("Start by editing this file here: $filePath")
* Templates for generating views.
*/
-fun viewTemplate(gen : Generator, filePath : String, isLanding : Boolean = false) : String {
+fun Generator.viewTemplate(filePath : String, isLanding : Boolean = false) : String {
return """
-package ${gen.appPackage}.views.${gen.routeSlug}
+package ${appPackage}.views.${routeSlug}
import kara.views.*
-class ${gen.viewName}() : HtmlView() {
+class ${viewName}() : HtmlView() {
override fun render(context: ActionContext) {
${if (isLanding) landingViewBody(filePath) else generalViewBody(filePath)}
}
@@ -37,18 +37,18 @@ class ${gen.viewName}() : HtmlView() {
}
-fun layoutTemplate(gen : Generator) : String {
+fun Generator.layoutTemplate() : String {
return """
-package ${gen.appPackage}.views
+package ${appPackage}.views
import kara.views.*
-import ${gen.appPackage}.styles.*
+import ${appPackage}.styles.*
-class ${gen.viewName}() : HtmlLayout() {
+class ${viewName}() : HtmlLayout() {
override fun render(context: ActionContext, mainView: HtmlView) {
head {
title("Kara App")
- stylesheet(${gen.stylesheetName}())
+ stylesheet(${stylesheetName}())
}
body {
h1("Kara App")
@@ -63,13 +63,13 @@ class ${gen.viewName}() : HtmlLayout() {
}
-fun stylesheetTemplate(gen : Generator) : String {
+fun Generator.stylesheetTemplate() : String {
return """
-package ${gen.appPackage}.styles
+package ${appPackage}.styles
import kara.styles.*
-class ${gen.stylesheetName}() : Stylesheet() {
+class ${stylesheetName}() : Stylesheet() {
override fun render() {
s("body") {
backgroundColor = c("#f0f0f0")
View
2  src/KaraLib/src/kara/Util.kt
@@ -60,5 +60,5 @@ fun Any.properties() : List<String> {
}
}
- return answer
+ return answer.sort()
}
View
2  src/KaraTests/src/karatests/controllers/ActionTests.kt
@@ -41,7 +41,7 @@ class ActionTests() {
}
Test fun externalForm() {
- assertEquals("/foo/compute?anInt=42&aFloat=3.1415", Routes.Foo.ComputeQuery(42, 3.1415.toFloat()).toExternalForm())
+ assertEquals("/foo/compute?aFloat=3.1415&anInt=42", Routes.Foo.ComputeQuery(42, 3.1415.toFloat()).toExternalForm())
assertEquals("/foo/compute/42/3.1415", Routes.Foo.Compute(42, 3.1415.toFloat()).toExternalForm())
}

0 comments on commit d56fe51

Please sign in to comment.
Something went wrong with that request. Please try again.