echo "hey, it works" > /dev/null

just enough to be dangerous

PUT and DELETE dropped on the floor


I mentioned previously that the AtomPub server in my WordPress installation wasn't successfully deleting entries. More specifically, I get a 403 Forbidden when trying to PUT or DELETE posts or media files. I posted to the wp-testers mailing list and Joseph Scott passed the question along to Sam Ruby, Tim Bray, Elias Torres, and Pete Lacey, and I basically eavesdropped on their conversation.

Turns out that the problem is likely to be a firewall rejecting PUTs and DELETEs. This started a discussion of how WordPress should workaround the problem. Some options are URL munging, custom headers, or message in a message. All horrible for various and obvious reasons, and none going to make it into 2.3. Sam cautioned, and suggested revisiting PacePutDelete, a method proposed by Joe Gregorio on the Atom lists to overcome a lack of PUT and DELETE support on clients, which led me off on a fascinating journey through the Atom mailing list archives.

I'm not sure how big the problem really is now. It may take more time and effort to come up with a "fix" than it would to lobby purveyors of broken internet devices to really fix them. The biggest concern with a workaround, however, is that it may slow said fix. Why should we fix our firewall when your client can just use X-Method-That-Really-Is: delete? If such a workaround is implemented it should be a fallback in case a correct request fails.

It sure is frustrating that the solution is baked right in to HTTP.

Serving static files with Camping


Camping interprets every request to the server using the paths in the controllers, so if you want to serve static files, like external stylesheets or images, you need to provide a controller for them. Take this bit of Markaby:

img :src => 'images/logo.png'

This will get interpreted by Camping and end up with this HTML:

<img src="images/logo.png">

When the browser reads that, it will send a GET request to the Camping server looking for logo.png, that Camping will try to match against the controller paths. If you haven't set one up, you'll get an error.

So, in your Controllers module:

class StaticImage &lt; R '/images/(.*)'
  def get(static_name)
    current_dir = File.expand_path(File.dirname(<strong>FILE</strong>))
    @headers['Content-Type'] = "image/png"
    @headers['X-Sendfile'] = "#{current_dir}/images/#{static_name}"
  end
end

and in your View module, create the link like this:

img :src => R(StaticImage, 'logo.png')

Shake and bake for any kind of static resource you want to send.

The system of use is the repository


In the beginning, Web search was based on aspects of the resources being indexed, like term frequency and inverse document frequency. That's of course still important but things really took off when search engines started to treat the Web as a connected graph, placing as much importance on the interconnectedness of the resources as what was in the resources themselves. Google made a huge jump forward in this area with its PageRank algorithm.

As things stand, search for digital material for teaching and learning (or learning objects or open educational resources) focuses on the resources themselves (or metadata about them), just as early search engines did. These resources are usually stored separately from the systems in which they are used, in disconnected repositories.

Erik Duval and his team are doing some interesting work in this area with what they call attention metadata. It's a good start, but until we do away with repository silos and start using the system of use as the repository, this area of search will move slowly. If this is done, there will be all sorts of other information to use in heuristics to optimise results.

Indenting your code


In HTML whitespace is not treated as significant, and therefore it gets collapsed. This is a problem when you want to publish code because your indenting will disappear. The most common way around this is to wrap code in a pre element, but that looks like crap because it's always the default monospace font, and you can't style it. A better way is to use CSS, specifically white-space: pre;.

In WordPress, log in to the admin section, click Presentation and select Theme Editor. Choose Stylesheet from the list on the right, then look for the code declaration. Add white-space: pre; and you're done. Now, whenever you want to display code, wrap it in a code element.

Corrupt countries were more likely to support the OOXML document format | EFFI.org


During the voting process the reputation of ISO as a dependable technical standardization organization was questioned. For example, in Sweden a Microsoft representative was caught offering to recompense partners for voting yes to OOXML. Also a sudden interest from countries like Ivory Coast to the OOXML issue has been found suspicious.We studied the relation between the corruption level and voting behaviours of the countries. We found that more corrupted the country is, the more likely it was to vote for the unreserved acceptance of the OOXML standard proposal.

WordPress AtomPub FAQ


I've posted a small WordPress AtomPub FAQ. It's a temporary home until I can find somewhere sensible to put it. If you have anything you'd like to add or correct or mock, comment here. If you can offer a sensible place to put it, let me know.

Alternative PHP syntax for control structures


Reading through the WordPress source, I found some syntax I didn't recognize.

if ( !function<em>exists('wp</em>set<em>current</em>user') ) :
function wp<em>set</em>current<em>user($id, $name = '') {
  global $current</em>user;
  if ( isset($current<em>user) &amp;&amp; ($id == $current</em>user->ID) )
    return $current<em>user;
  $current</em>user = new WP<em>User($id, $name);
  return $current</em>user;
}
endif;

A hunt revealed that this was an example of PHP's alternative syntax for control structures. You can replace an opening brace with a colon on some control structures, the closing brace with an end*;, where * is the control structure, and have blocks of multiple lines. Why would one use this? One example in the WordPress is a conditional function definition, which, okay, that's unusual, so maybe the unusual syntax makes it stand out, but in general I think using this is a terrible idea.

PHP as a CGI


In a previous post I talked about getting HTTP authentication working when PHP is intalled as a CGI. That, however, begged the question; why install PHP as a CGI? Performance is going to take a substantial hit, after all. The answer I got from the sys admin of one of the servers I was trying was:

- Better security
If a PHP process is compromised, it's only compromised for the duration of the request.

  • Upgrades are easier Upgrading an Apache module requires restarting the Apache server after the module has been replaced. Upgrading a CGI binary simply requires replacing the binary.
Sounds reasonable for low traffic sites. The other server is a run by a hosting company, so low traffic isn't really something on which they can or should rely.

Changing the format of WordPress quote posts


The WordPress 'new post' bookmarklet lets you highlight some text on a page, run the bookmarklet and redirects you to your admin new posts page with the title prefilled with the title of the page you were on and the content prefilled with a link to the page you were on and the text you had highlighted. However, the default layout isn't the way I like to do quote posts, so I had a poke around to find out how to change it.

In the file wp-admin/admin-functions.php there is a function getdefaultposttoedit(). Midway through the function the variable $post_content is set with an HTML snippet. Edit this snippet to how you would like quotes to be displayed.

I wonder what The Right Way to do this is.