Skip to content

Commit

Permalink
put formatters/transmitters info into publish doc
Browse files Browse the repository at this point in the history
  • Loading branch information
petrjasek committed Oct 4, 2016
1 parent a8ca0f3 commit 917ca92
Show file tree
Hide file tree
Showing 25 changed files with 150 additions and 192 deletions.
1 change: 0 additions & 1 deletion apps/publish/formatters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
# AUTHORS and LICENSE files distributed with this source code, or
# at https://www.sourcefabric.org/superdesk/license

import apps.publish.formatters.newsml_g2_formatter # NOQA
from superdesk import get_backend
from apps.publish.formatters.service import FormattersService
from apps.publish.formatters.resource import FormattersResource
Expand Down
5 changes: 0 additions & 5 deletions docs/formatters/email.rst

This file was deleted.

5 changes: 0 additions & 5 deletions docs/formatters/newsml.rst

This file was deleted.

5 changes: 0 additions & 5 deletions docs/formatters/newsmlg2.rst

This file was deleted.

20 changes: 0 additions & 20 deletions docs/formatters/ninjs.rst

This file was deleted.

5 changes: 0 additions & 5 deletions docs/formatters/nitf.rst

This file was deleted.

41 changes: 25 additions & 16 deletions docs/publish.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,22 @@ Enqueueing is done via:

There it finds all subscribers that should recieve the item and if any it will format the item and queue transmission.

Supported output formats are:
Output Formats
--------------

.. toctree::
:maxdepth: 1
.. module:: superdesk.publish.formatters

formatters/ninjs
formatters/nitf
formatters/newsml
formatters/newsmlg2
formatters/email
.. autoclass:: NINJSFormatter

Superdesk NINJS Schema in :download:`JSON <superdesk-ninjs-schema.json>`.

.. autoclass:: NITFFormatter

.. autoclass:: NewsML12Formatter

.. autoclass:: NewsMLG2Formatter

.. autoclass:: EmailFormatter

Transmission
------------
Expand All @@ -99,13 +104,17 @@ Last task is to send items to subscribers, that's handled via another async task

This task runs every 10s.

There are different means of transport:
Content Transmitters
--------------------

.. module:: superdesk.publish.transmitters

.. autoclass:: HTTPPushService

.. autoclass:: FTPPublishService

.. autoclass:: FilePublishService

.. toctree::
:maxdepth: 1
.. autoclass:: EmailPublishService

transmitters/http-push
transmitters/ftp
transmitters/file
transmitters/email
transmitters/odbc
.. autoclass:: ODBCPublishService
4 changes: 0 additions & 4 deletions docs/transmitters/email.rst

This file was deleted.

5 changes: 0 additions & 5 deletions docs/transmitters/file.rst

This file was deleted.

7 changes: 0 additions & 7 deletions docs/transmitters/ftp.rst

This file was deleted.

44 changes: 0 additions & 44 deletions docs/transmitters/http-push.rst

This file was deleted.

5 changes: 0 additions & 5 deletions docs/transmitters/odbc.rst

This file was deleted.

9 changes: 5 additions & 4 deletions superdesk/publish/formatters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ def get_all_formatters():
return formatters


import superdesk.publish.formatters.nitf_formatter # NOQA
import superdesk.publish.formatters.ninjs_formatter # NOQA
import superdesk.publish.formatters.newsml_1_2_formatter # NOQA
import superdesk.publish.formatters.email_formatter # NOQA
from .nitf_formatter import NITFFormatter # NOQA
from .ninjs_formatter import NINJSFormatter # NOQA
from .newsml_1_2_formatter import NewsML12Formatter # NOQA
from .newsml_g2_formatter import NewsMLG2Formatter # NOQA
from .email_formatter import EmailFormatter # NOQA
42 changes: 21 additions & 21 deletions superdesk/publish/formatters/email_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,6 @@
# AUTHORS and LICENSE files distributed with this source code, or
# at https://www.sourcefabric.org/superdesk/license

"""Superdesk Email formatter.
- Does not support any media output, it's for text items only.
It uses templates to render items, those can be overriden to customize the output:
- ``email_article_subject.txt``
email subject
- ``email_article_body.txt``
email text content
- ``email_article_body.html``
email html content
It gets ``article`` with item data, can be used in templates like::
<strong>{{ article.headline }}</strong>
"""

from superdesk.publish.formatters import Formatter
from superdesk.metadata.item import ITEM_TYPE, CONTENT_TYPE, FORMAT, FORMATS
from flask import render_template
Expand All @@ -40,6 +19,27 @@


class EmailFormatter(Formatter):
"""Superdesk Email formatter.
- Does not support any media output, it's for text items only.
It uses templates to render items, those can be overriden to customize the output:
- ``email_article_subject.txt``
email subject
- ``email_article_body.txt``
email text content
- ``email_article_body.html``
email html content
It gets ``article`` with item data, can be used in templates like::
<strong>{{ article.headline }}</strong>
"""

def format(self, article, subscriber, codes=None):
formatted_article = deepcopy(article)
pub_seq_num = superdesk.get_resource_service('subscribers').generate_sequence_number(subscriber)
Expand Down
4 changes: 0 additions & 4 deletions superdesk/publish/formatters/newsml_1_2_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
# AUTHORS and LICENSE files distributed with this source code, or
# at https://www.sourcefabric.org/superdesk/license

"""NewsML 1.2 Superdesk Formatter
"""

import time
import logging
import xml.etree.ElementTree as etree
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,21 @@

"""NewsML G2 Superdesk formatter"""

import superdesk
import xml.etree.ElementTree as etree
from xml.etree.ElementTree import SubElement

from bs4 import BeautifulSoup
from xml.etree.ElementTree import SubElement
from flask import current_app as app

from superdesk.publish.formatters import Formatter
from superdesk.metadata.item import ITEM_TYPE, CONTENT_TYPE, EMBARGO, FORMATS, FORMAT
from superdesk.utc import utcnow
import superdesk
from superdesk.errors import FormatterError
from superdesk.publish.formatters.nitf_formatter import NITFFormatter
from apps.archive.common import ARCHIVE, get_utc_schedule
from superdesk.metadata.packages import PACKAGE_TYPE, REFS, RESIDREF, ROLE, GROUPS, GROUP_ID, ID_REF
from bs4 import BeautifulSoup
from superdesk.filemeta import get_filemeta
from apps.archive.common import ARCHIVE, get_utc_schedule


def get_newsml_provider_id():
Expand Down
16 changes: 15 additions & 1 deletion superdesk/publish/formatters/ninjs_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,21 @@ def format_cv_item(item):

class NINJSFormatter(Formatter):
"""
NINJS Formatter
The schema we use for the ninjs format is an extension
of `the standard ninjs schema <http://www.iptc.org/std/ninjs/ninjs-schema_1.1.json>`_.
*Changes from ninjs schema*:
* ``uri`` was replaced by ``guid``: ``uri`` should be the resource identifier on the web
but since the item was not published yet it can't be determined at this point
* added ``priority`` field
* added ``service`` field
* added ``slugline`` field
* added ``keywords`` field
Associations dictionary may contain entire items like
in `ninjs example <http://dev.iptc.org/ninjs-Examples-3>`_ or just the item ``guid``
and ``type``. In the latest case the items are sent separately before the package item.
"""

direct_copy_properties = ('versioncreated', 'usageterms', 'language', 'headline', 'copyrightnotice',
Expand Down
10 changes: 3 additions & 7 deletions superdesk/publish/formatters/nitf_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@
# AUTHORS and LICENSE files distributed with this source code, or
# at https://www.sourcefabric.org/superdesk/license

"""NITF Formatter for Superdesk
Format items to `NITF <https://iptc.org/standards/nitf/>`_ version *3.6*.
"""

import xml.etree.ElementTree as etree
from xml.etree.ElementTree import SubElement
from flask import current_app as app
Expand All @@ -25,8 +20,9 @@


class NITFFormatter(Formatter):
"""
NITF Formatter
"""NITF Formatter for Superdesk
Format items to `NITF <https://iptc.org/standards/nitf/>`_ version *3.6*.
"""

XML_ROOT = '<?xml version="1.0"?>'
Expand Down
10 changes: 5 additions & 5 deletions superdesk/publish/transmitters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
# AUTHORS and LICENSE files distributed with this source code, or
# at https://www.sourcefabric.org/superdesk/license

import superdesk.publish.transmitters.ftp # NOQA
import superdesk.publish.transmitters.email # NOQA
import superdesk.publish.transmitters.odbc # NOQA
import superdesk.publish.transmitters.file_output # NOQA
import superdesk.publish.transmitters.http_push # NOQA
from .ftp import FTPPublishService # NOQA
from .email import EmailPublishService # NOQA
from .odbc import ODBCPublishService # NOQA
from .file_output import FilePublishService # NOQA
from .http_push import HTTPPushService # NOQA
12 changes: 6 additions & 6 deletions superdesk/publish/transmitters/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@
# AUTHORS and LICENSE files distributed with this source code, or
# at https://www.sourcefabric.org/superdesk/license

"""Superdesk Email transmitter.
Works only with :doc:`../formatters/email` formatter.
"""

from superdesk.emails import send_email
from flask import current_app as app
from superdesk.publish import register_transmitter
Expand All @@ -23,7 +18,12 @@


class EmailPublishService(PublishService):
"""Email Publish Service."""
"""Email Transmitter
Works only with email formatter.
:param recipients: email addresses separated by ``;``
"""

def _transmit(self, queue_item, subscriber):
config = queue_item.get('destination', {}).get('config', {})
Expand Down
10 changes: 5 additions & 5 deletions superdesk/publish/transmitters/file_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@
# AUTHORS and LICENSE files distributed with this source code, or
# at https://www.sourcefabric.org/superdesk/license

"""Superdesk file transmitter.
It creates files on superdesk server in configured folder.
"""

from superdesk.publish.publish_service import PublishService
from superdesk.publish import register_transmitter
from superdesk.errors import PublishFileError
Expand All @@ -22,6 +17,11 @@


class FilePublishService(PublishService):
"""Superdesk file transmitter.
It creates files on superdesk server in configured folder.
"""

def _transmit(self, queue_item, subscriber):
try:
config = queue_item['destination']['config']
Expand Down

0 comments on commit 917ca92

Please sign in to comment.