<commit_before>package asset.pipeline.grails

import asset.pipeline.AssetHelper
import asset.pipeline.DirectiveProcessor
import asset.pipeline.GenericAssetFile
import org.codehaus.groovy.grails.core.io.DefaultResourceLocator
import org.springframework.core.io.ByteArrayResource
import org.springframework.core.io.Resource
import groovy.util.logging.Slf4j

@Slf4j
class AssetResourceLocator extends DefaultResourceLocator {
	Resource findResourceForURI(String uri) {
		Resource resource = super.findResourceForURI(uri)
		if(!resource) {
			resource = findAssetForURI(uri)
		}
		return resource
	}

	Resource findAssetForURI(String uri) {
		Resource resource
		if(warDeployed) {
			uri = manifest?.getProperty(uri, uri)

			def assetUri = "assets/${uri}"
			Resource defaultResource = defaultResourceLoader.getResource(assetUri)
			if (!defaultResource?.exists()) {
				defaultResource = defaultResourceLoader.getResource("classpath:${assetUri}")
			}
			if (defaultResource?.exists()) {
				resource = defaultResource
			}
		} else {
			def contentTypes = AssetHelper.assetMimeTypeForURI(uri)
			def contentType
			if(contentTypes) {
				contentType = contentTypes[0]
			}

			def extension    = AssetHelper.extensionFromURI(uri)
			def name         = AssetHelper.nameWithoutExtension(uri)
			def assetFile    = AssetHelper.fileForUri(name,contentType,extension)
			if(assetFile) {
				if(assetFile instanceof GenericAssetFile) {
					resource = new ByteArrayResource(assetFile.bytes)<commit_msg>fixing missing property on asset-pipeline config holder<commit_after>package asset.pipeline.grails

import asset.pipeline.AssetHelper
import asset.pipeline.AssetPipelineConfigHolder
import asset.pipeline.DirectiveProcessor
import asset.pipeline.GenericAssetFile
import org.codehaus.groovy.grails.core.io.DefaultResourceLocator
import org.springframework.core.io.ByteArrayResource
import org.springframework.core.io.Resource
import groovy.util.logging.Slf4j

@Slf4j
class AssetResourceLocator extends DefaultResourceLocator {
	Resource findResourceForURI(String uri) {
		Resource resource = super.findResourceForURI(uri)
		if(!resource) {
			resource = findAssetForURI(uri)
		}
		return resource
	}

	Resource findAssetForURI(String uri) {
		Resource resource
		if(warDeployed) {
			def manifest = AssetPipelineConfigHolder.manifest
			uri = manifest?.getProperty(uri, uri)

			def assetUri = "assets/${uri}"
			Resource defaultResource = defaultResourceLoader.getResource(assetUri)
			if (!defaultResource?.exists()) {
				defaultResource = defaultResourceLoader.getResource("classpath:${assetUri}")
			}
			if (defaultResource?.exists()) {
				resource = defaultResource
			}
		} else {
			def contentTypes = AssetHelper.assetMimeTypeForURI(uri)
			def contentType
			if(contentTypes) {
				contentType = contentTypes[0]
			}

			def extension    = AssetHelper.extensionFromURI(uri)
			def name         = AssetHelper.nameWithoutExtension(uri)
			def assetFile    = AssetHelper.fileForUri(name,contentType,extension)
			if(assetFile) {
				if(assetFile instanceof GenericAssetFile) {
					resource = new ByteArrayResource(assetFile.bytes)
{'fraction_non_alphanumeric': 0.08713692946058091, 'fraction_numerical': 0.001915097350781998, 'mean_word_length': 5.003831417624521, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5934564', 'n_tokens_mistral': 1009, 'n_tokens_neox': 891, 'n_words': 170}