Search in sources :

Example 1 with Material

use of forpdateam.ru.forpda.api.news.models.Material in project ForPDA by RadiationX.

the class NewsApi method parseMaterials.

private void parseMaterials(ArrayList<Material> materials, String sourceMaterials) {
    if (sourceMaterials == null)
        return;
    Matcher matcher = materialsPattern.matcher(sourceMaterials);
    while (matcher.find()) {
        Material material = new Material();
        material.setImageUrl(matcher.group(1));
        material.setId(Integer.parseInt(matcher.group(2)));
        material.setTitle(ApiUtils.fromHtml(matcher.group(3)));
        materials.add(material);
    }
}
Also used : Matcher(java.util.regex.Matcher) Material(forpdateam.ru.forpda.api.news.models.Material)

Example 2 with Material

use of forpdateam.ru.forpda.api.news.models.Material in project ForPDA by RadiationX.

the class NewsRx method transform.

public static DetailsPage transform(DetailsPage page) throws Exception {
    MiniTemplator t = App.get().getTemplate(App.TEMPLATE_NEWS);
    App.setTemplateResStrings(t);
    t.setVariableOpt("style_type", App.get().getCssStyleType());
    t.setVariableOpt("details_title", ApiUtils.htmlEncode(page.getTitle()));
    t.setVariableOpt("details_content", page.getHtml());
    for (Material material : page.getMaterials()) {
        t.setVariableOpt("material_id", material.getId());
        t.setVariableOpt("material_image", material.getImageUrl());
        t.setVariableOpt("material_title", material.getTitle());
        t.addBlockOpt("material");
    }
    page.setHtml(t.generateOutput());
    t.reset();
    return page;
}
Also used : Material(forpdateam.ru.forpda.api.news.models.Material) MiniTemplator(biz.source_code.miniTemplator.MiniTemplator)

Aggregations

Material (forpdateam.ru.forpda.api.news.models.Material)2 MiniTemplator (biz.source_code.miniTemplator.MiniTemplator)1 Matcher (java.util.regex.Matcher)1