Skip to content
This repository was archived by the owner on Feb 13, 2024. It is now read-only.

Import formats

Peter Rudolfsen edited this page Feb 20, 2015 · 15 revisions

Description

Each import source in LayoutPreview supports three different URLs:

  • To fetch a specific article
  • To list available articles
  • Optionally to fetch articles for a specific user/author (typically the user currently logged in)

Examples

{username} will be replaced by the username of the user logged in.
{articleId} will be replaced by the ID of the article being imported.

List import format

Content from the list and author URLs must adhere to the structure below.

The fields created and modified follows either the RFC 2822 or ISO-8601 date and time standard.

Example format for GMT:

  • RFC 2822: Mon, 25 Feb 2013 23:59:14 +0000
  • ISO-8601: 2013-02-25T23:59:14+00:00 or 2013-02-25T23:59:14Z
[
    {
        "contents": {
            "title": "The Company Inc about to launch new mobile app"
        },
        "meta": {
            "id": "10000001",
            "created": "Mon, 25 Feb 2013 23:59:14 +0100",
            "modified": "Wed, 27 Feb 2013 10:03:59 +0100"
        }
    },
    {
        "contents": {
            "title": "Chairman at Company Inc: - Mobile publication is the future!"
        },
        "meta": {
            "id": "10000002",
            "created": "Sun, 24 Feb 2013 21:05:50 +0100",
            "modified": "Wed, 27 Feb 2013 10:00:53 +0100"
        }
    }
    // etc
]

Article import format

The basic structure

{
    // In the `contents` object you can send any data you'd like.
    // Everything here will be indexed and available through the DrMobile API
    // The only required field is `source` which contains the HTML of the article (used by [ALF](https://github.com/aptoma/drmobile-integration/wiki/Glossary))
    "contents": {
        "source": "<article>....</article>",
        "title": "...",
        "excerpt": "...",
        "body": "..."
    },
    // This behaves just like `contents`. Send any data here to have it indexed and availble through the API
    // The only required field is `id`.
    "meta": {
        "id": "12738914789",
        "category": "..."
    }
}

ALF HTML

This is an example of the article HTML that needs to be present in contents.source. For the sake of this example, we've only included parts of this article.

<article class="template-article-default section-featured" data-map="article article-type-default">
    <figure>
        <span data-map="section">Featured</span>
    </figure>
    <figure>
        <header data-map="title">
            <h1>The Meaning Of Sunrise</h1> </header>
    </figure>
    <figure>
        <header data-map="excerpt">
            <p>Sunrise or sun up is the instant at which the upper edge of the sun appears on the horizon in the morning.</p>
        </header>
    </figure>
    <figure>
        <div data-map="byline">Av Peter Rudolfsen</div>
    </figure>
    <figure>
        <div class="media-element" data-map="4x3-large">
            <img width="1024" height="767" data-src="http://drp-dev.aptoma.no/out/images/article/2014/01/17/20541166/1/box-1024x768/169792.jpg" data-src-2x="http://drp-dev.aptoma.no/out/images/article/2014/01/17/20541166/1/box-2048x1536/169792.jpg">
            <div class="alf-is-removable overlay overlay-bottom overlay-caption">
                <p>Get up before sunrise and wear warm clothes, especially if you are not usually the one who gets up early in the morning.</p>
            </div>
        </div>
        <div class="media-element" data-map="4x3-small">
            <img width="460" height="345" data-src="http://drp-dev.aptoma.no/out/images/article/2014/01/17/20541166/1/box-460x748/169792.jpg" data-src-2x="http://drp-dev.aptoma.no/out/images/article/2014/01/17/20541166/1/box-920x1496/169792.jpg" />
            <div class="alf-is-removable overlay overlay-bottom overlay-caption">
                <p>Get up before sunrise and wear warm clothes, especially if you are not usually the one who gets up early in the morning.</p>
            </div>
        </div>
    </figure>
    <p>
        <a href="https://www.flickr.com/search/?q=sunrise">Sunrise indicates a new beginning</a>, a fresh start. It is something to admire and has inspired many. The sunrise brings brightness into life and inspires people to start the day with energy and intensity. It gives us immense pleasure and joy. Whenever you come across a scenic, beautiful sunrise you cannot suppress a heavy sigh of happiness. The beauty of nature overshadows any sorrows, awakening nothing but cheerful thoughts. Nature, in the form of the sunrise, plays the role of magician. View the sight of the sunrise to enjoy its beauty. it is an awe-inspiring and spectacular sight. Often individuals out of pure laziness, or similar affliction, do not take the time to witness nature unveiled.
    </p>
    <p>Couples should especially not miss the fantastic panorama of the sunrise. As couples, you are company for one another and can enjoy the view even more. Each of you bears witness to the stunned silence of the other as the burning ball of the sun appears, like magic, from somewhere hidden beyond the horizon. Viewing the sunrise together can be a great date idea also. Something about the beauty of the shared sunrise my help you with that special someone.</p>
    <p>Get up before sunrise and wear warm clothes, especially if you are not usually the one who gets up early in the morning. Grab some hot coffee or tea to a point where you both can sit and take pleasure in the cinematic sunrise. It is something unique and rare that gives you a deep rooted feeling of pleasure. You might feel a kind of excitement that you have never felt before, exciting as well as inspirational. The beautiful scenery inspires you to begin the day afresh with renewed energy and intensity. A sunrise gives us immense pleasure and joy.</p>
    <p>One cannot help but wonder at the implication to all living creatures, but especially to humans. It seems that it is only people that need to understand what the sunrise is indicating. Nature in all its forms does signify something or other. Nature is a source of both entertainment and education. It indicates that one can start afresh, that there is still hope in life, even when all around you is gloom. Perhaps that explains the numerous souls scattered along the beach each morning, drawn to the light.</p>
    <blockquote>A sunrise gives us immense pleasure and joy.</blockquote>
    <figure>
        <div class="media-element" data-map="16x9-large">
            <img width="1024" height="575" data-src="http://drp-dev.aptoma.no/out/images/article/2014/01/17/20541167/1/box-1024x768/169820.jpg" data-src-2x="http://drp-dev.aptoma.no/out/images/article/2014/01/17/20541167/1/box-2048x1536/169820.jpg">
            <div class="alf-is-removable overlay overlay-bottom overlay-caption">Denali National Park in autumn, Alaska, USA, North America. Foto: Christian Vorhofer / Age Fotosto</div>
        </div>
        <div class="media-element" data-map="16x9-small">
            <img width="460" height="258" data-src="http://drp-dev.aptoma.no/out/images/article/2014/01/17/20541167/1/box-460x748/169820.jpg" data-src-2x="http://drp-dev.aptoma.no/out/images/article/2014/01/17/20541167/1/box-920x1496/169820.jpg">
            <div class="alf-is-removable overlay overlay-bottom overlay-caption">Denali National Park in autumn, Alaska, USA, North America. Foto: Christian Vorhofer / Age Fotosto</div>
        </div>
    </figure>
    <p>Each morning that I am able, I get up early and dress according to the weather. Checking the Weather Channel is a great idea before heading out to the beach. It is very windy at the beach usually and that can make a cool morning seem downright cold, especially when the northeast wind is blowing. Walking the dog has its advantages in that I am already getting exercise and she enjoys it also. We eventually make our way to the beach, her to run, me to take pictures. She is very patient, waiting for me to capture a scenic photograph before galloping off again down the beach. I have gotten used to taking the camera no matter whatthe weather, as you never know when the clouds will move and the sun will rise up behind them. The clouds themselves add to the beauty of the sunrise, sometimes fluffy and sometimes wispy. Get out and get some exercise and witness the beauty of the sunrise. Discover your very own meaning.always beautiful.</p>
    <figure>
        <div class="media-element" data-map="3x4-large">
            <img width="576" height="768" data-src="http://drp-dev.aptoma.no/out/images/article/2014/05/12/20549258/1/box-1024x768/5105818154_79758c4e7c_o.jpg" data-src-2x="http://drp-dev.aptoma.no/out/images/article/2014/05/12/20549258/1/box-2048x1536/5105818154_79758c4e7c_o.jpg">
        </div>
        <div class="media-element" data-map="3x4-small-media-only">
            <img width="460" height="613" data-src="http://drp-dev.aptoma.no/out/images/article/2014/05/12/20549258/1/box-460x748/5105818154_79758c4e7c_o.jpg" data-src-2x="http://drp-dev.aptoma.no/out/images/article/2014/05/12/20549258/1/box-920x1496/5105818154_79758c4e7c_o.jpg">
        </div>
    </figure>
</article>

Building blocks

An article is broken down into two types of elements:

Figures should have a data-map attribute on them so they can be targeted by your templates. Read more about recommendations for mapping images

Read more about building templates

Clone this wiki locally