Silverlight and Drupal: Syndication
- posted in:
- Drupal
- Silverlight
- RSS
I will be writing a few posts on connecting silverlight and drupal in which I will replicate my main site. I will be doing this piece by piece as I investigate each drupal module that I am using and how I can request the appropriate data to populate my silverlight controls. I have outlined the basics needed to accomplish this in my previous post and will be focusing on the new information that is needed to complete each new piece.
Drupal's aggregator module is a core module that is used for fetching syndicated content from other sites. However, it has the ability to provide an xml syndication button for your drupal site if you decide to show the syndication block. There is much more functionality that this module can provide, but all I needed was a simple link to my sites syndication. After doing some initial research I did not find a way to call some method that returned my sites syndication. So I decided to 'cheat' a little bit and produce my sites syndication link manually (at least I did not hard code this!). Here is the php below:
$mainSiteRSS = variable_get('site_name', 'Drupal'); $mainSiteRSS .= url('rss.xml'); return array('rssLoaded', $mainSiteRSS);
I simply grab the sites name, append 'rss.xml' and return a correctly formatted url string to my silverlight application. I then tie that url to my rss button:
private void rssLoaded(object feedSite) { string rssLocation = ((MethodToCall)feedSite).MethodName; Uri rssLink = new Uri("http://" + rssLocation, UriKind.RelativeOrAbsolute); HtmlPage.Window.Navigate(rssLink); }
Remember, I have a generic method that gets called when drupal returns its data that casts the data to a MethodToCall object as outlined in my previous post.
And that's it! This was one of the simpler controls and that is one reason that I decided to start with this one. The silverlight code was very simple as well; just a button that looks like the standard rss icon that was made using Expression Blend that has a click event that sends a request to drupal to return my sites syndication link, as outlined above in the php code. Here is the XAML for the rss icon:
<Button Click="rss_Click"> <Button.Template> <ControlTemplate TargetType="Button"> <Canvas> <Rectangle Width="50" Height="50" Fill="Orange" RadiusX="5" RadiusY="5" /> <Canvas> <Ellipse Width="10" Height="10" Fill="White" Canvas.Left="10" Canvas.Top="30" /> <Path Stroke="White" StrokeThickness="5" StrokeStartLineCap="Round" StrokeEndLineCap="Round" Data="M 15,20 a 15,15 90 0 1 15,15" /> <Path Stroke="White" StrokeThickness="5" StrokeStartLineCap="Round" StrokeEndLineCap="Round" Data="M 15,10 a 25,25 90 0 1 25,25" /> </Canvas> </Canvas> </ControlTemplate> </Button.Template> </Button>
I will post my full source code when I complete this entire replication of my site to silverlight. Until then, I will post the source for each control in a separate solution. If there is a specific drupal module that you would like converted to a silverlight control let me know and I will try to help you out!
file | file size |
---|---|
SLDrupal – RSS.rar | 141.97 KB |
RSSIcon.xaml | 939 bytes |
rssmodule.txt | 652 bytes |
Comments
Matt,
Nick McCreadyDo you a have a repository for this? I'm going to install VS 2008 on my home machine, and to do some fun coding. If you want to collaborate, I am game. Need to come up with something radical for Silverlight or WPF. What do you think?
Nick,
mattI do not have a repository set up at the current time. I have my source in a few different places but I should look into some sort of source control soon. Let me look at some possibilities and I will get back to you.
If you're looking for hosted source code, check out UnFuddle. Setup a free account and I believe you can setup anon access... or create a dummy user that can only read source and publish that. Then set up your own account to commit.
tedHere are the links:
tedSVN source control: http://unfuddle.com
GIT source control: http://github.com