Groovy Syntax when setting img src in gsp - gsp

I am trying to change my image source based on the current controller. I could hard code it in with the direct file path for each individual image but I want to see if the following works:
<img class="imageTest" src="${controllerName == 'testboard' ? ${resource(base: session['brandingBasePath'], dir: 'styles/ui/pictures', file: 'board1.png')} : ${resource(base: session['brandingBasePath'], dir: 'styles/ui/picture', file: 'board2.png')}};
I get an error when trying this, but I am sort of a beginner with this language. Any ideas on getting this to work?

Oops, found my problem. You don't need to repeat the ${} (what are these even called) for each function.
<img class="imageTest" src="${controllerName == 'testboard' ? resource(base: session['brandingBasePath'], dir: 'styles/ui/pictures', file: 'board1.png') : resource(base: session['brandingBasePath'], dir: 'styles/ui/picture', file: 'board2.png')};
That would work.

Related

How to create a Anatomic Regions in Study Code Sequence

I'd like to edit a DICOM file with dcmodify to add an 'Anatomic Regions in Study Code Sequence' element (TAG: 0008,0063) but I'm unsure how to do this.
I can add the tag but what do I then add as its children? Is is it a list of (0018,0015) tags?
That should work:
$ dcmodify -i "(0008,0063)[0].(0018,0015)=FOOBAR" test.dcm
If you get something like:
E: modifying tag in file test.dcm: Invalid Path: Non-sequence tag found with rest path following
E: There was 1 error
This indicate that the attribute 0008,0063 is not declared in your dicom.dic file. Eg:
$ grep 0008,0063 /usr/share/dcmtk/dicom.dic
-> returns nothing
In that case simply update your dcmtk package.
ref:
DCMTK: dcmodify: Modify DICOM files

ScriptAssert script to read from properties?

I am using ScriptAssert and the script work's fine. Now I would like to move the script to properties file.
I am able to read PONumber.mandatory as part of message. I am unable to read PONumber.mandatory.script as part of script. Any help is appreciated.
ValidationMessages.properties
PONumber.mandatory.script=!(_.OBJSTATE.equals('RELEASED') && (_.PONumber == '' ))
PONumber.mandatory=PONumber value is Mandatory
In Java:
#ScriptAssert(lang="javascript",script="{PONumber.mandatory.script}",alias = "_",message="{PONumber.mandatory}")

How to get relative path, not full path in map files with Closure Controller? `

I'm using Google Closure Compiler to minify my JS scripts: https://developers.google.com/closure/compiler/docs/gettingstarted_app?hl=en
The command I'm using is:
java -jar /home/user/compiler/compiler.jar --js $File::Find::name --create_source_map $File::Find::name.map --source_map_format=V3 --compilation_level=WHITESPACE_ONLY --js_output_file $minified --charset=Windows-1251 --output_wrapper '%output%\n//# sourceMappingURL=output.js.map'
Thats fine, apart from one thing - the .js.map file has the FULL path for the file, not the relative one:
"version":3,
"file":"/home/user/public_html/new_design/common37.min.js",
"lineCount":375,
....
I assume I can change this in the invocation of the compiler.jar script? Otherwise, I guess I will have to add some more code into my script (not something I want to do, if its possible "out of the box")
EDIT: I've done a little bit of a dirty hack in my Perl script:
# now open the map file one, and edit it to remove the full path.. needs to be relative
my $contents = File::Slurp::read_file("/home/user/public_html/$tmp.map");
$contents =~ s|/home/user/public_html||g;
File::Slurp::write_file("/home/user/public_html/$tmp.map",$contents);
That gets rid of the path info correctly. I've prefer if there were an option to use relative urls in the .map file (compared to the full path it currently puts in)
Thanks!
Specify sourcemap location transformations by using the --source_map_location_mapping flag. The flag expects a value formatted as:
--source_map_location_mapping=/filesystem/src/root|relative/source/root

Protractor-Cucumber: how to generate HTML report

After add line resultJsonOutputFile: 'report.json', to config file and run my test in Webstorm, there is a report.json created but there is no content on it. I don't know what's the reason.
Please help me to expland why my report.json has no content? And how to generate Html report for my test?
Use cucumber-html-report You might want to have a look at this:
https://stackoverflow.com/a/33739439/790950
Make sure you add the code snippet to your features/support/hooks.js file and also load that file as part of your protractor.conf file:
cucumberOpts: {
require: [
'../e2e/features/**/steps/*.js',
'../e2e/features/support/hooks.js',
],
format: 'pretty',
},
Notice that you don't have to change the console format as it does it dynamically. Also adds screenshots in case of failures.

Gulp gulp-less and gulp-sourcemaps giving wrong sourceMappingURL

I have a gulp workflow with a simple less task like so:
gulp.task('less', function() {
gulp.src(source_less)
.pipe(sourcemaps.init())
.pipe(less({
sourceMap: true
}))
.pipe(sourcemaps.write())
.pipe(gulp.dest(dest_less));
});
I want the gulp-sourcemaps module to display source maps as inline comments in my CSS file.
But whenever gulp compiles my LESS, the gulp-sourcemaps isn't displaying a path to my source file.
Instead, it displays something like this:
/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2
VzIjpbIm1haW4ubGVzcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTtFQUNJLG1DQUFBIiwi
ZmlsZSI6Im1haW4uY3NzIiwic291cmNlc0NvbnRlbnQiOlsibmF2IHtcclxuICAgIGJhY2tncm91bmQtY29
sb3I6IHllbGxvdyAhaW1wb3J0YW50O1xyXG59Il0sInNvdXJjZVJvb3QiOiIvc291cmNlLyJ9 */
I dramatically simplified my gulpfile, removing livereload, autoprefixer and such.
But even in this stripped down version I can't get the source URL to be right.
Been over this thing for quite some time now, any help would be very much appreciated!
You already have sourcemaps inline there. If you base64 decode what comes after sourceMappingURL=data:application/json;base64, you'll get this:
{"version":3,"sources":["main.less"],"names":[],"mappings":"AAAA;EACI,mCAAA","file":"main.css","sourcesContent":["nav {\r\n background-color: yellow !important;\r\n}"],"sourceRoot":"/source/"}
Try it yourself here: https://www.base64decode.org/
For those who stumble upon this post and are wondering how to get a separate file for the map that's is not in base64 format - you can pass a path relative to the destination.
For example:
.pipe(sourcemaps.write('./'))

Resources