2020-09-17 02:03:56 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2020 Christian Pierre MOMON <christian@momon.org>
|
|
|
|
*
|
|
|
|
* This file is part of StatoolInfos, simple service statistics tool.
|
|
|
|
*
|
|
|
|
* StatoolInfos is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* StatoolInfos is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with StatoolInfos. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
package fr.devinsy.statoolinfos.htmlize;
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
|
|
|
|
import org.apache.commons.io.FileUtils;
|
2020-09-19 17:37:37 +02:00
|
|
|
import org.apache.commons.lang3.StringUtils;
|
2020-09-17 02:03:56 +02:00
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
2020-10-17 17:57:10 +02:00
|
|
|
import fr.devinsy.statoolinfos.checker.PropertyChecker;
|
|
|
|
import fr.devinsy.statoolinfos.checker.PropertyChecks;
|
2020-09-25 04:36:38 +02:00
|
|
|
import fr.devinsy.statoolinfos.core.Categories;
|
2020-09-25 05:44:40 +02:00
|
|
|
import fr.devinsy.statoolinfos.core.Category;
|
2020-09-17 18:54:29 +02:00
|
|
|
import fr.devinsy.statoolinfos.core.Configuration;
|
|
|
|
import fr.devinsy.statoolinfos.core.Factory;
|
2020-09-17 02:03:56 +02:00
|
|
|
import fr.devinsy.statoolinfos.core.Federation;
|
|
|
|
import fr.devinsy.statoolinfos.core.Organization;
|
2020-10-11 06:57:21 +02:00
|
|
|
import fr.devinsy.statoolinfos.core.Organizations;
|
2020-09-17 02:03:56 +02:00
|
|
|
import fr.devinsy.statoolinfos.core.Service;
|
2020-09-25 05:44:40 +02:00
|
|
|
import fr.devinsy.statoolinfos.core.Services;
|
2020-10-11 06:57:21 +02:00
|
|
|
import fr.devinsy.statoolinfos.core.SocialNetworks;
|
2020-09-25 15:46:30 +02:00
|
|
|
import fr.devinsy.statoolinfos.core.Software;
|
|
|
|
import fr.devinsy.statoolinfos.core.Softwares;
|
2020-09-17 02:03:56 +02:00
|
|
|
import fr.devinsy.statoolinfos.core.StatoolInfosException;
|
|
|
|
import fr.devinsy.statoolinfos.core.StatoolInfosUtils;
|
2020-09-19 17:37:37 +02:00
|
|
|
import fr.devinsy.statoolinfos.crawl.CrawlCache;
|
2020-10-01 15:30:06 +02:00
|
|
|
import fr.devinsy.statoolinfos.crawl.CrawlCache.DefaultLogoGenerator;
|
2020-09-20 13:13:04 +02:00
|
|
|
import fr.devinsy.statoolinfos.stats.StatAgent;
|
2020-09-25 04:36:38 +02:00
|
|
|
import fr.devinsy.statoolinfos.stats.categories.CategoryStats;
|
2020-09-23 21:56:40 +02:00
|
|
|
import fr.devinsy.statoolinfos.stats.properties.PropertyStats;
|
|
|
|
import fr.devinsy.statoolinfos.stats.propertyfiles.PropertiesFileStats;
|
2020-09-25 15:46:30 +02:00
|
|
|
import fr.devinsy.statoolinfos.stats.softwares.SoftwareStats;
|
2020-09-17 02:03:56 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The Class Htmlizer.
|
|
|
|
*/
|
|
|
|
public class Htmlizer
|
|
|
|
{
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(Htmlizer.class);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Instantiates a new htmlizer.
|
|
|
|
*/
|
|
|
|
private Htmlizer()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-09-19 17:37:37 +02:00
|
|
|
/**
|
|
|
|
* Clear.
|
|
|
|
*
|
|
|
|
* @param configuration
|
|
|
|
* the configuration
|
|
|
|
*/
|
|
|
|
public static void clear(final Configuration configuration)
|
|
|
|
{
|
|
|
|
logger.info("Htmlize directory setting: {}", configuration.getHtmlizeDirectoryPath());
|
|
|
|
|
|
|
|
String htmlDirectoryPath = configuration.getHtmlizeDirectoryPath();
|
|
|
|
if (StringUtils.isBlank(htmlDirectoryPath))
|
|
|
|
{
|
|
|
|
logger.warn("Undefined htmlize directory.");
|
|
|
|
}
|
|
|
|
else if (!new File(htmlDirectoryPath).exists())
|
|
|
|
{
|
|
|
|
logger.warn("Htmlize directory does not exist: {}.", htmlDirectoryPath);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
File htmlizeDirectory = configuration.getHtmlizeDirectory();
|
|
|
|
|
|
|
|
for (File file : htmlizeDirectory.listFiles())
|
|
|
|
{
|
2020-09-25 04:36:38 +02:00
|
|
|
if ((file.isFile()) && (StringUtils.endsWithAny(file.getName(), ".properties", ".js", ".html", ".ico", ".css", ".jpg", ".png", ".xhtml")))
|
2020-09-19 17:37:37 +02:00
|
|
|
{
|
|
|
|
logger.info("Deleting " + file.getName());
|
|
|
|
file.delete();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-17 02:03:56 +02:00
|
|
|
/**
|
|
|
|
* Copy stuff.
|
|
|
|
*
|
|
|
|
* @param target
|
|
|
|
* the target
|
|
|
|
* @throws IOException
|
|
|
|
*/
|
|
|
|
private static void copyStuff(final File targetDirectory) throws IOException
|
|
|
|
{
|
|
|
|
// Copy commons files (index, images, favicon, css…).
|
|
|
|
if (!new File(targetDirectory, "index.html").exists())
|
|
|
|
{
|
2020-10-02 18:18:17 +02:00
|
|
|
final String source = "/fr/devinsy/statoolinfos/htmlize/stuff/";
|
2020-09-17 02:03:56 +02:00
|
|
|
|
2020-10-02 18:18:17 +02:00
|
|
|
StatoolInfosUtils.copyRessource(source + "index.html", targetDirectory);
|
|
|
|
StatoolInfosUtils.copyRessource(source + "statoolinfos.css", targetDirectory);
|
|
|
|
StatoolInfosUtils.copyRessource(source + "Chart.bundle.min.js", targetDirectory);
|
|
|
|
StatoolInfosUtils.copyRessource(source + "sorttable.js", targetDirectory);
|
|
|
|
StatoolInfosUtils.copyRessource(source + "datatables.min.css", targetDirectory);
|
|
|
|
StatoolInfosUtils.copyRessource(source + "datatables.min.js", targetDirectory);
|
|
|
|
StatoolInfosUtils.copyRessource(source + "statoolinfos-logo.jpg", targetDirectory);
|
|
|
|
StatoolInfosUtils.copyRessource(source + "statoolinfos-logo.ico", targetDirectory);
|
|
|
|
StatoolInfosUtils.copyRessource(source + "statoolinfos-logo-name.jpg", targetDirectory);
|
|
|
|
StatoolInfosUtils.copyRessource(source + "statoolinfos-logo.jpg", new File(targetDirectory, "logo.jpg"));
|
|
|
|
StatoolInfosUtils.copyRessource(source + "statoolinfos-logo.ico", new File(targetDirectory, "favicon.ico"));
|
|
|
|
|
2020-10-04 00:18:38 +02:00
|
|
|
//
|
|
|
|
StatoolInfosUtils.copyRessource(source + "status-ok.png", targetDirectory);
|
|
|
|
StatoolInfosUtils.copyRessource(source + "status-warning.png", targetDirectory);
|
|
|
|
StatoolInfosUtils.copyRessource(source + "status-alert.png", targetDirectory);
|
|
|
|
StatoolInfosUtils.copyRessource(source + "status-error.png", targetDirectory);
|
|
|
|
StatoolInfosUtils.copyRessource(source + "status-over.png", targetDirectory);
|
|
|
|
StatoolInfosUtils.copyRessource(source + "status-void.png", targetDirectory);
|
|
|
|
|
2020-10-11 06:57:21 +02:00
|
|
|
//
|
|
|
|
StatoolInfosUtils.copyRessource(source + "diaspora-logo.png", targetDirectory);
|
2020-10-16 03:50:53 +02:00
|
|
|
StatoolInfosUtils.copyRessource(source + "funkwhale-logo.png", targetDirectory);
|
|
|
|
StatoolInfosUtils.copyRessource(source + "funkwhale-logo2.png", targetDirectory);
|
2020-10-11 06:57:21 +02:00
|
|
|
StatoolInfosUtils.copyRessource(source + "mastodon-logo.png", targetDirectory);
|
2020-10-16 03:50:53 +02:00
|
|
|
StatoolInfosUtils.copyRessource(source + "mobilizon-logo.png", targetDirectory);
|
|
|
|
StatoolInfosUtils.copyRessource(source + "peertube-logo.png", targetDirectory);
|
|
|
|
StatoolInfosUtils.copyRessource(source + "pixelfed-logo.png", targetDirectory);
|
2020-10-11 06:57:21 +02:00
|
|
|
|
2020-10-02 18:18:17 +02:00
|
|
|
//
|
|
|
|
File color = new File(targetDirectory, "circle-icons/color");
|
|
|
|
color.mkdirs();
|
|
|
|
File mono = new File(targetDirectory, "circle-icons/mono");
|
|
|
|
mono.mkdirs();
|
|
|
|
|
2020-10-03 06:30:47 +02:00
|
|
|
StatoolInfosUtils.copyRessource(source + "circle-icons/color/booklet.png", color);
|
|
|
|
StatoolInfosUtils.copyRessource(source + "circle-icons/mono/booklet.png", mono);
|
2020-10-02 18:18:17 +02:00
|
|
|
|
2020-10-03 06:30:47 +02:00
|
|
|
StatoolInfosUtils.copyRessource(source + "circle-icons/color/bookshelf.png", color);
|
|
|
|
StatoolInfosUtils.copyRessource(source + "circle-icons/mono/bookshelf.png", mono);
|
2020-10-02 18:18:17 +02:00
|
|
|
|
2020-10-07 04:33:30 +02:00
|
|
|
StatoolInfosUtils.copyRessource(source + "circle-icons/color/clipboard.png", color);
|
|
|
|
StatoolInfosUtils.copyRessource(source + "circle-icons/mono/clipboard.png", mono);
|
|
|
|
|
2020-10-03 06:30:47 +02:00
|
|
|
StatoolInfosUtils.copyRessource(source + "circle-icons/color/contacts.png", color);
|
|
|
|
StatoolInfosUtils.copyRessource(source + "circle-icons/mono/contacts.png", mono);
|
2020-10-02 18:18:17 +02:00
|
|
|
|
2020-10-04 00:18:38 +02:00
|
|
|
StatoolInfosUtils.copyRessource(source + "circle-icons/color/cruise.png", color);
|
|
|
|
StatoolInfosUtils.copyRessource(source + "circle-icons/mono/cruise.png", mono);
|
|
|
|
|
|
|
|
StatoolInfosUtils.copyRessource(source + "circle-icons/color/dev.png", color);
|
|
|
|
StatoolInfosUtils.copyRessource(source + "circle-icons/mono/dev.png", mono);
|
|
|
|
|
2020-10-03 06:30:47 +02:00
|
|
|
StatoolInfosUtils.copyRessource(source + "circle-icons/color/document.png", color);
|
|
|
|
StatoolInfosUtils.copyRessource(source + "circle-icons/mono/document.png", mono);
|
2020-10-02 18:18:17 +02:00
|
|
|
|
|
|
|
StatoolInfosUtils.copyRessource(source + "circle-icons/color/creditcard.png", color);
|
|
|
|
StatoolInfosUtils.copyRessource(source + "circle-icons/mono/creditcard.png", mono);
|
|
|
|
|
2020-10-03 06:30:47 +02:00
|
|
|
StatoolInfosUtils.copyRessource(source + "circle-icons/color/email.png", color);
|
|
|
|
StatoolInfosUtils.copyRessource(source + "circle-icons/mono/email.png", mono);
|
|
|
|
|
|
|
|
StatoolInfosUtils.copyRessource(source + "circle-icons/color/global.png", color);
|
|
|
|
StatoolInfosUtils.copyRessource(source + "circle-icons/mono/global.png", mono);
|
|
|
|
|
2020-10-02 18:18:17 +02:00
|
|
|
StatoolInfosUtils.copyRessource(source + "circle-icons/color/mail.png", color);
|
|
|
|
StatoolInfosUtils.copyRessource(source + "circle-icons/mono/mail.png", mono);
|
|
|
|
|
2020-10-03 06:30:47 +02:00
|
|
|
StatoolInfosUtils.copyRessource(source + "circle-icons/color/money.png", color);
|
|
|
|
StatoolInfosUtils.copyRessource(source + "circle-icons/mono/money.png", mono);
|
2020-10-02 18:18:17 +02:00
|
|
|
|
2020-10-03 06:30:47 +02:00
|
|
|
StatoolInfosUtils.copyRessource(source + "circle-icons/color/profile.png", color);
|
|
|
|
StatoolInfosUtils.copyRessource(source + "circle-icons/mono/profile.png", mono);
|
2020-10-02 18:18:17 +02:00
|
|
|
|
2020-10-03 06:30:47 +02:00
|
|
|
StatoolInfosUtils.copyRessource(source + "circle-icons/color/ribbon.png", color);
|
|
|
|
StatoolInfosUtils.copyRessource(source + "circle-icons/mono/ribbon.png", mono);
|
2020-10-02 18:18:17 +02:00
|
|
|
|
|
|
|
StatoolInfosUtils.copyRessource(source + "circle-icons/color/toolbox.png", color);
|
|
|
|
StatoolInfosUtils.copyRessource(source + "circle-icons/mono/toolbox.png", mono);
|
|
|
|
|
|
|
|
StatoolInfosUtils.copyRessource(source + "circle-icons/color/tools.png", color);
|
|
|
|
StatoolInfosUtils.copyRessource(source + "circle-icons/mono/tools.png", mono);
|
2020-09-17 02:03:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-19 17:37:37 +02:00
|
|
|
/**
|
|
|
|
* Htmlize.
|
|
|
|
*
|
|
|
|
* @param configuration
|
|
|
|
* the configuration
|
|
|
|
* @throws IOException
|
|
|
|
* Signals that an I/O exception has occurred.
|
|
|
|
* @throws StatoolInfosException
|
|
|
|
* the statool infos exception
|
|
|
|
*/
|
|
|
|
public static void htmlize(final Configuration configuration) throws IOException, StatoolInfosException
|
|
|
|
{
|
|
|
|
logger.info("Cache setting: {}", configuration.getCrawlCachePath());
|
|
|
|
logger.info("Htmlize input setting: {}", configuration.getHtmlizeInputPath());
|
|
|
|
logger.info("Htmlize directory setting: {}", configuration.getHtmlizeDirectoryPath());
|
|
|
|
|
|
|
|
File htmlizeInput = configuration.getHtmlizeInput();
|
|
|
|
File htmlizeDirectory = configuration.getHtmlizeDirectory();
|
|
|
|
if (htmlizeInput == null)
|
|
|
|
{
|
|
|
|
throw new IllegalArgumentException("Htmlize input undefined.");
|
|
|
|
}
|
|
|
|
else if (!htmlizeInput.exists())
|
|
|
|
{
|
|
|
|
throw new IllegalArgumentException("Htmlize input is missing.");
|
|
|
|
}
|
|
|
|
else if (htmlizeInput.isDirectory())
|
|
|
|
{
|
|
|
|
throw new IllegalArgumentException("Htmlize input is a directory.");
|
|
|
|
}
|
|
|
|
else if (htmlizeDirectory == null)
|
|
|
|
{
|
|
|
|
throw new IllegalArgumentException("Htmlize directory undefined.");
|
|
|
|
}
|
|
|
|
else if (!htmlizeDirectory.exists())
|
|
|
|
{
|
|
|
|
throw new IllegalArgumentException("Htmlize directory is missing.");
|
|
|
|
}
|
|
|
|
else if (!htmlizeDirectory.isDirectory())
|
|
|
|
{
|
|
|
|
throw new IllegalArgumentException("Htmlize directory is not a directory.");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (configuration.isFederation())
|
|
|
|
{
|
|
|
|
Htmlizer.htmlizeFederation(configuration);
|
|
|
|
}
|
|
|
|
else if (configuration.isOrganization())
|
|
|
|
{
|
|
|
|
Htmlizer.htmlizeOrganisation(configuration);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
logger.warn("No htmlize for this input: {}.", configuration.getClassName());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Htmlize.
|
|
|
|
*
|
|
|
|
* @param configurationFile
|
|
|
|
* the configuration file
|
|
|
|
* @throws StatoolInfosException
|
|
|
|
* the statool infos exception
|
|
|
|
* @throws IOException
|
|
|
|
* Signals that an I/O exception has occurred.
|
|
|
|
*/
|
|
|
|
public static void htmlize(final File configurationFile) throws StatoolInfosException, IOException
|
|
|
|
{
|
|
|
|
logger.info("Htmlize {}", configurationFile.getAbsolutePath());
|
|
|
|
|
|
|
|
Configuration configuration = Factory.loadConfiguration(configurationFile);
|
|
|
|
|
|
|
|
htmlize(configuration);
|
|
|
|
}
|
|
|
|
|
2020-09-17 02:03:56 +02:00
|
|
|
/**
|
|
|
|
* Htmlize federation.
|
|
|
|
*
|
2020-09-19 17:37:37 +02:00
|
|
|
* @param configuration
|
|
|
|
* the configuration
|
2020-09-17 02:03:56 +02:00
|
|
|
* @throws IOException
|
2020-09-19 17:37:37 +02:00
|
|
|
* Signals that an I/O exception has occurred.
|
2020-09-17 02:03:56 +02:00
|
|
|
* @throws StatoolInfosException
|
2020-09-19 17:37:37 +02:00
|
|
|
* the statool infos exception
|
2020-09-17 02:03:56 +02:00
|
|
|
*/
|
2020-09-17 18:54:29 +02:00
|
|
|
public static void htmlizeFederation(final Configuration configuration) throws IOException, StatoolInfosException
|
2020-09-17 02:03:56 +02:00
|
|
|
{
|
2020-09-17 18:54:29 +02:00
|
|
|
CrawlCache cache = configuration.getCrawlCache();
|
|
|
|
File htmlizeInput = configuration.getHtmlizeInput();
|
|
|
|
File htmlizeDirectory = configuration.getHtmlizeDirectory();
|
2020-09-17 02:03:56 +02:00
|
|
|
|
2020-09-17 18:54:29 +02:00
|
|
|
Federation federation = Factory.loadFederation(htmlizeInput, cache);
|
2020-09-25 05:44:40 +02:00
|
|
|
Categories categories = Factory.loadCategories(configuration.getCategoryFile(), federation);
|
2020-09-17 18:54:29 +02:00
|
|
|
|
|
|
|
copyStuff(htmlizeDirectory);
|
2020-09-19 02:37:52 +02:00
|
|
|
|
|
|
|
// Manage the logo file.
|
2020-09-19 03:36:41 +02:00
|
|
|
logger.info("Htmlize federation logo.");
|
2020-10-01 15:30:06 +02:00
|
|
|
cache.restoreLogoTo(federation.getLogoURL(), new File(htmlizeDirectory, federation.getTechnicalName() + "-logo.png"), federation.getTechnicalName(), DefaultLogoGenerator.CAT);
|
2020-09-23 21:56:40 +02:00
|
|
|
logger.info("Htmlize federation properties files.");
|
|
|
|
FileUtils.copyFile(federation.getInputFile(), new File(htmlizeDirectory, federation.getTechnicalName() + ".properties"));
|
2020-09-17 18:54:29 +02:00
|
|
|
|
2020-09-21 03:41:46 +02:00
|
|
|
//
|
|
|
|
logger.info("Htmlize about page.");
|
|
|
|
String page = AboutPage.build();
|
|
|
|
FileUtils.write(new File(htmlizeDirectory, "about.xhtml"), page, StandardCharsets.UTF_8);
|
|
|
|
|
2020-09-17 18:54:29 +02:00
|
|
|
//
|
2020-09-19 03:36:41 +02:00
|
|
|
logger.info("Htmlize federation page: {}.", federation.getName());
|
2020-09-21 03:41:46 +02:00
|
|
|
page = FederationPage.build(federation);
|
2020-09-17 18:54:29 +02:00
|
|
|
FileUtils.write(new File(htmlizeDirectory, "index.xhtml"), page, StandardCharsets.UTF_8);
|
2020-09-17 02:03:56 +02:00
|
|
|
|
2020-09-17 18:54:29 +02:00
|
|
|
for (Organization organization : federation.getOrganizations())
|
|
|
|
{
|
2020-09-19 02:37:52 +02:00
|
|
|
// Manage the logo file.
|
2020-09-19 03:36:41 +02:00
|
|
|
logger.info("Htmlize organization logo: {}.", organization.getName());
|
2020-10-01 15:30:06 +02:00
|
|
|
cache.restoreLogoTo(organization.getLogoURL(), new File(htmlizeDirectory, organization.getTechnicalName() + "-logo.png"), organization.getTechnicalName(), DefaultLogoGenerator.CAT);
|
2020-09-19 03:36:41 +02:00
|
|
|
logger.info("Htmlize organization properties file: {}.", organization.getName());
|
2020-09-23 21:56:40 +02:00
|
|
|
FileUtils.copyFile(organization.getInputFile(), new File(htmlizeDirectory, organization.getTechnicalName() + ".properties"));
|
2020-09-19 02:37:52 +02:00
|
|
|
|
|
|
|
//
|
2020-09-19 03:36:41 +02:00
|
|
|
logger.info("Htmlize organization page: {}.", organization.getName());
|
2020-09-17 18:54:29 +02:00
|
|
|
page = OrganizationPage.build(organization);
|
|
|
|
FileUtils.write(new File(htmlizeDirectory, organization.getTechnicalName() + ".xhtml"), page, StandardCharsets.UTF_8);
|
2020-09-17 02:03:56 +02:00
|
|
|
|
2020-10-15 02:10:21 +02:00
|
|
|
//
|
2020-09-17 18:54:29 +02:00
|
|
|
for (Service service : organization.getServices())
|
2020-09-17 02:03:56 +02:00
|
|
|
{
|
2020-09-19 02:37:52 +02:00
|
|
|
// Manage the logo file.
|
2020-09-19 03:36:41 +02:00
|
|
|
logger.info("Htmlize service logo: {}.", service.getName());
|
2020-10-01 15:30:06 +02:00
|
|
|
cache.restoreLogoTo(service.getLogoURL(), new File(htmlizeDirectory, organization.getTechnicalName() + "-" + service.getTechnicalName() + "-logo.png"), service.getTechnicalName(),
|
|
|
|
DefaultLogoGenerator.BIRD);
|
2020-09-19 03:36:41 +02:00
|
|
|
logger.info("Htmlize service properties file: {}.", service.getName());
|
2020-09-23 21:56:40 +02:00
|
|
|
FileUtils.copyFile(service.getInputFile(),
|
2020-09-19 03:36:41 +02:00
|
|
|
new File(htmlizeDirectory, organization.getTechnicalName() + "-" + service.getTechnicalName() + ".properties"));
|
|
|
|
|
|
|
|
logger.info("Htmlize service page: {}.", service.getName());
|
|
|
|
page = ServicePage.build(organization, service);
|
2020-09-17 18:54:29 +02:00
|
|
|
FileUtils.write(new File(htmlizeDirectory, organization.getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml"), page, StandardCharsets.UTF_8);
|
2020-09-17 02:03:56 +02:00
|
|
|
}
|
2020-09-17 18:54:29 +02:00
|
|
|
}
|
2020-09-17 02:03:56 +02:00
|
|
|
|
2020-09-20 13:13:04 +02:00
|
|
|
//
|
2020-09-21 06:15:07 +02:00
|
|
|
logger.info("Htmlize services page.");
|
|
|
|
page = ServicesPage.build(federation.getAllServices());
|
|
|
|
FileUtils.write(new File(htmlizeDirectory, "services.xhtml"), page, StandardCharsets.UTF_8);
|
|
|
|
|
2020-09-25 04:36:38 +02:00
|
|
|
//
|
2020-10-17 17:57:10 +02:00
|
|
|
PropertyChecker checker = new PropertyChecker();
|
|
|
|
|
|
|
|
PropertyChecks checks = checker.checkFederation(federation.getInputFile());
|
|
|
|
page = PropertyFileCheckPage.build("fede", checks);
|
|
|
|
FileUtils.write(new File(htmlizeDirectory, federation.getTechnicalName() + "-check.xhtml"), page, StandardCharsets.UTF_8);
|
|
|
|
|
|
|
|
for (Organization organization : federation.getOrganizations())
|
|
|
|
{
|
|
|
|
checks = checker.checkOrganization(organization.getInputFile());
|
|
|
|
page = PropertyFileCheckPage.build("orga", checks);
|
|
|
|
FileUtils.write(new File(htmlizeDirectory, organization.getTechnicalName() + "-check.xhtml"), page, StandardCharsets.UTF_8);
|
|
|
|
|
|
|
|
for (Service service : organization.getServices())
|
|
|
|
{
|
|
|
|
checks = checker.checkService(service.getInputFile());
|
|
|
|
page = PropertyFileCheckPage.build("serv", checks);
|
|
|
|
FileUtils.write(new File(htmlizeDirectory, organization.getTechnicalName() + "-" + service.getTechnicalName() + "-check.xhtml"), page, StandardCharsets.UTF_8);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2020-09-23 21:56:40 +02:00
|
|
|
{
|
|
|
|
logger.info("Htmlize propertiesFiles page.");
|
|
|
|
PropertiesFileStats stats = StatAgent.statAllPropertiesFiles(federation, cache).sortByName();
|
|
|
|
page = PropertiesFilesPage.build(stats);
|
|
|
|
FileUtils.write(new File(htmlizeDirectory, "propertiesFiles.xhtml"), page, StandardCharsets.UTF_8);
|
|
|
|
}
|
2020-09-25 04:36:38 +02:00
|
|
|
|
2020-09-20 13:13:04 +02:00
|
|
|
//
|
2020-09-21 00:20:14 +02:00
|
|
|
{
|
|
|
|
logger.info("Htmlize propertyStats page.");
|
2020-10-09 05:05:00 +02:00
|
|
|
|
2020-09-21 00:20:14 +02:00
|
|
|
PropertyStats stats = StatAgent.statAllProperties(federation);
|
2020-10-09 05:05:00 +02:00
|
|
|
page = PropertyStatsPage.build("Toutes les propriétés", stats);
|
|
|
|
FileUtils.write(new File(htmlizeDirectory, "propertyStats.xhtml"), page, StandardCharsets.UTF_8);
|
|
|
|
|
2020-09-21 00:20:14 +02:00
|
|
|
PropertyStats federationStats = StatAgent.statFederationProperties(federation);
|
2020-10-09 05:05:00 +02:00
|
|
|
page = PropertyStatsPage.build("Les propriétés de la fédération", federationStats);
|
|
|
|
FileUtils.write(new File(htmlizeDirectory, "propertyStats-federation.xhtml"), page, StandardCharsets.UTF_8);
|
|
|
|
|
2020-09-21 00:20:14 +02:00
|
|
|
PropertyStats organizationsStats = StatAgent.statOrganizationsProperties(federation.getOrganizations());
|
2020-10-09 05:05:00 +02:00
|
|
|
page = PropertyStatsPage.build("Les propriétés des organizations", organizationsStats);
|
|
|
|
FileUtils.write(new File(htmlizeDirectory, "propertyStats-organizations.xhtml"), page, StandardCharsets.UTF_8);
|
|
|
|
|
2020-09-21 00:20:14 +02:00
|
|
|
PropertyStats servicesStats = StatAgent.statServicesProperties(federation.getAllServices());
|
2020-10-09 05:05:00 +02:00
|
|
|
page = PropertyStatsPage.build("Les propriétés des services", servicesStats);
|
|
|
|
FileUtils.write(new File(htmlizeDirectory, "propertyStats-services.xhtml"), page, StandardCharsets.UTF_8);
|
2020-09-21 00:20:14 +02:00
|
|
|
}
|
2020-09-25 04:36:38 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
{
|
|
|
|
logger.info("Htmlize categories page.");
|
|
|
|
CategoryStats stats = StatAgent.statAllCategories(federation, categories);
|
|
|
|
page = CategoriesPage.build(stats);
|
|
|
|
FileUtils.write(new File(htmlizeDirectory, "categories.xhtml"), page, StandardCharsets.UTF_8);
|
|
|
|
}
|
2020-09-25 05:44:40 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
{
|
2020-09-25 15:46:30 +02:00
|
|
|
logger.info("Htmlize category pages.");
|
2020-09-25 05:44:40 +02:00
|
|
|
for (Category category : categories)
|
|
|
|
{
|
|
|
|
Services services = federation.getAllServices().getBy(category);
|
|
|
|
page = CategoryPage.build(category, services);
|
|
|
|
FileUtils.write(new File(htmlizeDirectory, "category-" + category.getTechnicalName() + ".xhtml"), page, StandardCharsets.UTF_8);
|
|
|
|
}
|
|
|
|
}
|
2020-09-25 15:46:30 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
{
|
|
|
|
logger.info("Htmlize softwares page.");
|
|
|
|
SoftwareStats stats = StatAgent.statAllSoftwares(federation, categories);
|
|
|
|
page = SoftwaresPage.build(stats);
|
|
|
|
FileUtils.write(new File(htmlizeDirectory, "softwares.xhtml"), page, StandardCharsets.UTF_8);
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
{
|
|
|
|
logger.info("Htmlize software pages.");
|
|
|
|
Softwares catalog = federation.getSoftwares();
|
|
|
|
for (Software software : catalog.values())
|
|
|
|
{
|
|
|
|
Services services = federation.getAllServices().getBy(software);
|
|
|
|
page = SoftwarePage.build(software, services);
|
|
|
|
FileUtils.write(new File(htmlizeDirectory, "software-" + software.getTechnicalName() + ".xhtml"), page, StandardCharsets.UTF_8);
|
|
|
|
}
|
|
|
|
}
|
2020-10-11 06:57:21 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
{
|
|
|
|
logger.info("Htmlize social networks pages.");
|
|
|
|
Organizations organizations = federation.getOrganizations().filterBySocialNetworks();
|
|
|
|
page = SocialNetworksPage.build("Tous", organizations);
|
|
|
|
FileUtils.write(new File(htmlizeDirectory, "socialNetworks.xhtml"), page, StandardCharsets.UTF_8);
|
|
|
|
|
|
|
|
organizations = federation.getOrganizations().filterBySocialNetwork(SocialNetworks.DIASPORA);
|
|
|
|
page = SocialNetworksPage.build("Disapora*", organizations);
|
|
|
|
FileUtils.write(new File(htmlizeDirectory, "socialNetworks-diaspora.xhtml"), page, StandardCharsets.UTF_8);
|
|
|
|
|
|
|
|
organizations = federation.getOrganizations().filterBySocialNetwork(SocialNetworks.MASTODON);
|
|
|
|
page = SocialNetworksPage.build("Mastodon", organizations);
|
|
|
|
FileUtils.write(new File(htmlizeDirectory, "socialNetworks-mastodon.xhtml"), page, StandardCharsets.UTF_8);
|
|
|
|
}
|
2020-09-17 02:03:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-09-19 17:37:37 +02:00
|
|
|
* Htmlize organisation.
|
2020-09-17 02:03:56 +02:00
|
|
|
*
|
2020-09-19 17:37:37 +02:00
|
|
|
* @param configuration
|
|
|
|
* the configuration
|
2020-09-17 02:03:56 +02:00
|
|
|
* @throws IOException
|
2020-09-19 17:37:37 +02:00
|
|
|
* Signals that an I/O exception has occurred.
|
2020-09-17 02:03:56 +02:00
|
|
|
* @throws StatoolInfosException
|
2020-09-19 17:37:37 +02:00
|
|
|
* the statool infos exception
|
2020-09-17 02:03:56 +02:00
|
|
|
*/
|
2020-09-17 18:54:29 +02:00
|
|
|
public static void htmlizeOrganisation(final Configuration configuration) throws IOException, StatoolInfosException
|
2020-09-17 02:03:56 +02:00
|
|
|
{
|
2020-09-17 18:54:29 +02:00
|
|
|
CrawlCache cache = configuration.getCrawlCache();
|
2020-09-19 02:37:52 +02:00
|
|
|
File htmlizeInput = configuration.getHtmlizeInput();
|
|
|
|
File htmlizeDirectory = configuration.getHtmlizeDirectory();
|
|
|
|
|
2020-09-17 18:54:29 +02:00
|
|
|
Organization organization = Factory.loadOrganization(configuration.getBuildInput(), cache);
|
|
|
|
|
2020-09-19 02:37:52 +02:00
|
|
|
copyStuff(htmlizeDirectory);
|
|
|
|
|
|
|
|
// Manage the logo file.
|
2020-10-01 15:30:06 +02:00
|
|
|
cache.restoreLogoTo(organization.getLogoURL(), new File(htmlizeDirectory, organization.getTechnicalName() + "-logo.jpg"), organization.getTechnicalName(), DefaultLogoGenerator.CAT);
|
2020-09-17 02:03:56 +02:00
|
|
|
|
2020-09-19 02:37:52 +02:00
|
|
|
//
|
2020-09-21 03:41:46 +02:00
|
|
|
logger.info("Htmlize about page.");
|
|
|
|
String page = AboutPage.build();
|
|
|
|
FileUtils.write(new File(htmlizeDirectory, "about.xhtml"), page, StandardCharsets.UTF_8);
|
|
|
|
|
|
|
|
//
|
|
|
|
page = OrganizationPage.build(organization);
|
2020-09-19 02:37:52 +02:00
|
|
|
FileUtils.write(new File(htmlizeDirectory, "index.xhtml"), page, StandardCharsets.UTF_8);
|
|
|
|
|
|
|
|
for (Service service : organization.getServices())
|
2020-09-17 02:03:56 +02:00
|
|
|
{
|
2020-09-19 02:37:52 +02:00
|
|
|
// Manage the logo file.
|
2020-10-01 15:30:06 +02:00
|
|
|
cache.restoreLogoTo(service.getLogoURL(), new File(htmlizeDirectory, service.getTechnicalName() + "-logo.jpg"), service.getTechnicalName(), DefaultLogoGenerator.BIRD);
|
2020-09-17 02:03:56 +02:00
|
|
|
|
|
|
|
//
|
2020-09-19 03:36:41 +02:00
|
|
|
page = ServicePage.build(organization, service);
|
2020-09-19 02:37:52 +02:00
|
|
|
FileUtils.write(new File(htmlizeDirectory, organization.getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml"), page, StandardCharsets.UTF_8);
|
|
|
|
}
|
2020-09-17 02:03:56 +02:00
|
|
|
}
|
|
|
|
}
|