Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #669 from sonatype/use-reference-factory

[NXCM-4804] Fix index template to use the right baseUrl + relative URLs for requirejs
  • Loading branch information...
commit 77adfd8f744129f02e6da780e7f942bb36ac99a2 2 parents 86ef139 + 36f46b4
@nabcos nabcos authored
View
7 ...s-restlet1x-plugin/src/main/java/org/sonatype/nexus/rest/IndexTemplatePlexusResource.java
@@ -44,6 +44,7 @@
import org.sonatype.nexus.Nexus;
import org.sonatype.nexus.plugins.rest.NexusIndexHtmlCustomizer;
import org.sonatype.nexus.plugins.restlet1x.BuildNumberService;
+import org.sonatype.plexus.rest.ReferenceFactory;
import org.sonatype.plexus.rest.representation.VelocityRepresentation;
import org.sonatype.plexus.rest.resource.AbstractPlexusResource;
import org.sonatype.plexus.rest.resource.ManagedPlexusResource;
@@ -58,6 +59,8 @@
{
private Nexus nexus;
+ private ReferenceFactory referenceFactory;
+
private Map<String, NexusIndexHtmlCustomizer> bundles;
private Velocity velocity;
@@ -68,6 +71,7 @@
@Inject
public IndexTemplatePlexusResource( final Map<String, NexusIndexHtmlCustomizer> bundles, final Nexus nexus,
+ final ReferenceFactory referenceFactory,
final @Named("${index.template.file:-templates/index.vm}") String templateFilename,
final Velocity velocity, final BuildNumberService buildNumberService )
{
@@ -75,6 +79,7 @@ public IndexTemplatePlexusResource( final Map<String, NexusIndexHtmlCustomizer>
this.bundles = bundles;
this.nexus = nexus;
+ this.referenceFactory = referenceFactory;
this.templateFilename = templateFilename;
this.velocity = velocity;
this.buildNumberService = buildNumberService;
@@ -135,7 +140,7 @@ protected VelocityRepresentation render( Context context, Request request, Respo
templatingContext.put( "nexusVersion", nexus.getSystemStatus().getVersion() );
- templatingContext.put( "nexusRoot", request.getRootRef().toString() );
+ templatingContext.put( "nexusRoot", referenceFactory.getContextRoot(request).toString() );
// gather plugin stuff
View
2  nexus/plugins/restlet1x/nexus-restlet1x-plugin/src/main/resources/templates/index.vm
@@ -99,7 +99,7 @@
}
#foreach( $js in $pluginJsFiles )
- require([ '$nexusRoot/$js' ], init, errorCallback);
+ require([ '$js' ], init, errorCallback);
#end
});
</script>

0 comments on commit 77adfd8

Please sign in to comment.
Something went wrong with that request. Please try again.