Added CatGenerator management. Improved logo links and properties file

links.
This commit is contained in:
Christian P. MOMON 2020-09-19 03:36:41 +02:00
parent 350df0bfa2
commit a2ff39faaa
5 changed files with 33 additions and 18 deletions

View file

@ -28,6 +28,7 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import fr.devinsy.catgenerator.core.CatGenerator;
import fr.devinsy.statoolinfos.properties.PathProperties; import fr.devinsy.statoolinfos.properties.PathProperties;
import fr.devinsy.statoolinfos.properties.PathPropertyList; import fr.devinsy.statoolinfos.properties.PathPropertyList;
import fr.devinsy.statoolinfos.properties.PathPropertyUtils; import fr.devinsy.statoolinfos.properties.PathPropertyUtils;
@ -175,7 +176,8 @@ public class CrawlCache
{ {
try try
{ {
StatoolInfosUtils.generateCatLogo(seed, target); logger.info("CatGeneratoring cat avatar (1): {}", target.getAbsoluteFile());
CatGenerator.buildAvatarTo(seed, target);
} }
catch (IOException exception) catch (IOException exception)
{ {
@ -190,7 +192,8 @@ public class CrawlCache
{ {
try try
{ {
StatoolInfosUtils.generateCatLogo(seed, target); logger.info("CatGeneratoring cat avatar (2): {}", target.getAbsoluteFile());
CatGenerator.buildAvatarTo(seed, target);
} }
catch (IOException exception) catch (IOException exception)
{ {

View file

@ -62,9 +62,9 @@ public class FederationPage
data.setContent("versionsup", BuildInformation.instance().version()); data.setContent("versionsup", BuildInformation.instance().version());
data.setContent("lastUpdateDate", LocalDateTime.now().format(DateTimeFormatter.ofPattern("dd/MM/yyyy HH':'mm", Locale.FRANCE))); data.setContent("lastUpdateDate", LocalDateTime.now().format(DateTimeFormatter.ofPattern("dd/MM/yyyy HH':'mm", Locale.FRANCE)));
data.setAttribute("federationRawButton", "href", federation.getTechnicalName() + "-raw.properties"); data.setAttribute("federationRawButton", "href", federation.getTechnicalName() + ".properties");
data.setAttribute("federationLogo", "src", federation.getTechnicalName() + "-logo.jpg"); data.setAttribute("federationLogo", "src", federation.getTechnicalName() + "-logo.png");
data.setEscapedContent("federationName", federation.getName()); data.setEscapedContent("federationName", federation.getName());
data.setEscapedContent("federationDescription", federation.getDescription()); data.setEscapedContent("federationDescription", federation.getDescription());
data.setContent("organizationCount", federation.getOrganizations().size()); data.setContent("organizationCount", federation.getOrganizations().size());
@ -74,7 +74,7 @@ public class FederationPage
for (Organization organization : federation.getOrganizations()) for (Organization organization : federation.getOrganizations())
{ {
data.setAttribute("organizationListLine", index, "organizationListLineNameLink", "href", organization.getTechnicalName() + ".xhtml"); data.setAttribute("organizationListLine", index, "organizationListLineNameLink", "href", organization.getTechnicalName() + ".xhtml");
data.setAttribute("organizationListLine", index, "organizationListLineLogo", "src", organization.getTechnicalName() + "-logo.jpg"); data.setAttribute("organizationListLine", index, "organizationListLineLogo", "src", organization.getTechnicalName() + "-logo.png");
data.setEscapedContent("organizationListLine", index, "organizationListLineNameValue", organization.getName()); data.setEscapedContent("organizationListLine", index, "organizationListLineNameValue", organization.getName());
data.setEscapedContent("organizationListLine", index, "organizationListLineUrlLink", organization.getWebsite()); data.setEscapedContent("organizationListLine", index, "organizationListLineUrlLink", organization.getWebsite());
data.setAttribute("organizationListLine", index, "organizationListLineUrlLink", "href", organization.getWebsite()); data.setAttribute("organizationListLine", index, "organizationListLineUrlLink", "href", organization.getWebsite());

View file

@ -95,30 +95,40 @@ public class Htmlizer
copyStuff(htmlizeDirectory); copyStuff(htmlizeDirectory);
// Manage the logo file. // Manage the logo file.
cache.restoreLogoTo(federation.getLogoURL(), new File(htmlizeDirectory, federation.getTechnicalName() + "-logo.jpg"), federation.getTechnicalName()); logger.info("Htmlize federation logo.");
FileUtils.copyFile(federation.getLocalFile(), new File(htmlizeDirectory, federation.getTechnicalName() + "-raw.properties")); cache.restoreLogoTo(federation.getLogoURL(), new File(htmlizeDirectory, federation.getTechnicalName() + "-logo.png"), federation.getTechnicalName());
logger.info("Htmlize federation properties file.");
FileUtils.copyFile(federation.getLocalFile(), new File(htmlizeDirectory, federation.getTechnicalName() + ".properties"));
// //
logger.info("Htmlize federation page: {}.", federation.getName());
String page = FederationPage.build(federation); String page = FederationPage.build(federation);
FileUtils.write(new File(htmlizeDirectory, "index.xhtml"), page, StandardCharsets.UTF_8); FileUtils.write(new File(htmlizeDirectory, "index.xhtml"), page, StandardCharsets.UTF_8);
for (Organization organization : federation.getOrganizations()) for (Organization organization : federation.getOrganizations())
{ {
// Manage the logo file. // Manage the logo file.
cache.restoreLogoTo(organization.getLogoURL(), new File(htmlizeDirectory, organization.getTechnicalName() + "-logo.jpg"), organization.getTechnicalName()); logger.info("Htmlize organization logo: {}.", organization.getName());
FileUtils.copyFile(organization.getLocalFile(), new File(htmlizeDirectory, organization.getTechnicalName() + "-raw.properties")); cache.restoreLogoTo(organization.getLogoURL(), new File(htmlizeDirectory, organization.getTechnicalName() + "-logo.png"), organization.getTechnicalName());
logger.info("Htmlize organization properties file: {}.", organization.getName());
FileUtils.copyFile(organization.getLocalFile(), new File(htmlizeDirectory, organization.getTechnicalName() + ".properties"));
// //
logger.info("Htmlize organization page: {}.", organization.getName());
page = OrganizationPage.build(organization); page = OrganizationPage.build(organization);
FileUtils.write(new File(htmlizeDirectory, organization.getTechnicalName() + ".xhtml"), page, StandardCharsets.UTF_8); FileUtils.write(new File(htmlizeDirectory, organization.getTechnicalName() + ".xhtml"), page, StandardCharsets.UTF_8);
for (Service service : organization.getServices()) for (Service service : organization.getServices())
{ {
// Manage the logo file. // Manage the logo file.
cache.restoreLogoTo(service.getLogoURL(), new File(htmlizeDirectory, service.getTechnicalName() + "-logo.jpg"), service.getTechnicalName()); logger.info("Htmlize service logo: {}.", service.getName());
FileUtils.copyFile(service.getLocalFile(), new File(htmlizeDirectory, service.getTechnicalName() + "-raw.properties")); cache.restoreLogoTo(service.getLogoURL(), new File(htmlizeDirectory, organization.getTechnicalName() + "-" + service.getTechnicalName() + "-logo.png"), service.getTechnicalName());
logger.info("Htmlize service properties file: {}.", service.getName());
FileUtils.copyFile(service.getLocalFile(),
new File(htmlizeDirectory, organization.getTechnicalName() + "-" + service.getTechnicalName() + ".properties"));
page = ServicePage.build(service); logger.info("Htmlize service page: {}.", service.getName());
page = ServicePage.build(organization, service);
FileUtils.write(new File(htmlizeDirectory, organization.getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml"), page, StandardCharsets.UTF_8); FileUtils.write(new File(htmlizeDirectory, organization.getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml"), page, StandardCharsets.UTF_8);
} }
} }
@ -167,7 +177,7 @@ public class Htmlizer
cache.restoreLogoTo(service.getLogoURL(), new File(htmlizeDirectory, service.getTechnicalName() + "-logo.jpg"), service.getTechnicalName()); cache.restoreLogoTo(service.getLogoURL(), new File(htmlizeDirectory, service.getTechnicalName() + "-logo.jpg"), service.getTechnicalName());
// //
page = ServicePage.build(service); page = ServicePage.build(organization, service);
FileUtils.write(new File(htmlizeDirectory, organization.getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml"), page, StandardCharsets.UTF_8); FileUtils.write(new File(htmlizeDirectory, organization.getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml"), page, StandardCharsets.UTF_8);
} }

View file

@ -62,9 +62,9 @@ public class OrganizationPage
data.setContent("versionsup", BuildInformation.instance().version()); data.setContent("versionsup", BuildInformation.instance().version());
data.setContent("lastUpdateDate", LocalDateTime.now().format(DateTimeFormatter.ofPattern("dd/MM/yyyy HH':'mm", Locale.FRANCE))); data.setContent("lastUpdateDate", LocalDateTime.now().format(DateTimeFormatter.ofPattern("dd/MM/yyyy HH':'mm", Locale.FRANCE)));
data.setAttribute("organizationRawButton", "href", organization.getTechnicalName() + "-raw.properties"); data.setAttribute("organizationRawButton", "href", organization.getTechnicalName() + ".properties");
data.setAttribute("organizationLogo", "src", organization.getTechnicalName() + "-logo.jpg"); data.setAttribute("organizationLogo", "src", organization.getTechnicalName() + "-logo.png");
data.setEscapedContent("organizationName", organization.get("organization.name")); data.setEscapedContent("organizationName", organization.get("organization.name"));
data.setEscapedContent("organizationDescription", organization.get("organization.description")); data.setEscapedContent("organizationDescription", organization.get("organization.description"));
data.setContent("serviceCount", organization.getServices().size()); data.setContent("serviceCount", organization.getServices().size());
@ -72,6 +72,7 @@ public class OrganizationPage
int index = 0; int index = 0;
for (Service service : organization.getServices()) for (Service service : organization.getServices())
{ {
data.setAttribute("serviceListLine", index, "serviceListLineLogo", "src", service.getTechnicalName() + "-logo.png");
data.setEscapedContent("serviceListLine", index, "serviceListLineNameLink", service.getName()); data.setEscapedContent("serviceListLine", index, "serviceListLineNameLink", service.getName());
data.setAttribute("serviceListLine", index, "serviceListLineNameLink", "href", organization.getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml"); data.setAttribute("serviceListLine", index, "serviceListLineNameLink", "href", organization.getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml");
data.setEscapedContent("serviceListLine", index, "serviceListLineWebsiteLink", service.getWebsite()); data.setEscapedContent("serviceListLine", index, "serviceListLineWebsiteLink", service.getWebsite());

View file

@ -25,6 +25,7 @@ import java.util.Locale;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.core.Organization;
import fr.devinsy.statoolinfos.core.Service; import fr.devinsy.statoolinfos.core.Service;
import fr.devinsy.statoolinfos.core.StatoolInfosException; import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.util.BuildInformation; import fr.devinsy.statoolinfos.util.BuildInformation;
@ -48,7 +49,7 @@ public class ServicePage
* @throws StatoolInfosException * @throws StatoolInfosException
* the statool infos exception * the statool infos exception
*/ */
public static String build(final Service service) throws StatoolInfosException public static String build(final Organization organization, final Service service) throws StatoolInfosException
{ {
String result; String result;
@ -61,9 +62,9 @@ public class ServicePage
data.setContent("versionsup", BuildInformation.instance().version()); data.setContent("versionsup", BuildInformation.instance().version());
data.setContent("lastUpdateDate", LocalDateTime.now().format(DateTimeFormatter.ofPattern("dd/MM/yyyy HH':'mm", Locale.FRANCE))); data.setContent("lastUpdateDate", LocalDateTime.now().format(DateTimeFormatter.ofPattern("dd/MM/yyyy HH':'mm", Locale.FRANCE)));
data.setAttribute("serviceRawButton", "href", service.getTechnicalName() + "-raw.properties"); data.setAttribute("serviceRawButton", "href", organization.getTechnicalName() + "-" + service.getTechnicalName() + ".properties");
data.setAttribute("serviceLogo", "src", service.getTechnicalName() + "-logo.jpg"); data.setAttribute("serviceLogo", "src", organization.getTechnicalName() + "-" + service.getTechnicalName() + "-logo.png");
data.setEscapedContent("serviceName", service.getName()); data.setEscapedContent("serviceName", service.getName());
data.setEscapedContent("serviceDescription", service.getDescription()); data.setEscapedContent("serviceDescription", service.getDescription());