-
Notifications
You must be signed in to change notification settings - Fork 7
Using Rit.
Now that you’ve installed Rit. you can begin using it.
Rit organizes content by context, and schedules content for display. That’s it. Highly dynamic code that concerns itself with anything other than context and schedule is not a good fit for Rit. However, content that could benefit from being managed by a non-developer, and content that may need to change over time is a great fit for Rit.
In this example, this website occasionally wants to display “alert” style information bubbles. The notice may be related to an upcoming event or holiday, or any other last-minute notice to their users.
You can use any names you like, but in this example I’m using the site name as the layout, since this plate will be used all across the site, not just on a particular page. I left the instance name blank, since there are not several instances of this same layout (we’ll address those in a bit). I’m using ‘information-bubble’ as the plate name.
Selecting our new plate shows that we don’t have any editions yet.
Now let’s create an edition that will go live for a week to announce our 2nd anniversary as a blog:
You’re encouraged to name each edition something meaningful. Rit. allows you to have any number of editions per plate, so next year at this time you might want to check out what you did for your anniversary last year. This is great for when you have content that you may want to resurrect on a schedule, like seasonal and holiday content. You can use the description to further clarify what the content pertains to, which is handy to see on other Rit. pages.
Notice we’re scheduling exactly what day and hour this content should show up, and when it should go away.
We indicated that we want this edition published. If this content is just a draft, and not ready to show up, even when the schedule indicates it should, we can uncheck that box.
A ‘fallback edition’ is a default plate edition that shows up when no other edition matches the current schedule. Since we want this plate to render nothing when there is no editions scheduled, we’ll leave that unchecked.
After saving the edition, we can see the schedule indicates that our edition will go live at 8AM on 3/31 and will be taken down on 4/7 at 8AM:
If this is a Rails app, make sure to first install the rit_client Rails plugin
Now from any controller, helper or view, you can make a call like this:
rit_plate('example.com', nil, 'information-bubble')
Note: the second argument is nil because we didn’t provide an instance name for this plate.
When that code is executed, an HTTP call will be made to the Rit. API to GET content according to that context and the current time, as local to Rit. So, when this code is called before or after our edition’s schedule indicates it should be published, it will return no content. However, between 8AM on 3/31 and 8AM on 4/7, we’ll get our anniversary announcement bubble on our site.