Showing posts with label facebook. Show all posts
Showing posts with label facebook. Show all posts

Saturday, 16 October 2010

Google's Dynamic Feed Wizard + feeding Facebook problem and hacked solution

Google's Dynamic Feed Wizard is really good.


http://www.google.com/uds/solutions/wizards/dynamicfeed.html

BUT I found a problem with facebook feeds. The feed displayed fine BUT the links to go to external feed or items were relative links to local site.
e.g. /posted.php?id=199235386657&share_id=155115854527260&comments=1#s155115854527260 instead of:
http://www.facebook.com//posted.php?id=199235386657&share_id=155115854527260&comments=1#s155115854527260


This is where we're using it: http://lhra.info/
See also the changed javascript: (hardcoded for facebook feed as it is at current moment in time = Oct17 2010) http://lhra.info/gfdynamicfeedcontrol_forfacebook.js

Also changed is ability to default title link to not what is returned by RSS feed.

 wwwLHRA$ diff -u gfdynamicfeedcontrol.js gfdynamicfeedcontrol_forfacebook.js
--- gfdynamicfeedcontrol.js    2010-10-17 01:23:52.000000000 +0100
+++ gfdynamicfeedcontrol_forfacebook.js    2010-10-17 02:39:08.000000000 +0100
@@ -27,7 +27,7 @@
   this.feeds = [];
   this.results = [];

-alert("debug feedUrls:"+feedUrls);
+//alert("debug feedUrls:"+feedUrls);

   if (typeof feedUrls == 'string') {
     this.feeds.push({url:feedUrls});
@@ -45,7 +45,7 @@
       o.title = s.replace(//g, '>');
     }
       }
-alert("debug maybe url:"+o.url);
+//alert("debug maybe url:"+o.url);
       this.feeds.push(o);
     }
   }
@@ -115,7 +115,8 @@
     sortByDate : false,
     horizontal : false,
     stacked : false,
-    title : null
+    title : null,
+    titleurl : null
   };

   if (options) {
@@ -162,7 +163,7 @@
   // The feedControl instance for generating entry HTML.
   this.feedControl = new google.feeds.FeedControl();
   this.feedControl.setLinkTarget(this.options.linkTarget);
-alert("debug this.options.linkTarget:"+this.options.linkTarget);
+//alert("debug this.options.linkTarget:"+this.options.linkTarget);


   // The feeds
@@ -174,7 +175,7 @@
     feed.setResultFormat(google.feeds.Feed.JSON_FORMAT);
     feed.setNumEntries(this.options.numResults);
     feed.load(this.bind_(this.feedLoaded_, i));
-alert("debug feed "+i+" :"+feed);
+//alert("debug feed "+i+" :"+feed);
   }
 };

@@ -217,6 +218,14 @@
   if (this.feeds[index].title) {
     result.feed.title = this.feeds[index].title;
   }
+//alert("debug result:"+result+" tit:"+result.feed.title);
+//alert("debug feed i:"+index+" result:"+result+" tit:"+result.feed.title+" lin:"+result.feed.link);
+  var entries = result.feed.entries;
+  // CHANGE RELATIVE Facebook URL to ABSOLUTE for use in external page
+  for (var i = 0; i < entries.length; i++) {
+    //alert("debug ent i:"+i+" e:"+entries[i]+" tit:"+entries[i].title+" //lin:"+entries[i].link);
+    result.feed.entries[i].link="http://www.facebook.com/"+entries[i].link
+  }
   this.results.push(result);

   if (!this.started) {
@@ -375,9 +384,14 @@
   this.clearNode_(el);
   var link = document.createElement('a');
   link.target = google.feeds.LINK_TARGET_BLANK;
-  link.href = resultFeed.link;
+  // SET The URL the feed title links to (was http://www.facebook.com, we wish to link to facebook/ourgroup)
+  if (this.options.titleurl == null) {
+    this.options.titleurl = resultFeed.link;
+  }
+  link.href = this.options.titleurl;
   link.className = 'gfg-collapse-href';
   link.innerHTML = resultFeed.title;
+//alert("debug title link:"+link+"  link.href:"+link.href);
   el.appendChild(link);
 }

@@ -408,10 +422,13 @@
     var className = 'gfg-listentry ';
     className += (i%2)?'gfg-listentry-even':'gfg-listentry-odd';
     var listEntry = this.createDiv_(className);
-alert("debug entry create link:"+entries[i].link+"  title:"+entries[i].title);
-    var link = this.createLink_("http://www.facebook.com/"+entries[i].link,
+//alert("debug entry create link:"+entries[i].link+"  title:"+entries[i].title);
+    // adjusting the link URL here (from relative to absolute) worked for list elements but not selected item
+    //entries[i].link="http://www.facebook.com/"+entries[i].link
+    var link = this.createLink_(entries[i].link,
                                 entries[i].title,
                                 this.options.linkTarget);
+
     listEntry.appendChild(link);
     if (this.options.pauseOnHover) {
       listEntry.onmouseover = this.bind_(this.listMouseOver_, resultIndex, i);


Javascript debugger (Venkmann+Firefox) a bit crashy, hence the old alert("") style debugging.


One thing to do to change this from hack to good solution would be detect relative URLs (look for beginning which is not http:// or file:// ...) and do the right thing.




Surprised grepping internet to not find people finding this problem ... ?

Sunday, 4 January 2009

facebook

So _anyway_.

I had to, you see John's in Australia and posting news to facebook.

Actually I'm impressed. Good one-stop-show/compilation of blog/pictures/urls/messages.
Fast site. And very featureful. But simple in the important places.
I was tickled when sending a message to John as part of a Christmas present - tickets to a Peter Pan show in Sydney, I included urls for the theatre venue and group. And facebook picked a bunch of images from those urls to use as iconof the message. perfect! snazzy. nice.
Here is me on there (if'n ye can see): http://www.facebook.com/profile.php?id=1118555017

Signed up on it (facebook) just before Christmas.
Ex-colleagues and long lost friends and current friends are added to a snowball/mini-avalanche rythm.
Theatre group (Glencullen Musical and Dramatic society) friends appeared today.
*Friend* *Friend* *Friend* *Friend* *Friend*
Uohhh I feel so loved!
Got lots of the components of an effective drug! Oerrr.

Incidentially went to Tallaght to do some singing for Jack and the Beanstalk in rehersal.
Motorbiked out and collected Fionnuala's phone which was rescued from somewhere up three rock on the way.
Very very little singing done. Bits and pieces mostly in Act 1.
Panto looks like loads of fun. Quite messy yet though! It starts Friday. eek! :)
http://homepage.eircom.net/~blynchehaun/ttg.html
http://www.dublintourist.com/details/tallaght_theatre_group.shtml
Tom posted a pantomime script resource:
http://www.lazybeescripts.co.uk/Pantomimes/Index.htm