Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Minkyu Cho committed Jan 19, 2017
1 parent 5185fae commit 49bf239
Show file tree
Hide file tree
Showing 17 changed files with 502 additions and 107 deletions.
21 changes: 21 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
language: java

jdk:
- oraclejdk8

os:
- linux

branches:
only:
- master

cache:
directories:
- $HOME/.gradle

script:
- ./gradlew clean check

after_success:
- ./gradlew reportScoverage coveralls
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# 0.1.0

Init Project
20 changes: 20 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright (c) 2017 Minkyu Cho

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
105 changes: 67 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,41 @@
# Spring Node View Resolver

## [Node.js](https://nodejs.org) view resolver for [Spring MVC](https://spring.io) based on [J2V8](https://github.com/eclipsesource/J2V8)

[![Build Status](https://travis-ci.org/Pitzcarraldo/spring-node-view.svg?branch=master)](https://travis-ci.org/Pitzcarraldo/spring-node-view)
[![Coverage Status](https://coveralls.io/repos/Pitzcarraldo/spring-node-view/badge.png?branch=master)](https://coveralls.io/r/Pitzcarraldo/spring-node-view?branch=master)
[![Coverage Status](https://coveralls.io/repos/github/Pitzcarraldo/spring-node-view/badge.svg?branch=master)](https://coveralls.io/github/Pitzcarraldo/spring-node-view?branch=master)

## Use any type of JavaScript View Framework(React.js, Vue.js, etc) you want with Spring Project in Server Side!
### ⚠️️ Caution: This library is experimental yet. Please be careful when using for production service.

- What is Node.js: [Node.js](https://nodejs.org)
- What is J2V8: [J2V8](https://github.com/eclipsesource/J2V8)
- This Library is fully written in [Scala](https://www.scala-lang.org/), but works well with Java too.
- Support Spring MVC 3 and 4

## Getting Started

### Gradle

```groovy
buildscript {
repositories {
...
mavenCentral()
...
}
// ...
dependencies {
...
// ...
classpath 'com.google.gradle:osdetector-gradle-plugin:1.4.0'
classpath "com.layer:gradle-git-repo-plugin:2.0.2"
...
}
}
apply plugin: 'com.google.osdetector'
apply plugin: 'git-repo'
repositories {
mavenCentral()
github("Pitzcarraldo", "maven", "master", "snapshots")
// ...
maven {
url "https://oss.sonatype.org/content/repositories/snapshots"
}
}
dependencies {
...
compile("com.github.pitzcarraldo:spring-node-view:0.1.${osdetector.os}-SNAPSHOT")
....
// ...
compile("com.github.pitzcarraldo:spring-node-view:0.1.0.${osdetector.os}-SNAPSHOT")
}
```
Expand All @@ -46,24 +44,30 @@ dependencies {
### Maven

```xml
<build>
<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.4.0.Final</version>
</extension>
</extensions>
</build>
<repositories>
<repository>
<id>sonatype-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<dependencies>
...
<dependency>
<groupId>com.github.pitzcarraldo</groupId>
<artifactId>spring-node-view</artifactId>
<version>0.1.${inster_your_os, [osx|linux|windows]}-SNAPSHOT</version>
<version>0.1.0.${os.detected.name}-SNAPSHOT</version>
</dependency>
...
</dependencies>

<repositories>
...
<repository>
<id>com.github.pitzcarraldo</id>
<url>https://github.com/Pitzcarraldo/maven/raw/master/snapshots</url>
</repository>
...
</repositories>
```

### Spring configuration
Expand All @@ -72,11 +76,11 @@ dependencies {

```java
@Bean
public ViewResolver getViewResolver {
ViewResolver resolver = new NodeViewResolver();
public ViewResolver nodeViewResolver() {
NodeViewResolver resolver = new NodeViewResolver();
resolver.setPrefix("/WEB-INF/views/");
resolver.setSuffix(".js");
resolver.setViewClass(classOf[NodeView]);
resolver.setViewClass(NodeView.class);
resolver.setContentType("text/html;charset=UTF-8");
resolver.setCache(false);
// resolver.setCache(true);
Expand All @@ -90,7 +94,7 @@ dependencies {

```scala
@Bean
def getViewResolver: ViewResolver = {
def nodeViewResolver: ViewResolver = {
val resolver = new NodeViewResolver
resolver.setPrefix("/WEB-INF/views/")
resolver.setSuffix(".js")
Expand All @@ -109,7 +113,7 @@ dependencies {
// Just return generated HTML as String
module.exports = function(model) {
// ...
return '<html><head>~~~</head><body>~~~</body></html>';
return '<html><head>...</head><body>...</body></html>';
}

// Also could respond headers and body as Object
Expand All @@ -132,7 +136,7 @@ module.exports = function(model) {
headers: {
'Set-Cookie': 'userId=Pitzcarraldo; Domain=github.com; Expires=Wed, 17-Jan-2018 18:36:54 GMT; '
},
body: '<html><head>~~~</head><body>~~~</body></html>'
body: '<html><head>...</head><body>...</body></html>'
};
}
```
Expand All @@ -143,7 +147,7 @@ module.exports = function(model) {
// Just return callback with generated HTML as String
module.exports = function(model, callback) {
// ...
callback('<html><head>~~~</head><body>~~~</body></html>');
callback('<html><head>...</head><body>...</body></html>');
}

// Also could respond headers and body as Object
Expand All @@ -166,7 +170,32 @@ module.exports = function(model, callback) {
headers: {
'Set-Cookie': 'userId=Pitzcarraldo; Domain=github.com; Expires=Wed, 17-Jan-2018 18:36:54 GMT; '
},
body: '<html><head>~~~</head><body>~~~</body></html>'
body: '<html><head>...</head><body>...</body></html>'
});
}
```
```

## Trouble Shooting

This library uses the latest version of dependencies. And they can conflict with your project. You can exclude conflicting dependencies as follows:

```groovy
compile("com.github.pitzcarraldo:spring-node-view:0.1.0.${osdetector.os}-SNAPSHOT") {
   // Please uncomment the dependency that you want to exclude.
   // exclude group: 'com.google.guava', module: 'guava'
// exclude group: 'com.google.code.findbugs', module: 'jsr305'
// exclude group: 'javax.servlet', module: 'javax.servlet-api'
// exclude group: 'com.fasterxml.jackson.core', module: 'jackson-databind'
// exclude group: 'org.springframework', module: 'spring-webmvc'
}
```

## TODO

- Documentation
- Performance Test and Tuning
- Improve Test Coverage

## LICENSE

[MIT](LICENSE)
Loading

0 comments on commit 49bf239

Please sign in to comment.