Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Free Nodelet Hack: 'Newest Nodes' Menubar

by jdporter (Canon)
on Feb 24, 2006 at 16:43 UTC ( #532596=note: print w/ replies, xml ) Need Help??


in reply to Free Nodelet freed

The Free Nodelet can have javascript in it. This can be used to modify how your PerlMonks pages appear and behave. Also, the Free Nodelet, unlike any other nodelets or node, is allowed to have virtually any HTML in it. (This is because no matter what nasty code you might put in your Free Nodelet, the only person it affects is you. :-)

I've taken advantage of this freedom to display a condensed list of "newest nodes" links across the top of every PerlMonks page. Here is a screenshot (126kb) of my PerlMonks experience.

The links themselves come from the RSS feeds at prlmnks.org, filtered through a CGI script I wrote which converts the RSS XML to HTML. My script takes several parameters which control the HTML generation.

I embed this small fragment of HTML in my PerlMonks web page using <iframe...>. You don't see the iframe border in the screenshot, because I've set its frameBorder attribute to 0. You'll notice that some of the page style (css) propagates into the iframe, but not all.

In order to place the iframe in the exact web page location I desire, I use javascript running in the Free Nodelet.

So — if you'd just like to include a list like this in your Free Nodelet and skip the javascript part, simply go to Free Nodelet Settings and insert the following code in the HTML textarea:

<iframe width="400" height=240 src="http://jdporter.perlmonk.org/pmrss +.cgi?feeds=top&max=12"> </iframe>
This will put a 'newest nodes' link list in your Free Nodelet. (Of course, you'll want to have your Free Nodelet enabled in Nodelet Settings.)

In the example above, 'top' is the name of the feed. Here is the list of available feeds:

	top	all	cufp	note	poem	user	snippet
	perlnews	usergroup	perlquestion
	bookreview	qandasection	obfuscated
	sourcecode	scratchpad	monkdiscuss
	perltutorial	perlmeditation	categorized_question
(This is similar to, but not quite the same as, the list for the Newest Nodes XML Ticker.)
You can actually have more than one feed in the output listing — simply give more than one feed name, separated by commas. For example, pmrss.cgi?feeds=perlquestion,perlmeditation,monkdiscuss&max=12
You can also override the link count maximum on a feed-by-feed basis: put a number after the feed name, separated by a colon. For example, pmrss.cgi?feeds=perlmeditation,monkdiscuss:4&max=12
If you leave off the max= parameter, the limit used by prlmnks.org in its rss feeds will apply. I don't know what that limit might be, but the list of links is never very long.

Now — if you'd like to duplicate what I've done, as shown in the screenshot above, you'll want to add code like the following in your Free Nodelet:

function add_nn_iframe() { var tbl = document.getElementById('titlebar-bottom'); var hr = document.createElement('hr'); var tbl2 = document.createElement('table'); var row = document.createElement('tr'); var cel = document.createElement('td'); var ifr = document.createElement('iframe'); tbl2.width = "100%"; ifr.src = "http://jdporter.perlmonk.org/pmrss.cgi?feed=monkdiscuss +:4,snippet&max=8"; ifr.width = "100%"; ifr.height = 64; ifr.border = 0; ifr.frameBorder = 0; ifr.margin = 0; cel.width = "100%"; cel.align = "center"; cel.appendChild(ifr); row.appendChild(cel); tbl2.appendChild(row); tbl.parentNode.insertBefore(hr,tbl.nextSibling); tbl.parentNode.insertBefore(tbl2,hr); } add_nn_iframe();

Also note the image I've embedded in my Free Nodelet. ;-)

We're building the house of the future together.









(<script type="text/javascript"> stuff I'm storing here temporarily</script>)


Comment on Free Nodelet Hack: 'Newest Nodes' Menubar
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://532596]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2014-09-02 04:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (20 votes), past polls