api.article

Basic article handling that enables functionality as clearing and creating new copies of a newsitem article

article.clear(disableWarning)

Clear the article and create a new based on the configured base template.

Param Type Description
disableWarning boolean Optional, default false. If true, the article will be cleared without warning

article.copy(name)

Attempt to execute copy hooks if at least one exists, then create a new, unsaved, article based on the current article.

Param Type Description
name string Name or identifier of caller

article.setPubStatus(data)

Sets the publication status for this document. The value is one of what is defined in the NewsML G2 standard: https://www.iptc.org/std/NewsML-G2/latest/QuickStart-NewsML-G2-ItemBasics under the Publication Status section, together with custom extension in the format [customExtensionPrefix]:[customValue], such as imext:draft

Param Type Description
data object The change specification
data.change string The value to be set in pubStatus. Expected value is in the form "stat:usable"
[data.eventType] string Type of event to be sent when data has changed. default "document:changed"

Example

import {api} from 'writer'

api.Article.setPubStatus({
     'change': 'stat:withheld'
  });

<itemMeta>
  <pubStatus qcode="stat:withheld"/>
</itemMeta>

article.addService(data)

Adds a service to the itemMeta section of the article. The service tag concists of a mandatory 'qcode' value and an optional 'why' attribute with extra information.

Param Type Description
data object The change specification
data.change string The change specification
data.change.qcode string The value to be set in the qcode for the service. Expected value is in the form "xxx:yyy"
data.change.why string Optional parameter for the 'why' attribute for service.
[data.eventType] string Type of event to be sent when data has changed. default "document:changed"

Example

import {api} from 'writer'

api.article.addService({
    change: {
     qcode: "imchn:abc",
     why: "imext:main"
   }
});


<contentMeta>
    <service qcode="imchn:abc" why="imext:main"/>
</contentMeta>

article.removeService(data)

Removes a service from the itemMeta section of the article.

Param Type Description
data object The change specification
data.change string The qcode value matching the service to be removed. If there is no match, no event is sent.
[data.eventType] string Type of event to be sent when data has changed. default "document:changed"

Example

import {api} from 'writer'

api.article.removeService({
    change: "imchn:abc"
});

article.setPubStart(data)

Sets the publish start time, using ISO_8601 standard. If value is null, pubStart will be unset.

Param Type Description
data object The change specification
data.change string The time, in ISO_8601
[data.eventType] string Type of event to send when data has changed. Default Event.DOCUMENT_CHANGED

Example

import {api} from 'writer'

api.article.setPubStart({
     'change': '2018-04-21T00:00:00+02:00'
  });
<itemMeta>
  <itemMetaExtProperty type="imext:pubstart" value="2018-04-21T00:00:00+02:00"/>
</itemMeta>

article.setPubStop(data)

Sets the publish stop time, using ISO_8601 standard.

Param Type Description
data object The change specification
data.change string The time, in ISO_8601
[data.eventType] string Type of event to send when data has changed. Default Event.DOCUMENT_CHANGED

Example

import {api} from 'writer'

api.article.setPubStop({
     'change': '2018-04-21T00:00:00+02:00'
  });
<itemMeta>
  <itemMetaExtProperty type="imext:pubstop" value="2018-04-21T00:00:00+02:00"/>
</itemMeta>

article.setTitle(data)

Sets the value of the title.

Param Type Description
data object The change specification
data.change string Value of the title to set. Must not be null or undefined
[data.eventType] object Type of event to be sent when data has changed. Default Event.DOCUMENT_CHANGED

Example

import {api} from 'writer'

api.article.setTitle({
     "change": "Document title"
  });
<itemMeta>
  <title>Document title</title>
</itemMeta>

article.setEdNote(data)

Sets the value of editor note

Param Type Description
data object The change specification
data.change string The text value of editor note. If null or empty, the element will be removed from document.
[data.eventType] object Type of event to be sent when data has changed. Default Event.DOCUMENT_CHANGED

Example

import {api} from 'writer'

api.article.setEdNote({
     "change": "Instructions to editor"
  });
<itemMeta>
  <edNote>Instructions to editor</edNote>
</itemMeta>

article.setItemMetaExtProperty(data)

Sets the value of a property. If value is null, the property will be removed. The type of property to change is specified by the type argument.

The type is defined by the [customPrefix]:[type] syntax, such as imext:url

Param Type Description
data object The change specification
data.change object Specification of the property to set.
data.change.type string The identification of the property
data.change.value string The value of the property. If null, the property will be removed.
[data.eventType] object Type of event to be sent when data has changed. Default Event.DOCUMENT_CHANGED

Example

import {api} from 'writer'

api.article.setItemMetaExtProperty({
     "change": {
         type: "imext:haspublishedversion",
         value: "true"
     }
  });
<itemMeta>
  <itemMetaExtProperty type="imext:haspublishedversion" value="true"/>
</itemMeta>

article.addItemMetaLink(data)

Adds a link to the itemMeta section of the article.

Param Type Description
data object The change specification
data.change object Specifies the link to be created.
data.change.rel string The 'rel' attribute of the link. Example: "author". This parameter is mandatory and must be defined. Must not contain spaces
data.change.type string The 'type' attribute of the link. Example: "x-im/person". This parameter is mandatory and must be defined.
data.change.uri string The 'uri' pointing to an external resource. This OR the 'uuid' parameter must be present.
data.change.uuid string The 'uuid', which is an ID of a resource in the writer repository. This OR the 'uri' parameter must be present.
data.change.data string An optional data block with custom tags.
data.change.links array Optional links for the link to be created. Should be of the same format as the top-most link.
[data.eventType] string The type of event to be sent when data has changed. Default Event.DOCUMENT_CHANGED

Example

import {api} from 'writer'

api.article.addItemMetaLink({
     change: {
         rel: "subject",
         title: "Mora",
         type: "x-im/category",
         uuid: "7b8461e8-4a22-11e8-aa12-b79c05b8e6d5",
         links: [
             {
                 rel: "broader",
                 title: "Dalarna",
                 uuid: "03d22994-91e4-11e5-8994-feff819cdc9f",
                 type: "x-im/category",
                 data: {
                     "placement": {
                         attributes: {
                             "type": "position"
                         },
                         value: "left"
                     }
                 }
             }
         ]
     }
  });

<itemMeta>
  <links>
      <link rel="subject" title="Mora" type="x-im/category" uuid="7b8461e8-4a22-11e8-aa12-b79c05b8e6d5">
          <links>
              <link rel="broader" title="Dalarna" uuid="03d22994-91e4-11e5-8994-feff819cdc9f" type="x-im/category">
                  <data>
                      <placement type="position>left</placement>
                  </data>
          </links>
      </link>
  </links>
</itemMeta>

article.removeItemMetaLink(data)

Removes a link from itemMeta section

Param Type Description
data object The change specification
data.change object The link to remove
data.rel string The rel attribute of the link
data.uri string The URI that identifies the link, OR
data.uuid string The uuid that identifies the link.
[data.eventType] string The type of event to be sent when data has changed. Default Event.DOCUMENT_CHANGED

Example

import {api} from 'writer'

api.article.removeItemMetaLink({
     change: {
         rel: 'subject',
         uuid: '320938f8-db94-11e5-b5d2-0a1d41d68578'
     }
  });

article.setAltId(data)

Sets the alternative ID for the article. If null, the element will be removed.

Param Type Description
data object The change specification
data.change string The new ID to set
[data.eventType] string The type of event to be sent when data has changed. Default Event.DOCUMENT_CHANGED

Example

import {api} from 'writer'

api.article.setAltId({
     "change": "854575"
  });

<contentMeta>
  <altId>854575</altId>
</contentMeta>

article.setSlugline(data)

Sets the slugline for the article. If null, the element will be removed.

Param Type Description
data object The change specification
data.change string The new slugline
[data.eventType] string The type of event to be sent when data has changed. Default Event.DOCUMENT_CHANGED

Example

import {api} from 'writer'

api.article.setSlugline({
     "change": "This article is all about"
  });

<contentMeta>
  <slugline>This article is all about</slugline>
</contentMeta>

article.setDescription(data)

Sets the description of the article. If null, the element will be removed.

Param Type Description
data object The change specification
data.change string The new description
[data.eventType] string The type of event to be sent when data has changed. Default Event.DOCUMENT_CHANGED

Example

import {api} from 'writer'

api.article.setDescription({
     "change": "Description of the article"
  });

<contentMeta>
  <description>Description of the article</description>
</contentMeta>

article.setLanguage(data)

Sets the language for the article. If null, the element will be removed.

Param Type Description
data object The change specification
data.change string The language to set
[data.eventType] string The type of event to be sent when data has changed. Default Event.DOCUMENT_CHANGED

Example

import {api} from 'writer'

api.article.setLanguage({
     "change": "en"
  });

<contentMeta>
  <language tag="en"/>
</contentMeta>

article.setIdfLanguage(data)

Sets the language in the idf section of the document. See https://www.w3.org/2005/05/font-size-test/starhtml-test.html for valid language codes.

Param Type Description
data object The change specification
data.change string The specification of language and optional direction
data.change.lang string The language specification, as specified in the link above.
data.change.dir string The text direction
[data.eventType] string The type of event to be sent when data has changed. Default Event.DOCUMENT_CHANGED

article.setBy(data)

Sets the byline for the article. If null, the element will be removed.

Param Type Description
data object The change specification
data.change string The new byline
[data.eventType] string The type of event to be sent when data has changed. Default Event.DOCUMENT_CHANGED

Example

import {api} from 'writer'

api.article.setBy({
     "change": "Boris Byline"
  });

<contentMeta>
  <by>Boris Byline</by>
</contentMeta>

article.setHeadline(data)

Sets the headline of the article. If null, the element will be removed.

Param Type Description
data object The change specification
data.change string The new headline
[data.eventType] string The type of event to be sent when data has changed. Default Event.DOCUMENT_CHANGED

Example

import {api} from 'writer'

api.article.setHeadline({
     "change": "Article headline"
  });

<contentMeta>
  <headline>Article headline</headline>
</contentMeta>

article.addContentMetaLink(data)

Adds a link to the contentMeta section of the article.

Param Type Description
data object The change specification
data.change object Specifies the link to be created.
data.change.rel string The 'rel' attribute of the link. Example: "author". This parameter is mandatory and must be defined.
data.change.type string The 'type' attribute of the link. Example: "x-im/person". This parameter is mandatory and must be defined.
data.change.uri string The 'uri' pointing to an external resource. This OR the 'uuid' parameter must be present.
data.change.uuid string The 'uuid', which is an ID of a resource in the writer repository. This OR the 'uri' parameter must be present.
data.change.data string An optional data block with custom tags.
data.change.links array Optional links for the link to be created. Should be of the same format as the top-most link.
[data.eventType] string The type of event to be sent when data has changed. Default Event.DOCUMENT_CHANGED

Example

import {api} from 'writer'

api.article.addContentMetaLink({
  change: {
    rel: "articlesource",
    title: "Online",
    type: "x-im/articlesource",
    uri: "im://articlesource/online"
  }
});

<contentMeta>
    <links>
        <link rel="articlesource" title="Online" type="x-im/articlesource" uri="im://articlesource/online"/>
    </links>
</contentMeta>

article.removeContentMetaLink(data)

Removes a link from contentMeta section

Param Type Description
data object The change specification
data.change object The link to remove
data.rel string The rel attribute of the link
data.uri string The URI that identifies the link, OR
data.uuid string The uuid that identifies the link.
[data.eventType] string The type of event to be sent when data has changed. Default Event.DOCUMENT_CHANGED

Example

import {api} from 'writer'

api.article.removeContentMetaLink({
     change: {
         rel: 'subject',
         uuid: '320938f8-db94-11e5-b5d2-0a1d41d68578'
     }
  });

article.addContentMetadata(data)

Adds an object element to the metadata section in contentMeta

Param Type Description
data object The change specification
data.change object The specification of the object tag to add
data.change.id string A mandatory id of the object
data.change.type string A mandatory type of object
data.change.title string A an optional title of the object
data.change.data object Optional data element, with custom tags.
data.change.links array Optional array with link elements. The link follows the same format as with #addContentMetaLink
[data.eventType] string The type of event to be sent when data has changed. Default Event.DOCUMENT_CHANGED

Example

import {api} from 'writer'

api.article.addContentMetadata({
    change: {
        id: "8400c74d667e",
        type: "x-im/teaser",
        title: "Sed sit amet turpis a purus fringilla",
        data: {
            subject: "In sodales lectus vel egestas rhoncus",
            text: "Duis eget magna lacus. In sodales lectus vel egestas rhoncus."
        }
        links: [
            {
                rel: "image",
                type: "x-im/image",
                uri: "im://image/znX8U1CU124n26zu7gb40_jBzSk.jpeg",
                uuid: "c382c937-8511-5d48-9677-55658c2bbb32",
                data: {
                    width: "1536",
                    height: "1024"
                }
            }
        ]
    }
})

<contentMeta>
    <metadata>
        <object id="8400c74d667e" type="x-im/teaser" title="Sed sit amet turpis a purus fringilla">
           <data>
               <subject>In sodales lectus vel egestas rhoncus</subject>
               <text>Duis eget magna lacus. In sodales lectus vel egestas rhoncus.</text>
           </data>
           <links>
               <link rel="image"
                         type="x-im/image"
                         uri="im://image/znX8U1CU124n26zu7gb40_jBzSk.jpeg"
                         uuid="c382c937-8511-5d48-9677-55658c2bbb32">
                   <data>
                       <width>1536</width>
                       <height>1024</height>
                   </data>
               </link>
           </links>
        </object>
    </metadata>
</contentMeta>

article.removeContentMetadata(data)

Removes an object in the contentMeta metadata section of the article.

Param Type Description
data object The change specification
data.change object The specification of the object tag to remove
data.change.id string The ID for the tag to remove. This argument is required
[data.eventType] string The type of event to be sent when data has changed. Default Event.DOCUMENT_CHANGED

Example

import {api} from 'writer'

api.article.removeContentMetadata({
     change: {
         id: 'A8567B335'
     }
  });

article.itemMeta(path) ⇒ DocumentNode

Returns the itemMeta node

Returns: DocumentNode - A node instance
Throws:

  • Error when node does not exist
Param Description
path Optional path to find node under itemMeta

article.contentMeta(path) ⇒ DocumentNode

Returns the contentMeta node

Returns: DocumentNode - A node instance
Throws:

  • Error when node does not exist
Param Description
path Optional path to find node under contentMeta

results matching ""

    No results matching ""