Skip to content

Commit

Permalink
Merge pull request #16 from mb720/master
Browse files Browse the repository at this point in the history
Markdown example
  • Loading branch information
renaudpawlak authored Jul 2, 2016
2 parents cb514ee + 8d6317f commit f2f4256
Show file tree
Hide file tree
Showing 9 changed files with 1,494 additions and 133 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
.generated
/.gradle/
/build/
/gradle/
*.swp
*.swo
*.iml
.idea/
88 changes: 50 additions & 38 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,58 +12,70 @@ sourceCompatibility = 1.8
targetCompatibility = 1.8

buildscript {
boolean snapshotMode = true;
project.ext.repoType = snapshotMode ? 'snapshot' : 'release';
project.ext.dependenciesVersionSuffix = snapshotMode ? '-SNAPSHOT' : '';

println "repoType=" + project.repoType
println "dependenciesVersionSuffix=" + project.dependenciesVersionSuffix

repositories {
mavenCentral()
maven { url "http://repository.jsweet.org/artifactory/libs-" + project.repoType + "-local" }
maven { url "http://repository.jsweet.org/artifactory/plugins-" + project.repoType + "-local" }
maven { url "http://google-diff-match-patch.googlecode.com/svn/trunk/maven" }
}
dependencies {
classpath('org.jsweet:jsweet-gradle-plugin:1.1.0-SNAPSHOT') { //
transitive = true }
}
boolean snapshotMode = true;
project.ext.repoType = snapshotMode ? 'snapshot' : 'release';
project.ext.dependenciesVersionSuffix = snapshotMode ? '-SNAPSHOT' : '';

println "repoType=" + project.repoType
println "dependenciesVersionSuffix=" + project.dependenciesVersionSuffix

repositories {
mavenCentral()
maven { url "http://repository.jsweet.org/artifactory/libs-" + project.repoType + "-local" }
maven { url "http://repository.jsweet.org/artifactory/plugins-" + project.repoType + "-local" }
maven { url "http://google-diff-match-patch.googlecode.com/svn/trunk/maven" }
}
dependencies {
classpath('org.jsweet:jsweet-gradle-plugin:1.1.0-SNAPSHOT') { //
transitive = true
}
}
}


task wrapper(type: Wrapper) {
description = "Generates gradlew(.bat) scripts. To update, run this after changing Gradle's version number."
gradleVersion = "3.0-milestone-2"

// Include Gradle documentation and source
distributionUrl = "https://services.gradle.org/distributions/gradle-${gradleVersion}-all.zip"
}

repositories {
mavenCentral()
maven { url "http://repository.jsweet.org/artifactory/libs-" + project.repoType + "-local" }
maven { url "http://google-diff-match-patch.googlecode.com/svn/trunk/maven" }
mavenCentral()
maven { url "http://repository.jsweet.org/artifactory/libs-" + project.repoType + "-local" }
maven { url "http://google-diff-match-patch.googlecode.com/svn/trunk/maven" }
}

configurations {
jsweetcorestrict
configurations {
jsweetcorestrict
}

dependencies {
compile group: 'org.jsweet', name: 'jsweet-transpiler', version:"1.1.0" + project.dependenciesVersionSuffix
compile group: 'org.jsweet.candies', name: 'jsweet-core', version:"1.1.0" + project.dependenciesVersionSuffix
compile group: 'org.jsweet.candies', name: 'jquery', version:"1.10.0" + project.dependenciesVersionSuffix
compile group: 'org.jsweet.candies', name: 'jqueryui', version:"1.9.0" + project.dependenciesVersionSuffix
compile group: 'org.jsweet.candies', name: 'angular', version:"1.4.0" + project.dependenciesVersionSuffix
compile group: 'org.jsweet.candies', name: 'angular-route', version:"1.3.0" + project.dependenciesVersionSuffix
compile group: 'org.jsweet.candies', name: 'es6-promise', version:"0.0.0" + project.dependenciesVersionSuffix
compile group: 'org.jsweet.candies', name: 'backbone', version:"1.0.0" + project.dependenciesVersionSuffix
compile group: 'org.jsweet.candies', name: 'knockout', version:"3.2.0" + project.dependenciesVersionSuffix
compile group: 'org.jsweet', name: 'jsweet-transpiler', version: "1.2.0" + project.dependenciesVersionSuffix
compile group: 'org.jsweet.candies', name: 'jsweet-core', version: "1.1.0" + project.dependenciesVersionSuffix
compile group: 'org.jsweet.candies', name: 'jquery', version: "1.10.0" + project.dependenciesVersionSuffix
compile group: 'org.jsweet.candies', name: 'jqueryui', version: "1.9.0" + project.dependenciesVersionSuffix
compile group: 'org.jsweet.candies', name: 'angular', version: "1.4.0" + project.dependenciesVersionSuffix
compile group: 'org.jsweet.candies', name: 'angular-route', version: "1.3.0" + project.dependenciesVersionSuffix
compile group: 'org.jsweet.candies', name: 'es6-promise', version: "0.0.0" + project.dependenciesVersionSuffix
compile group: 'org.jsweet.candies', name: 'backbone', version: "1.0.0" + project.dependenciesVersionSuffix
compile group: 'org.jsweet.candies', name: 'knockout', version: "3.2.0" + project.dependenciesVersionSuffix
// Allows us to use 'marked', a Markdown to HTML converter: https://github.com/chjj/marked
compile group: 'org.jsweet.candies', name: 'marked', version: "0.0.0-SNAPSHOT"
}

compileJava {
enabled = false
enabled = false
}

apply plugin: 'org.jsweet.jsweet-gradle-plugin'

jsweet {
verbose = true
encoding = 'UTF-8'
sourceMap = true
outDir = new File('target/js')
targetVersion = EcmaScriptComplianceLevel.ES3
includes = ['**/org/jsweet/examples/**/*.java']
verbose = true
encoding = 'UTF-8'
sourceMap = true
outDir = new File('target/js')
targetVersion = EcmaScriptComplianceLevel.ES3
includes = ['**/org/jsweet/examples/**/*.java']
}
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Sat Jun 25 16:33:36 CEST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.0-milestone-2-all.zip
180 changes: 90 additions & 90 deletions gradlew.bat
Original file line number Diff line number Diff line change
@@ -1,90 +1,90 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################

@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto init

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:init
@rem Get command-line arguments, handling Windowz variants

if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args

:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2

:win9xME_args_slurp
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*
goto execute

:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1

:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################

@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto init

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:init
@rem Get command-line arguments, handling Windows variants

if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args

:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2

:win9xME_args_slurp
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*
goto execute

:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1

:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega
43 changes: 43 additions & 0 deletions src/main/java/org/jsweet/examples/markdown/MarkdownExample.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package org.jsweet.examples.markdown;

import jsweet.dom.HTMLElement;
import jsweet.dom.HTMLInputElement;

import static def.marked.Globals.marked;
import static jsweet.dom.Globals.document;

/**
* Lets the user enter text and converts it from Markdown to HTML.
* Created by Matthias Braun on 6/25/2016.
*/
public class MarkdownExample {

public MarkdownExample() {
// Get the input and output elements from markdown/index.hml
HTMLInputElement markdownInput = (HTMLInputElement) document.querySelector("#markdownInput");
HTMLElement htmlOutput = (HTMLElement) document.querySelector("#htmlOutput");

// Initially, show the default text of the input element in the HTML output
convert(markdownInput, htmlOutput);

// Markdown text in the input element appears as HTML in the output element when the user types
markdownInput.addEventListener("keyup", evt -> convert(markdownInput, htmlOutput));
}

public static void main(String... args) {
new MarkdownExample();
}

/**
* Takes the text of the {@code inputElement}, converts it from Markdown to HTML, and puts the HTML into the
* {@code outputElement}.
*
* @param inputElement we convert the text of this {@link HTMLInputElement} from Markdown to HTML
* @param outputElement this {@link HTMLElement} contains the text of the {@code inputElement} converted from Markdown to HTML
*/
private static void convert(HTMLInputElement inputElement, HTMLElement outputElement) {
String inputText = inputElement.value;
String html = marked(inputText);
outputElement.innerHTML = html;
}
}
4 changes: 0 additions & 4 deletions src/main/java/org/jsweet/examples/todomvc/ToDos.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,6 @@ class TodoList extends Collection<Todo> {
Class<Todo> model = Todo.class;

// Save all of the todo items under the `"todos"` namespace.
// TODO: the Store class in backbone does not define any parameter in the
// constructor... maybe a mistake in the original TypeScript exammle, which
// declare the Store class as an "any" variable...
// Store localStorage = new Store("todos-backbone");
Store localStorage = new Store("todos-backbone");

// Filter down the list of all todo items that are finished.
Expand Down
Loading

0 comments on commit f2f4256

Please sign in to comment.