Tải bản đầy đủ - 0 (trang)
Hack 35. Track Your Favorite Sites with RSS

Hack 35. Track Your Favorite Sites with RSS

Tải bản đầy đủ - 0trang

RSSstandsfor"reallysimplesyndication"or"richsite

summary,"dependingonwhoyouask.What'simportantisthat

RSSisastandardXMLformatforsharingheadlinesandnews

summariesacrosswebsites.Justasawebpageisformatted

fordisplayinawebbrowser,RSSfeedsareformattedfor

displayinnewsreaderslikeMyYahoo!.

Everyonefromanindividualinhisbasementwritingaweblogto

alargemediagiantliketheNewYorkTimescanpublishRSSto

beusedwithservicessuchasMyYahoo!Knowingthisallows

youtobringinmorenewssourcesthanthestandardchoices

Yahoo!providesautomatically.



2.14.1.FindingRSSFeeds



KeepinmindthatnoteverynewssourceouttherehasanRSS

feed.Andthosethatdodon'talwaysmaketheRSSfeedeasyto

find.PartoftheskillofaddingcontenttoMyYahoo!isbeing

abletofindtheRSSfeedsyoucareabout.Thekeytothe

processisfindingthefeedURLsoyoucancopyandpasteit

intoaformatMyYahoo!.Likeanaddressonahouse,afeed

URLtellsserviceslikeMyYahoo!wheretofindupdated

information.HerearesometipsforspottingfeedURLs.



2.14.1.1.Gotothesource.

ThefirstplacetolookforfeedURLsisatyourfavoriteweb

sites.MostsitesthatofferanRSSfeedwillhaveanorange

imagewithwhitelettersthatsay"XML"or"FindingRSSFeeds."

Figure2-34showsanumberofvariationsyoumightseeonthe

frontpageofawebsite.



Figure2-34.Variationsonthewhite-on-orange

XMLtheme



Ninetimesoutoften,thisimagewilllinktosite'sfeedURL



RememberthatRSSisanXMLformat,whichiswhythetermsareused

interchangeablyintheimages.



TocopythefeedURL,right-clicktheiconandchooseCopyLink

Location(orCopyShortcutinInternetExplorer)fromthemenu.



Atthispoint,thefeedURLwillbeavailableonyourvirtual

clipboard,readytopasteintoMyYahoo!



2.14.1.2.Lookforauto-discovery.

Evensitesthatdon'tincludeanorange-and-whiteXMLicon

mightleavecluesabouttheRSSfeedURLintheirsourceHTML.

Tosolvetheproblemoffindingfeeds,astandardcalledRSS

auto-discoveryhasemerged.Sitesthatwanttomakeiteasy

forpeopletofindtheirfeedURLcanincludeaspecialHTMLtag

inthesourceoftheirpagestoletapplicationssuchasweb

browsersfindtheirfeedURL.Oncebrowsersare"aware"of

auto-discoveryandlookingfortheauto-discoverytag,theycan

lettheuserknowwhenthey'vespottedanRSSfeedURLina

webpage.Firefoxletsusersknowbydisplayinganorangeicon

inthelower-rightcornerofthebrowserwindow,asshownin

Figure2-35.

EventhoughSFgate.comdoesn'thaveanorangeXMLiconora

linktoitsRSSfeedonthehomepage,onceyouspotthis

orangeRSSfeedindicator,youcanuseFirefox'sViewSource

featuretofindtheauto-discoveryHTMLtagthatholdsthefeed

URL.Toviewthesourceofanywebpage,chooseView Page

Sourcefromthebrowser'stopmenu.Findingthetagcanbe

tricky,butitisalwayslocatedtowardthetopoftheHTMLpage,

betweentheopeningandclosingtags.For

example,theSFGate.compageinFigure2-35hasthefollowing

auto-discoverytaginitsHTMLsource:








type="application/rss+xml"title="SFGate:TopNewsStor



NotetheURLcontainedintheHRefelement.Thisisthesite's

RSSfeedURL,readyforcopyingandpastingintoMyYahoo!.



LikeFirefox,theYahoo!Toolbarisalsosmartenoughto

recognizethistaginpagesyouvisit.Ifyouhavethetoolbar

installedandbrowseasitewiththeRSSauto-discoverytag,

you'llfindthatablue"AddtoMyYahoo!"buttonwithaplus

signliketheoneshowninFigure2-36willappearonthetoolbar.

Insteadofrootingaroundinasite'sHTMLtofindtheURL,you'll

beabletosimplyclickthebuttontoaddthesitetoyourlistof

newssources.



Figure2-35.FirefoxwiththeorangeRSSfeed

indicatorinthelower-rightcorner



Figure2-36.TheYahoo!toolbarwithablue"Add

toMyYahoo!"button



2.14.2.AddingtoMyYahoo!

OnceyouhavethefeedURLofthenewssourcecopiedtoyour

virtualclipboard,headtoMyYahoo!andlogin.Fromthere,

clicktheAddContentlinktowardthetopofthepage.Onthe

AddContentpage,clickthe"AddRSSbyURL"linkshownin

Figure2-37.

TheRSSAddpagecontainsasingleformfield,whereyoucan

pastethefeedURLyou'vebeensavinginyourclipboardwith

Ctrl-V.ClickingAddwillletyoupreviewthefeedsothatyoucan

makesureit'swhatyouwant.Figure2-38showsthe

SFGate.comfeedpreview.

IfyoucomparethepreviewinFigure2-38withthewebpagein

Figure2-35,you'llseethattheheadlinesarethesame.And

finally,theAddbuttonwiththeblueplussignwillfinishthe

workofaddingthefeed.Fromthatpointon,you'llfindthe

newssourceonyourMyYahoo!page,asshowninFigure2-39.



Figure2-37."AddRSSbyURL"linkatMyYahoo!



Figure2-38.SFGate.comRSSfeedpreviewatMy

Yahoo!



Figure2-39.SFGate.cominMyYahoo!



Nowthatyouknowthecomplexwaytoaddoutsidesourcesto

MyYahoo!,you'llbehappytoknowthere'saneasierway.The

entirecopyandpasteprocesscanbeshortenedtooneclickat

sitesthatsupportthe"AddtoMyYahoo!"buttonshownin

Figure2-40.



Figure2-40.The"AddtoMyYahoo!"buttonfound

atsomesites



NoteverysitewithanRSSfeedincludesthe"AddtoMyYahoo!"

button,butasRSSfeedsbecomemoreandmorepopularandas

MyYahoo!becomesknownasaplacetoconsumeRSSyou

mightseeitpoppingupatmoreofthesitesyouvisit.Whenyou

spotone,clickit,andyou'llgodirectlytothepreviewpagefor

thatfeedatMyYahoo!

TakingthetimetoaddyourfavoritesitestoMyYahoo!willlet

youkeepupwithmanymoresitesthanyou'dbeabletoby

visitingeachsiteindividually.Notonlywillyoubereading

informationthat'smorerelevanttoyou,you'llbereadingit

moreefficientlywhenit'supdated,andalongsidetherestof

yourfavorites.



Hack36.AddaFeedtoMyYahoo!withaRightClick



SpeedupthetimeittakestoaddRSSfeedstoMyYahoo!

withInternetExplorer.

AddinganRSSfeedtoMyYahoo!isn'tacomplexprocess,butit

doesinvolvesomecopying,pasting,clicking,andgenerally

breakingoutoftheflowofreadingasite.Withabitofbrowser

hacking,youcanreducethefrictionofaddingsitestoMy

Yahoo!byaddingacontextmenuentry.

Acontextmenuisthemenuthatpopsupwhenyouright-click

anelementonawebpage(orCtrl-clickitonaMac).The

contextpartofitsnamereferstothefactthatdifferentchoices

appearindifferentsituations.Forexample,whenyouright-click

alink,youhavetheoptionsto"OpenLinkinNewWindow,"

CopyLinkLocation,BookmarkThisLink,andothers.Inanother

context,suchaswhenclickinganimageorclickinghighlighted

text,youhavedifferentchoicesinthemenu.

Ifyou'vebeenreadingpersonalweblogsforawhile,you've

probablyseenmanyvariationsofthewhite-on-orangeXML

buttonsthatindicatealinktoanRSSfeed,andifnotyoucan

findsomeexamples[Hack#35]inthisbook.

Wouldn'titbegreatifyoucouldright-clickoneofthesebuttons

andhavetheoptionto"AddtoMyYahoo!"?Thatwouldsave

youquiteafewsteps,andyouwouldn'thavetobreakfromthe

siteyou'recurrentlyreadingtoaddthefeed.Thishackshows

howtoaddthiscontextmenuentryinInternetExplorer.



2.15.1.TheCode

Muchlikeabookmarklet[Hack#28],anyJavaScriptthatruns

viaacontextmenuentryhasaccesstothepagecurrently

loadedinthebrowser.Thatmeansthatwhenyouclickthe

contextmenuentryyou'veadded,thebrowserexecutesascript

thattakessomeactionusinginformationfromthecurrentpage.

Inthiscase,theactionisgrabbingtheURLlinkedfromthe

currentlyclickedimage,constructingaspecialMyYahoo!URL

thatincludesthefeedURL,andopeningthenewURLinanew

browserwindow.

SavethefollowingcodetoafilecalledAddToMyYahoo.html:









varaddURL=newString("http://add.my.yahoo.com/rss?ur









varw=window.external.menuArguments

varurl=w.event.srcElement.parentElement.href;











window.open(addURL+url,null,



"height=455,width=788,status=yes,scrollbars=





Theexternal.menuArgumentsobjectholdsinformationaboutthe

currentdocument,andtheevent.srcElementisthedocumentitem

theuserclicked.GrabbingtheHRefattributeoftheelement's

parentwillgiveyouthelinkURLthatisaroundtheimagetag.

Savethefileinaspotyou'llremember.Forsimplicityinthis

hack,saveittoadirectorycalledc:\scripts\.

Nowthatthescriptisreadytogo,youjustneedtoaddthe

contextmenuentrytoInternetExplorerandtellittorunthis

particularscriptwhenyouclicktheentry.You'llaccomplishthis



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Hack 35. Track Your Favorite Sites with RSS

Tải bản đầy đủ ngay(0 tr)

×