The importance of peers at the work place
tl;dr: What?
I cannot stress how important it is to have someone to share your accomplishments / suffering with at work. Often overlooked, this is one of the most important feats to look for in your future employer’s offering. Make no mistake about it.
Case in point
I was having a really hard time today with some of Croportal’s partner feeds. Two unrelated issues came up, both having something to do with parsing Atom feeds using Zend_Feed:
- A certain site published it’s feed in Atom format using non-absolute URIs within the
<content>element. That’s not a problem per se, since the spec allows it (and defines how to deal with that). However, Zend_Feed has no knowledge of what’s going on (and that’s probably ok, since it’s a general purpose lib). However, publishers place whatever HTML content they want within their<content>element and expect the same behaviour from aggregators as they get from browsers when they open their feed URLs in them (ie. Firefox). This means you have to do a shitload of “magic” on your end. And that shit ain’t trivial. - Another site published their feed using Atom as well, except they decided to use the (rarely used)
<content type="xhtml">feature of the Atom protocol. Which is all fine and dandy untill you actually have to pull the content and display it on your end (being an aggregator). The spec is somewhat vague and yet pretty specific at the same time. Except it doesn’t cover what to do in cases such as this:... <content type="xhtml"> <div xmlns="http://www.w3.org/1999/xhtml"> <p>Paragraph with an <img src="whatever.jpg" /><![CDATA[This is <strong>XHTML</strong> content.]]></p> </div> </content> ...
Which kind of sucks, since you’re on your own now. I have an actual publisher with such a feed. And the feed validates. What does one do? Well, you start introducing crap code into your codebase. Shit such as this, to handle the case described above:
... if ($item->content && $item->content['type'] && $item->content['type'] == 'xhtml') { $item_simple = simplexml_import_dom($item->content->getDOM()); $item_summary = $item_simple->asXML(); // end-tag is fixed in form so it's easy to replace $item_summary = str_replace('</content>', '', $item_summary); // remove start-tag, possibly including attributes and white space $item_summary = preg_replace('/<content[^>]*>/i', '', $item_summary); } ...
This sucks on so many levels it’s not even funny. Zend_Feed’s
$item->content()method returns only the raw text, but my use case requires the surrounding elements as well (images etc). So, I hack my way around all this using SimpleXML which allows me to (somewhat) easily dump the structure into a somewhat acceptable form of HTML.Of course, later on you have to call
strip_tags()on content such as this (to display it safely on your end), but — surprise, surprise — you run into another issue: if you have a<








