Class: Outputs

Configurator. Outputs


new Outputs(configurator)

Provide an object to manipulate the outputs of the ADC (config.xml > outputs)

 const ADX = require('adxutil').ADX;

 const myAdx = new ADC('path/to/adx/');
 myAdx.load(function (err) {
     if (err) {
         throw err;
     }

     // Get the instance of the Outputs
     const outputs = myAdx.configurator.outputs;

     console.log(outputs.get());

 });
Parameters:
Name Type Description
configurator ADX.Configurator

Instance of the configurator

Members


configurator :Configurator

Parent configurator

Type:

Methods


defaultOutput( [data])

Get or set the default ADX output

  // Get the id default output
  adxOutputs.defaultOutput();

  // Set the default output id
  adxOutputs.defaultOutput("without_javascript");
Parameters:
Name Type Argument Description
data String <optional>

Id of the default output to set

Returns:

Id of the default output

Type
String

get()

Get outputs as an object

  // Get the outputs object
  adxOutputs.get();
  // {
  //   defaultOutput  : "main",
  //   outputs : [{
  //      id : 'main',
  //      description : "Description of the output"
  //      condition : "Condition of the output",
  //      contents  : [{
  //         fileName : "default.html",
  //         type     : "html",
  //         mode     : "dynamic",
  //         position : "placeholder"
  //      }]
  //   }]
Returns:
Type
Object

set(data)

Set the outputs using a plain object

  // Get the outputs object
  adxOutputs.set({
     defaultOutput : "main",
     outputs : [
        {
            id : "main",
            description : "Main output",
             contents : [
                  {
                     fileName : 'main.css',
                     type : 'css',
                     mode : 'static',
                     position : 'head'
                 },
                 {
                     fileName : 'main.html',
                     type : 'html',
                     mode : 'dynamic',
                     position : 'placeholder'
                 },
                 {
                     fileName : 'main.js',
                     type : 'javascript',
                     mode : 'static',
                     position: 'foot'
                 }
             ]
         },
         {
             id : "second",
             description : "Second output",
             condition : "Browser.Support(\"javascript\")",
             contents : [
                 {
                     fileName : 'second.css',
                     type : 'css',
                     mode : 'static',
                     position : 'head'
                 },
                 {
                     fileName : 'second.html',
                     type : 'html',
                     mode : 'dynamic',
                     position : 'placeholder'
                 },
                 {
                     fileName : 'second.js',
                     type : 'javascript',
                     mode : 'static',
                     position : 'foot'
                 }
             ]
         },
         {
             id : "third",
             description : "Third output",
             maxIterations : 12,
             defaultGeneration : false,
             contents : [
                 {
                     fileName : "third.css",
                     type  : "css",
                     mode : "static",
                     position : "head",
                     attributes : [
                         {
                             name : "rel",
                             value : "alternate"
                         },
                         {
                             name : "media",
                             value : "print"
                         }
                     ]
                 },
                 {
                     fileName : 'HTML5Shim.js',
                     type : 'javascript',
                     mode : 'static',
                     position : 'head',
                     yieldValue : '<!--[if lte IE 9]><script type="text/javascript"  src="{%= CurrentADC.URLTo("static/HTML5Shim.js") %}" ></script><![endif]-->'
                 }
             ]
        }

  });
Parameters:
Name Type Description
data Object

Data to set

Properties
Name Type Argument Description
defaultOutput String <optional>

Id of the default output

outputs Array.<Object> <optional>

Outputs

Properties
Name Type Argument Description
id String <optional>

Id of the output

masterPage String <optional>

Master page to use for the ADP output

description String <optional>

Description of the output

condition String <optional>

AskiaScript condition to use the output

contents Array.<Object> <optional>

List of contents (files) used by the output

Properties
Name Type Argument Description
fileName String <optional>

Name of the file

type String | "text" | "html" | "css" | "javascript" | "binary" | "image" | "audio" | "video" | "flash" <optional>

Name of the file

mode String | "dynamic" | "static" | "share" <optional>

Extract mode

position String | "none" | "head" | "placeholder" | "foot" <optional>

Position in the final page document

attributes Array.<Object> <optional>

List of HTML attributes

Properties
Name Type Argument Description
name String <optional>

Name of the HTML attribute

value String <optional>

Value of the HTML attribute

yieldValue String <optional>

Yield value, used to override the auto-generation


toXml()

Return the outputs as xml string

  // Serialize the outputs to XML
  adxOutputs.toXml();
  // -> <outputs defaultOutput="main"><output id="main"> ...</outputs>
Returns:
Type
String