boogdesign posts

Longer posts on standards based web design, portable web development and Linux, intermingled with some stuff on my other nerd interests.

Rob Crowther, London, UK based Blogger, Web Developer, Web Designer and System Administrator - read my Curriculum Vitae

Buy my book!

Book CoverHello! HTML5 and CSS3 available now

Buy my other book!

Book CoverEarly access to HTML5 in Action available now

02/09/09

06:21:22 pm Permalink Rounded Corners for Image Elements in Firefox with SVG

Categories: Front End Web Development, Standards, HTML and CSS

In my post on CSS3 a few months back I mentioned some issues I had getting -moz-border-radius to clip content that it contained. After my writing the post the question came up a couple of times on stackoverflow, first from Brandon Wang and later a similar one from dougoftheabaci. Here is a simple example of the problem, the CSS is uncomplicated:

.target {
    border-radius: 20px;
    -moz-border-radius: 20px;
    -webkit-border-radius: 20px;
}

With that class applied direct to an img element it looks great in Safari and Chrome:

Example page in Chrome

But it doesn't work so well in Firefox:

Example page in Firefox

Today I came across the Applying SVG effects to HTML content article on the MDC wiki, one of the things it discusses is using SVG as a clipping mask for HTML elements. It occurred to me that it ought to be relatively straightforward to use a clipping mask to create the rounded corner effect directly on an img element in Firefox.

So I started off with the example code from the article, removed the circle, made the rectangle full size and used the rx and ry attributes to round the corners:

<svg:svg height="0">
    <svg:clipPath id="c1" clipPathUnits="objectBoundingBox">
        <svg:rect x="0" y="0" rx="0.05" ry="0.05" width="1" height="1"/>
    </svg:clipPath>
</svg:svg>

Then use a CSS class to apply it to my image:

.target { clip-path: url(#c1); }

It didn't work at first, but then I realised I'd created my document with a .html extension rather than .xhtml - to allow mixing of SVG into XHTML the document must have content type application/xhtml+xml. Once I fixed this the effect was exactly as I'd hoped:

Example SVG page in Firefox

Here is the full code. Of course, embedding it all this way isn't going to work for any browser other than Firefox 3.5, and serving application/xhtml+xml is going to break Internet Explorer, so it's not really a practical solution in it's current state. It's more useful to break the content into separate files, then the SVG can be served as image/svg+xml while your HTML is text/html. This final example works across browsers and will round the corners of the image in Chrome, Safari and Firefox.


Tweet this!
5 feedbacks »PermalinkPermalink

03/08/09

03:10:22 pm Permalink CSS with PHP

Categories: Front End Web Development, Server Side Web Development, Standards, HTML and CSS

Last week I re-designed the home page of my personal website as the previous version was quite plain looking, mostly because I'd never gotten around to updating it. I had a visual theme for most of the sub-pages, a strong graphic as a background 'column' on the left and side, with the graphic differing by section. My idea was to reuse these graphics on the front page, except randomly select two of them each time the page loaded.

Since they were background images, I couldn't add a dynamic element in the page itself to contain them. I could perhaps have defined several new CSS classes to apply to the body element and then inserted a class name with PHP, but with six images, picking two, that means 30 class names which seemed inelegant, plus would be a bit of a pain if I later added an new section. So instead of making the page itself dynamic, I decided to make the CSS dynamic instead.

From a coding point of view the implementation is very straightforward. You rename your CSS file to be .php and make sure you return the correct content type in the header by adding this as your first line:

<?php header("Content-type: text/css"); ?>

I then just declared an array with all my images in and use a built in PHP function to give me two random images:

$bg_images = array('vertical_essays.jpg','vertical_default.jpg','vertical_books.jpg','vertical_football.jpg','vertical_writing.jpg','vertical_blog.jpg');
$bg_keys = array_rand($bg_images, 2);

Then in the CSS itself I just select the appropriate image:

html {
	background-image: url('/image/<?= $bg_images[$bg_keys[0]] ?>');
	background-repeat: no-repeat;
	background-attachment: fixed;
	background-position: bottom left;
}
body {
	background-image: url('/image/<?= $bg_images[$bg_keys[1]] ?>');
	background-repeat: no-repeat;
	background-attachment: fixed;
	background-position: bottom right;
}

After getting this working I then decided it would be fun to have my main navigation boxes have a background colour related to the images which are shown. The DeGraeve.com Color Palette Generator lets you generate a palette of colours from any image, so I put each of my background images into it and got a set of 'vibrant' and 'dull' colours for each image. I stuck this into another array, using the image names as keys and simply alternating vibrant and dull colours into an array value:

$colours = array(
    'vertical_essays.jpg' => array('#440','#553','#670','#332','#9b7','#eee'), 
    'vertical_default.jpg' => array('#560','#452','#02d','#36a','#8a7','#995'), 
    'vertical_books.jpg' => array('#720','#532','#d10','#a64','#d90','#a85'),
    'vertical_football.jpg' => array('#581','#564','#8a3','#785','#9c5','#eee'),
    'vertical_writing.jpg' => array('#644','#c73','#f20','#e82','#f30','#ded'),
    'vertical_blog.jpg' => array('#732','#644','#c30','#965','#c96','#cbb')
);

I could then set the background and border colours of the navigation boxes using the two random keys I'd already generated. To keep it simple I just had the left two boxes take colours from the left image, and the right box take colours from the right image:

#nav li.cv {
	background-color: <?= $colours[$bg_images[$bg_keys[0]]][0] ?>
	border-color: <?= $colours[$bg_images[$bg_keys[0]]][1] ?>
}
#nav li.writing {
	background-color: <?= $colours[$bg_images[$bg_keys[0]]][2] ?>
	border-color: <?= $colours[$bg_images[$bg_keys[0]]][3] ?>
}
#nav li.gameplan {
	background-color: <?= $colours[$bg_images[$bg_keys[1]]][4] ?>
	border-color: <?= $colours[$bg_images[$bg_keys[1]]][5] ?>
}

Here is the end result:

dotrob.com screenshot

As you can see, generating your CSS with PHP is just as easy as generating HTML with PHP. Even with my fairly simple minded implementation of the idea you can achieve some nice tricks. However, there are some drawbacks I ran into:

  • Because you're now editing a PHP file, you might have some trouble persuading your auto-completing CSS editor to recognise what's going on
  • You're now going to have to handle caching yourself, as your CSS is no longer a static file - not much of an issue for a small site like mine, but could be an unnecessary overhead on a large site
  • Once you've added background colours to the mix you have to consider your text and link foreground colours, I just settled for a light grey with light blue links which worked OK (but not great) on all the colours - could be a bit of a maintenance problem in the future (and a readability problem now)

Fortunately, there are possible ways round all these issues, especially if you were considering this technique for a serious site rather than a one page vanity domain &amp;#58;&amp;#41; You could always use your PHP to generate the appropriate set of colours for you from a given base colour - this saves you having to work out text, non-visited and visited link colours for each background colour. For bonus points, you could probably add the code which extract the base colour from the image in the first place to end up with a completely flexible solution. The first two issues both have the same solution - use an actual CSS file as a template, thus preserving the editor features, but use a server-side pre-processor to deliver the file to the web. This allows you, among other thing, to extend CSS with variables as well as taking care of all the cache issues for you.


Tweet this!
Send feedback »PermalinkPermalink

05/07/09

11:50:31 pm Permalink Adventures in Web 3.0: Part 2 - CSS 3

Categories: Front End Web Development, Standards, HTML and CSS

Some time ago I wrote a post about my initial experiments with HTML 5. At the time I envisaged a series of posts as I explored new and future web technologies, so far it's been a series of length one &amp;#58;&amp;#41; But after Standards Next last weekend I've been inspired to do another post, this time I'm going to look at some of the neat things coming soon, to a browser near you, in CSS3.

Unlike it's predecessors, CSS3 is not a single, monolithic spec, but a collection of modules all of which are at different levels of completeness. For instance the selectors module became a candidate recommendation in November 2001 and is already widely supported. In this post I'm going to be experimenting with the Backgrounds and Borders module and the Transitions module, mostly because the recent Firefox 3.5 release includes improved (but still experimental) support for some of the more interesting bits of it.

I tested everything in Firefox 3.5 and Safari 4, and Chrome 3, though Chrome rendered identically to Safari as far as I could tell. The Gecko and WebKit engines have experimental support for CSS properties like border-radius implemented as vendor specific properties. Each browser engine has it's own prefix - for Gecko it's moz- and for WebKit it's webkit-, making the current Firefox implementation moz-border-radius and the Safari one webkit-border-radius. This does mean you have to specify everything twice, which is a bit of a pain, but it also avoids possible conflicts if the implementation changes as the spec gets finalized.

So I started with some simple markup (I've elided the lorem ipsum for brevity):

<div id="mybox">
    <h1>Big heading</h1>
    <p>Lorem ipsum ...semper eu urna.</p>
    <p>Aliquam at arcu ... luctus.</p>
</div>

My goal in this initial experiment was to get a box with nice rounded corners and the heading sitting in a bar along the top of it. This is my first attempt at the CSS:

#mybox1 {
    border: 2px solid #666;
    -moz-border-radius: 20px;
    -webkit-border-radius: 20px;
}
#mybox1 h1 {
    background-color: #666;
    margin-top: 0;
}

The main problem with this is that the background for the h1 sticks out over the top of the rounded corner:
Heading background sticks out past rounded border
The obvious approach for this is to put 'overflow: hidden' on the div, unfortunately this only seems to work in WebKit. So I wondered if perhaps I could put a rounded corner on the h1 so it would match:

#mybox h1 {
    background-color: #666;
    border: 2px solid #666;
    margin-top: 0;
    -moz-border-radius-topright: 20px;
    -webkit-border-top-right-radius: 20px
}

Although it stopped the overflow, the two borders didn't really line up and left some artifacts inside the border. I experimented with different radii, different border thicknesses, putting a border on the h1 too, and even putting a background colour on the whole div and then making the paragraph backgrounds white, but couldn't completely eliminate it:
Matching border on div and h1 attempt 1Matching border on div and h1 attempt 2Matching border on div and h1 attempt 3
The one thing that did work OK on Firefox was to make the top border really thick and then make the border itself the background for the h1, using a negative margin to push it into the border:

#mybox {
    border-top: 40px solid #666;
    border-bottom: 40px solid #666;
    border-left: 2px solid #666;
    border-right: 2px solid #666;
    -moz-border-radius: 20px;
    -webkit-border-radius: 20px;
}
#mybox h1 {
    background-color: #666;
    margin-top: -30px;
}

Having got it looking OK in Firefox, however, I notice that WebKit looks very strange:
Different width borders meet in WebKit
When two borders coming into the rounded corner are different widths, Firefox rounds the corner of the 'thick' bit, whereas WebKit only rounds the corner on the thick line to the halfway point. The effect is especially pronounced when you make one of the borders zero thickness:
Rounded corner with only one border
Here is my full set of border radius examples. Having spent enough time mucking around with the above fragment I decided to see how border-radius interacted with tables.

<table>
    <tr>
        <td>Hello borders</td>
        <td>Hello borders</td>
        <td>Hello borders</td>
    </tr>
    <tr>
        <td>Hello borders</td>
        <td>Hello borders</td>
        <td>Hello borders</td>
    </tr>
    <tr>
        <td>Hello borders</td>
        <td>Hello borders</td>
        <td>Hello borders</td>
    </tr>
</table>

First I simply applied a border to the whole thing, as well as a drop shadow (just to keep things interesting). Here's the code:

#table {
    margin-top: 1em;
    background-color: #ccc;
    border: 2px solid #666;
    -moz-border-radius: 20px;
    -webkit-border-radius: 20px;
    -moz-box-shadow: 3px 3px 5px black, 3px 3px 5px black;
    -webkit-box-shadow: 3px 3px 5px black, 3px 3px 5px black;
}
#table td {
    padding: 0.5em;
}

And here is the result:
Table with rounded corners and drop shadow
I did a quick test with a background colour on the table cells and noted that, similar to the

h1

and containing div elements, the td background sticks out past the rounded corner on the table. However, once you start applying the rounded corners to the td elements themselves, the effects get a bit more interesting:
Table with rounded corners and rounded cells
Then I started adding a drop shadow to the cell elements too:
Table with rounded corners and rounded cells, all with drop shadows
Here's the CSS for that last example:

table {
    margin-top: 1em;
    background-color: #ccc;
    border-collapse: separate;
    border-spacing: 10px;
    border: 2px solid #666;
    -moz-border-radius: 20px;
    -webkit-border-radius: 20px;
    -moz-box-shadow: 3px 3px 5px black, 3px 3px 5px black;
    -webkit-box-shadow: 3px 3px 5px black, 3px 3px 5px black;
}
table td {
    padding: 0.5em;
    border: 2px solid #666;
    -moz-border-radius: 20px;
    -webkit-border-radius: 20px;
    -moz-box-shadow: 3px 3px 5px black, 3px 3px 5px black;
    -webkit-box-shadow: 3px 3px 5px black, 3px 3px 5px black;
}

Now you've seen some examples, a brief aside about the box-shadow CSS property. Here's the spec, as before Gecko and Webkit have their current implementations available through vendor specific extensions. To specify a shadow you give a vertical offset, a horizontal offset, (optionally) a blur radius - these should be familiar terms if you've ever used Photoshop - and a colour. More than one drop shadow can be specified, there are two in the code above (because it looks nice that way &amp;#58;&amp;#41; ). You can also use the inset keyword to make the drop shadow appear inside the element instead of outside it (doesn't yet work in WebKit). In the spirit of just trying stuff out to see what happens, I tried putting an infix drop shadow on the :hover pseudo class of the td element. This creates a button pressing effect, though for realism I decided that the contents of the cells would also need to move as the drop shadow appeared, I also went ahead and turned my sample table into a keypad:

<table>
    <tr>
        <td><span>1</span></td>
        <td><span>2</span></td>
        <td><span>3</span></td>
    </tr>
    <tr>
        <td><span>4</span></td>
        <td><span>5</span></td>
        <td><span>6</span></td>
    </tr>
    <tr>
        <td><span>7</span></td>
        <td><span>8</span></td>
        <td><span>9</span></td>
    </tr>
    <tr>
        <td></td>
        <td><span>0</span></td>
        <td></td>
    </tr>
</table>

This is the CSS I ended up with:

table {
    margin-top: 1em;
    background-color: #ccc;
    border-collapse: separate;
    border-spacing: 10px;
    border: 2px solid #666;
    empty-cells:hide;
    -moz-border-radius: 20px;
    -webkit-border-radius: 20px;
    -moz-box-shadow: 3px 3px 5px black, 3px 3px 5px black;
    -webkit-box-shadow: 3px 3px 5px black, 3px 3px 5px black;
}
table td {
    padding: 0.5em;
    border: 2px solid #666;
    -moz-border-radius: 20px;
    -webkit-border-radius: 20px;
}
table td:hover {
    -moz-box-shadow: inset 3px 3px 5px black, inset 3px 3px 5px black;
    -webkit-box-shadow: 3px 3px 5px black, 3px 3px 5px black;
}
table td:hover span {
    -moz-transform-origin: top left;
    -webkit-transform-origin: top left;
    -moz-transform: translate(3px, 3px);
    -webkit-transform: translate(3px, 3px);
}

This worked quite well (I'm hovering over the number 5 in this screenshot):
Table cells with infix shadows for button effect
You'll notice I've started adding transform rules in the above CSS, and that's what I want to talk about next, but first a few notes about the table examples. First off, I'm not advocating the use of tables to lay out phone keypad type interfaces, that's just where I ended up while exploring - it could equally well have been a more semantically appropriate element. Second, I noticed a weird effect in Safari when the table cells just contained one number - the rounded corners didn't get applied:
Safari rounded corner fail on small elements
Though Chromium on Ubuntu rounded these corners OK, so I'm assuming this is an issue fixed in a later build of WebKit. Here is my full set of table and drop shadow examples.

So, finishing off with the fun stuff - CSS Transformations! The spec is quite a hard read, I found it much easier just to try out a few examples and see what happens. The basic rule is -moz-transform or -webkit-transform, and then you have a choice of operators which can be applied, individually and in combination. You've already seen translate above - which moves the element by the specified number of pixels in the x and y axes, the other fun one is rotate:

#mybox {
    border: 2px solid #666;
    -moz-border-radius: 20px;
    -webkit-border-radius: 20px;
    -moz-transform: rotate(45deg);
    -webkit-transform: rotate(45deg);
}

The above, when applied to the HTML I was using at the start of the article, rotates the box 45 degrees clockwise. As before you can use these rules in the :hover pseudo class to do the sort of effects that would previously have been accomplished with Javascript. WebKit is especially cool for this as it lets you specify a duration for the transition:

#mybox {
    border-top: 40px solid #666;
    border-bottom: 40px solid #666;
    -moz-border-radius: 20px;
    -webkit-border-radius: 20px;
    -webkit-transition-duration: 1s;
}
#mybox:hover {
    -moz-transform: rotate(-90deg);
    -webkit-transform: rotate(-90deg);
    -webkit-transition-duration: 1s;
}

The above CSS rotates the box 90 degrees anticlockwise when you mouseover, and takes one second to animate the transition from the 'normal' state to the rotated version. It's harder to describe than it is to see, so you may as well take a look at my transformation examples. One thing that's worth noting - Firefox seems to change the z-index of the element when you hover over it, whereas Safari doesn't. If you rotate an element in Firefox it will cover up everything it rotates over, in Safari everything will just mix together - I recommend testing how your elements interact when they move over each other. Also, if you're going to move larger elements around with these rules in response to user activities like mousing over an element then there's a good chance that your transition will mean the mouse pointer is no longer over the element, which could certainly be confusing as the element flip flops.


Tweet this!
Send feedback »PermalinkPermalink

27/06/09

11:45:23 pm Permalink Standards.Next HTML5

Categories: Usability & Accessibility, Front End Web Development, Standards, HTML and CSS

Review: Standards.Next HTML5 at Bricklayer's Arms, 31 Gresse Street, London, W1T 1QY 13:00 to 17:30

This was a free event with several speakers covering several aspects of the draft HTML5 standard. It wasn't an ideal venue for presentations as there was a big pillar in the middle of the room, and as a result I couldn't see the right hand side of most of the presentations, but I think I got the gist of it.
Picture of the audience listening attentively to Martin Kliehm

HTML5: Are you mything the point? - Bruce Lawson

Bruce covered several popular misconceptions people have about HTML5:

  • Evil browser vendors dominate - while they do have a lot of influence, because ultimately it's the browser vendors who have to implement it all, the key point is that all the browser vendors are collaborating so they'll all be implementing the same standard. Also the spec takes a 'pave the cowpaths' approach - if browsers already support it, and it is in common use, the spec defines and legitimizes it - for example the embed element.
  • Hello tag soup, goodbye XML - while it's true that you don't have to close elements if you don't want to (unless you're using XHTML5), the HTML5 spec defines what browser should do with invalid markup, so invalid markup should look the same in all browsers.
  • Kills Flash/Silverlight/Javascript - while it provides an open alternative to Flash and Silverlight, they're not going away any time soon. The Javascript one is a bit hard to understand, but Bruce had been asked about it several times so he felt it was worth mentioning - HTML5 provides several things which replace the need for lots of the 'little' stuff that JS is currently used for, eg. the details element.
  • It'll break the intertubes - HTML5 has been designed to be backwards compatible and the choice between several options has been decided by what works in current browsers: for example many people wanted the href on arbitrary elements but this didn't work in any browser; however allowing the a element to wrap arbitrary content does work, so that's what's in the spec.
  • It hates accessibility - the philosophy behind the WHATWG's approach to accessibility is to build it in to the elements, for example the new form elements provide lots of extra data and functionality, so the accessibility happens without any special effort by the author, while the approach taken by ARIA is more to 'bolt on' accessibility. Of course, there are some issues with this approach - ARIA can do a lot of things HTML5 doesn't support, and assistive technologies already support ARIA, while the AT suppliers have not gotten involved in the HTML5 spec process despite being invited.
  • Can't use it until 2022 - in fact a loot of it can be used right now, even in Internet Explorer. The definition of 'ready' comes from a misinterpretation - Ian Hickson was asked when the spec would be finished, since 'finishing' requires two complete and fully interoperable implementations he said it wasn't likely to be finished until about 2022.

Bruce then discussed several of the new elements in HTML5, many of which I covered in my earlier blog post, the outlining algorithm (so you can have multiple h1 elements in the page), and then covered the new form elements - now supported in Opera 10 beta. The forms stuff looks quite cool, so I'll try and do a full post on that in a few weeks.

HTML5.js - Dean Edwards

Dean is the creator of ie7.js, a script "to make Microsoft Internet Explorer behave like a standards-compliant browser" and now he's done it again with html5.js, a script which adds support for HTML5, including all the new structural and form elements to browsers which don't currently support it. He did a very impressive demo, which included demonstrating all the form elements inheriting the windows theme and rendering correctly. There was some discussion about how he'd achieved all this, and Dean admitted to "quite a lot of browser sniffing," but "the good kind of browser sniffing."

Javascript APIs - Remy Sharp

Remy gave an overview of several of the new APIs in the HTML5 spec, including some which are now in separate specs:

  • Canvas - supported in every major browser except IE, and even there you have options.
  • Drag and Drop - Supposed to work in Firefox, Safari and Opera, but Remy had only managed to get it working in Firefox. Instead of writing a whole load of javascript to implement drag and drop, in HTML5 you just declare draggable=true on an element and then hang some functions off the dragstart and dragend events.
  • Offline Apps - one of the most interesting possibilities presented by HTML5 is the possibility of offline web applications. Native support is coming in Firefox, Safari and Opera and is available already, sort of, in other browsers thanks to Google Gears. Remy covered the application cache, online and offline events, the navigator.online flag (which, unfortunately, only appears to work in Firefox) and the cache manifest file.
  • Geolocation - supported in the latest Firefox and the iPhone version of Safari and in other browsers, again, sort of, by Gears. The interface is fairly simple, just call getCurrentPosition and pass in a callback function.
  • Messaging - an API to pass messages between pages in different domains, supported by all the latest versions of the major browsers (even IE). Remy showed us the postMessage function and onMessage event, and discussed some of the security features.
  • Web Workers - threading for Javascript, supported by Chrome, Firefox and Safari and also another feature of Gears.
  • Storage - actually two different types of storage: key/value stores for both the window and the domain plus a SQL storage engine, sessionStorage, localStorage and Database respectively.

Remy has several examples online if you want to have a more detailed look.

The HTML5 Canvas Element - Martin Kliehm

The bulk of this presentation was made up of a bunch of demos of really cool stuff done with the canvas element, so a bit hard to describe in a blog post and keep things short. Hopefully it'll appear online shortly, in the meantime this is one of the more blogged about and well known parts of HTML5 so I'll not go into details. Martin discussed several 'fake 3D' rendering techniques, some of the performance advantages over stuff like SVG as well as some of the possibilities to come once full 3D support was available.

HTML5 Accessibility - Steve Faulkner

Steve started off with a couple of entertaining slides illustrating the contrast between what he thinks is important as far as accessibility in HTML5 is concerned and what has seen the most discussion. So far everything has centred around whether or not to require the alt attribute and various apocrypha of tables, where it needs to discuss ARIA, the canvas element and text alternatives. So while so far things have not been so great there is a great deal of potential in HTML5. All the extra semantic elements (header, article etc.) can provide additional information to assistive technologies, as will the new form controls. While canvas and the new video element don't currently offer much (canvas is worse than Flash - fallback content placed inside of it simply disappears as far as ATs are concerned), having these elements as first order members of the DOM presents opportunities in the future for screen readers and other technologies to interact directly with media experiences at a deep level. Steve then discussed the compatibility (or otherwise) of HTML5 with ARIA - after some argument the validator accepts valid ARIA attributes and browsers already implement support in HTML5 anyway, so in many ways it doesn't matter whether the WHATWG adds specific support. He finished off with some slides showing the level of browser, screen reader and Javascript library support for ARIA (IE, for once, leading the pack in a standard alongside Firefox, Dijit leading the way in libraries - though several major JS libraries were surprisingly good).

This was a great event, in spite of the pillar, and I've just skipped over a lot of it (we overran by more than an hour &amp;#58;&amp;#41; ) so 5 out of 5. Watch the website for news of future events in the series or follow #standardsnext on Twitter.

Technorati tags for this review:      

Tweet this!
3 feedbacks »PermalinkPermalink

24/06/09

11:18:32 pm Permalink Fun with b2evolution plugins

Categories: Web Develop, Blogging and Internet Culture

As I've mentioned in my recent posts, this blog hasn't received a lot of love in the last two years or so. I'm slowly getting back on track but, following my upgrade to b2evo 2.x in February, I've been missing some of the features I used to have.

About two and half years ago I implemented social network sharing buttons on my skin. I didn't have the time to figure out how to make them work in my 2.x skin, but today I discovered BAE Social Bookmarks. The developer's website is sadly defunct but the plugin has been made available by someone who'd downloaded it before the site disappeared. I had a bit of trouble figuring out how it worked but I eventually worked it out from the code. Basically you insert a template for the link and insert $permanent_url$ and $title$ in an appropriate place:

<a href="http://del.icio.us/post" onclick="window.open('http://del.icio.us/post?v=4&noui&jump=close&url='+encodeURIComponent('$permanent_url$')+'&title='+encodeURIComponent('$title$'),'delicious', 'toolbar=no,width=700,height=400'); return false;" title="del.icio.us"><img src="/images/delicious.gif" border="0" height="16" width="16"></a>

<script type="text/javascript">document.write('  <a href="http://reddit.com/submit?url='+encodeURIComponent('$permanent_url$')+'&title='+encodeURIComponent('$title$')+'" target="blank" title="Reddit"><img src="/images/reddit.png" width="16" height="16" border="0" /></a>');</script>

After this success I turned my attention to my technorati tags. There are a couple of different versions of this, Technorati Plugin and Rich Tags Plugin, though I couldn't find a download for the former and the latter seemed to be for 1.9 and earlier versions. Also the 0.3 version Rich Tags plugin was missing the 'Technorati' button on the edit post screen which the 0.2 version had. Looking at the code, the AdminDisplayEditorButton function was still defined in /inc/plugins/_plugin.class.php so it seemed like all I had to do was simply copy that bit across:

function AdminDisplayEditorButton( & $params )
	{
		?><script language="JavaScript" type="text/javascript">
function WriteTag(){
		document.getElementById('itemform_post_content').value += "<!--tags MyTag My+Tag -->";
}
</script><input type="button" id="b2eRchTgs_button" value="Rich Tags" onclick="WriteTag()" /><?php
		return true;
	}

Tried it, and it worked &amp;#58;&amp;#41;

Intoxicated by this early success I decided to see what else I could do, so I read the documentation and also had another look at the BAE Social Bookmarks plugin. I thought it would be good to have options other than technorati for tagging - I use delicious a lot and there are some other good candidates. First thing I wanted was some configuration options, looking at the BAE code this didn't seem too difficult, but I didn't need a textarea like it uses and the one thing that did seem hard to find was documentation. The source code again comes to the rescue, there is some quite extensive documentation starting from line 361 in /inc/plugins/_plugin.class.php, so I figured out I wanted a checkbox which takes a value of 0 or 1:

   function GetDefaultSettings( & $params )
    {
      $r = array(
         'technorati_tags' => array(
               'label' => 'Enable Technorati Tags',
               'type' => 'checkbox',
               'defaultvalue' => 1,
                'note' => 'Inserts links to technorati tag pages, you should also add a CSS rule for either .tags (generic) or technorati_tags (specific)',
                ),
          'delicious_tags' => array(
               'label' => 'Enable Delicious Tags',
               'type' => 'checkbox',
               'defaultvalue' => 0,
                'note' => 'Inserts links to delicious tag pages, you should also add a CSS rule for either .tags (generic) or delicious_tags (specific)',
                ),
        );
      return $r;
    }

Easy enough, I also copied this function from the BAE plugin, because I assume it's just a bit of boilerplate:

    function PluginSettingsUpdateAction()
    {
      global $DB;
      $DB->query('DELETE FROM T_items__prerendering WHERE 1');
      $this->msg( sprintf( T_('Removed %d cached entries.'), $DB->rows_affected ), 'success' );
    }

Finally I modified the RenderItemAsHtml method to detect the settings and render the appropriate tags (nothing fancy here):

    if ($this->Settings->get( 'technorati_tags' ) == 1) {
            $AddedAtLeastOneTag |= $this->addTags( $content, $Matches[ 1 ], '<div class="tags technorati_tags"><strong>Technorati tags for this post :</strong> ', '</div>', 'http://technorati.com/tag/', ' rel="tag"' );
    }

    if ($this->Settings->get( 'delicious_tags' ) == 1) {
            $AddedAtLeastOneTag |= $this->addTags( $content, $Matches[ 1 ], '<div class="tags delicious_tags"><strong>Delicious tags for this post :</strong> ', '</div>', 'http://delicious.com/tag/', ' rel="tag"' );
    }

It all seems to work, so I added flickr and twitter just for the heck of it and then some extra CSS rules for my template to make them look distinctive. Download Rich Tags Plugin v0.4.


Tweet this!
4 feedbacks »PermalinkPermalink

13/06/09

12:51:15 pm Permalink Things I did last year (part two)

Categories: Web Design, Web Develop, Gadgets, Blogging and Internet Culture, Semantic Web and Microformats

Following on from Wednesday's post, this post covers the last six months of 2008 and the early part of 2009. This should finally get me up to date and back to the point where I can post about things I did last week without a guilty conscience &amp;#58;&amp;#41; Even in summary form this is taking me a lot of time (that OpenTech event had a lot of stuff!), so I'm just going to publish it half finished and fill in the later events over the next few days.

Summer 2008

  • London Geek Nights: Ajax - I managed to write this one up
  • SearchMonkey Developer Event - obviously in a purple patch of productivity, I got this event written up too, I also wrote a tutorial for developerWorks a few months later.
  • Open Tech 2008 - Session 1
    • Rembrandt, Pr0n and Robot Monkeys (Kim Plowright) - An interesting talk on the relationship of man and machine, how we think into our tools, and the refreshing view that porn is one of the ways we reunite with our bodies.
    • Living with Chaos (Simon Wardley) - I was to see variations of Simon's talk several times over the coming months, and if you get a chance I recommend you go see him too as he's a very entertaining speaker. The message of the talk is that open standards are a necessary end result of the technology curve as we travel through the Innovation -> Bespoke -> Products -> Services continuum. By the time everyone is selling services you're at a commercial disadvantage if you're still on a bespoke solution or selling a locked in product.
    • What the Frog's Eye Tells the Future (Matt Webb) - A talk about the connections between the founding fathers of neuroscience, computers and cybernetics, eg. The Macy Conferences, Pitts and McCullogh, Norbert Wiener, Vannevar Bush, Ted Nelson and Douglas Engelbart. Cybernetics is a cross domain concept language, and the people in cybernetics are the 'dark matter' which link everything together.
    Session 2
    • Sponsor Presentation: TiddlyWiki Tales (Jeremy Ruston) - TiddlyWiki is a javascript driven, single page wiki - no need for a server, everything is saved directly into the file, so it can be used offline from your desktop.
    • Android and the Open Handset Alliance (Michael Jennings) -
    • Social networks and FOAF (Tom Morris) -
    Session 3
    • OpenID and Decentralised Social Networks
    • Distributed, Federated, Partial
    • The Web is Agreement
    Session 4
    • From Stealth Mode to Open Source in 90 days
    • No Comply: or Why the Paranoid Android Approach to Security is a Bad Idea
    Session 5
    • Publishing with Microformats
    • Power of Information: Rewiring the London Gazette with RDFa
    Session 6
    • Finding Good TV on the Interwebs with RDF and REST
    • The Bastard Child of Baird and Berners Lee
    Session 7
    • Intro to Hadoop
    • Guardian.co.uk: building for the open web
    This was a really good day, I would recommend going along to the 2009 event if you can fit it in (unfortunately I have a prior commitment &amp;#58;&amp;#40; )
  • Momolondon July - Enabling location in applications - A set of lighting talks: Interesting stuff from Ted Morgan of Skyhook (the iPhone geolocation provider) about using wireless network signatures to determine where you are; a talk on FireEagle; Charles Wiles explained how Gears for Mobile is R & D for HTML5; there was a talk on the W3C Geolocation API; Rummble and BuddyPing, location aware, mobile based social network apps; finally Mark White on Locatrix who are a platform/service provider for people looking to provide location based mobile services.
  • CloudCamp - this has now turned into a regular event, so the original links are long gone. Saw Simon Wardley again, with a similar talk to OpenTech but with cloud, and standards therein, substituted for open source.

Autumn 2008

  • Google Developer Day 2008 - I attended four sessions as well as the starting and concluding keynotes: Intro to Android, after seeing a real, live Android phone in the keynote this was a nice talk to get a closer look - the questions went on longer than the talk though &amp;#58;&amp;#41; ; A Deeper Look at Google App Engine, I was getting quite into the whole cloud computing concept at this point and I likle the way App Engine allows you to just write code and then get started without the bother of setting up VMs etc.; Codelab: Gears, although I went to this I couldn't get very far as my hurried Ubuntu install the day before had left me with a 64bit build - I had built a version of Gears but it didn't contain APIs compatible with what everyone was using so I skipped out of this half way through; this allowed me to got to V8 - the Chrome engine which described some of the techniques used in the recently announced V8 (it was a very popular talk!) including native code compilation and behind the scenes static classes. I wore my Ubuntu 'Linux for human beings' t-shirt which got featured on the closing video/photo montage (the message on the back, rather than me).
  • Scripting Enabled - This was an excellent event, I think videos of all the presentations along with text transcripts and slides are available at the website so I won't go on about it too much. Highlights for me were seeing videos of real users with screen readers and Jonathan Hassell on Dyslexia which both made accessibility issues real to me in a way they hadn't been before.
  • Mobile Location-Based Services
  • YUI 3.0
  • CloudCamp
  • London Perl Workshop 2008 - Since I'd enjoyed his introductory tutorial at the 2007 event, I went to Dave Cross's Introduction to Web Programming tutorial: some interesting stuff on how CGI actually works which I'd never really investigated before, how to work with HTTP in Perl, some hints on security (check all input variables - good advice in any language, and use taint mode, which is Perl specific solution for that) and he finished off with a short introduction on how to use template toolkit to make life easier. After the tutorial I went to a number of short talks: Regexp mini tutorial: Character Classes; Painless OO <-> XML with XML :: Pastor; and‎ ‎Intermediate Moose where things started to get a little beyond me and my rudimentary knowledge of Perl.‎

Tweet this!
Send feedback »PermalinkPermalink

10/06/09

10:50:48 pm Permalink Blogging motivations and things I did last year (part one)

Categories: Web Design, Web Develop, Gadgets, Blogging and Internet Culture, Semantic Web and Microformats

In the admin pages of this blog (when I first started writing this post, five months ago!) I have a 'list view' for posts which has a few pertinent details alongside the post title - notably date and visibility (published or draft). In pages thirteen to four (twenty per page), covering July 2003 up until June 2007 all the posts are at status 'published.' On page three, starting about August 2007, there were a couple of posts at 'draft', on page four there were six, on page one, even with the couple of posts I finally published in January, there were seven. There's a definite trend developing here &amp;#58;&amp;#41;

There are a few factors at work here: a major one is that last year I switched from never going to the gym to going five or six times a week meaning that not only did I go to events less often but I had less free time to write them up; getting paid to write articles also decreased my motivation to write 'for free' - plus after spending a week or so where my entire evening (up until the early hours in the morning several times) had been spent writing I did feel like I owed myself some time off.

This led to me starting a number of 'place holder' posts and, once I had a few posts sitting in draft status it was very easy to leave the next one in draft too and say to myself "I'll finish them all off at the same time." What this led to is a whole mountain of unpublished, half-finished posts which eventually put me off even starting new ones.

I read some advice on another blog about not writing things out straight away - hold off seven days and see if it's still worth writing about. For me this just led to not writing anything at all (this may have been the effect he was after). If I'm going to write posts and keep writing them, I've got to do it that day, right there and then, and get it published. It turns out that getting paid to write stuff actually puts me off writing for free on my blog (other than a short burst of activity as the first thing was published just to make it look a bit more up to date).

So, in an effort to clear the decks, I'm going to attempt to summarize 18 months of event attendance in just a few long posts, then delete all those draft posts and make a fresh start. I did manage to spit out some blog posts in this period and I'll link to those where appropriate. The final part of this exercise will involve me finally publishing the few 'technical/tutorial' type posts I have in draft status which I'll then link to from a short post.

Autumn 2007 / Winter 2008

  • Going Beyond REST - This was a fascinating talk. Applying the principals of REST architecture on the inside of a system rather than between systems - all functions are represented by URIs, which it turns out has some nice side effects. For instance if one process within the system calculates 2+2 then the result is cached and any other process gets to use the result 'for free' (I know this is hardly significant for 2+2, but imagine a collection of more complex calculations). This means recursive stuff can be automatically optimised - the results of each iteration are cached and so the minimum number of operations are performed. As I was listening to this talk, Greg Egan's Permutation City kept popping in to my head.
  • Know IT and Share IT - This was an evening about how to go about facilitating enterprise knowledge sharing: "What knowledge do you have and where is it? Employee minds: 85%, Other media: 15%." Three talks on the themes of social network analysis, knowledge networks, communities of practice and tools to support it. A quote I noted down from the final talk which resonated with my experiences: "Any solution which requires significant change in behaviour will be difficult to implement. Any solution which requires significant consistent behaviour will not be possible."
  • Erlang for five nines - Since I've found a video I won't go on about it, but a good introduction.
  • London Perl Workshop 2007 - Attended the 'Beginners Perl Tutorial' Dave Cross which was quite enlightening - certainly an explanation of the default variable made a whole load of code suddenly more comprehensible to me (slides).
  • Javascript as a disruptive language - I went to this mostly because I enjoyed Ajax in Action so much. Again, you can see the video yourself so I won't go on about it.
  • Momolondon February - Mobile Operating Systems - four talks on the current state of mobile operating systems. Mark Burk's talk was interesting as it showed the strong divisions between the US phone market and the rest of the world, also notable the lack of penetration the iPhone had on the world market despite all the hoo ha. David Wood of Symbian takes the in retrospect prize for his strong defence of the closed source development model for mobile OS development (though misrepresenting several aspects of open source in is argument) only for Nokia to open source Symbian five months later.
  • Momolondon March - Mobile London - Excellent venue at the London Transport Museum for this event focussing on mobile apps for Londoners. Some of the trials LUL had been conducting with audio travel guides and travel news while actually in underground stations looked very interesting, also the trial to add Oyster payment functions directly into your mobile phone. The "Huh!?" moment of the evening was provided by the O2 marketing person who claimed (with a straight face) that customers thought it was really important that they could always see the O2 branding on their phone display - yes I just love having 20% of my screen taken up by the operator logo...

Spring 2008


Tweet this!
Send feedback »PermalinkPermalink