In the last installment of this series we took an existing *form Task that posted a Link *form to HubPages and converted it to post an Article *form to HubPages. Today we’re going go one step further and combine elements of two working Tasks to produce a new Task that will post an Event *form to HubPages.
Event *forms are one of two *form Types that can be represented as microformats (the other is the Contact *form). Many Tasks that post Event *form data target calendar web sites that have specific fields for the various properties of an Event such as the description, location, start date/time and end date/time. You can also post an Event to a simple publishing destination, however, and just format the properties of the Event for display. In those circumstances, it is always nice to format the Event using the rules for an hcalendar microformat. One of many existing Tasks that already does that is the Task that posts an Event *form to Tumblr, which happens to be Task #28. Since someone has already gone to the trouble of working out all of those details, the quickest way to set up a new Task to post an Event to HubPages would be to start with the Task that posts a Link, just like we did before, and replace the Link data with the formatted Event data, which we can lift right out of the existing Tumblr Task.
So, let’s start out with another copy of our old friend, Task #520, “Post Link to a HubPages Hub”:
Once again, we are simply changing parameters to be posted in the final step — everything else remains the same. Events do not have a “title” property, but they do have an “event” property that can serve as a tile, so let’s change this parameter:
The only other thing that we need to do is to change the content parameter, and for that, let’s take a quick look at our source Task, #28:
This Task, which is a one-step POSTing Task that leverages the Tumblr API, contains a POST parameter called body, which is what we want to snag for the basis of our own content parameter. Our existing content parameter does have some interesting stuff that we might want to hang on to, though, so let’s take a quick peek before we get to carried away.
<p><em>Posted:</em> $rightNow.toString("EEE, MMMM d, yyyy 'at' hh:mm aaa")<br/><em>From:</em> <a href="$url" target="_blank">$url</a></p> <p>$comments.replace("\n","</p><p>")</p> <p><em>Tags:</em> $tags</p>
That first line publishes the posting date, which is actually useful information and worth keeping around, so let’s drop everything else, but leave that part in place:
<p><em>Posted:</em> $rightNow.toString("EEE, MMMM d, yyyy 'at' hh:mm aaa")</p>
Now all we need to do is add in the microformatted event code that we lifted from the Tumblr task, and we now have a new value for the content parameter:
<p><em>Posted:</em> $rightNow.toString("EEE, MMMM d, yyyy 'at' hh:mm aaa")</p><div class="vevent"><p><strong>#if($url)<a class="summary url" target="_blank" href="$url">$event</a>#else <span class="summary">$event</span>#end</strong></p><p> <em>When:</em> <abbr class="dtstart" title="$startDate"> $dtstart.toString("m/d/yy hh:mm a")</abbr><br/>#if($endDate) #if($endDate!="")<em>Ends:</em> <abbr class="dtend" title="$endDate">$dtend.toString("m/d/yy hh:mm a")</abbr><br/> #end #end #if($location)#if($location!="")<em>Where:</em> <span class="location">$location</span>#end #end #if($description)#if($description!="")</p><p class="description">$description</p>#end #end</div>
That’s it. Now we have a new Task to post an Event *form to HubPages, and do it in a way that makes the Event visible to any tool that recognizes microformats. And we really didn’t have to do much of the work at all! It was all from parts and pieces that we found laying around.
There are plenty of working Tasks out there to grab and start playing with. A little of this Task mixed with a little of that Task mixed with a dash of your own unique stylings and all of sudden there’s a brand new Task in the pile. Go ahead — give it a try. You might even find yourself having a little fun with all of the possibilities!