/** * Convert the passed HC node to an HTML string using the default conversion * settings. * * @param aHCNode * The node to be converted. May not be <code>null</code>. * @return The node as XML with or without indentation. */ @Nonnull public static String getAsHTMLString (@Nonnull final IHCNode aHCNode) { return getAsHTMLString (aHCNode, HCSettings.getConversionSettings ()); }
@Override @OverrideOnDemand @OverridingMethodsMustInvokeSuper public void before () { HCSettings.setDefaultHTMLVersion (EHTMLVersion.XHTML11); HCSettings.getMutableConversionSettings ().setToOptimized (); HCSettings.setOnDocumentReadyProvider (aJSCodeProvider -> new UnparsedJSCodeProvider ("$(document).ready(function(){" + aJSCodeProvider.getJSCode () + "});")); }
@Nonnull public HCScriptInlineOnDocumentReady setOnDocumentReadyCode (@Nonnull final IHasJSCode aOnDocumentReadyCode) { return setOnDocumentReadyCode (HCSettings.getOnDocumentReadyProvider (), aOnDocumentReadyCode); }
@Override @OverrideOnDemand @OverridingMethodsMustInvokeSuper public void before () { m_ePrevHTMLVersion = HCSettings.getConversionSettings ().getHTMLVersion (); HCSettings.setDefaultHTMLVersion (m_eHTMLVersion); }
/** * Set the default HTML version to use. This sets the HTML version in the * {@link HCSettings} class and performs some additional modifications * depending on the chosen version. * * @param eHTMLVersion * The HTML version to use. May not be <code>null</code>. */ public static void setDefaultHTMLVersion (@Nonnull final EHTMLVersion eHTMLVersion) { ValueEnforcer.notNull (eHTMLVersion, "HTMLVersion"); // Update the HCSettings getMutableConversionSettings ().setHTMLVersion (eHTMLVersion); // Update the XMLWriterSettings getMutableConversionSettings ().setXMLWriterSettings (HCConversionSettings.createDefaultXMLWriterSettings (eHTMLVersion)); s_aLogger.info ("Default HTML version set to " + eHTMLVersion); if (eHTMLVersion.isAtLeastHTML5 ()) { // No need to put anything in a comment if (getScriptInlineMode () != EHCScriptInlineMode.PLAIN_TEXT_NO_ESCAPE) setScriptInlineMode (EHCScriptInlineMode.PLAIN_TEXT_NO_ESCAPE); } else { // Use default mode if (getScriptInlineMode () != DEFAULT_SCRIPT_INLINE_MODE) setScriptInlineMode (DEFAULT_SCRIPT_INLINE_MODE); } }
final IHCConversionSettings aConversionSettings = HCSettings.getConversionSettings (); final boolean bAutoCompleteForPasswordEdits = aWPEC.params () .isCheckBoxChecked (FIELD_AUTO_COMPLETE_FOR_PASSWORD_EDITS, !HCSettings.isAutoCompleteOffForPasswordEdits ()); final boolean bOOBDebug = aWPEC.params ().isCheckBoxChecked (FIELD_OUT_OF_BAND_DEBUG, HCSettings.isOutOfBandDebuggingEnabled ()); final boolean bScriptsInBody = aWPEC.params ().isCheckBoxChecked (FIELD_SCRIPTS_IN_BODY, HCSettings.isScriptsInBody ()); final boolean bUseRegularResources = aWPEC.params ().isCheckBoxChecked (FIELD_USE_REGULAR_RESOURCES, HCSettings.isUseRegularResources ()); HCSettings.getMutableConversionSettings () .setXMLWriterSettingsOptimized (!bFormatHTML) .setCSSWriterSettingsOptimized (!bFormatCSS) .setConsistencyChecksEnabled (bConsistencyChecksEnabled) .setExtractOutOfBandNodes (bExtractOutOfBandNodes); HCSettings.setAutoCompleteOffForPasswordEdits (!bAutoCompleteForPasswordEdits); HCSettings.setOutOfBandDebuggingEnabled (bOOBDebug); HCSettings.setScriptsInBody (bScriptsInBody); HCSettings.setUseRegularResources (bUseRegularResources); aForm.addFormGroup (new BootstrapFormGroup ().setLabel (EText.MSG_AUTO_COMPLETE_FOR_PASSWORD_EDITS.getDisplayText (aDisplayLocale)) .setCtrl (new BootstrapCheckBox (new RequestFieldBoolean (FIELD_AUTO_COMPLETE_FOR_PASSWORD_EDITS, !HCSettings.isAutoCompleteOffForPasswordEdits ())))); aForm.addFormGroup (new BootstrapFormGroup ().setLabel (EText.MSG_ON_DOCUMENT_READY_PROVIDER.getDisplayText (aDisplayLocale)) .setCtrl (String.valueOf (HCSettings.getOnDocumentReadyProvider ()))); aForm.addFormGroup (new BootstrapFormGroup ().setLabel (EText.MSG_SCRIPT_INLINE_MODE.getDisplayText (aDisplayLocale))
if (HCConversionSettings.isDefaultCustomizer (HCSettings.getConversionSettings ().getCustomizer ())) HCSettings.getMutableConversionSettings () .setCustomizer (new HCCustomizerList (new BootstrapCustomizer (), new HCCustomizerAutoFocusFirstCtrl ()));
/** * @return The global read-only non-<code>null</code> conversion settings */ @Nonnull public static IHCConversionSettings getConversionSettings () { return getMutableConversionSettings (); }
final IHCConversionSettingsToNode aConversionSettings = HCSettings.getConversionSettings (); if (HCSettings.isScriptsInBody ()) aHtml.moveScriptElementsToBody ();
@Override @OverrideOnDemand @OverridingMethodsMustInvokeSuper public void after () { HCSettings.setOnDocumentReadyProvider (new DefaultHCOnDocumentReadyProvider ()); HCSettings.getMutableConversionSettings ().setToDefault (); } }
return ""; final IHCConversionSettings aConversionSettings = HCSettings.getConversionSettingsWithoutNamespaces (); if (HCSettings.isScriptsInBody ()) aHtml.moveScriptElementsToBody ();
public static void addCSSAndJS (@Nonnull final IRequestWebScopeWithoutResponse aRequestScope, @Nonnull final HCSpecialNodes aSpecialNodes) { ValueEnforcer.notNull (aRequestScope, "RequestScope"); // Grab per-request CSS/JS only in success case! // Grab all CSS/JS independent of conditional comment :( final boolean bRegular = HCSettings.isUseRegularResources (); for (final ICSSPathProvider aCSS : PhotonCSS.getAllRegisteredCSSIncludesForThisRequest ()) aSpecialNodes.addExternalCSS (aCSS.getMediaList (), PhotonHTMLSettings.getCSSPath (aRequestScope, aCSS, bRegular) .getAsStringWithEncodedParameters ()); for (final IJSPathProvider aJS : PhotonJS.getAllRegisteredJSIncludesForThisRequest ()) aSpecialNodes.addExternalJS (PhotonHTMLSettings.getJSPath (aRequestScope, aJS, bRegular) .getAsStringWithEncodedParameters ()); }
public static void prepareHtmlForConversion (@Nonnull final HCHtml aHtml, @Nonnull final IHCConversionSettingsToNode aConversionSettings) { // customize, finalize and extract resources prepareForConversion (aHtml, aHtml.getBody (), aConversionSettings); // Extract all out-of-band nodes into the body if (aConversionSettings.isExtractOutOfBandNodes ()) { final ICommonsList <IHCNode> aOOBNodes = aHtml.getAllOutOfBandNodesWithMergedInlineNodes (); aHtml.addAllOutOfBandNodesToHead (aOOBNodes); } // This would be the correct place to perform aggregation of CSS and JS // nodes (before they are potentially moved) // Move scripts to body? if (HCSettings.isScriptsInBody ()) aHtml.moveScriptElementsToBody (); }
public void initHCSettings () { HCSettings.setOnDocumentReadyProvider (new JQueryOnDocumentReadyProvider ()); } }
public HCEditPassword () { super (EHCInputType.PASSWORD); if (HCSettings.isAutoCompleteOffForPasswordEdits ()) setAutoComplete (false); }
final boolean bDebug = HCSettings.isOutOfBandDebuggingEnabled (); int nNodeIndex = 0;
final IHCConversionSettings aConversionSettings = HCSettings.getConversionSettings (); final boolean bAutoCompleteForPasswordEdits = aWPEC.params () .isCheckBoxChecked (FIELD_AUTO_COMPLETE_FOR_PASSWORD_EDITS, !HCSettings.isAutoCompleteOffForPasswordEdits ()); final boolean bOOBDebug = aWPEC.params () .isCheckBoxChecked (FIELD_OUT_OF_BAND_DEBUG, HCSettings.isOutOfBandDebuggingEnabled ()); final boolean bScriptsInBody = aWPEC.params () .isCheckBoxChecked (FIELD_SCRIPTS_IN_BODY, HCSettings.isScriptsInBody ()); final boolean bUseRegularResources = aWPEC.params () .isCheckBoxChecked (FIELD_USE_REGULAR_RESOURCES, HCSettings.isUseRegularResources ()); HCSettings.getMutableConversionSettings () .setXMLWriterSettingsOptimized (!bFormatHTML) .setCSSWriterSettingsOptimized (!bFormatCSS) .setConsistencyChecksEnabled (bConsistencyChecksEnabled) .setExtractOutOfBandNodes (bExtractOutOfBandNodes); HCSettings.setAutoCompleteOffForPasswordEdits (!bAutoCompleteForPasswordEdits); HCSettings.setOutOfBandDebuggingEnabled (bOOBDebug); HCSettings.setScriptsInBody (bScriptsInBody); HCSettings.setUseRegularResources (bUseRegularResources); aForm.addFormGroup (new BootstrapFormGroup ().setLabel (EText.MSG_AUTO_COMPLETE_FOR_PASSWORD_EDITS.getDisplayText (aDisplayLocale)) .setCtrl (new HCCheckBox (new RequestFieldBoolean (FIELD_AUTO_COMPLETE_FOR_PASSWORD_EDITS, !HCSettings.isAutoCompleteOffForPasswordEdits ())))); aForm.addFormGroup (new BootstrapFormGroup ().setLabel (EText.MSG_ON_DOCUMENT_READY_PROVIDER.getDisplayText (aDisplayLocale))
/** * @return The global read-only non-<code>null</code> conversion settings with * XML namespaces disabled */ @Nonnull public static HCConversionSettings getConversionSettingsWithoutNamespaces () { // Create a copy!! final HCConversionSettings aCS = getMutableConversionSettings ().getClone (); // And modify the copied XML settings aCS.getXMLWriterSettings ().setEmitNamespaces (false); return aCS; }
/** * Add all global and per-request CSS and JS includes to the HTML page. * * @param aRequestScope * Current request scope. Never <code>null</code>. * @param aHtml * The current HTML object. Never <code>null</code>. */ @OverrideOnDemand protected void addGlobalAndPerRequestCSSAndJS (@Nonnull final IRequestWebScopeWithoutResponse aRequestScope, @Nonnull final HCHtml aHtml) { final boolean bRegular = HCSettings.isUseRegularResources (); final HCHead aHead = aHtml.head (); // Add configured and per-request CSS final ICommonsOrderedSet <ICSSPathProvider> aCSSs = PhotonCSS.getAllRegisteredCSSIncludesForGlobal (); PhotonCSS.getAllRegisteredCSSIncludesForThisRequest (aCSSs); // Add each CSS separately for (final ICSSPathProvider aCSS : aCSSs) aHead.addCSS (PhotonHTMLHelper.getCSSNode (aRequestScope, aCSS, bRegular)); // Add all configured and per-request JS final ICommonsOrderedSet <IJSPathProvider> aJSs = PhotonJS.getAllRegisteredJSIncludesForGlobal (); PhotonJS.getAllRegisteredJSIncludesForThisRequest (aJSs); // Add each JS separately for (final IJSPathProvider aJS : aJSs) aHead.addJS (PhotonHTMLHelper.getJSNode (aRequestScope, aJS, bRegular)); }
public void initHCSettings () { HCSettings.setOnDocumentReadyProvider (new JQueryOnDocumentReadyProvider ()); } }