Marfeel uses PhantomJS to extract a publisher's items for the section mosaic. As it does this, Marfeel detects metadata and stores this information in the DOM inside a script.
To avoid reparsing the DOM, Marfeel doesn't make direct calls to the script tag and defines another way of getting metadata from the DOM.
Specifically, when Marfeel loads a customer's page, PhantomJS identifies and extracts all the articles first. Then the metadata is scanned to detect any active metadata.
In Marfeel Touch, the definition.json includes the metadataProviders flag that contains all the active metadata providers in an array. The file must have the same name as the metadataProvider in order to be detected and replicated with the same logic:
If a file has a different name to what is indicated in the metadataProviders in definition.json, this is detailed in the error code 12 of the PhantomJS exit codes. That is, a metadataProvider error is produced because something unsupported was identified.
Marfeel matches all the detected metadata from a publisher's section mosaic to the ones in Marfeel Touch in an array.
The following example indicates metadata being matched from a RegExp:
Marfeel searches all the scripts in a website to detect and match metadata after the article details have been identified and extracted. The scripts are loaded not for performance, but for the specific function of having their information inspected. Once the information is scanned, this information is sent to the sections mosaic.
Detecting and extracting metadata from the window object
More complex usage with custom matcher function and toString
|String className||Class name for metadata tag|
|String type||Type of metadata|
|Function | RegExp matcher||Matcher for the metadata. Will execute for each script tag.|
|Function toString||Converts data to JSON stringm|
|Boolean detailsOnly||Default false, if true ignore this provider|