Added SocialNetworks pages.

This commit is contained in:
Christian P. MOMON 2020-10-11 06:57:21 +02:00
parent 2b967836c3
commit 82cd6e374b
9 changed files with 389 additions and 0 deletions

View file

@ -123,6 +123,21 @@ public class Organization extends PathPropertyList
return result; return result;
} }
/**
* Gets the diaspora page.
*
* @return the diaspora page
*/
public String getDiasporaWebpage()
{
String result;
result = get("organization.socialnetworks.diaspora");
//
return result;
}
/** /**
* Gets the end date. * Gets the end date.
* *
@ -203,6 +218,21 @@ public class Organization extends PathPropertyList
return result; return result;
} }
/**
* Gets the mastodon page.
*
* @return the mastodon page
*/
public String getMastodonWebpage()
{
String result;
result = get("organization.socialnetworks.mastodon");
//
return result;
}
/** /**
* Gets the name. * Gets the name.
* *
@ -332,6 +362,65 @@ public class Organization extends PathPropertyList
return result; return result;
} }
/**
* Checks for social network.
*
* @return true, if successful
*/
public boolean hasSocialNetwork()
{
boolean result;
if (StringUtils.isAllBlank(getDiasporaWebpage(), getMastodonWebpage()))
{
result = false;
}
else
{
result = true;
}
//
return result;
}
/**
* Checks for social network.
*
* @param value
* the value
* @return true, if successful
*/
public boolean hasSocialNetwork(final SocialNetworks value)
{
boolean result;
String link;
switch (value)
{
case DIASPORA:
link = getDiasporaWebpage();
break;
case MASTODON:
link = getMastodonWebpage();
break;
default:
link = null;
}
if (StringUtils.isBlank(link))
{
result = false;
}
else
{
result = true;
}
//
return result;
}
public void setFederation(final Federation federation) public void setFederation(final Federation federation)
{ {
this.federation = federation; this.federation = federation;

View file

@ -36,6 +36,54 @@ public class Organizations extends ArrayList<Organization>
super(); super();
} }
/**
* Filter by social network.
*
* @return the organizations
*/
public Organizations filterBySocialNetworks()
{
Organizations result;
result = new Organizations();
for (Organization organization : this)
{
if (organization.hasSocialNetwork())
{
result.add(organization);
}
}
//
return result;
}
/**
* Filter by social network.
*
* @param value
* the value
* @return the organizations
*/
public Organizations filterBySocialNetwork(final SocialNetworks value)
{
Organizations result;
result = new Organizations();
for (Organization organization : this)
{
if (organization.hasSocialNetwork(value))
{
result.add(organization);
}
}
//
return result;
}
/** /**
* Reverse. * Reverse.
* *

View file

@ -0,0 +1,28 @@
/*
* 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.core;
/**
* The Enum SocialNetworks.
*/
public enum SocialNetworks
{
DIASPORA,
MASTODON
}

View file

@ -33,8 +33,10 @@ import fr.devinsy.statoolinfos.core.Configuration;
import fr.devinsy.statoolinfos.core.Factory; import fr.devinsy.statoolinfos.core.Factory;
import fr.devinsy.statoolinfos.core.Federation; import fr.devinsy.statoolinfos.core.Federation;
import fr.devinsy.statoolinfos.core.Organization; import fr.devinsy.statoolinfos.core.Organization;
import fr.devinsy.statoolinfos.core.Organizations;
import fr.devinsy.statoolinfos.core.Service; import fr.devinsy.statoolinfos.core.Service;
import fr.devinsy.statoolinfos.core.Services; import fr.devinsy.statoolinfos.core.Services;
import fr.devinsy.statoolinfos.core.SocialNetworks;
import fr.devinsy.statoolinfos.core.Software; import fr.devinsy.statoolinfos.core.Software;
import fr.devinsy.statoolinfos.core.Softwares; import fr.devinsy.statoolinfos.core.Softwares;
import fr.devinsy.statoolinfos.core.StatoolInfosException; import fr.devinsy.statoolinfos.core.StatoolInfosException;
@ -129,6 +131,10 @@ public class Htmlizer
StatoolInfosUtils.copyRessource(source + "status-over.png", targetDirectory); StatoolInfosUtils.copyRessource(source + "status-over.png", targetDirectory);
StatoolInfosUtils.copyRessource(source + "status-void.png", targetDirectory); StatoolInfosUtils.copyRessource(source + "status-void.png", targetDirectory);
//
StatoolInfosUtils.copyRessource(source + "diaspora-logo.png", targetDirectory);
StatoolInfosUtils.copyRessource(source + "mastodon-logo.png", targetDirectory);
// //
File color = new File(targetDirectory, "circle-icons/color"); File color = new File(targetDirectory, "circle-icons/color");
color.mkdirs(); color.mkdirs();
@ -401,6 +407,22 @@ public class Htmlizer
FileUtils.write(new File(htmlizeDirectory, "software-" + software.getTechnicalName() + ".xhtml"), page, StandardCharsets.UTF_8); FileUtils.write(new File(htmlizeDirectory, "software-" + software.getTechnicalName() + ".xhtml"), page, StandardCharsets.UTF_8);
} }
} }
//
{
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);
}
} }
/** /**

View file

@ -0,0 +1,103 @@
/*
* 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 org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.core.Organization;
import fr.devinsy.statoolinfos.core.Organizations;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.DisplayMode;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
/**
* The Class SocialNetworks.
*/
public class SocialNetworksPage
{
private static Logger logger = LoggerFactory.getLogger(SocialNetworksPage.class);
/**
* Builds the.
*
* @param federation
* the federation
* @return the string
* @throws StatoolInfosException
* the statool infos exception
*/
public static String build(final String title, final Organizations organizations) throws StatoolInfosException
{
String result;
try
{
logger.debug("Building social networks page {}…");
TagDataManager data = new TagDataManager();
data.setEscapedContent("title", title);
data.setContent("organizationCount", organizations.size());
int index = 0;
for (Organization organization : organizations)
{
data.setAttribute("organizationListLine", index, "organizationListLineNameLink", "href", organization.getTechnicalName() + ".xhtml");
data.setAttribute("organizationListLine", index, "organizationListLineLogo", "src", organization.getTechnicalName() + "-logo.png");
data.setAttribute("organizationListLine", index, "organizationListLineLogo", "alt", organization.getName());
data.setEscapedContent("organizationListLine", index, "organizationListLineNameValue", organization.getName());
data.setEscapedContent("organizationListLine", index, "organizationListLineUrlLink", organization.getWebsite());
data.setAttribute("organizationListLine", index, "organizationListLineUrlLink", "href", organization.getWebsite());
if (StringUtils.isNotBlank(organization.getDiasporaWebpage()))
{
data.setAttribute("organizationListLine", index, "organizationListLineDiasporaImg", "class", "");
data.getIdData("organizationListLine", index, "organizationListLineDiasporaImg").getAttribute("class").setMode(DisplayMode.REPLACE);
data.setAttribute("organizationListLine", index, "organizationListLineDiasporaLink", "href", organization.getDiasporaWebpage());
}
if (StringUtils.isNotBlank(organization.getMastodonWebpage()))
{
data.setAttribute("organizationListLine", index, "organizationListLineMastodonImg", "class", "");
data.getIdData("organizationListLine", index, "organizationListLineMastodonImg").getAttribute("class").setMode(DisplayMode.REPLACE);
data.setAttribute("organizationListLine", index, "organizationListLineMastodonLink", "href", organization.getMastodonWebpage());
}
index += 1;
}
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/socialNetworks.xhtml", data).toString();
BreadcrumbTrail trail = new BreadcrumbTrail();
result = WebCharterView.build(content, trail);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building social networks page: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -0,0 +1,98 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>StatoolInfos</title>
<meta charset="UTF-8" />
<meta name="keywords" content="statoolinfos,devinsy,federation" />
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="statoolinfos.css" />
<script src="sorttable.js" />
<script src="Chart.bundle.min.js"></script>
</head>
<body>
<div class="row center_table" style="width: 1100px;">
<div style="margin: 5px;">
<a id="" href="socialNetworks.xhtml" class="button">Tous</a>
<a id="" href="socialNetworks-diaspora.xhtml" class="button">Diaspora</a>
<a id="" href="socialNetworks-mastodon.xhtml" class="button">Mastodon</a>
</div>
<div class="center">
<h2 id="title">n/a</h2>
<div>Nombre de membres : <span id="organizationCount">n/a</span></div>
</div>
<div class="center_table" style="width: 700px;">
<div class="legend right" style="float: right; margin-top: -75px;">
<div class="left">
<img src="diaspora-logo.png" title="Diaspora"/>Diaspora*<br/>
<img src="mastodon-logo.png" title="Mastodon"/>Mastodon<br/>
</div>
</div>
<table id="organizations" class="table_classic left">
<thead>
<tr>
<th style="width: 200px;">Nom du membre</th>
<th style="">URL</th>
<th style="width: 10px;" colspan="2">Réseaux sociaux</th>
</tr>
</thead>
<tbody>
<tr id="organizationListLine">
<td id="organizationListLineName" style="padding-top: 0; padding-bottom: 0;">
<a href="#" id="organizationListLineNameLink">
<img id="organizationListLineLogo" src="" style="width: 26px; height: 26px; padding-top:0; padding-bottom: 0; vertical-align: middle;"/>
&#160;<span id="organizationListLineNameValue">n/a</span>
</a>
</td>
<td id="organizationListLineUrl"><a href="#" id="organizationListLineUrlLink">n/a</a></td>
<td id="" class="td_center center"><a id="organizationListLineDiasporaLink" href="#"><img id="organizationListLineDiasporaImg" src="diaspora-logo.png" class="disabled" title="Diaspora*" style="width: 25px;"/></a></td>
<td id="" class="td_center center"><a id="organizationListLineMastodonLink" href="#"><img id="organizationListLineMastodonImg" src="mastodon-logo.png" class="disabled" title="Mastodon" style="width: 25px;"/></a></td>
</tr>
</tbody>
</table>
</div>
</div>
<script type="text/javascript">
$('#organizations').DataTable(
{
paging: false,
ordering: true,
"order": [[ 2, "desc" ]],
language:
{
"sEmptyTable": "Aucune donnée disponible dans le tableau",
"sInfo": "Affichage de l'élément _START_ à _END_ sur _TOTAL_ éléments",
"sInfoEmpty": "Affichage de l'élément 0 à 0 sur 0 élément",
"sInfoFiltered": "(filtré à partir de _MAX_ éléments au total)",
"sInfoPostFix": "",
"sInfoThousands": ",",
"sLengthMenu": "Afficher _MENU_ éléments",
"sLoadingRecords": "Chargement...",
"sProcessing": "Traitement...",
"sSearch": "Rechercher :",
"sZeroRecords": "Aucun élément correspondant trouvé",
"oPaginate": {
"sFirst": "Premier",
"sLast": "Dernier",
"sNext": "Suivant",
"sPrevious": "Précédent"
},
"oAria": {
"sSortAscending": ": activer pour trier la colonne par ordre croissant",
"sSortDescending": ": activer pour trier la colonne par ordre décroissant"
},
"select": {
"rows": {
"_": "%d lignes sélectionnées",
"0": "Aucune ligne sélectionnée",
"1": "1 ligne sélectionnée"
}
}
}
});
</script>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

@ -23,6 +23,7 @@
<a id="" href="services.xhtml" class="button">Services</a> <a id="" href="services.xhtml" class="button">Services</a>
<a id="" href="categories.xhtml" class="button">Catégories</a> <a id="" href="categories.xhtml" class="button">Catégories</a>
<a id="" href="softwares.xhtml" class="button">Logiciels</a> <a id="" href="softwares.xhtml" class="button">Logiciels</a>
<a id="" href="socialNetworks.xhtml" class="button" style="width: 130px;">Réseaux sociaux</a>
</div> </div>
<div id="breadcrumbTrail" style="margin: 5px;">n/a > n/a</div> <div id="breadcrumbTrail" style="margin: 5px;">n/a > n/a</div>