Access keys: more confusion than else?

April 10th, 2006

These days I’ve been won­der­ing on an impor­tant (web) issue: does the access keys really helps the end user more than con­fus­ing it?
I used access keys in dif­fer­ent sit­u­a­tions: a company’s site, an “ama­to­r­ial” page, a very little asso­ci­a­tion and so on. Every time I used them because I felt I had to do it, but not this time. I’ve been redesign­ing a company’s site (as I said in the pre­vi­ous post) that now is pretty fin­ished, and I choose to remove the access keys. And I have at least three rea­sons to moti­vate this choice.

1. Dif­fer­ent imple­men­ta­tions for every browser
Let do an exam­ple: sup­pose we have to go to the link pointed by the access key ‘0’. Now you’re run­ning explorer on win­dows, so you have to press CTRL + ALT + 0. If you are, instead, run­ning fire­fox on win­dows, you have to press CTRL + 0. And if you run opera, you have to press ALT + 0. And wait, if you’re on linux, with fire­fox, you have to press ALT + 0. And, at least for me, it’s a bit confusing.

2. Short­cut rede­f­i­n­i­tion
What hap­pens if you define ‘F’ as an access key? Well, hap­pens that you can’t use it. Not always, at least. Because you’re redefin­ing one of the most used short­cuts: ALT + F. This means you can’t use the ‘F’ as an access key under fire­fox on linux and opera both on win­dows and on linux. And this is just an example.

3. Do you remem­ber?
When you have more than three links with an access key defined, becomes hard to know what to press every­time. If you want to know what access key you should press, then you should see what letter is next to the link (sup­pos­ing is writ­ten, as it should be). Or worst, you should pass the mouse over the link. At this point, I guess that a click is faster.

By the way I didn’t talked about dis­able users. I guess they uses the access keys, although I don’t know in what per­centual. But they’re a restricted group, and I think that if you can make an acces­si­ble menu (I should make an entire post ded­i­cated to this topic), you shouldn’t have any big problem.

0 Comments, tagged with Web

PHP, PATH_INFO and url-friendly site

April 9th, 2006

These days I had to redesign a company’s site layout, due to host­ing ser­vices upgrades. Before, they were simple static HTML pages: now, they are (not really, they are about to be…) dynamic gen­er­ated ones. I cannot use mod_rewrite since the hoster dis­abled it due to secu­rity issues (?).
So I had to look for other ways to get a URL-​friendly site. The answer came from the phpinfo(); func­tion. I looked at the gen­er­ated page if there were some para­me­ter that well fits to have a URL friendly site. So I dis­cov­ered PATH_INFO.
I’m using PHP since a long time but I never heard such a fea­ture, so I had to learn some­thing new.
We can have, in this way, a URL like this: http://​www.​site.​com/​p​a​g​e​.​p​h​p​/​s​e​c​t​i​o​n​/​s​u​b​s​e​c​t​i​o​n​/​s​u​b​s​u​b​s​e​ction that can easily become using apache .htaccess (if the hoster sup­ports it, obvi­ously) like this: http://​www.​site.​com/​p​a​g​e​/​s​e​c​t​i​o​n​/​s​u​b​s​e​c​t​i​o​n​/​s​u​b​s​u​b​s​e​ction, hence by remov­ing the .php exten­sion and by make the php page as another sub­di­rec­tory (I’ll describe how to do this later).

So let start look­ing at how PATH_INFO works.
First of all, let create a page called page.php that will handle the para­me­ter pass­ing. Now let sup­pose that we are pass­ing a URL like this: /page.php/section/subsection. We will found in PATH_INFO some­thing like this: /section/subsection. Hence, sup­pose we want to show the file named “section_subsection.php” in the pages/ direc­tory. Simply, a $array = explode('/', $_SERVER['PATH_INFO']); will give us “sec­tion” into $array[0] and “sub­sec­tion” into $array[1]. Now you just need to con­cate­nate the two array ele­ments and adding .php (or what­ever you want) exten­sion and, after check­ing the file exis­tance, you’ll have the work done.

Thats the code I used in order to achieve such effect (the code that’s in pro­duc­tion, I am still work­ing on it so it may have some error):

<?php
  require(dirname(__FILE__) . "/config.php");
  require(dirname(__FILE__) . "/functions.php");

  $exclude_list = array("img", "frontpage");

  if (!isset($_SERVER['PATH_INFO']))
    header("Location: {$_CONFIG['url']}{$_CONFIG['pager']}/home");
  else $tpath = $_SERVER['PATH_INFO'];

  $tpath = explode('/', $tpath);
  $path = $tpath[1];
  if (isset($tpath[2]))
    $subpath = $tpath[2];
  else $subpath = "";

  $exclude = FALSE;
  foreach($exclude_list as $exc)
    if ($exc == $path)
      $exclude = TRUE;

  if (!$exclude) {
    if ((count($tpath) > 3) || (!file_exists(dirname(__FILE__) . "/pages/" . $path . ".php")))
      $page = "/pages/404.php";
    else {
      // if $subpath exists, we have /path/subpath, traslated as path_subpath.php
      if ($subpath !== "")
        $page = "/pages/" . $path . "_" . $subpath . ".php";
      else $page = "/pages/$path.php";
    }

    ob_start("ob_gzhandler");
    require(dirname(__FILE__) . "/head.php");
    require(dirname(__FILE__) . "/title.php");
    require(dirname(__FILE__) . "/menu.php");
    echo "<div id="content">n";
    require(dirname(__FILE__) . $page);
    echo "</div> <!--/content -->n";
    require(dirname(__FILE__) . "/footer.php");
    ob_end_flush();
  } else {
    $fullpath = implode('/', $tpath);
    $fp = fopen(dirname(__FILE__) . $fullpath, "r");
    $contents = fread($fp, filesize(dirname(__FILE__) . $fullpath));
    echo $contents;
  }
?>

Let anal­ize it. Firstly, why do we have an $exclude_list? This is needed because with this way of URL han­dling, every file that we will request under the site path will pass from that script. So, since we want to dis­play images and other things, just take the file as they are and print them out if such path is in the exclude list.
I used a couple of $_CONFIG values (that I define in con​fig.php) to have a cen­tral­ized con­fig­u­ra­tion system. Specif­i­cally, $_CONFIG['url'] will con­tain the site’s URL, while $_CONFIG['pager'] will con­tain the file­name of the script that will handle the PATH_INFO data, in our case page.php.

Suc­ces­sively, there’s a check about the file exis­tence into the /pages direc­tory. The rest is just the use of the buffered output since I some­times use a header() call in the other pages both to redi­rect the user to some other page and to set the right error­code for a 404 page.

Of course there are some improve­ments that could be done. Prob­a­bly, the most impor­tant lim­i­ta­tion in the script now is that it has a limit of two sub­sec­tions (like /section/subsection). This limit could be expanded by doing some­thing like this: implode('_', explode('/', $tpath)); but will need more checks for consistency.

Another thing: as I said before, you could want to delete the .php suffix on the page.php. This can be done by putting this lines in the .htaccess:

<files page>
ForceType application/x-httpd-php
</files>

In this way we will force apache to call page.php if it is called as page only.

That’s all :) I have to make shorter posts, I know.

1 Comment, tagged with PHP

IBM Thinkpad R50e

April 4th, 2006

WARN­ING: long post
I bought my first laptop: an IBM ThinkPad R50e (I found only an ital­ian page for this model, sorry me, but I guess there’s a trans­la­tion some­where over the IBM’s site). It has all the things I need with­outh any esotic com­po­nent. So I started hack­ing it…
The debian’s instal­la­tion worked well (with test­ing netinstaller) and I hadn’t any prob­lem. The only think you should keep in mind when con­fig­ur­ing xorg is to use this in the video section:

Section "Device"
        Identifier      "Intel Corporation 82852/855GM Integrated Graphics Device"
        Driver          "i810"
        Option          "VBERestore" "yes"
        Option          "Clone" "true"
        Option          "MonitorLayout" "CRT,LFP"
        Option          "DevicePresence" "yes"
EndSection

In this way you’ll have the mon­i­tor port work­ing (for exam­ple if you want to con­nect the laptop to a video projector).

The first thing I wanted to make work has been the soft­ware sus­pend fea­ture (I’m not talk­ing about the ACPI sleep state, or as it is com­monly named “stand by”, but a real suspend-to-disk fea­ture).
This can be accom­plished in sev­eral ways, but usu­ally with swsusp (that’s kernel inte­grated since 2.6.12 if I recall cor­rectly) or suspend2. With a default setup it doesn’t always work; the shut­down process works well, but the resume hangs when restor­ing ACPI inter­rupts. I tried both ways, with suspend2 it never worked: when resum­ing it hangs at “copy­ing orig­i­nal kernel back”. With swsusp you have to exclude some dri­vers in order to don’t always hang. First of all, remove rtc (real time clock) sup­port. With it enabled I get crash­ing more often than I need. Then don’t use intelfb: although it should be sup­ported, the swsusp with this module loaded works one out three times. I had some crashes with­outh 3D accel­er­a­tion enabled too (but just load i915 and every­thing goes ok).

Then I tried to make some­thing cool with the thin­k­light. There’s already some­thing really cool out there (rock­light over every­thing). But I did some­thing cooler: every key I press makes the thin­k­light blink. That’s not useful, nor mind­sane, but def­i­nitely geek. That’s done through a kernel patch over the key­board driver. As soon as I finish to do some checks I’ll pub­lish the patch here.

About the wire­less card: I can’t get it in mon­i­tor mode by using vanilla kernel sources. If you want mon­i­tor mode, use ipw2200 and ieee80211 from sf.net (http://​www.​ieee80211.sf.net and http://​www.​ipw2200.sf.net) but they’re not so stable. I keep losing 10-15% of wire­less pack­ets with them. There’s not mon­i­tor mode, but since I never done wardriv­ing (and I don’t plan to make it), I think it’s good for me.

And if you want to make some­thing cool to show to the friends, then install fluxbox and 3ddesktop and bind /usr/bin/3ddesk to some key: that’s what will bring your friends to linux.

0 Comments, tagged with Linux

Microblogging

July 29th

twitter (feed #2)
Python's date & time functions are horrible. Really. [krat]
2:31pm via Twitter
twitter (feed #2)
Wondering whether I should buy a new set of hearphones or if I should try to fix the old ones [krat]
11:13am via Twitter

July 28th

twitter (feed #2)
discovered beeseek (http://beeseek.org), looks like a very interesting project [krat]
6:08pm via Twitter

July 26th

twitter (feed #2)
just wrote down some help numbers for my next trip, the most important one being the italy's embassy [krat]
2:12pm via Twitter

July 24th

twitter (feed #2)
that's what I call hot weather [krat]
2:00pm via Twitter

July 23rd

twitter (feed #2)
Looking for an (italian|english)<->bulgarian dictionary [krat]
2:05pm via Twitter
twitter (feed #2)
home, sweet home. [krat]
10:10am via Twitter

July 22nd

twitter (feed #2)
Heading to bulgaria (sunny beach) this summer. Not one of the classical holidays places, that's for sure. [krat]
8:50am via Twitter

July 19th

twitter (feed #2)
I hate hotels. [krat]
2:32pm via Twitter

July 17th

twitter (feed #2)
Back in Italy. Discovered this P3 disgusting thing. Want to go back in Spain. [krat]
12:20pm via Twitter

Powered by Lifestream.

Search

« Authored by Giuliani Vito Ivan »