Main Stories
Slash Boxes

Slash Open Source Project

Slashcode Log In

Log In

[ Create a new account ]

Mozilla sidebar

posted by Krow on 02:20 PM October 18th, 2002   Printer-friendly   Email story

I've built something that I think was sorely lacking on Slashdot: a Mozilla sidebar. It's pretty cool, if I may toot my own horn:

http://r2d2.easydns.com/~cmv/slashdot/

The headlines and info comes from the XML feed. The icons are grabbed from Slashdot as needed, resized, PNG-ed, and stored locally.

Now, the sidebar is *NOT* available to the entire world, so don't go posting that URL everywhere (I've taken off the link to load the sidebar). That server isn't designed to handle huge loads.

However, I've had an email convo with Rob Malda where I said I'm happy to share the source code so that Slashdot could provide this service directly from their site.

His response was:

If you ported that to Slashcode (www.slashcode.com) I'm almost certain it would be live on Slashdot a week or 2 later. The only thing you'd have to make certain is that the page itself was a static piece of HTML and regenerated every 30 minutes, so millions of sidebar loads wouldn't kill us.

Very cool tho. I've seen several attempts to make a good sidebar, but thats the first that looks good.

So ... that's why I'm posting here. I don't know the first thing about slashcode. My code is written using PHP to parse the XML feed and format the output, with a few calls to the ppm image functions to resize the icons.

Is there somebody here who would be interested in helping me port my code to slashcode? I suppose, once it is ported, it would be an additional server for not only Slashdot, but any site that uses the same code ... which is pretty cool.

Comments?

This discussion has been archived. No new comments can be posted.
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login
Loading... please wait.
  • Based on your description, it sounds like what you've got could be generalized to generate a side-bar based on any RDF feed (allthough maybe not ... I'm not sure where you're getting the comment counts, or topic/image -- since those aren't in the feed [slashdot.org])

    "Porting to slashcode" would be very easy ... make it a command line perl script that can read the RDF file from disk, and write out a file in whatever format the side-bars are in, and it can be run as a regular "task"

    As for getting people to help you rewrite it in perl, the folks over at PerlMonks [perlmonks.org] could probably lend a hand. If you submit a post that:

    1. Explains what you are trying to do.
    2. Includes whatever code you allready have (preferably perl, but if you've got PHP post that).
    3. Points out that it could be used on any RDF feed (assuming i'm right about that)
    ...then you'll probably get all sorts of advice on where to start, and what perl libraries will match up most closely to whatever PHP libraries you used.
    • The comment counts and topic/image are in the XML feed, which is what I'm using. Do most slashcode sites provide XML feeds, or just RDF?
    • Based on your description, it sounds like what you've got could be generalized to generate a side-bar based on any RDF feed (allthough maybe not ... I'm not sure where you're getting the comment counts, or topic/image -- since those aren't in the feed)

      Not in the RDF feed to which you linked, but in the sitename.xml file. If you look at http://slashdot.org/slashdot.xml:

      <story>
      <title>Pioneer DVR-A05 Review</title>
      <url>http://slashdot.org/article.pl?sid=02/10/21/0 38210</url>
      <time>2002-10-21 12:47:56</time>
      <author>Hemos</author>
      <department>learning-'bout-it</department>
      <topic>137</topic>
      <comments>28</comments>
      <section>articles</section>
      <image>topichardware.gif</image>
      </story>

      The comment count as well as topic and image are listed. There's no absolute URL for the image, but with a Slash-based site, you could probably assume domain/images/topics/.

      I don't see why the "sidebar" functionality couldn't be placed in a standalone script. If all you're doing is interpreting the XML and resizing images, you could just code a quickie script to run out of cron. Or perhaps make it a task for slashd, maybe after new XML/RSS/RDF files are written.

      After seeing this post during the weekend, I coded up a quickie CGI [perldude.org] to take any slash-style XML feed and whip it into the format in Greedo's sample image. The whole thing is highly inefficient, as no images are cached locally, but it was just more of a POC for myself. Obviously, this would be a cool addition to Slashcode itself (or the slashd process), but it can be easily made into a server-side cron job or a standalone cgi/php page.

      Apologies, Greedo, if I've violated any copylefts ;)

      --

      --
      Kill-HUP.com [kill-hup.com], proudly running Slash since 1/28/2002.

      • I've also learned that some images just don't scale well with Image::Magick, on the fly ;)

        Guess I'll have to revisit some of Kill-HUP's topic icons...

        --

        --
        Kill-HUP.com [kill-hup.com], proudly running Slash since 1/28/2002.

      • Looks nice, except for those resized images. :) I used the pnm shell functions to do my resizing, not Imagemagik. Although it looks like you just forgot to convert the GIF to a 24-bit colour image before resizing.

        Anyway, my goal (I think) was to make this part of the slashcode code, so that sites that use slash will have automatically generated XML, RSS, RDF and now Moz sidebar feeds. Basically, make the flat HTML file at the same time the other feeds are made (and cache the images locally of course).

        Looks like your CGI is a great start ... just tweak the CSS a bit, make the table 100% width, ... :)
        • Oops, forgot about the GIF conversion. Makes all the difference in the world ;)

          I did manage to get it down to a task capable of running under slashd. I opted to make it a separate task, as not to clutter the open_backend util. Makes it a great add-in, even for sites running "older" slash versions who aren't looking to upgrade.

          If I get a chance to clean up the code a bit more, I'll be sure to post something.

          --

          --
          Kill-HUP.com [kill-hup.com], proudly running Slash since 1/28/2002.

  • We've done it for a slash 1.0.9 site, here's the sidebar [symlink.ch].

    You can tell from the filename that we just changed the code for ultramode.txt (which wrote out a preliminary version of an rss feed) and added some html tags for the sidebar. All story information was already in the DB query for ultramode.txt. Our /ultramode.html is in fact just a symbolic link to /ultramode.txt [symlink.ch].

    So all that needs to be done is find the place where the rss file is written, and edit it to write out the sidebar file contents in HTML

    --

    --
    symlink.ch [symlink.ch]: YAGSS - yet another German slash si

  • I wouldn't mind taking a stab at the port,
    or at the very least giving you whatever
    assistance you might need to assist you
    with a port.

    Email me: cliff at slashdot dot org.

    :D

  • For those who are interested in porting this to slashcode, you can see the PHP source code of the files required here:

    File used to add sidebar to Mozilla (just javascript code):
            http://r2d2.easydns.com/~cmv/slashdot/add.phps

    Outer HTML page:
            http://r2d2.easydns.com/~cmv/slashdot/sidebar.phps

    Inner HTML page (does all the XML stuff):
            http://r2d2.easydns.com/~cmv/slashdot/sidebar-inne r.phps

    Image manipulation function:
            http://r2d2.easydns.com/~cmv/slashdot/img_manip.ph ps

    Stylesheet
            http://r2d2.easydns.com/~cmv/slashdot/style-sideba r.css

    The 4 pages that make up the actual sidebar could probably be reduced to 2 (inner and outer HTML), maybe even 1, since the goal would be to have a server side script to all the parsing and output to a flat HTML file every 15 minutes or so ... or at the same time the RDF/XML feeds are generated. Oh, and store the resized images locally.

    Anyway, let me know what more I can do to help! An "official" Slashdot Mozilla Sidebar would be doubleplusgood. :)
    • I've changed it so that the side bar is only one file, instead of an inner, outer and css file. Source is:

      http://r2d2.easydns.com/~cmv/slashdot/mozbar.php s
  • I've been playing with this idea ever since I saw Greedo's post on Saturday and think I've got a fairly stable test "task" for slashd. There is still room for work, but this is a good start. I've bitten the bullet and have gone "live" with this on Kill-HUP.com, so I'm willing to say it's fairly reliable ;) I've tested it on 2.2.5, 2.2.6 and a few CVS R_2_3_0_x candidates (all Linux), so other release tests would be helpful.

    Anyone interested in taking a peek can visit the project page I've set up [perldude.org] and feel

    --

    --
    Kill-HUP.com [kill-hup.com], proudly running Slash since 1/28/2002.

    • If anyone's interested, I cleaned up the code a bit, (thanks to slashstyle.pod) and applied some changes to the look suggested by Colin. I've also some version info to track changes like a real project would ;) All in all, I think it's coming together nicely.

      Of course, that's just one geek's opinion ;)

      Feel free to check out the code [perldude.org] or take a look at the bar in action [kill-hup.com].

      --

      --
      Kill-HUP.com [kill-hup.com], proudly running Slash since 1/28/2002.