[Project_owners] Using Livefeed RSS aggregator

HJ bugus at universum.org
Wed Jan 5 09:04:46 EST 2005


josh zeidner wrote:
> Hello Mozilla people,
> 
>   I want to use the RSS aggregation code from the
> Livefeed feature on Firefox 1.0.  Where do go to get
> information on this?  Are there any other good Firefox
> development lists?  Does anyone know anything about
> this?  I want to reuse the GUI functionality for a
> livefeed elsewhere( not really as a bookmark ).  Any
> information would be very useful.
> 
>   Thanks, Joshua Zeidner

Joshua,

I always do some research when new features are introduced, but I didn't 
do this
(yet) for LiveMarks, but now I did. The following block of information 
is what I found
so far.

FYI: LiveMarks UI/FE won't work with in The Mozilla Suite (.cpp patches 
required)

I hope this help, but feel free to contact me, per e-mail, any time ;)

/HJ

http://lxr.mozilla.org/aviarybranch/source/browser/base/content/browser.js#112
112     updatePageLivemarks();

http://lxr.mozilla.org/aviarybranch/source/browser/base/content/browser.js#618
618   gBrowser.addEventListener("DOMLinkAdded", livemarkOnLinkAdded, false);

http://lxr.mozilla.org/aviarybranch/source/browser/base/content/browser.js#3068
3068     setTimeout(function () { updatePageLivemarks(); }, 0);

http://lxr.mozilla.org/aviarybranch/source/browser/base/content/browser.js#5364
5364 function livemarkOnLinkAdded(event)
5365 {
5366   if (!gLivemarksButton)
5367     gLivemarksButton = document.getElementById("livemark-button");
5368
5369   // from tabbrowser.xml
5370   // mechanism for reading properties of the underlying XPCOM object
5371   // (ignoring potential getters/setters added by malicious content)
5372   var safeGetProperty = function(obj, propname) {
5373     return Components.lookupMethod(obj, propname).call(obj);
5374   }
5375
5376   var erel = event.target.rel;
5377   var etype = event.target.type;
5378   var etitle = event.target.title;
5379
5380   // this is a blogger post service URL; so skip it
5381   if (erel && erel == "service.post")
5382     return;
5383
5384   if (etype == "application/rss+xml" ||
5385       etype == "application/atom+xml" ||
5386       etype == "application/x.atom+xml" ||
5387       etitle.indexOf("RSS") != -1 ||
5388       etitle.indexOf("Atom") != -1 ||
5389       etitle.indexOf("rss") != -1)
5390   {
5391     const targetDoc = safeGetProperty(event.target, "ownerDocument");
5392
5393     // find which tab this is for, and set the attribute on the browser
5394     // should there be a getTabForDocument method on tabbedbrowser?
5395     var browserForLink = null;
5396     if (gBrowser.mTabbedMode) {
5397       var browserIndex = 
gBrowser.getBrowserIndexForDocument(targetDoc);
5398       if (browserIndex == -1)
5399         return;
5400       browserForLink = gBrowser.getBrowserAtIndex(browserIndex);
5401     } else if (gBrowser.mCurrentBrowser.contentDocument == targetDoc) {
5402       browserForLink = gBrowser.mCurrentBrowser;
5403     }
5404
5405     if (!browserForLink) {
5406       // ??? this really shouldn't happen..
5407       return;
5408     }
5409
5410     var livemarkLinks = [];
5411     if (browserForLink.livemarkLinks != null) {
5412       livemarkLinks = browserForLink.livemarkLinks;
5413     }
5414
5415     var wrapper = new XPCNativeWrapper(event.target, "href", 
"type", "title");
5416
5417     livemarkLinks.push({ href: wrapper.href,
5418                          type: wrapper.type,
5419                         title: wrapper.title});
5420
5421     browserForLink.livemarkLinks = livemarkLinks;
5422     if (browserForLink == gBrowser || browserForLink == 
gBrowser.mCurrentBrowser)
5423       gLivemarksButton.setAttribute("livemarks", "true");
5424   }
5425 }

http://lxr.mozilla.org/aviarybranch/source/browser/base/content/browser.js#5427
5427 // this is called both from onload and also whenever the user
5428 // switches tabs; we update whether we show or hide the livemark
5429 // button based on whether the window has livemarks set.
5430 function updatePageLivemarks()
5431 {
5432   if (!gLivemarksButton)
5433     gLivemarksButton = document.getElementById("livemark-button");
5434
5435   var livemarkLinks = gBrowser.mCurrentBrowser.livemarkLinks;
5436   if (!livemarkLinks || livemarkLinks.length == 0) {
5437     gLivemarksButton.removeAttribute("livemarks");
5438     gLivemarksButton.setAttribute("tooltiptext", 
gNavigatorBundle.getString("livemarkNoLivemarksTooltip"));
5439   } else {
5440     gLivemarksButton.setAttribute("livemarks", "true");
5441     gLivemarksButton.setAttribute("tooltiptext", 
gNavigatorBundle.getString("livemarkHasLivemarksTooltip"));
5442   }
5443 }

http://lxr.mozilla.org/aviarybranch/source/browser/base/content/browser.js#5445
5445 function livemarkFillPopup(menuPopup)
5446 {
5447   var livemarkLinks = gBrowser.mCurrentBrowser.livemarkLinks;
5448   if (livemarkLinks == null) {
5449     // XXX hack -- menu opening depends on setting of an "open"
5450     // attribute, and the menu refuses to open if that attribute is
5451     // set (because it thinks it's already open).  onpopupshowing gets
5452     // called after the attribute is unset, and it doesn't get unset
5453     // if we return false.  so we unset it here; otherwise, the menu
5454     // refuses to work past this point.
5455     menuPopup.parentNode.removeAttribute("open");
5456     return false;
5457   }
5458
5459   while (menuPopup.firstChild) {
5460     menuPopup.removeChild(menuPopup.firstChild);
5461   }
5462
5463   for (var i = 0; i < livemarkLinks.length; i++) {
5464     var markinfo = livemarkLinks[i];
5465
5466     var menuItem = document.createElement("menuitem");
5467     var baseTitle = markinfo.title || markinfo.href;
5468     var labelStr = 
gNavigatorBundle.getFormattedString("livemarkSubscribeTo", [baseTitle]);
5469     menuItem.setAttribute("label", labelStr);
5470     menuItem.setAttribute("data", markinfo.href);
5471     menuItem.setAttribute("tooltiptext", markinfo.href);
5472     menuPopup.appendChild(menuItem);
5473   }
5474
5475   return true;
5476 }

http://lxr.mozilla.org/aviarybranch/source/browser/base/content/browser.js#5478
5478 function livemarkAddMark(wincontent, data) {
5479   var title = wincontent.document.title;
5480   BookmarksUtils.addLivemark(wincontent.document.baseURI, data, title);
5481 }

http://lxr.mozilla.org/aviarybranch/source/browser/base/content/browser.xul#448
447     <statusbarpanel id="livemark-button" type="menu" 
class="statusbarpanel-menu-iconic" chromedir="&locale.dir;">
448       <menupopup onpopupshowing="return livemarkFillPopup(this);"
449                  oncommand="livemarkAddMark(window._content, 
event.target.getAttribute('data'));" />
450     </statusbarpanel>

http://lxr.mozilla.org/aviarybranch/source/browser/locales/en-US/chrome/browser/browser.properties#79
  79 livemarkHasLivemarksTooltip=Add Live Bookmark for this page's feed
  80 livemarkNoLivemarksTooltip=Page has no feeds for Live Bookmark
  81 livemarkSubscribeTo=Subscribe to '%S'...

http://lxr.mozilla.org/aviarybranch/source/browser/locales/en-US/chrome/browser/bookmarks/bookmarks.dtd#35
  35 <!ENTITY menuitem.newLivemark.label    "New Live Bookmark...">
  36 <!ENTITY menuitem.newLivemark.accesskey "L">

http://lxr.mozilla.org/aviarybranch/source/browser/components/bookmarks/content/bookmarksTree.xml#983
983           <rule rdf:type="http://home.netscape.com/NC-rdf#Livemark">
984             <treechildren>
985               <treeitem uri="rdf:*">
986                 <treerow 
properties="rdf:http://www.w3.org/1999/02/22-rdf-syntax-ns#type 
rdf:http://home.netscape.com/NC-rdf#loading 
rdf:http://home.netscape.com/WEB-rdf#status">
987                   <treecell 
label="rdf:http://home.netscape.com/NC-rdf#Name" />
988                 </treerow>
989               </treeitem>
990             </treechildren>
991           </rule>



More information about the Project_owners mailing list