Search in sources :

Example 1 with HCP

use of com.helger.html.hc.html.grouping.HCP 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)

Example 2 with HCP

use of com.helger.html.hc.html.grouping.HCP in project phoss-directory by phax.

the class PublicHTMLProvider method getContent.

@Nonnull
public static IHCNode getContent(@Nonnull final LayoutExecutionContext aLEC) {
    final Locale aDisplayLocale = aLEC.getDisplayLocale();
    final IRequestWebScopeWithoutResponse aRequestScope = aLEC.getRequestScope();
    final HCNodeList ret = new HCNodeList();
    // Header
    ret.addChild(_getNavbar(aLEC));
    final BootstrapContainer aOuterContainer = ret.addAndReturnChild(new BootstrapContainer().setFluid(false));
    // Content - no menu
    aOuterContainer.addChild(BootstrapPageRenderer.getPageContent(aLEC));
    // Footer
    {
        final BootstrapContainer aDiv = new BootstrapContainer().setFluid(true).setID(CLayout.LAYOUT_AREAID_FOOTER);
        aDiv.addChild(new HCP().addChild(CPDPublisher.getApplication() + " - an ").addChild(new HCA(new SimpleURL(VENDOR_URL)).addChild(VENDOR_NAME)).addChild(" service"));
        if (PDServerConfiguration.getConfig().getAsBoolean("webapp.showtwitter", true)) {
            aDiv.addChild(new HCP().addChild("Follow us on Twitter: ").addChild(new HCA(new SimpleURL("https://twitter.com/PEPPOLDirectory")).addChild("@PEPPOLDirectory")));
        }
        final HCP aP = new HCP().addChild("Download data [");
        aP.addChild(new HCA(LinkHelper.getURLWithContext(aRequestScope, ExportServlet.SERVLET_DEFAULT_PATH + ExportDeliveryHttpHandler.SPECIAL_BUSINESS_CARDS_XML_FULL)).addChild("BusinessCards XML"));
        aP.addChild(" | ").addChild(new HCA(LinkHelper.getURLWithContext(aRequestScope, ExportServlet.SERVLET_DEFAULT_PATH + ExportDeliveryHttpHandler.SPECIAL_BUSINESS_CARDS_XML_NO_DOC_TYPES)).addChild("BusinessCards w/o doctypes XML"));
        if (CPDPublisher.EXPORT_BUSINESS_CARDS_EXCEL) {
            aP.addChild(" | ").addChild(new HCA(LinkHelper.getURLWithContext(aRequestScope, ExportServlet.SERVLET_DEFAULT_PATH + ExportDeliveryHttpHandler.SPECIAL_BUSINESS_CARDS_EXCEL)).addChild("BusinessCards Excel"));
        }
        if (CPDPublisher.EXPORT_BUSINESS_CARDS_CSV) {
            aP.addChild(" | ").addChild(new HCA(LinkHelper.getURLWithContext(aRequestScope, ExportServlet.SERVLET_DEFAULT_PATH + ExportDeliveryHttpHandler.SPECIAL_BUSINESS_CARDS_CSV)).addChild("BusinessCards CSV"));
        }
        if (CPDPublisher.EXPORT_PARTICIPANTS_XML) {
            aP.addChild(" | ").addChild(new HCA(LinkHelper.getURLWithContext(aRequestScope, ExportServlet.SERVLET_DEFAULT_PATH + ExportDeliveryHttpHandler.SPECIAL_PARTICIPANTS_XML)).addChild("Participant IDs XML"));
        }
        if (CPDPublisher.EXPORT_PARTICIPANTS_JSON) {
            aP.addChild(" | ").addChild(new HCA(LinkHelper.getURLWithContext(aRequestScope, ExportServlet.SERVLET_DEFAULT_PATH + ExportDeliveryHttpHandler.SPECIAL_PARTICIPANTS_JSON)).addChild("Participant IDs JSON"));
        }
        if (CPDPublisher.EXPORT_PARTICIPANTS_CSV) {
            aP.addChild(" | ").addChild(new HCA(LinkHelper.getURLWithContext(aRequestScope, ExportServlet.SERVLET_DEFAULT_PATH + ExportDeliveryHttpHandler.SPECIAL_PARTICIPANTS_CSV)).addChild("Participant IDs CSV"));
        }
        aP.addChild("]");
        aDiv.addChild(aP);
        final BootstrapMenuItemRendererHorz aRenderer = new BootstrapMenuItemRendererHorz(aDisplayLocale);
        final HCUL aUL = aDiv.addAndReturnChild(new HCUL().addClass(CSS_CLASS_FOOTER_LINKS));
        for (final IMenuObject aMenuObj : s_aFooterObjects) {
            if (aMenuObj instanceof IMenuSeparator)
                aUL.addItem(aRenderer.renderSeparator(aLEC, (IMenuSeparator) aMenuObj));
            else if (aMenuObj instanceof IMenuItemPage)
                aUL.addItem(aRenderer.renderMenuItemPage(aLEC, (IMenuItemPage) aMenuObj, false, false, false));
            else if (aMenuObj instanceof IMenuItemExternal)
                aUL.addItem(aRenderer.renderMenuItemExternal(aLEC, (IMenuItemExternal) aMenuObj, false, false, false));
            else
                throw new IllegalStateException("Unsupported menu object type!");
        }
        ret.addChild(aDiv);
    }
    // Google Analytics?
    final String sAccountID = PDServerConfiguration.getConfig().getAsString("webapp.google.analytics.account");
    if (StringHelper.hasText(sAccountID))
        ret.addChild(new HCUniversalAnalytics(sAccountID, false, false, false, false));
    ret.addChild(HCCookieConsent.createBottomDefault("#000", "#0f0", "#0f0", null));
    return ret;
}
Also used : Locale(java.util.Locale) HCNodeList(com.helger.html.hc.impl.HCNodeList) HCUniversalAnalytics(com.helger.photon.uicore.html.google.HCUniversalAnalytics) HCA(com.helger.html.hc.html.textlevel.HCA) IMenuItemPage(com.helger.photon.core.menu.IMenuItemPage) IMenuObject(com.helger.photon.core.menu.IMenuObject) SimpleURL(com.helger.commons.url.SimpleURL) ISimpleURL(com.helger.commons.url.ISimpleURL) IMenuItemExternal(com.helger.photon.core.menu.IMenuItemExternal) IRequestWebScopeWithoutResponse(com.helger.web.scope.IRequestWebScopeWithoutResponse) BootstrapMenuItemRendererHorz(com.helger.photon.bootstrap4.uictrls.ext.BootstrapMenuItemRendererHorz) HCUL(com.helger.html.hc.html.grouping.HCUL) IMenuSeparator(com.helger.photon.core.menu.IMenuSeparator) BootstrapContainer(com.helger.photon.bootstrap4.layout.BootstrapContainer) HCP(com.helger.html.hc.html.grouping.HCP) Nonnull(javax.annotation.Nonnull)

Aggregations

ISimpleURL (com.helger.commons.url.ISimpleURL)2 SimpleURL (com.helger.commons.url.SimpleURL)2 HCP (com.helger.html.hc.html.grouping.HCP)2 HCA (com.helger.html.hc.html.textlevel.HCA)2 BootstrapContainer (com.helger.photon.bootstrap4.layout.BootstrapContainer)2 Nonnull (javax.annotation.Nonnull)2 CommonsHashSet (com.helger.commons.collection.impl.CommonsHashSet)1 HC_Target (com.helger.html.hc.html.HC_Target)1 HCUL (com.helger.html.hc.html.grouping.HCUL)1 HCSpan (com.helger.html.hc.html.textlevel.HCSpan)1 HCNodeList (com.helger.html.hc.impl.HCNodeList)1 BootstrapMenuItemRendererHorz (com.helger.photon.bootstrap4.uictrls.ext.BootstrapMenuItemRendererHorz)1 IMenuItemExternal (com.helger.photon.core.menu.IMenuItemExternal)1 IMenuItemPage (com.helger.photon.core.menu.IMenuItemPage)1 IMenuObject (com.helger.photon.core.menu.IMenuObject)1 IMenuSeparator (com.helger.photon.core.menu.IMenuSeparator)1 HCUniversalAnalytics (com.helger.photon.uicore.html.google.HCUniversalAnalytics)1 IRequestWebScopeWithoutResponse (com.helger.web.scope.IRequestWebScopeWithoutResponse)1 Locale (java.util.Locale)1