Ok, so now it is time to present how to change the *structure* of how a RIPL list renders. This is fairly easy to do as the RIPL library was built with the concept of customizable plug-in renderers in the design process.

You’ll need to create a function that takes in a riplCollection (UserList, ContentList, EventList) and writes that content to the collection’s displayOptions.renderTarget. That function will need to be added to the ripl.renderers object, and there’s a handy method of doing that using the ripl.renderers.addCollectionRenderer method.

Here’s the simplest example, which creates a closure and then passes that in as the renderer for the ‘my_renderstyle’ key:

function renderHelloWorld(contentList)
{
     $ripl.updateElement(contentList.displayOptions.renderTarget, 'Hello world!');
}
ripl.renderers.addCollectionRenderer('my_renderstyle', renderHelloWorld);

Note the use of $ripl, which is a helper utility for interacting with dom objects. The RIPL Library creates 3 top-level items:

  • ripl – this is the core library object
  • $ripl – this is the DOM manipulation helper utility. If you’re used to JQuery, it is somewhat similar to the ‘$’ function, although much simplified.
  • $$ripl – Don’t worry about this too much, unless you’re looking through the source. It is there as an internal caching function to help manage the size of the RIPL library.

Let’s do something more useful than writing ‘hello world!’ to the screen. Let’s write out a set of RIPL content thumbnails without the content-type borders. I generally recommend against this practice because users lose the concept of what *kind* of item is in the list, but rules are made to be broken.

Because of the intricacies of WordPress, I’ve just posted a script file here. It should be fairly well commented… let me know if you’ve got any questions.


ripl.renderers.addCollectionRenderer('contentlist_custom1',function (contentList)
{
    // If this content list doesn't have anywhere to render, then exit out.
    if (!contentList.displayOptions.renderTarget) { return; }

    // First, set up the vars & create a base container.
    var pContent, pBottomBar, pRow, pTd, pAnchor, pImage, i, pageInfo,
        pContainer = $ripl.create('div', {className:'ripl_displayObject'});

    if (contentList._availableItems.length == 0)
    {
        // If our content list doesn't have any items in it,
        // then render the 'no items' html.
        pContainer.add(contentList.displayOptions.noitems);
    }
    else
    {
        // The pagination_helper is a handy function for determining
        // what content to show in a 'paged' environment.
        pageInfo = ripl.renderers.collectionRenderers.pagination_helper(contentList);

        // Create a box of content items for the parent container.
        // Normallly, I'd use a DIV but using a table makes it easier
        // to vertically align content.  RIPL thumbnails are not
        // homogenous to a given size... they actually vary slightly
        // depending on the kind of content and the source.
        pContent = $ripl.create('table',{
                className:'ripl_contentcontainer'
            });
        pBody = $ripl.create('tbody');
        pRow = $ripl.create('tr');

        for (i = pageInfo.start; i < pageInfo.max; i++)
        {
            // Start with a table cell, since we're using a table structure.
            pTd = $ripl.create('td');
            // Create an anchor (< A >) tag.  Make sure to add the new
            // className, which we'll define in our CSS additions.
            pAnchor = contentList._availableItems[i].getAnchor({
                    className:'custom1_contentitem'
                });
            // Create an img (< IMG >) tag which will go inside the anchor.
            pImage = $ripl.create('img',{
                    className:'custom1_contentimage',
                    src:contentList._availableItems[i].thumbnail_image_url
                });
            // Add the Image to the anchor.
            pAnchor.add(pImage);
            // Add the anchor to the Table cell.
            pTd.add(pAnchor);
            pRow.add(pTd);
        }
        // Add the entire box of content items into the parent container.
        pBody.add(pRow);
        pContent.add(pBody);
    }
    // Standard code to create page steppers for a content list.
    if ((contentList.displayOptions.itemsperpage < contentList._availableItems.length) && (contentList.displayOptions.itemsperpage > 0))
    {
        pBottomBar = $ripl.create('div',{
            className:"ripl_displayoptions"
        });
        pBottomBar.add(ripl.renderers.collectionRenderers.collection_helper_pageChanger(contentList));
    }
    pContainer.add([pContent, pBottomBar]);

    // Finally, update our rendering container with the enclosing container.
    $ripl.update(contentList.displayOptions.renderTarget,pContainer);
});

Ok, let’s add the CSS, although some of this is designed to defeat the defaults from our current WordPress style:

#demo_custom .custom1_contentitem {border:1px solid #333333;border-bottom::1px solid #333333; text-align:center;
vertical-align:middle;display:block; float:left; text-decoration:none}
#demo_custom .custom1_contentitem:hover {border:1px solid #cccccc; background-color:#ffffff;}
#demo_custom .custom1_contentimage {background-color:transparent; border:none;padding:0px}
#demo_custom .ripl_contentcontainer td {border:0px; padding:2px}

Embed your custom renderer:
<script type="text/javascript" src="http://www.ripl.com/developer/1/demos/custom_renderer1.js"></script>

Add your Ripl block (note the use of the ‘ripl:display_targetstyle’ attribute, which references the collection renderer contained in the code we just added).

And your results should look like this:

Often enough, you’ll want to present multiple lists on a page. However, you may not want to show all of the content at once.

In this case, an accordion construct (http://en.wikipedia.org/wiki/Accordion_%28GUI%29) may be the way to go. The RIPL JavaScript library has an accordion built-in, which allows you to easily and unobtrusively add a number of RIPL display containers to a single page.

Here’s the demo:

Cool People’s Stuff
Juanune’s Content
Contacting server…

Bill’s Content
Adam’s Content

Is it hard? Nope… utilizing RIPL’s scriptless rendering, it is simply a matter of hooking up a number of specially classed items. Here is the structure of the accordion:
* div – this serves as the container for the entire object
|* div – this serves as the header
|* div – this serves as the content for the previous header, and can be defined as a standard RIPL content display object.
||* div – this is the default text that the container holds, before it is overwritten with content.
|* div – Another header header
|* div – Another standard RIPL content display object.
||* div – Another bit of default text
|* footer

There re a couple of ‘new’ concepts in here. First, you’ll notice the ‘ripl:deferred’ attribute set on these items. Deferred tells the RIPL engine that it is not to pull the content down until the user ‘asks’ for it by clicking into a tab. This saves loading time and bandwidth… and is honestly easier on our own servers if it is a ‘best practice’ to not ask for information that you won’t necessarily be using.

You’ll also note that in our demo, we’re showcasing the ability for the RIPL JavaScript library to render multiple kinds of lists. Specifically, we’re showing the ‘cards’ view, the default (or ‘grid’) view, and the text view.

Cool People's Stuff
Juanune's Content
Contacting server...
Bill's Content
Adam's Content

The RIPL library is designed to be easily extensible to a variety of presentation types. Today, I’m going to show how to update the library to show content in an alternative presentation.

Building on our previous example, we’re going to add a few new parameters. We’ll change the target rendering style and add a new handler for the onclick event…. plus we’ll add a little CSS to change things up.

So, we’ve added a few new attributes:

  • ripl:display_targetstyle – There are predefined styles for rendering content and users, plus you can add your own. We’re going to use the preset ‘contentlist_cards’ rendering style for this list.
  • ripl:display_itemsperpage – Because the contentlist_cards view takes up more space, we’ll actually be showing fewer items, though we’ll be showing more information about each one.
  • ripl:event_onclick – Now we get to use the new RIPL PopUp display.

So we get:

Great, but we want to really change up the look, so let’s lay some CSS on top:

#demo2 .ripl_contentitem_render_card {background-color:#80a020; border-top:1px solid #D9DB56;border-bottom:1px solid #757116;border-left:1px solid #757116;border-right:1px solid #757116; width:100%}
#demo2 .ripl_contentitem_render_card:hover {background-color:#AEBC21}
#demo2 .ripl_colors_normal {color:#f0f25e}
#demo2 .ripl_colors_deemphasis {color:#D9DB56}
#demo2 .ripl_colors_link {color:#ffffff}

And voila:

We’ve been hard at work making it easier for 3rd party developers to access RIPL features.  Our API set is pretty extensive, but we wanted to ease the burden of implementation, and have created the RIPL JavaScript Library to that end.

Usage is pretty simple… just add the RIPL JavaScript library to your Web site by including the appropriate script tag:

<script type="text/javascript" src="http://www.ripl.com/api/1/jslib/ripllib.js"></script>

From there, all you need to do is add a new DIV to a Web page like this:

The structure is pretty simple. It is a div. Its CSS class is ‘ripl_renderer’, which is important because the RIPL library will look through the page to determine which items it needs add RIPL content to.

From there, we add a few display properties:

  • target_login – This is the user login of the appropriate user.  In this case, we’re using my login (juanune).
  • method – This is the RIPL API we’re going to use to get data for.  ‘ripl.user.getOwnedContent’ will retreive all of my content.

Add a couple of specific rendering things (background color, etc), and voila… we get this:

Cool huh? …and all created with developers only needing to add a single HTML element.

I’ll be posting another article soon on how you can go in and change the appearance of the list.

Welcome to the RIPL blog.

I’m John, lead developer and architect of the RIPL engine.  In the coming weeks, you’ll see a lot of updates and changes coming through here… and I think you’ll like what you’re going to see.