Added breadcrumb management.
This commit is contained in:
parent
a2de6cf940
commit
ff0e9cfb1e
12 changed files with 237 additions and 15 deletions
|
@ -52,7 +52,9 @@ public class AboutPage
|
|||
|
||||
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/about.xhtml", data).toString();
|
||||
|
||||
result = WebCharterView.build(content);
|
||||
BreadcrumbTrail trail = new BreadcrumbTrail();
|
||||
trail.add("À propos", "about.xhtml");
|
||||
result = WebCharterView.build(content, trail);
|
||||
}
|
||||
catch (XidynException exception)
|
||||
{
|
||||
|
|
89
src/fr/devinsy/statoolinfos/htmlize/Breadcrumb.java
Normal file
89
src/fr/devinsy/statoolinfos/htmlize/Breadcrumb.java
Normal file
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
public class Breadcrumb
|
||||
{
|
||||
private String label;
|
||||
private String link;
|
||||
|
||||
/**
|
||||
* Instantiates a new breadcrumb.
|
||||
*/
|
||||
public Breadcrumb()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new breadcrumb.
|
||||
*
|
||||
* @param label
|
||||
* the label
|
||||
* @param link
|
||||
* the link
|
||||
*/
|
||||
public Breadcrumb(final String label, final String link)
|
||||
{
|
||||
this.label = label;
|
||||
this.link = link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the label.
|
||||
*
|
||||
* @return the label
|
||||
*/
|
||||
public String getLabel()
|
||||
{
|
||||
return this.label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the link.
|
||||
*
|
||||
* @return the link
|
||||
*/
|
||||
public String getLink()
|
||||
{
|
||||
return this.link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the label.
|
||||
*
|
||||
* @param label
|
||||
* the new label
|
||||
*/
|
||||
public void setLabel(final String label)
|
||||
{
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the link.
|
||||
*
|
||||
* @param link
|
||||
* the new link
|
||||
*/
|
||||
public void setLink(final String link)
|
||||
{
|
||||
this.link = link;
|
||||
}
|
||||
|
||||
}
|
103
src/fr/devinsy/statoolinfos/htmlize/BreadcrumbTrail.java
Normal file
103
src/fr/devinsy/statoolinfos/htmlize/BreadcrumbTrail.java
Normal 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 java.util.ArrayList;
|
||||
|
||||
import fr.devinsy.strings.StringList;
|
||||
|
||||
/**
|
||||
* The Class BreadcrumbTrail.
|
||||
*/
|
||||
public class BreadcrumbTrail extends ArrayList<Breadcrumb>
|
||||
{
|
||||
private static final long serialVersionUID = -2688444486042912675L;
|
||||
|
||||
/**
|
||||
* Instantiates a new breadcrumb trail.
|
||||
*/
|
||||
public BreadcrumbTrail()
|
||||
{
|
||||
this("🏡", "index.xhtml");
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new breadcrumb trail.
|
||||
*
|
||||
* @param label
|
||||
* the label
|
||||
* @param link
|
||||
* the link
|
||||
*/
|
||||
public BreadcrumbTrail(final String label, final String link)
|
||||
{
|
||||
super();
|
||||
add(label, link);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the.
|
||||
*
|
||||
* @param label
|
||||
* the label
|
||||
* @param link
|
||||
* the link
|
||||
*/
|
||||
public BreadcrumbTrail add(final String label, final String link)
|
||||
{
|
||||
BreadcrumbTrail result;
|
||||
|
||||
Breadcrumb crumb = new Breadcrumb(label, link);
|
||||
|
||||
add(crumb);
|
||||
|
||||
result = this;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* To string.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
String result;
|
||||
|
||||
StringList buffer = new StringList();
|
||||
|
||||
for (Breadcrumb crumb : this)
|
||||
{
|
||||
buffer.append(String.format("<a href=\"%s\" style=\"text-decoration: none; padding: 5px;\">%s</a>", crumb.getLink(), crumb.getLabel()));
|
||||
buffer.append(" > ");
|
||||
}
|
||||
if (buffer.size() > 2)
|
||||
{
|
||||
buffer.removeLast();
|
||||
}
|
||||
|
||||
result = buffer.toString();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -76,7 +76,8 @@ public class FederationPage
|
|||
|
||||
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/federation.xhtml", data).toString();
|
||||
|
||||
result = WebCharterView.build(content);
|
||||
BreadcrumbTrail trail = new BreadcrumbTrail();
|
||||
result = WebCharterView.build(content, trail);
|
||||
}
|
||||
catch (XidynException exception)
|
||||
{
|
||||
|
|
|
@ -77,7 +77,9 @@ public class OrganizationPage
|
|||
|
||||
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/organization.xhtml", data).toString();
|
||||
|
||||
result = WebCharterView.build(content);
|
||||
BreadcrumbTrail trail = new BreadcrumbTrail();
|
||||
trail.add(organization.getName(), organization.getTechnicalName() + ".xhtml");
|
||||
result = WebCharterView.build(content, trail);
|
||||
}
|
||||
catch (XidynException exception)
|
||||
{
|
||||
|
|
|
@ -86,7 +86,9 @@ public class PropertiesFilesPage
|
|||
|
||||
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/propertiesFiles.xhtml", data).toString();
|
||||
|
||||
result = WebCharterView.build(content);
|
||||
BreadcrumbTrail trail = new BreadcrumbTrail();
|
||||
trail.add("Fichiers", "propertiesFiles.xhtml");
|
||||
result = WebCharterView.build(content, trail);
|
||||
}
|
||||
catch (XidynException exception)
|
||||
{
|
||||
|
|
|
@ -140,7 +140,9 @@ public class PropertyStatsPage
|
|||
//
|
||||
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/propertyStats.xhtml", data).toString();
|
||||
|
||||
result = WebCharterView.build(content);
|
||||
BreadcrumbTrail trail = new BreadcrumbTrail();
|
||||
trail.add("Propriétés", "propertyStats.xhtml");
|
||||
result = WebCharterView.build(content, trail);
|
||||
}
|
||||
catch (XidynException exception)
|
||||
{
|
||||
|
|
|
@ -62,7 +62,10 @@ public class ServicePage
|
|||
|
||||
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/service.xhtml", data).toString();
|
||||
|
||||
result = WebCharterView.build(content);
|
||||
BreadcrumbTrail trail = new BreadcrumbTrail();
|
||||
trail.add(service.getOrganization().getName(), service.getOrganization().getTechnicalName() + ".xhtml");
|
||||
trail.add(service.getName(), service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml");
|
||||
result = WebCharterView.build(content, trail);
|
||||
}
|
||||
catch (XidynException exception)
|
||||
{
|
||||
|
|
|
@ -74,7 +74,9 @@ public class ServicesPage
|
|||
|
||||
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/services.xhtml", data).toString();
|
||||
|
||||
result = WebCharterView.build(content);
|
||||
BreadcrumbTrail trail = new BreadcrumbTrail();
|
||||
trail.add("Services", "services.xhtml");
|
||||
result = WebCharterView.build(content, trail);
|
||||
}
|
||||
catch (XidynException exception)
|
||||
{
|
||||
|
|
|
@ -52,6 +52,27 @@ public class WebCharterView
|
|||
{
|
||||
String result;
|
||||
|
||||
result = build(content, new BreadcrumbTrail());
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the.
|
||||
*
|
||||
* @param content
|
||||
* the content
|
||||
* @param trail
|
||||
* the trail
|
||||
* @return the string
|
||||
* @throws StatoolInfosException
|
||||
* the statool infos exception
|
||||
*/
|
||||
public static String build(final String content, final BreadcrumbTrail trail) throws StatoolInfosException
|
||||
{
|
||||
String result;
|
||||
|
||||
try
|
||||
{
|
||||
logger.debug("Building WebCharterView.");
|
||||
|
@ -61,6 +82,7 @@ public class WebCharterView
|
|||
data.setContent("versionsup", BuildInformation.instance().version());
|
||||
data.setContent("lastUpdateDate", LocalDateTime.now().format(DateTimeFormatter.ofPattern("dd/MM/yyyy HH':'mm", Locale.FRANCE)));
|
||||
data.setContent("webCharterContent", XidynUtils.extractBodyContent(content));
|
||||
data.setContent("breadcrumbTrail", trail.toString());
|
||||
|
||||
result = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/webCharterView.xhtml", data).toString();
|
||||
}
|
||||
|
|
|
@ -13,9 +13,6 @@
|
|||
<body>
|
||||
<div class="center">
|
||||
<h2><img id="federationLogo" src="#" style="width: 100px; heigth: 100px; vertical-align: middle;"/> <span id="federationName">Federation name</span></h2>
|
||||
<div style="margin: 5px;">
|
||||
<a id="federationRawButton" href="#" class="button">Raw</a>
|
||||
</div>
|
||||
<p id="federationDescription">Bla bla description</p>
|
||||
<div>Nombre de membres : <span id="organizationCount">n/a</span></div>
|
||||
<div>Nombre de services : <span id="serviceCount">n/a</span></div>
|
||||
|
|
|
@ -19,14 +19,11 @@
|
|||
<a id="propertiesRawButton" href="propertiesFiles.xhtml" class="button">Fichiers</a>
|
||||
<a id="propertiesRawButton" href="propertyStats.xhtml" class="button">Propriétés</a>
|
||||
<a id="" href="services.xhtml" class="button">Services</a>
|
||||
<a id="" href="#" class="button" disabled="disabled">Logiciels</a>
|
||||
<a id="" href="#" class="button">Logiciels</a>
|
||||
<a id="" href="#" class="button">Catégories</a>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<a href="index.xhtml">Fédération</a> <span id="menuPath"> > …<span id="menuPathItem"></span></span>
|
||||
</div>
|
||||
|
||||
<div id="breadcrumbTrail" style="margin: 5px;">n/a > n/a</div>
|
||||
|
||||
<div id="webCharterContent" />
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue