Search in sources :

Example 1 with HC_Target

use of com.helger.html.hc.html.HC_Target in project phoss-smp by phax.

the class SMPRendererPublic method createDefaultFooter.

/**
 * @param bShowApplicationName
 *        <code>true</code> to show the application name and version,
 *        <code>false</code> to hide it.
 * @param bShowSource
 *        <code>true</code> to show the link to the source, <code>false</code>
 *        to hide it.
 * @param bShowAuthor
 *        <code>true</code> to show the author, <code>false</code> to hide it.
 * @return The footer to be used for /public and /secure. Never
 *         <code>null</code> but maybe empty.
 */
@Nonnull
public static BootstrapContainer createDefaultFooter(final boolean bShowApplicationName, final boolean bShowSource, final boolean bShowAuthor) {
    final BootstrapContainer aContainer = new BootstrapContainer().setID(CLayout.LAYOUT_AREAID_FOOTER).setFluid(true);
    if (bShowApplicationName) {
        aContainer.addChild(new HCP().addChild(CSMP.getApplicationTitleAndVersion() + " with " + SMPServerConfiguration.getRESTType().getDisplayName() + " API"));
    }
    // By
    {
        final HCP aBy = new HCP();
        // Author
        if (bShowAuthor)
            aBy.addChild("Created by ").addChild(HCA_MailTo.createLinkedEmail("philip@helger.com", "Philip Helger"));
        // Source
        if (bShowSource) {
            if (aBy.hasChildren())
                aBy.addChild(" - ");
            aBy.addChild(new HCA(new SimpleURL("https://github.com/phax/phoss-smp")).setTargetBlank().addChild(CSMP.APPLICATION_TITLE + " on GitHub"));
        }
        if (aBy.hasChildren())
            aContainer.addChild(aBy);
    }
    // Imprint
    if (SMPWebAppConfiguration.isImprintEnabled()) {
        final String sImprintText = SMPWebAppConfiguration.getImprintText();
        if (StringHelper.hasText(sImprintText)) {
            final ISimpleURL aImprintHref = SMPWebAppConfiguration.getImprintHref();
            final IHCElementWithChildren<?> aNode;
            if (aImprintHref != null) {
                // Link and text
                final String sImprintTarget = SMPWebAppConfiguration.getImprintTarget();
                final HC_Target aTarget = StringHelper.hasText(sImprintTarget) ? new HC_Target(sImprintTarget) : null;
                aNode = new HCA(aImprintHref).addChild(sImprintText).setTarget(aTarget);
            } else {
                // Text only
                aNode = new HCSpan().addChild(sImprintText);
            }
            // Already trimmed
            final String sImprintCSSClasses = SMPWebAppConfiguration.getImprintCSSClasses();
            if (StringHelper.hasText(sImprintCSSClasses)) {
                final ICommonsSet<String> aUniqueNames = new CommonsHashSet<>(RegExHelper.getSplitToList(sImprintCSSClasses, "\\s+"));
                for (final String sCSSClass : aUniqueNames) aNode.addClass(DefaultCSSClassProvider.create(sCSSClass));
            }
            aContainer.addChild(new HCP().addChild("Imprint ").addChild(aNode));
        }
    }
    return aContainer;
}
Also used : HCSpan(com.helger.html.hc.html.textlevel.HCSpan) BootstrapContainer(com.helger.photon.bootstrap4.layout.BootstrapContainer) HCP(com.helger.html.hc.html.grouping.HCP) HC_Target(com.helger.html.hc.html.HC_Target) HCA(com.helger.html.hc.html.textlevel.HCA) ISimpleURL(com.helger.commons.url.ISimpleURL) CommonsHashSet(com.helger.commons.collection.impl.CommonsHashSet) SimpleURL(com.helger.commons.url.SimpleURL) ISimpleURL(com.helger.commons.url.ISimpleURL) Nonnull(javax.annotation.Nonnull)

Aggregations

CommonsHashSet (com.helger.commons.collection.impl.CommonsHashSet)1 ISimpleURL (com.helger.commons.url.ISimpleURL)1 SimpleURL (com.helger.commons.url.SimpleURL)1 HC_Target (com.helger.html.hc.html.HC_Target)1 HCP (com.helger.html.hc.html.grouping.HCP)1 HCA (com.helger.html.hc.html.textlevel.HCA)1 HCSpan (com.helger.html.hc.html.textlevel.HCSpan)1 BootstrapContainer (com.helger.photon.bootstrap4.layout.BootstrapContainer)1 Nonnull (javax.annotation.Nonnull)1