Recommended releases

Download Released

Moby lets the Moby microblogging apps for iOS and Android post to a Backdrop
site. It provides a REST API for creating posts with a description, a date, a
location, tags, and photos or videos, saved into the content type you choose.

Requirements

This module requires only Backdrop core: the Node, File, and Image modules.

To store location coordinates, the
Geofield module is also needed.
Without it, posts can only have a location name.

Installation

  • Install this module using the official Backdrop CMS instructions at
    https://docs.backdropcms.org/documentation/extend-with-modules.

  • Enabling the module shows a link to a setup wizard, which is also available
    from the settings page. It walks through the steps below, and can create a
    new "Mobile Post" content type with all the fields it needs.

  • Grant Post via Moby to the roles that may post from the app, along with
    permission to create, edit, and delete their own content of the content
    type. Also grant View own unpublished content, so users can read back
    drafts they post.

  • Visit the configuration page under Administration > Configuration > Web
    services > Moby (admin/config/services/moby). Select a content type and
    save. Then map the description, date, location, and media to that content
    type's fields.

  • Optionally, to store location coordinates, enable the Geofield module, add
    a Geofield to the content type, and select it as "Location coordinates".
    Without Geofield, this setting is hidden, and the app only offers a location
    name.

  • Optionally, to store a thumbnail for each video, add an image field to the
    Video file type (Structure > File types) and select it as the "Video
    thumbnail field".

  • Tags from the app, and #hashtags in descriptions, are saved in a "Tag
    vocabulary", which defaults to "Tags" if the site has it. Choose another, or
    none, in the wizard or on the settings page. A tags field is added to the
    content type if it has none.

  • Optionally, choose the "Thumbnail image style" that apps show in place of
    full-size photos and video thumbnails. It defaults to Moby's own "Moby
    preview (1200x1200)" style (moby_preview), which Moby installs. It scales
    photos to fit within 1200 by 1200 pixels, without cropping or enlarging
    them, since apps show thumbnails as wide as the screen. The setup wizard
    selects it if the style chosen no longer exists, and the Moby Carousel
    display uses it by default too. Edit it on the image styles page, or revert
    it there to Moby's version. Uninstalling Moby removes it, unless it has been
    changed, in which case it's kept as an ordinary style.

Documentation

Showing posts

Posts are shown with templates/moby-post.tpl.php, which the theme's node
template prints in place of the post's fields. It shows the photos and videos,
then the description, then the location with a map pin icon. Exact coordinates
are shown only when they're stored in a Geofield, as
"39.96124° N, 105.51306° W". To change the layout, copy the template into your
theme.

The Moby Carousel formatter, for file and image fields, shows photos and
videos one at a time. The setup wizard uses it for the media field. It:

  • Is written for this module, with no library (see "Carousel libraries"
    below).
  • Follows the
    WAI-ARIA carousel pattern:
    labeled previous and next buttons (44px), a dot for each slide, slide
    positions announced to screen readers, slides out of view kept from being
    focused, and no automatic rotation.
  • Uses the browser's own sideways scrolling with snap points, so swiping feels
    native on touch screens, and the slides can still be scrolled without
    JavaScript.
  • Respects reduced motion and Windows high contrast mode, and pauses videos
    that are moved away from.
  • Gives every slide the shape of the tallest photo or video, within limits, so
    the page doesn't jump. A single item is shown on its own, without controls.

Photos and videos never grow wider than the content area. Themes can restyle
the carousel with the CSS custom properties listed in css/moby.carousel.css.

Carousel libraries

These were considered before writing the carousel from scratch:

  • Splide (MIT): the best accessibility of the
    libraries, with touch support, but about 30 KB, and it re-implements
    swiping in JavaScript.
  • Swiper (MIT): full featured and widely used, but
    large (40 KB or more), and its accessibility module needs care to set up.
  • Embla Carousel (MIT): small and
    well-built, but it provides no buttons, dots, or ARIA; those would have to be
    written anyway.
  • Glide.js (MIT): small, but weak on accessibility and
    little maintained.
  • Flickity: needs a commercial license for
    non-GPL use, and its accessibility is limited.

Native scroll snapping gives touch behavior as good as these libraries, so the
carousel only needed a small script for the buttons, dots, and ARIA.

Logging in

By default, the app logs in with a username (or email address) and password.
The included Moby email login module (moby_auth_email) adds logging in
with a 6-digit code emailed to the user. The site needs to be able to send
email.

The included Moby login test module (moby_auth_test) adds a three-step
test login: the password, a code that the app shows instead of emailing it,
and three security questions. It is for testing the apps only, so don't
enable it on a live site.

When more than one way of logging in is available, choose which are enabled
under Logging in on the settings page, and drag them into order. The app
shows the first one, with the others under "Log in a different way".

API

The REST API is described in API.md, with the rest of
the Moby documentation.

Extending

Other modules can provide authentication mechanisms with
hook_moby_auth_info(). See moby.api.php and
includes/moby_auth.class.inc. A mechanism with more than one form returns
a MobyAuthStep. MobyAuthRequest carries its state between steps, in a
signed ID, and counts wrong answers with flood control.
modules/moby_auth_email and modules/moby_auth_test are examples.

Tests

The test cases in the Moby group log in through the REST API as the apps
do:

  • Multi-step login API (tests/), with the three steps of the Moby login
    test module.
  • Email login API (modules/moby_auth_email/tests/), with codes emailed
    by the Moby email login module.
  • Install defaults (tests/), which checks that installing Moby adds its
    image style and uses it by default, and that uninstalling removes it.

The two login tests extend MobyApiTestCase, in tests/moby_test_case.test, which makes
requests as the apps do. Enable the Testing module to run them at
admin/config/development/testing, or from the command line:

php core/scripts/run-tests.sh --url http://localhost --class MobyAuthStepsTestCase,MobyAuthEmailTestCase,MobyInstallTestCase

Status

Under development. Working so far: the menu routes, JSON delivery, error
handling, the settings form, token authentication, media uploads, creating
posts, and listing, viewing, updating, and deleting posts.

Issues

Bugs and Feature Requests should be reported in the Issue Queue:
https://github.com/backdrop-contrib/moby/issues.

Current Maintainers

Credits

License

This project is GPL v2 software.
See the LICENSE.txt file in this directory for complete text.