-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
94 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,95 @@ | ||
# grace-unpoly | ||
[![Main branch build status](https://github.com/grace-plugins/grace-unpoly/workflows/Grace%20CI/badge.svg?style=flat)](https://github.com/grace-plugins/grace-unpoly/actions?query=workflow%3A%Grace+CI%22) | ||
[![Apache 2.0 license](https://img.shields.io/badge/License-APACHE%202.0-green.svg?logo=APACHE&style=flat)](https://opensource.org/licenses/Apache-2.0) | ||
[![Latest version on Maven Central](https://img.shields.io/maven-central/v/org.graceframework.plugins/unpoly.svg?label=Maven%20Central&logo=apache-maven&style=flat)](https://search.maven.org/search?q=g:org.graceframework.plugins) | ||
|
||
This project is generated by Grace v2022.2.4. | ||
# Grace with Unpoly | ||
|
||
Grace Plugin for using Grace/Grails app with [Unpoly.js](https://unpoly.com). | ||
|
||
|
||
## Usage | ||
|
||
Add dependency to the `build.gradle`, | ||
|
||
```gradle | ||
repositories { | ||
mavenCentral() | ||
} | ||
dependencies { | ||
implementation "org.graceframework.plugins:unpoly:VERSION" | ||
} | ||
``` | ||
|
||
Unpoly plugin supports controller-specific `withFormat()` method, | ||
|
||
```groovy | ||
class BookController { | ||
def list() { | ||
def books = Book.list() | ||
withFormat { | ||
unpoly { | ||
render(template: "book", model: [bookList: books]) | ||
} | ||
json { | ||
render books as JSON | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
Also, this plugin supports extendsions for Grails Request and Response, | ||
|
||
```groovy | ||
// You can get unpoly request headers from Grails Request | ||
request.unpoly.version == request.getHeader('X-UP-Version') | ||
request.unpoly.target == request.getHeader('X-UP-Target') | ||
// Check Unpoly request? | ||
if (request.unpoly as boolean) { // or use request.isUnpoly() | ||
template = 'book-detail' | ||
} | ||
// You can set Unpoly response headers in Grails | ||
response.unpoly.target = '.content' | ||
response.unpoly.events = JsonOutput.toJson([["type": "itemDeleted"]]) | ||
``` | ||
|
||
## Development | ||
|
||
### Build from source | ||
|
||
``` | ||
git clone https://github.com/grace-plugins/grace-unpoly.git | ||
cd grace-unpoly | ||
./gradlew publishToMavenLocal | ||
``` | ||
|
||
## Support Version | ||
|
||
* Grace 2022.0.0+ | ||
* Grails 3.0+ | ||
|
||
## Roadmap | ||
|
||
### 1.x | ||
|
||
* Unpoly 3.x | ||
|
||
## License | ||
|
||
This plugin is available as open source under the terms of the [APACHE LICENSE, VERSION 2.0](http://apache.org/Licenses/LICENSE-2.0) | ||
|
||
## Links | ||
|
||
- [Grace Framework](https://github.com/graceframework/grace-framework) | ||
- [Grace Plugins](https://github.com/grace-plugins) | ||
- [Grace Unpoly Plugin](https://github.com/grace-plugins/grace-unpoly) | ||
- [Unpoly](https://unpoly.com) |