Creating a Custom Mashlet for Dapper Mashup

nzblue_fish
nzblue_fish's picture
User offline. Last seen 2 weeks 4 days ago. Offline
Joined: 09/30/2009
Points: 1165

Hi mashers,

Beginner in the house ... so, apologies to the experts!

I've successfully created a new mashup using the Dapper connector and now want to do something useful with the output. I used the basic mashlet maker to create a simple html mashlet, but it doesn't quite do what I want or present the mashup output in a useful form for the users. So I'm thinking what I need to do is create a "custom mashlet type".

I've watched the basic custom mashlet video (featuring MySamples.hello) and get the general gist of the approach, but I work best with a bit of cheat-sheet help. Can anyone help with some slightly more detailed how-to material or sample custom mashlet code that I can look at.

The Dapper mashup returns a lot of data that I don't need. I just want to pick out 4 elements and present them to the user in a simple RSS feed type format.

Thanks,

Innes (NZ)

 

 

0
Your rating: None
nzblue_fish
nzblue_fish's picture
User offline. Last seen 2 weeks 4 days ago. Offline
Joined: 09/30/2009
Points: 1165

Hi mashers

I've just discovered that you can generate alternative formats from the Dapper service including an RSS type feed, but my initial question still stands as I'd like to know how I can take the initial Dapper mashup output and reform it in a custom mashlet.

Cheers, Innes (NZ)

aishmishra
aishmishra's picture
User offline. Last seen 10 weeks 6 days ago. Offline
Joined: 09/24/2008
Points: 3

Hi Innes,

Before proceeding to create a custom mashlet let us check if the Out of the Box mashlets will help.

As you said, there is a lot of information in the Dapper response that you want to filter out and keep just some.

You can use Wires - the visual mashup editor to achieve that.

Wires provides functionality to perform various operations on service response.

Please check the documentation available at http://www.jackbe.com/prestodocs/v2.7.0/prestolibrary

Let us know how it goes.

 

smitchell
smitchell's picture
User offline. Last seen 17 hours 47 min ago. Offline
Joined: 08/29/2008
Points: 34

If you use your Dapper service in Wires and then filter the result, this may give you what you want with one of the built-in views for a basic mashlet.

If you find that that is not enough, you need to make the UI look different or you want to add behavior, then you are right that a custom mashlet type is what you need.

There are several "how to" topics with snippets of code for most of the basics involved in creating a custom mashlet type in the documentation at: 

http://www.jackbe.com/prestodocs/v2.70/prestolibrary/

Simply search for "custom mashlet" to find topics. There are also a few samples that ship with Presto that you can look at. You can find the code in subfolders named Sample* under: 

{web-apps-home}/mashlets

 

Sara, technical writer/jackbe

 

nzblue_fish
nzblue_fish's picture
User offline. Last seen 2 weeks 4 days ago. Offline
Joined: 09/30/2009
Points: 1165

Hi guys,

thanks for your replies today and your suggestions on how to approach this. I have tried to use the MashletMaker to create an RSS mashlet to take the mashup output from my two Dapper feeds. When I preview the feeds in Wires using the RSS format, it appears as I expect it to, but once I try to create the mashlet using the RSS type, I get a "Service type mismatch". If I use another service type (XML) it works, but clearly it's not what I was after. If I examine the XML mashlet instance (see attachment) I can see why it doesn't work since it doesn't conform to RSS XML. So that leaves me with a problem. How to create a mashlet that my users can take advantage of.

In case it helps, here is the Resource URL for one of the services used in the mashup: http://www.dapper.net/transform.php?dappName=DairyNZCurrentNews&transformer=RSS&extraArg_title=News_Header&extraArg_description[]=News_Summary&extraArg_pubDate=News_Date&applyToUrl=http%3A%2F%2Fwww.dairynz.co.nz%2Fpage%2Fpageid%2F2145837796%2FCurrent_News

Look forward to some suggestions.

Cheers, Innes

smitchell
smitchell's picture
User offline. Last seen 17 hours 47 min ago. Offline
Joined: 08/29/2008
Points: 34

Looks like the output from Dapper is part of the problem. Some other users may have better suggestions on how to deal with this. When I tried your link, I get no data.

One other option is to create a mashup that does 'web clipping' from the source URL you used in Dapper rather than using the Dapper Connector. This is a more technical solution, but it would give you much better control over exactly what data you get and how the data is represented.

That solution involves creating a mashup using EMML (the XML language underlying Wires graphical view). The basic idea is to use  the <directinvoke> statement to get your source page  back as data. Then in the mashup, use other statements to select only the data you are interested in and build an XML format that you can use, such as RSS, as the output of the mashup with only that data.

There is a very basic example of web scraping in the documentation for EMML. Go to http://www.jackbe.com/prestodocs/v2.7.0/prestolibrary. Then search for web clipping to find the topic.

 

Sara, technical writer/jackbe

 

nzblue_fish
nzblue_fish's picture
User offline. Last seen 2 weeks 4 days ago. Offline
Joined: 09/30/2009
Points: 1165

Although I haven't got to the point of building a custom mashlet, I did manage to produce an RSS feed out of the Dapper webclipping output. See another of my posts for that mashup. Cheers, Innes (NZ)

http://www.jackbe.com/enterprise-mashup/forum/foreach-loop-produces-no-r...

nzblue_fish
nzblue_fish's picture
User offline. Last seen 2 weeks 4 days ago. Offline
Joined: 09/30/2009
Points: 1165

Hi mashers,

For anyone coming along and reading this post, I have managed to produce exactly what I wanted to when I first started out and since I had so much help from the the Community I thought I would post back the final results. I came a long way in learning to mashup and create a custom mashlet. There's so much more to learn!

I hope this might help another beginner get started. I'm sure there are lots of possible improvements, and any suggestions are more than welcome.

Cheers, Innes (NZ)

Deepak Alur
Deepak Alur's picture
User offline. Last seen 2 weeks 1 day ago. Offline
Joined: 09/09/2008
Points: 525

Awesome! Thanks for sharing in the spirit of the community!

I will check it out as I am sure others will as well. You might also want to attach a screenshot/diagram to help some of us who want to take a peek at what the end result looks like.

Mash On!
- deepak alur | vp product + engineering at jackbe  | follow me

nzblue_fish
nzblue_fish's picture
User offline. Last seen 2 weeks 4 days ago. Offline
Joined: 09/30/2009
Points: 1165

Hi Deepak,

No problem. nice to be able to give something back. I've included a jpg in the zipfile that shows the mashlet as presented to the user. There are two emml files: One executes a Dapper webclip and takes the returned standardised xml output and reforms it into RSS 2.0. The second emml file invokes 3 parallel instances of the webclip mashup to combine the feeds into a single RSS output ready to be used in the mashlet. There's some nifty date processing (thanks to Sara) going on in both mashups to sort and select on dates and ages. The custom mashlet then displays the results in a "our look & feel" mashlet that gets presented on our intranet as a portlet. I've got some ideas already to improve it and I'd like to be able to recycle my mashlet to work with any standard RSS feed rather than just the source mashup I've created.

Really cool stuff you guys have done. I'm enjoying this stuff immensely and can't wait to do some serious mashup stuff.

Cheers, Innes (NZ)

nzblue_fish
nzblue_fish's picture
User offline. Last seen 2 weeks 4 days ago. Offline
Joined: 09/30/2009
Points: 1165

Hi mashers,

Slight updated version of the mashlet code that makes it more generic. It now takes two preferences: One for a service name and the other for an invocation name. It means the mashlet can now be used for any RSS feed from a service or mashup that is in the required format.

The new preferences defined in the mashlet JSON  are  "RSSFeedService": "AHCDefaultRSSMashletFeed" and   "invokeRSS": "getRSSFeed" with the defaults as shown. I created a default mashup called AHCDefaultRSSMashletFeed so that when creating a new mashlet based on "Type" it will execute something before you go ahead and set the values you want.

I've attached the default mashup code as well.

Hope this is useful for anyone.

Cheers, Innes