From 859bbe95cb14e911f42c2fb8f33cc1c9523aef17 Mon Sep 17 00:00:00 2001 From: Greg Turnquist Date: Mon, 28 Nov 2016 10:34:44 -0600 Subject: [PATCH] Add programmatic token to automate editing browser.html In Spring Data REST, we need a more suitable way to tweak browser.html and inject our custom form and JSON Editor. Having a token to search on is quite handy. Updated the docs, sharing how others can use this as well. --- README.adoc | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++-- browser.html | 2 ++ 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/README.adoc b/README.adoc index 7fc98a7..dc52fad 100644 --- a/README.adoc +++ b/README.adoc @@ -151,10 +151,62 @@ HAL.customPostForm = CustomPostForm; ---- -NOTE: To load a custom JavaScript module AND a custom HTML template, you will probably need to create a customized version of `browser.html`. - NOTE: The HAL Browser uses a global `HAL` object, so there is no need to deal with JavaScript packages. +=== Hooking in custom code + +To load a custom JavaScript module AND a custom HTML template, you will probably need to create a customized version of `browser.html`. Manually editing the file might be good enough. Just look for the comment at the end of `browser.html`. + +But if you need something a little more sophisticated, like hooking into your build system, you can do a token search like this: + +[source,xml] +---- + + org.apache.maven.plugins + maven-antrun-plugin + + + process-resources + + run + + + + + + + + + + + + + <!-- Need to plugin some custom code? Put it here. --> + + + <!-- Spring Data REST's plugin --> + + <script src="vendor/js/jsoneditor.js" /> + <script src="js/CustomPostForm.js" /> + +</body> + + + + + + + + +---- + +This is code from http://projects.spring.io/spring-data-rest/[Spring Data REST] + +* The HAL Browser and the JSON Editor are both unpacked from WebJars +* Key files are copied into the target artifacts. +* The custom editor (driven by Spring Data REST's metadata) are then swapped in with a <>. + == Usage Instructions All you should need to do is copy the files into your webroot. diff --git a/browser.html b/browser.html index b890f51..14aa817 100644 --- a/browser.html +++ b/browser.html @@ -246,6 +246,8 @@

Embedded Resources

+ +