Del

Developer: Syndication

This chapter is intended for webmasters and developers that wish to redistribute content. It describes how to grab stuff from a FirstMagic site and deliver it onto web pages and apps anywhere, on any platform.



THE FIRSTMAGIC SHARE TAG
You may have noticed that FirstMagic Blogs and Galleries have an "embed" button near the top of the page. Clicking it will reveal a tag that looks like this:

<script type="text/javascript" src="[http://]mydomain.com/mycontainer/portal/?leaves&embed"></script>

This tag will grab content from the page it came from and republish it on whatever other page you place it on. It´s basically an embeddable RSS reader.

All FirstClass containers in FirstMagic can be accessed this way, though only Blogs and Galleries displays the button. Insert the URL to your container of  choice, and it is ready for use.

The part after the question mark tells FirstMagic what to deliver. leaves&embed is the minimal configuration: it means get articles from this URL and place them here. However, FirstMagic offers many parameters for tweaking the incoming stream: ways to change its appearance as well as the content itself, in any number of ways.

Available tags:

Required
leaves&embed
Required pair: must always be at the start of the parameters string, right after the question mark.
Tags for articles and blog posts
leaves&embed
Will retrieve the 15 top-sorted/newest FirstClass documents, conference posts, FirstMagic web pages, podcasts and YouTube videos in the container. Displays the title and the first two hundred characters of text.
&dates
Adds publication date.
&larger
Scales up the font sizes, and gives h2 and h3 titles instead of h3 and h4 titles.
&numX-numY

&1-10 | Retrieves any number of objects instead of the default 15. 1 means the topmost sorted object; you can start and end at any value, retrieving the -nth through nth articles from the top.
&short
120 characters of text preview instead of 200.
&full
Retrieves full articles - with images and formatting intact.
Tags for image galleries
&gallery
leaves&embed&gallery | Will get the 15 top-sorted images from the container and display them as clickable thumbnails in a mini-gallery.
&numX-numY
&1-10 | Retrieves any number of objects instead of the default 15, starting at the nth image.
Tags for container listings
&files
leaves&embed&files | Retrieves lists of objects instead of displaying them in full. Will get 150 items unless used with [&num-num]. Displays the item´s FirstClass Subject for the clickable link if it exists. Else, the filename is used.
&verbose
leaves&embed&files&verbose |  Displays both the filename and the subject.
&dates
Adds publication date for each list item.
&sizes
Adds file size for each list item.
&icons
Displays each item´s icon.
&largeicons
[instead of Icons] Scales up the icon to 48x48 pixels
&horizontal
Displays the list table-style - each item is a row, with columns for filename, subject, icon, date...
&nosubheader
Removes the title row from [horizontal] table view.
&larger
Scales up the font sizes, and gives the content box a h2 title instead of h3.
&numX-numY
&1-10 | Retrieves any number of files instead of the default 150, starting at the nth file.
General formatting
&semantic
FirstMagic will attempt to construct human-readable links from the paths to the objects, using container and filenames. This will only succeed if all filenames in your container, as well as all container names on the path to it, is unique. If you do not use this tag, all items will have normal FirstClass object ID URLs instead.

Note: this feature is smart enough to substitute a semantic URL with the FirstClass object ID if the item in question is a message [since all messages from the same author will have identical filenames]. In containers that contains a mix of messages, uploads and documents, you would then get a mix of FirstClass URLs and semantic URLs for your items.
&internal
For use only if the tag is placed on a FirstMagic website: will discard all built-in styling and make the contentbox use the active FirstMagic Skin on that site - integrating it seamlessly into its design.
&fctext
Makes the built-in styles FirstMagic-compatible [without using the internal tag]: if the tag is applied on a FirstMagic website, this will make it adopt font styles from the active Skin on that site, while still using styling options available through parameters in this list.
&linktitle
Makes the header [the h2 tag]  a link to the container on the originating website.
&notitle
Removes the header.
&nofooter
Removes the footer [the RSS feed button].
&dark
Renders the content box inverted -  dark colors instead of bright.
&nobox
Removes the entire framing design, leaving only the contents.
&nostyle
Discards all formatting, leaving the raw feed. With this option, the feed can be styled freely with CSS on the receiving website or app.
CSS tags for use with the &nostyle parameter
.fm_embed {}
Class for the entire contentbox.
h2, h3, h4
Titles: | .fm_embed h2{}
.fm_embeditem {}
Class for a single article item | .fm_embed .fm_embeditem{}
.fm_embedtxt {}
Class for inner content of an .fm_embeditem box [sans the h4 tag]
.listobject.listtop {}
Class for the title row in table view | .fm_embed .listobject.listtop{}
.listobject {}
Class for a single row in table view | .fm_embed .listobject{}
.listobject img {}
... For icons.
.fm_embeditem a {}
... For links. Use fm_embeditem h2|h3|h4 for title links, .fm_embedtxt a or .listobject a for inline links.
h4.fctext
Subtitleformatting - only applicable for internal FirstMagic use.
.fctext {}
The built-in FirstMagic text class.
Filtering content
&@keyword
&@onlymykeyword |
All FirstClass objects has a Keywords field. We can filter content by what this field contains. Add one or more of your keywords to this field (comma-separated), and it becomes possible to restrict the output by those keywords.

Place this tag as far back in the argument string as possible - ideally, it should be the last. This because anything after the @ symbol will be compared to the keywords in your FirstClass objects.

Example:

leaves&embed&@apples will cause the feed to omit all items that do NOT have the keyword apples.

leaves&embed&@applespears will cause it to omit all items that do NOT have the keywords apples OR pears.

Note that the feed simply compares the content of the @ argument with whatever is in the Keywords field; it would, for example, also trigger plespear.

One important note about using filtering together with the numX-numY argument: FirstMagic will not actually know how many items you discard from the stream. This means that the omitted ones will also be counted - resulting in a lower number of displayed items than you set the values for. To account for this, simply up the numX-numY values to give it a buffer.
Sending clicks to a different domain
All FirstClass objects have a Category field. If you fill it in with a domain name, the object in question will be opened on that domain instead of on the originating FirstMagic domain. This allows you to render any object on any FirstClass template, or in any third-party layout.

The domain you send the click to must be on the same server as the FirstMagic website, and the FirstClass container must have an alias there, on an identical path. E.g, the alias must have the same relative URL on both domains.
Implementation
A container you wish to export to a third party must be open to the public, to some degree:
  • For lists, the minimum is All Users = Summary
  • For posts, the minimum is All Users = Browser
Summary allows the feed to see the item titles. If clicked on, the visitor will be required to authenticate with his FirstClass credentials. To avoid any authentication, set the container to:
  • All Users = Reader
To use a feed, simply paste it in where you want it to appear. For legacy reasons, it uses a document.write() to output the contents, so the feed will appear exactly where you place the tag. This is the default mode, and it happens automatically.

However, FirstMagic offers a more modern way to implement the tag, too; you can inject it directly into the DOM - just tell it so with a parameter.
Injection parameters
&inject
Will cancel the document.write and use append() instead. This will drop it directly into <body>, from where you can grab it with the .fm_embed{} class. Alternately, you can tell it which ID on your page to drop into.
&localid&myid
To use this parameter, it needs to be the very last one in your request.

Example:
leaves&embed&localid&YOUR_CHOSEN_DIV_ID.
Practical examples
Get only 3 news articles, shortened to the first paragraph, and omit the very newest one:

<script type="text/javascript" src="[http://]mydomain.com/mycontainer/?leaves&embed&short&2-4"></script>  

Get the 10 newest list objects in verbose table format, and display only items tagged with the keyword "apples":

<script type="text/javascript" src="[http://]mydomain.com/mycontainer/?leaves&embed&files&verbose&horizontal&1-10&@apples"></script>