Jason basically rocks at coding

edited July 2023 in Forum Support
Some of you may or may not be aware of the fact that The Orange Belt main page now displays a basic list of the latest comics made from some of the community sites. Until now, the list has been somewhat rudimentary; comic authors make an image that's always at the same URL, update it whenever they update the comic, and I put a static link on theorangebelt.org to their comic's front page. It does the trick, but it lacks a certain flair I originally desired with this project. Ideally I wanted to have the newest comics show up on top, and have the links go directly to the updated comic, wherever that might be.

So I got ahold of Jason and expressed my general desires, and he coded the whole damn thing in a day!

Now we've got a fancy dynamic display of comic RSS feeds (Zelda Comic is the only one that's formatted properly so far, I'll have to chat with Geoff, Steven et al to get them up to snuff) fit for a king. It checks each feed in its list looking for the latest entry that contains an image, so that only your newest comic shows up (and so that the lists isn't cluttered with a single prolific comic, pushing everyone else off the list). It looks like feeds that don't have an image choke the PHP, so I'll add other feeds in once they meet the criteria.

Thanks Jason! You really went above and beyond on this one. And I definitely appreciate your propensity to // comment on everything your code does. Very easy on the eyes.

Comments

  • edited November 2007
    Hurrah!
  • edited November 2007
    Jason is my role model.
  • edited November 2007
    I really need to learn some PHP. It would help at my new job sometimes. Also, comments are good. I usually don't do them unless someone asks me to do so, but then I'll have a comment for nearly every line of code.
  • edited November 2007
    Why not comment your comments?

    //The next line is a comment
    //This line prints "Hello World!"

    Etc.
  • edited November 2007
    No.
  • edited November 2007
    We're talking about Jason here, alright? We're not talking about how we all wish we were one tenth of a percent as awesome as Jason, and then we wouldn't be the lazy slogs that we currently are.

    Jason doesn't wear sunblock. The sun wears Jasonblock.
  • edited November 2007
    He clearly actually does do the sort of things I say I should do and then never get around to doing.
  • edited November 2007
    Jason doesn't wear sunblock. The sun wears Jasonblock.
    Wow, I think I just got a Chuck-Norris-ism.

    Mario, thanks for the heads up on the glitch...my bad for being lazy. (It's actually something that should be solvable with regular expressions. Is it possible that these feeds will have images in them that are in
    <[[[!CDATA
    
    blocks, or images that aren't wrapped in anchor (link) tags? (Your CSS selector suggestion is an excellent idea, too.) Let me know so that I can write something that discriminates.

    Another non-robust issue is the fact that I try to insert the title of the RSS item as the title attribute of the image, but it probably breaks if there's not a space in between the <a href...> and the <img /> ...so I'll fix that as well.

    Might be another day or so, as I have some other stuff to tackle (to put food on the table), but I'll likely get to it tonight.
  • edited November 2007
    There won't be any CDATA sections (I don't use them in general, and I don't think Wordpress' syndication system generates them), and the image will usually just be sitting in the RSS post all by its lonesome (as in, sans <a> anchor). I'm the only one that has the image link to something. The trick is going to be to get it to grab the correct image in the case of multiples; if we don't uniquely identify the image (though I have no problem doing so), perhaps you could have your script look for the first 100x100px image within the <description> field.
  • edited November 2007
    Mario, thanks again for the patience. (After a few more revisions of code, it turned out Mario had to upgrade the server from PHP4 to PHP5 to prevent some bizarro errors from being thrown, so The OB is now on PHP5. Huzzah.)

    (Hamelin, I still haven't forgotten about phpoetry, I swear. Just been super-mega-busy, and it's a slightly larger undertaking than this was.)
  • edited November 2007
    You truly are a king among men! Thanks for making our front page that much more Rockin'!©
  • edited December 2007
    jkirchoff.net is almost completely hidden behind Penny Racers.
  • edited December 2007
    That glitch seems to happen in IE, probably because I have all my images aligned to the right as part of my layout.

    Can Jason make it so it'll strip out any ALIGN tags? I see most of the other ones are aligned to center, and the one from Mario's blog isn't aligned at all.
  • edited December 2007
    Argh. Yes, I'll do what I can to fix that, but it may have to be later this week. Too much other work on my plate (that puts food on the table) right now. Might be able to fix on Mario's side with some CSS declarations... i.e., a css reset on the image tags, then a redeclaration of the desired alignment on the .ob_img class, but CSS usually defers to what is hard coded to the tag first (am I right?). I tried doing some test CSS tweaks with firebug, but didn't have any luck.

    Side rant: align, border, and nearly all of the attributes that you folks (or wordpress?) are throwing into the <img> tag are what Cascading Style Sheets were invented for, people. I know CSS is scary, but seriously, it's been in use for a decade now, people. Even if you don't use CSS-based layouts, a little tweaking of it can be your friend!
    :tmyk:

    And please don't get me started on IE.
    End rant.
  • edited December 2007
    I know, I'm trying to get into CSS nowadays, but sometimes I feel like it's just easier to throw in a quick <img> attribute while typing up a blog entry. I'll try to improve my habits for the sake of ob_img though.
  • edited December 2007
    Alright, I CSS'd up my images, but now they're not displaying in the Orange Belt RSS feed.

    Here's what the latest one looks like, "postimage" is the style to display my images correctly. Are the two classes messing things up? I looked it up and you can use two css classes in an image tag if you separate them by a space.[HTML]<img class="ob_img postimage" src="http://www.jkirchoff.net/image/balrogf.png&quot; />[/HTML]
  • edited December 2007
    Can you try it without the postimage class? I believe our code looks for the string "ob_img" with quotes, so a space following it might affect that. Your image worked before your most recent code changes, so if postimage wasn't there previously, that would probably be the problem.
  • edited December 2007
    Why include the quotes then? Not like anything else on the page is going to happen to be ob_img.

    I'm not removing the css class for my images because I don't want to change how my site looks.
  • edited December 2007
    I meant to do it as a test, to see if it would bring your images back. Troubleshooting, man!
  • edited December 2007
    Oh, well, yeah, that's what's doing it.

    EDIT: I fixed it temporally by putting the CSS right in the image tag by doing the style= thingie, it works in the feed now, but it takes the style I added to it and uses it on the image on the orange belt page.

    That includes throwing it at the very end of the list for some reason.
  • edited December 2007
    All right, I got things squared on that front. There's just one issue remaining, but it's minor: I can't figure out how to reverse the order of the array. I'd like it to display the newest entries first, but it currently goes from oldest to newest. I imagine there's some quick variable switch or ! operand to throw in, but I haven't had the time to sit down and dig through PHP help resources to figure it out. Hopefully I can get to it this weekend, but beyond that, the whole thing's going great!
  • edited December 2007
    How big's the code, can you paste it into the forum?
  • edited December 2007
    If it's anything like Java, I think I could help with a backwards array, I had to do an assignment that required one last week.
  • edited December 2007
    If you haven't already gotten it (sorry, just popped back into this thread for a sec), it's array_reverse(). Just replace the line
    if (isset($latest)) ksort($latest);
    
    with
    if (isset($latest)) { 
       ksort($latest);
       array_reverse($latest);
    }
    
    and you should be good.
  • edited December 2007
    Yay!
Sign In or Register to comment.