java.lang.Object
org.nasdanika.html.model.app.gen.Util
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
configureSearch
(String path, org.jsoup.nodes.Document doc, String searchDocumentsPath) Inserts search json and search script tags into the document.static boolean
configureSearch
(String path, org.jsoup.nodes.Document doc, String searchDocumentsPath, Supplier<InputStream> searchScriptSupplier) Inserts search json and search script tags into the document.static Consumer<? super org.jsoup.nodes.Element>
createInspector
(Predicate<String> linkPredicate, Consumer<String> errorConsumer) Creates an inspector consumer which finds and reports broken links, missing images and elements with nsd-error class.static Label
createLabel
(Label source, Label activeAction, BiFunction<Label, URI, URI> uriResolver, Function<Label, String> idProvider, String appearancePath, boolean recursive, boolean inNavPanel, boolean decorate) createRelativeLinkPredicate
(File file, File dir) Creates a predicate checking for links relative to the argument file in the argument directory.static ResourceSet
createResourceSet
(org.nasdanika.common.Context context, org.nasdanika.common.ProgressMonitor progressMonitor) CreatesNcoreResourceSet
withXMIResourceFactoryImpl
,ObjectLoaderResourceFactory
handling yml, json extensions and data scheme.static org.json.JSONObject
createSearchDocument
(String path, File file, Consumer<? super org.jsoup.nodes.Element> contentConsumer, BiFunction<String, org.jsoup.nodes.Document, Boolean> processor, Consumer<Exception> errorConsumer) For Nasdanika App pages extracts page title, breadcrumbs and content text into a JSONObject to add to a collector and then to use for constructing search indices.static org.json.JSONObject
createSearchDocument
(String path, File file, Consumer<Exception> errorConsumer) static String
filterDrawio
(String spec, Consumer<org.nasdanika.drawio.Element> visitor, org.nasdanika.drawio.ConnectionBase connectionBase, Boolean compress) Loads document, traverses all elements and then saves and returns the document.static void
generateContainer
(URI resourceModelURI, org.nasdanika.resources.BinaryEntityContainer container, org.nasdanika.common.Context context, org.nasdanika.common.ProgressMonitor progressMonitor) Generates files (binary entities) from a resource model .static void
generateContainer
(EObject eObj, org.nasdanika.resources.BinaryEntityContainer container, org.nasdanika.common.Context context, org.nasdanika.common.ProgressMonitor progressMonitor) Generates files (binary entities) from a resource model .static void
generateContainer
(Resource containerResource, org.nasdanika.resources.BinaryEntityContainer container, org.nasdanika.common.Context context, org.nasdanika.common.ProgressMonitor progressMonitor) Generates files (binary entities) from a resource model .static void
generateSite
(Label root, Label principal, Label activeAction, List<Label> actionPath, org.nasdanika.html.model.bootstrap.Page pageTemplate, BiFunction<Label, URI, URI> uriResolver, URI baseURI, org.nasdanika.exec.resources.Container container, ActionContentProvider actionContentProvider, PageContentProvider pageContentProvider, org.nasdanika.common.ProgressMonitor progressMonitor) Generates application site from anAction
modelstatic void
generateSite
(Label root, Label principal, Label activeAction, List<Label> actionPath, org.nasdanika.html.model.bootstrap.Page pageTemplate, org.nasdanika.exec.resources.Container container, ActionContentProvider.Factory contentProviderFactory, PageContentProvider.Factory pageProviderFactory, org.nasdanika.common.Context context, org.nasdanika.common.ProgressMonitor progressMonitor) Generates application site from anAction
model using a random base URI and a caching URI resolver created from the argument context with base-uri injected.static void
generateSite
(Label root, org.nasdanika.html.model.bootstrap.Page pageTemplate, org.nasdanika.exec.resources.Container container, ActionContentProvider.Factory actionContentProviderFactory, PageContentProvider.Factory pageContentProviderFactory, org.nasdanika.common.Context context, org.nasdanika.common.ProgressMonitor progressMonitor) Generates application site from anAction
model root.static void
generateSitemapAndSearch
(File dir, String domain, BiPredicate<File, String> siteMapPredicate, com.redfin.sitemapgenerator.ChangeFreq changeFrequency, BiPredicate<File, String> searchPredicate, BiConsumer<String, String> errorConsumer) static org.json.JSONObject
generateSitemapAndSearch
(File dir, String domain, BiPredicate<File, String> siteMapPredicate, com.redfin.sitemapgenerator.ChangeFreq changeFrequency, BiPredicate<File, String> searchPredicate, BiConsumer<String, String> errorConsumer, String searchDocumentsPath) Generates sitemap and search using search.js resource.static org.json.JSONObject
generateSitemapAndSearch
(File dir, String domain, BiPredicate<File, String> siteMapPredicate, com.redfin.sitemapgenerator.ChangeFreq changeFrequency, BiPredicate<File, String> searchPredicate, BiConsumer<String, String> errorConsumer, String searchDocumentsPath, Supplier<InputStream> searchScriptSupplier) static org.json.JSONObject
generateSitemapAndSearch
(File dir, String domain, BiPredicate<File, String> siteMapPredicate, com.redfin.sitemapgenerator.ChangeFreq changeFrequency, BiPredicate<File, String> searchPredicate, BiConsumer<String, String> errorConsumer, BiFunction<String, org.jsoup.nodes.Document, Boolean> searchConfigurator) Generates sitemap and search index for lunrjs by scanning files in a directory.static org.nasdanika.drawio.Document
loadDrawioDocument
(org.jsoup.nodes.Element mxGraphDiv) LoadsmxGraphModel
from mxgraph div.loadSemanticMap
(URI uri, BiFunction<String, String, org.nasdanika.ncore.ModelElement> factory) Loads a semantic map (EObject -> Label) from JSON or YAML resource.loadSemanticMap
(URI uri, ResourceSet resourceSet) Loads a semantic map (EObject -> Label) from JSON or YAML resource.static org.nasdanika.html.Tag
navbar
(org.nasdanika.html.Tag brand, List<Object> items, org.nasdanika.html.bootstrap.Breakpoint expand, boolean dark, org.nasdanika.html.bootstrap.Color background, org.nasdanika.html.bootstrap.BootstrapFactory bootstrapFactory) Creates Bootstrap Navs from a list of items.static org.nasdanika.html.Tag
Creates Bootstrap Navs from a list of items.static void
processHTML
(Util.HTMLProcessor processor, File... files) static void
traverseDrawio
(org.jsoup.nodes.Element mxGraphDiv, Consumer<org.nasdanika.drawio.Element> visitor, org.nasdanika.drawio.ConnectionBase connectionBase)
-
Field Details
-
DATA_NSD_LABEL_UUID_ATTRIBUTE
- See Also:
-
-
Method Details
-
generateSite
public static void generateSite(Label root, org.nasdanika.html.model.bootstrap.Page pageTemplate, org.nasdanika.exec.resources.Container container, ActionContentProvider.Factory actionContentProviderFactory, PageContentProvider.Factory pageContentProviderFactory, org.nasdanika.common.Context context, org.nasdanika.common.ProgressMonitor progressMonitor) Generates application site from anAction
model root.- Parameters:
root
- Root action to generate header and footer. Can be null.pageTemplate
- Page template.context
- Context used for uri resolution - interpolation of action locations and names. can be null.container
- Receiver of generated resources.progressMonitor
- Progress monitor.
-
generateSite
public static void generateSite(Label root, Label principal, Label activeAction, List<Label> actionPath, org.nasdanika.html.model.bootstrap.Page pageTemplate, org.nasdanika.exec.resources.Container container, ActionContentProvider.Factory contentProviderFactory, PageContentProvider.Factory pageProviderFactory, org.nasdanika.common.Context context, org.nasdanika.common.ProgressMonitor progressMonitor) Generates application site from anAction
model using a random base URI and a caching URI resolver created from the argument context with base-uri injected.- Parameters:
root
- Root action to generate header and footer. Can be null.principal
- Principal action to generate navigation bar and navigation panel. Can be null.activeAction
- Active action to generate the content panel if instance of action.actionPath
- Action path to show in breadcrumbs.pageTemplate
- Page template.context
- Context used for uri resolution - interpolation of action locations and names. can be null.container
- Receiver of generated resources.progressMonitor
- Progress monitor.
-
generateSite
public static void generateSite(Label root, Label principal, Label activeAction, List<Label> actionPath, org.nasdanika.html.model.bootstrap.Page pageTemplate, BiFunction<Label, URI, URI> uriResolver, URI baseURI, org.nasdanika.exec.resources.Container container, ActionContentProvider actionContentProvider, PageContentProvider pageContentProvider, org.nasdanika.common.ProgressMonitor progressMonitor) Generates application site from anAction
model- Parameters:
root
- Root action to generate header and footer. Can be null.principal
- Principal action to generate navigation bar and navigation panel. Can be null.activeAction
- Active action to generate the content panel.pageTemplate
- Page template.uriResolver
- ResolvesAction
toURI
.baseURI
- Base URI for resolution, specifically to create relative URI's.container
- Receiver of generated resources.progressMonitor
- Progress monitor.
-
createLabel
public static Label createLabel(Label source, Label activeAction, BiFunction<Label, URI, URI> uriResolver, Function<Label, String> idProvider, String appearancePath, boolean recursive, boolean inNavPanel, boolean decorate) - Parameters:
source
-uri
-active
-appearancePath
-- Returns:
-
createSearchDocument
public static org.json.JSONObject createSearchDocument(String path, File file, Consumer<Exception> errorConsumer) throws IOException - Throws:
IOException
-
createSearchDocument
public static org.json.JSONObject createSearchDocument(String path, File file, Consumer<? super org.jsoup.nodes.Element> contentConsumer, BiFunction<String, org.jsoup.nodes.Document, throws IOExceptionBoolean> processor, Consumer<Exception> errorConsumer) For Nasdanika App pages extracts page title, breadcrumbs and content text into a JSONObject to add to a collector and then to use for constructing search indices.- Parameters:
path
-file
-contentConsumer
- Consumer of content elements which can be used to analyze page contents, e.g. find dead links. Can be null.processor
- If not null the document is passed to the processor. If the processor returns true that means that the document was manipulated by the processor and shall be saved to the source file.- Returns:
- Search document object for non-empty Nasdanika App pages, null otherwise.
- Throws:
IOException
-
loadDrawioDocument
public static org.nasdanika.drawio.Document loadDrawioDocument(org.jsoup.nodes.Element mxGraphDiv) throws ParserConfigurationException, SAXException, IOException LoadsmxGraphModel
from mxgraph div.- Parameters:
mxGraphDiv
-- Returns:
- Throws:
IOException
SAXException
ParserConfigurationException
-
traverseDrawio
public static void traverseDrawio(org.jsoup.nodes.Element mxGraphDiv, Consumer<org.nasdanika.drawio.Element> visitor, org.nasdanika.drawio.ConnectionBase connectionBase) throws ParserConfigurationException, SAXException, IOException -
filterDrawio
public static String filterDrawio(String spec, Consumer<org.nasdanika.drawio.Element> visitor, org.nasdanika.drawio.ConnectionBase connectionBase, Boolean compress) throws ParserConfigurationException, SAXException, IOException, TransformerException Loads document, traverses all elements and then saves and returns the document.- Parameters:
spec
-visitor
-connectionBase
-compress
-- Returns:
- Throws:
IOException
SAXException
ParserConfigurationException
TransformerException
-
createInspector
public static Consumer<? super org.jsoup.nodes.Element> createInspector(Predicate<String> linkPredicate, Consumer<String> errorConsumer) Creates an inspector consumer which finds and reports broken links, missing images and elements with nsd-error class.- Parameters:
file
-path
-siteDir
-errorConsumer
-- Returns:
-
createRelativeLinkPredicate
Creates a predicate checking for links relative to the argument file in the argument directory.- Parameters:
file
- Base filedir
- Directory within which check for relative links- Returns:
-
configureSearch
public static boolean configureSearch(String path, org.jsoup.nodes.Document doc, String searchDocumentsPath, Supplier<InputStream> searchScriptSupplier) Inserts search json and search script tags into the document.- Parameters:
path
-doc
-- Returns:
-
configureSearch
public static boolean configureSearch(String path, org.jsoup.nodes.Document doc, String searchDocumentsPath) Inserts search json and search script tags into the document. Uses search.js resource for the search script.- Parameters:
path
-doc
-- Returns:
-
generateSitemapAndSearch
public static org.json.JSONObject generateSitemapAndSearch(File dir, String domain, BiPredicate<File, String> siteMapPredicate, com.redfin.sitemapgenerator.ChangeFreq changeFrequency, BiPredicate<File, throws IOExceptionString> searchPredicate, BiConsumer<String, String> errorConsumer, BiFunction<String, org.jsoup.nodes.Document, Boolean> searchConfigurator) Generates sitemap and search index for lunrjs by scanning files in a directory.- Parameters:
dir
- Directory to scanbase
- URI prefix for file paths with or without dangling /- Throws:
IOException
-
generateSitemapAndSearch
public static org.json.JSONObject generateSitemapAndSearch(File dir, String domain, BiPredicate<File, String> siteMapPredicate, com.redfin.sitemapgenerator.ChangeFreq changeFrequency, BiPredicate<File, throws IOExceptionString> searchPredicate, BiConsumer<String, String> errorConsumer, String searchDocumentsPath, Supplier<InputStream> searchScriptSupplier) - Throws:
IOException
-
generateSitemapAndSearch
public static org.json.JSONObject generateSitemapAndSearch(File dir, String domain, BiPredicate<File, String> siteMapPredicate, com.redfin.sitemapgenerator.ChangeFreq changeFrequency, BiPredicate<File, throws IOExceptionString> searchPredicate, BiConsumer<String, String> errorConsumer, String searchDocumentsPath) Generates sitemap and search using search.js resource.- Parameters:
dir
-domain
-siteMapPredicate
-changeFrequency
-searchPredicate
-errorConsumer
-searchDocumentsPath
-- Throws:
IOException
-
generateSitemapAndSearch
public static void generateSitemapAndSearch(File dir, String domain, BiPredicate<File, String> siteMapPredicate, com.redfin.sitemapgenerator.ChangeFreq changeFrequency, BiPredicate<File, throws IOExceptionString> searchPredicate, BiConsumer<String, String> errorConsumer) - Throws:
IOException
-
createResourceSet
public static ResourceSet createResourceSet(org.nasdanika.common.Context context, org.nasdanika.common.ProgressMonitor progressMonitor) CreatesNcoreResourceSet
withXMIResourceFactoryImpl
,ObjectLoaderResourceFactory
handling yml, json extensions and data scheme.NcoreDrawioResourceFactory
for drawio extension. UsesGitMarkerFactory
forEObjectLoader
. RegistersAppAdapterFactory
. Registers Ncore, Exec, and HTML packages.- Parameters:
progressMonitor
-- Returns:
-
generateContainer
public static void generateContainer(URI resourceModelURI, org.nasdanika.resources.BinaryEntityContainer container, org.nasdanika.common.Context context, org.nasdanika.common.ProgressMonitor progressMonitor) throws DiagnosticException Generates files (binary entities) from a resource model .- Throws:
DiagnosticException
Exception
-
generateContainer
public static void generateContainer(Resource containerResource, org.nasdanika.resources.BinaryEntityContainer container, org.nasdanika.common.Context context, org.nasdanika.common.ProgressMonitor progressMonitor) throws DiagnosticException Generates files (binary entities) from a resource model .- Throws:
DiagnosticException
Exception
-
generateContainer
public static void generateContainer(EObject eObj, org.nasdanika.resources.BinaryEntityContainer container, org.nasdanika.common.Context context, org.nasdanika.common.ProgressMonitor progressMonitor) throws DiagnosticException Generates files (binary entities) from a resource model .- Throws:
DiagnosticException
Exception
-
loadSemanticMap
public static Map<org.nasdanika.ncore.ModelElement,Label> loadSemanticMap(URI uri, BiFunction<String, String, throws IOExceptionorg.nasdanika.ncore.ModelElement> factory) Loads a semantic map (EObject -> Label) from JSON or YAML resource. The resource is considered to by YAML if its URI ends with .yml or .yaml case insensitive.- Parameters:
uri
- Semantic map URI. Link locations in the map are resolved relative to this URI.factory
- Factory for creating keyEObject
s if map entries havetype
key. Keys must implementModelElement
so URI's can be injected into them.- Returns:
- Throws:
IOException
-
loadSemanticMap
public static Map<org.nasdanika.ncore.ModelElement,Label> loadSemanticMap(URI uri, ResourceSet resourceSet) throws IOException Loads a semantic map (EObject -> Label) from JSON or YAML resource. The resource is considered to by YAML if its URI ends with .yml or .yaml case insensitive.- Parameters:
uri
- Semantic map URI. Link locations in the map are resolved relative to this URI.resouceSet
- Resource set to use the package registry to create semantic elements.- Returns:
- Throws:
IOException
-
processHTML