Random Ramblings
Valid HTML5
March 06, 2012 at 10:34 AM | categories: websiteExciting stuff! Have to say I was amazed how easy it was to get valid.
=== modified file '_templates/site.mako'
--- _templates/site.mako 2012-02-26 01:07:15 +0000
+++ _templates/site.mako 2012-03-05 23:28:10 +0000
@@ -1,9 +1,8 @@
<%inherit file="base.mako" />
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
+<!DOCTYPE HTML>
+<html>
<head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
${self.head()}
</head>
<body>
Three line change, valid with the latest version. Wish all the software I worked with was so easy to stay valid with!
You might notice I've removed the XHTML/CSS validity buttons from the website. A couple of people commented on the way they floated around, and now the site is no longer using XHTML it seems smarter to simply hide them completely.
All website posts updated.
March 04, 2012 at 07:01 PM | categories: website, personalAfter spending most of today updating posts on my website, I'm feeling much happier about its quality - even thinking about opening it up to robots.
Almost every single post was updated in some way, in many cases complete rewrites occurred. A couple of stub posts (which were just whinging anyway) were deleted, with another half dozen drafts tagged (they will no longer appear on the site).
If you've looked at this site in the last month or so, please have another browse - hopefully this time you'll get a better impression ;)
This website is going mobile
February 27, 2012 at 09:15 AM | categories: website, hacking aroundOver the last few days I've spent a couple of hours working on making this website work better on mobile devices. I've found 4 sites to test with, and all are showing the same problem: My navigation bar is squished down the side so its unreadable, and takes up valuable navigation space.
Page validity
My first stop was the w3 mobile website validator. The tools the W3C provide are great (You'll notice I try to keep this site CSS and XHTML valid too).
The interesting thing about the mobile validator compared to the other two, is that it provides a percentage bar to show how close you are to validity (Fixing two critical issues bumped me from 49% to 93%... whatever that means). It also includes a list of informational points for things you might wish to fix (eg, too much whitespace/comments) - a feature I plan to take advantage of down the line. Unfortunately, the validator doesn't help with my specific problem, as the nav bar is a layout issue not a code issue.
The only glaring omission that I can find, is that it doesn't check for 'jump to content' and 'jump to navigation' links. While these are primarily for accessibility, I feel they are also useful on a mobile screen.
Another validity check is ready.mobi, which gives all sorts of information, including page size, estimated load times and a collection of additional tests. These show a different set of possibilities to the W3 checker, so provide a bit of extra depth to the testing.
But how does it look?
Thats where the other sites come in handy. To test the structure I was aiming for, I found that mowser gave a good layout test. I just need to work out the CSS they use so I can copy it ;) To get the layout I'm after, I'll need to move the website title back over the navigation bar, which means moving it into a different div. (And that means more possible display issues). Despite my using it in this way, mowser isn't a website tester. Its a website minimiser, so you can view any website mobile.
The last page shows how the site looks in a variety of smartphones by loading an image of the phone, then poking the website into it. This is a great way to see how well you fit on various devices... and a great way to discover that this website fits badly!
Mako doesn't like what I'm doing
February 06, 2012 at 10:00 AM | categories: website, hacking aroundI'm working on my website again, and to try and fix categories being listed several times in the navigation bar instead of once, I seem to have introduced another.
I'd managed to have each category from each post printed out (See code below), but there was a problem: categories with multiple posts were being listed multiple times.
% for post in bf.config.blog.posts[:]:
% for category in post.categories:
<li><a href="category/${category}">${category}</a></li>
% endfor
% endfor
What I needed was a way to have python/mako check for duplicates and only print out values once. I asked andrew for some help, and he suggested I use this:
buffer = [ '<li><a href="category/%s">%s</a></li>' % (category, category) for post in bf.config.blog.posts for category in post.categories ]
And it looks pretty cool. I stuck a % in front of it (like the for loops had), and it exploded:
16:36:10 kgoetz@epicfail: ~/srccache/website-blogofile $ SKIPRST='x' ./_make.sh
+ blogofile build
WARNING:blogofile.post:2011102301-running_crg_derbyscoreboard_behind_apache.rst: Post has no YAML section : Skipping this post.
ERROR:blogofile.writer:Error rendering template
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.6/blogofile/writer.py", line 155, in template_render
return template.render(**attrs)
File "/usr/lib/pymodules/python2.6/mako/template.py", line 189, in render
return runtime._render(self, self.callable_, args, data)
[...cut lots of mako calls...]
File "/usr/lib/pymodules/python2.6/mako/parsetree.py", line 69, in __init__
code = ast.PythonFragment(text, **self.exception_kwargs)
File "/usr/lib/pymodules/python2.6/mako/ast.py", line 74, in __init__
code, **exception_kwargs)
CompileException: Fragment 'buffer = [ '<li><a href="category/%s">%s</a></li>' % (category, category) for post in bf.config.blog.posts for category in post.categories ]' is not a partial control statement in file '_templates/navigation.mako' at line: 12 char: 1
After reading the docs it turns out that % is used for things like if/else/for/while etc. What I needed for my python line (buffer= []) was %%.
The code snippet is now:
<%
buffer = [ '<li><a href="category/%s">%s</a></li>' % (category, category) for post in bf.config.blog.posts for category in post.categories ]
%>
Thanks to Andrew for the buffer line, its much fancier then what I had.
Removing duplicate categories.
The problem with the code above is that it collects duplicates into buffer. This means printing it directly through mako lists the tags several times in the side bar - not a feature.
An easy solution is available thanks to Nathan Hamiel of neohaxor.org, in one line of python. (See the next section for the line, albeit combined with the initial code).
The result
The final template file looks like this:
<%
# Build an array with all the categories in it.
# Lowercase so we don't have (eg) Debian and debian listed.
all_categories = [ '<li><a href="/category/%s">%s</a></li>' % \
(repr(category).lower(), repr(category).lower()) \
for post in bf.config.blog.posts for category in post.categories ]
# Dedupe the array before adding it to the nav bar.
nodupes_categories = set(all_categories)
%>
<ul>
% for category in nodupes_categories:
${category}
% endfor
</ul>
Transferring a domain name to Jumba
November 23, 2011 at 10:00 AM | categories: website, opinion, my projectsI've decided to start moving away from domaincentral - their web UI was always horrible, and now they have bumped up the price of their service. I saw Jumba mentioned on the SAGE-AU list as a cheap but reliable provider and I thought I'd give them a go. Because I'd not gone through this before, here is a bit of a story about what happened.
First to move is medeopolis.com. Its a domain I'm planning to use later in the year, but nothing is associated with it yet. As a .com its handled differently to the .au domains, but I only have one of them anyway (kgoetz.id.au).
What happens
- I decide I want to transfer the domain
- Email domaincentral for my domain key
- Register an account with Jumba
- Put in the domain key on the Domain central website, wait about a week
- Got an email from domaincentral asking me to verify my whois info
- Got an email asking me to follow a link to confirm (details taken from whois entry). I followed the link and selected 'I approve'
- Jumba charge you for 12 months service ($11 at the time of writing) on transfer of a domain
- Got an email saying I can cancel the transfer in the next 3~ days and not to do anything if I want it to go through.
- 1-2 weeks later get a message from Jumba to let me know the domain is transferred.
All done!
Only catch is to log into Jumba domains you need to use the domain name+password in the email; your username+password won't work.
I'm yet to really shake down the Jumba UI, but so far its not looking all that much easier then domaincentral - fingers crossed and I'll provide an update later :)
Next Page ยป