Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

The Perl Monks Scrolls

by Solo (Deacon)
on Feb 16, 2003 at 04:00 UTC ( #235669=monkdiscuss: print w/ replies, xml ) Need Help??

Update: I have discontinued my account with this ISP and the URL is unavailable.

Waiting for Newest Nodes to refresh has been killing me lately, and seeing Jaap's discussion about mirroring or proxies, I got the itch to try something.

I called it 'The Perl Monks Scrolls' and the first iteration can be found at http://www288.pair.com/mhicks/pmScrolls/.

It's a quick-n-dirty frameset around a newest-nodes XML grab w/ XSLT and PM. Links from the PM Scrolls frame target the PM frame, so it's a little like a newest nodes navigation bar. An hourly cron job rebuilds the Scroll. Code follows. XSLT available upon request ;)

use LWP::UserAgent; use XML::LibXML; use XML::LibXSLT; my $parser = XML::LibXML->new(); my $xslt = XML::LibXSLT->new(); my $source = $parser->parse_string( getURL( "http://www.perlmonks.org/index.pl?node=Newest%20Nodes%20XML%20Genera +tor;days=0.5" )); my $style_doc = $parser->parse_file('/usr/home/mhicks/pmScrolls/pm_new +est.xsl'); my $stylesheet = $xslt->parse_stylesheet($style_doc); my $results = $stylesheet->transform($source); print $stylesheet->output_string($results); sub getURL { my $url = shift; my $request = HTTP::Request->new(GET => $url); my $ua = LWP::UserAgent->new; my $response = $ua->request($request); return $response->content(); }
Opinions, insights, complaints, foolish-mortal mistakes, etc?

--Solo

--
There's no mystical energy field that controls my destiny. It's all a lot of simple tricks and nonsense.

Comment on The Perl Monks Scrolls
Download Code
Re: The Perl Monks Scrolls
by hossman (Prior) on Feb 16, 2003 at 07:19 UTC
Re: The Perl Monks Scrolls
by Solo (Deacon) on Feb 16, 2003 at 15:44 UTC
    Well, I can't figure out how to edit my root node, so here's a reply with the XSLT file.

    <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Tr +ansform"> <xsl:output method="html" /> <xsl:template match="/"> <html> <head> <style> body { font-family:Verdana,Arial,Helvetica,sans-serif; } a:link, a:visited { text-decoration: none; } a:hover { text-decoration: underline; } .node_name { font-size: x-small } .parent_node { font-size: xx-small } .root_node { font-size: xx-small } </style> </head> <body> <xsl:variable name="date" select="//INFO/@lastchecked" /> Perl Monks Scroll <span style="font-size: xx-small">created at <xsl:value-of select="substring($date,9,2)" /> : <xsl:value-of select="substring($date,11,2)" /> (in a TZ far, far away)</span> <p /> <xsl:apply-templates select="//NODE" /> </body> </html> </xsl:template> <xsl:template match="NODE"> <span class="node_name"> <a href="http://www.perlmonks.org/index.pl?node_id={@node_id} +" target="perlmonks"> <xsl:value-of select="." /> </a> </span> <xsl:if test="@parent_node"> <span class="parent_node"> <a href="http://www.perlmonks.org/index.pl?node_id={@paren +t_node}" target="perlmonks">[parent]</a> </span> </xsl:if> <xsl:if test="@root_node"> <span class="root_node"> <a href="http://www.perlmonks.org/index.pl?node_id={@root_ +node}" target="perlmonks">[root]</a> </span> </xsl:if> <p /> </xsl:template> </xsl:stylesheet>
    --Solo
Re: The Perl Monks Scrolls
by Jaap (Curate) on Feb 17, 2003 at 23:21 UTC
    That's pretty slick, solo. You could also make the links point to the mirror ;)

    But you say you keep waiting for the newsest nodes to refresh and now the refresh rate is refreshed every hour?
      How about I add a {mirror} link that goes to the mirrored root node? I'll work on that tonight.

      By waiting for newest nodes, I mean reloading the newest nodes page and then getting a cup of coffee. During peak hours the wait can be 1-2 minutes! So I decided to sacrifice up-to-the-minute nodes for 1-2 second loading of the scroll.

      On the technical side, my ISP's policy restricts cron jobs to once an hour at most. And part of the idea is to examine ways to reduce load on PM, so building the scroll on-the-fly is out of the question.

      I also find that the links to parent and root nodes save me a TON of time.

      --
      Bring them on! I prefer a straight fight to all this sneaking around.

Re: The Perl Monks Scrolls
by pfaut (Priest) on Feb 17, 2003 at 23:29 UTC

    I've been working on one of these myself. Mine uses a slightly modified PerlMonksTickers (see Automate your Perlmonks Activities), presents a threaded view sorted by section, and saves node information in a local database so that it can build the threads without beating up on the PerlMonks servers. I'm still working out a couple of kinks but I've been using it all day without any problems. You can try it out at http://nbpfaus.net/~pfau/PM.pl. There's some instructions at http://nbpfaus.net/~pfau/PerlMonksTools.html.

    --- print map { my ($m)=1<<hex($_)&11?' ':''; $m.=substr('AHJPacehklnorstu',hex($_),1) } split //,'2fde0abe76c36c914586c';
      I like it! It's a little unfortunate about the additional logon, but it's required for the "I've seen all these" function.

      I wonder if that functionality is necessary, though?

      Personally, I don't expect to get through every node anymore. I'd like search and filter capability on newest nodes. Getting to every post is probably more important to those who need to review/approve/edit nodes, though.

        I just put up another version that doesn't require a login. It will give you the last day's worth of nodes when you connect and saves the time in a hidden field. When you press "I've seen these", it will show nodes created since the last update. Try it at http://nbpfaus.net/~pfau/PM2.html.

        --- print map { my ($m)=1<<hex($_)&11?' ':''; $m.=substr('AHJPacehklnorstu',hex($_),1) } split //,'2fde0abe76c36c914586c';

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: monkdiscuss [id://235669]
Approved by pfaut
Front-paged by gmax
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (11)
As of 2014-12-22 13:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (117 votes), past polls