/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.ocelotds.web.rest;

import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import javax.enterprise.context.RequestScoped;
import javax.ws.rs.Path;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.UriInfo;
import org.ocelotds.Constants;
import org.ocelotds.annotations.OcelotResource;

/**
 *
 * @author hhfrancois
 * The core include ocelotServices.js
 */
@Path("cor{min}.js")
@RequestScoped
@OcelotResource
public class RsJsCore extends AbstractRsJs {
	@Context
	private UriInfo context;
	
	@Override
	List<InputStream> getStreams() {
		List<InputStream> streams = new ArrayList<>();
		addStream(streams, getJsCore());
		return streams;
	}
	
	String getJsCore() {
		if(context.getPath().contains(".min")) {
			return Constants.SLASH + Constants.OCELOT_CORE_MIN + Constants.JS;
		}
		return Constants.SLASH + Constants.OCELOT_CORE + Constants.JS;
	}
}


@@ -609,12 +609,41 @@
 th(%22
-cor%7B
+%7Ba:core%7Ccore.min%7Ccore.ng%7Ccore.ng.
 min%7D
@@ -942,186 +942,48 @@
 %7B%0A%09%09
-if(context.getPath().contains(%22.min%22)) %7B%0A%09%09%09return Constants.SLASH + Constants.OCELOT_CORE_MIN + Constants.JS;%0A%09%09%7D%0A%09%09return Constants.SLASH + Constants.OCELOT_CORE + Constants.JS
+return Constants.SLASH+context.getPath()
 ;%0A%09%7D

allow dl ocelot/core.ng.js