<commit_before>package fr.openwide.core.wicket.markup.html.util.css3pie;

import java.util.Map;

import org.apache.wicket.RequestCycle;
import org.apache.wicket.ResourceReference;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.util.collections.MiniMap;
import org.apache.wicket.util.template.PackagedTextTemplate;
import org.apache.wicket.util.template.TextTemplate;
import org.apache.wicket.util.template.TextTemplateHeaderContributor;
import org.springframework.util.StringUtils;

public class Css3PieHeaderContributor extends TextTemplateHeaderContributor {

	private static final long serialVersionUID = -4091910399987963790L;
	
	private static final String CSS_TEMPLATE_FILENAME = "include-pie-htc.css";
	
	private static final String PIE_HTC_FILENAME = "PIE.htc";
	
	private static final String STYLES_VARIABLE = "styles";
	
	private static final String PIE_HTC_URL_VARIABLE = "pieHtcUrl";
	
	public static final Css3PieHeaderContributor forStyles(final String[] stylesWithCss3Properties) {
		return new Css3PieHeaderContributor(getTemplate(), getVariablesModel(stylesWithCss3Properties));
	}

	protected Css3PieHeaderContributor(final TextTemplate template, IModel<Map<String, Object>> variablesModel) {
		super(template, variablesModel);
	}
	
	private static TextTemplate getTemplate() {
		return new PackagedTextTemplate(Css3PieHeaderContributor.class, CSS_TEMPLATE_FILENAME);
	}
	
	private static IModel<Map<String, Object>> getVariablesModel(String[] stylesWithCss3Properties) {
		Map<String, Object> variables = new MiniMap<String, Object>(2);
		variables.put(STYLES_VARIABLE, StringUtils.arrayToCommaDelimitedString(stylesWithCss3Properties));
		variables.put(PIE_HTC_URL_VARIABLE, RequestCycle.get().urlFor(new ResourceReference(Css3PieHeaderContributor.class, PIE_HTC_FILENAME)).toString());
		
		return Model.ofMap(variables);
	}

}<commit_msg>utilisation d'un LoadableDetachableModel pour éviter d'avoir l'URL mise dans la session en effet, typiquement, quand on a de la pagination, on va directement dans le mur vu que la profondeur de l'URL n'est pas la même...<commit_after>package fr.openwide.core.wicket.markup.html.util.css3pie;

import java.util.Map;

import org.apache.wicket.RequestCycle;
import org.apache.wicket.ResourceReference;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.LoadableDetachableModel;
import org.apache.wicket.util.collections.MiniMap;
import org.apache.wicket.util.template.PackagedTextTemplate;
import org.apache.wicket.util.template.TextTemplate;
import org.apache.wicket.util.template.TextTemplateHeaderContributor;
import org.springframework.util.StringUtils;

public class Css3PieHeaderContributor extends TextTemplateHeaderContributor {

	private static final long serialVersionUID = -4091910399987963790L;
	
	private static final String CSS_TEMPLATE_FILENAME = "include-pie-htc.css";
	
	private static final String PIE_HTC_FILENAME = "PIE.htc";
	
	private static final String STYLES_VARIABLE = "styles";
	
	private static final String PIE_HTC_URL_VARIABLE = "pieHtcUrl";
	
	public static final Css3PieHeaderContributor forStyles(final String[] stylesWithCss3Properties) {
		return new Css3PieHeaderContributor(getTemplate(), getVariablesModel(stylesWithCss3Properties));
	}

	protected Css3PieHeaderContributor(final TextTemplate template, IModel<Map<String, Object>> variablesModel) {
		super(template, variablesModel);
	}
	
	private static TextTemplate getTemplate() {
		return new PackagedTextTemplate(Css3PieHeaderContributor.class, CSS_TEMPLATE_FILENAME);
	}
	
	private static IModel<Map<String, Object>> getVariablesModel(final String[] stylesWithCss3Properties) {
		return new LoadableDetachableModel<Map<String, Object>>() {
			private static final long serialVersionUID = 1L;

			@Override
			protected Map<String, Object> load() {
				Map<String, Object> variables = new MiniMap<String, Object>(2);
				variables.put(STYLES_VARIABLE, StringUtils.arrayToCommaDelimitedString(stylesWithCss3Properties));
				variables.put(PIE_HTC_URL_VARIABLE, RequestCycle.get().urlFor(new ResourceReference(Css3PieHeaderContributor.class, PIE_HTC_FILENAME)).toString());
				
				return variables;
			}
		};
	}

}
{'fraction_non_alphanumeric': 0.0882491741387447, 'fraction_numerical': 0.014865502595563945, 'mean_word_length': 6.763736263736264, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, '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': '5018565', 'n_tokens_mistral': 1424, 'n_tokens_neox': 1306, 'n_words': 261}