Archive for October, 2007

Open Source Alternative

If you’re looking for a Free Software/Open source (FLOSS) alternative to proprietary software, Open Source Alternative (www.osalt.com) is a good starting point. Just put the proprietary application name in the search box and you can quickly find a free alternative.

HTTP 301 Page moved in Drupal

Scope: Move an old document to a new URL with HTTP 301 Permanent Redirect.

Module used (required if you don’t want to modify an existing page): URL aliases.

  1. Create a new page (or edit an old one). Select “PHP code” in input type.
  2. Fill the url alias box, with the old document path
  3. Insert the following code: <?php
    // Permanent redirection
    header(”HTTP/1.1 301 Moved Permanently”);
    header(”Location: http://www.yoursite.tld/location”);
    exit();
    ?>
  4. Save.

Note: Obviously you can’t see the page (you’ll be redirected to specified address), but you can edit or delete the page from admin/content/node. As admin, if you try to unpublish the page you’ll be redirected anyway: you have to delete the page to fix it.

See also: http://www.somacon.com/p145.php

tar copy on-the-fly

*nix command of the day:

tar -cf - <source directory> | (cd /<target directory>;tar -xf -)

It can copies many files quickly.

See also:

http://unix.derkeiler.com/Mailing-Lists/SunManagers/2005-03/0413.html

moving files directory in Drupal

I’ve a multisite installation of Drupal 5.x, a modified Garland theme and user pictures (avatars) enabled. Till now, I used a single “/files” directory for all sites…yes, it sounds freaky (and it’s). I want to enable image upload, so now I want to create something like “files/my1stsite” without Drupal explodes. How to do that?

  1. If you have enabled CSS compression in admin/settings/performance, disable it
  2. Copy (not move!) the user picture folder (i.e. avatar) to “files/my1stsite”. Note: you have to make files and folder writable, if they aren’t: if you omit this step, users cannot change their avatar.
  3. (recommended) Put your site offline to prevent changes.
  4. Change manually all the user pictures path on the database table drp_shared_users, field “picture”. Before: files/avatar/picture-… After: files/my1stsite/avatar/picture-… Existing users images now are taken from the new folder.
  5. Go to admin/settings/file-system and set the new system path (i.e. “files/my1stsite”). Now even new users pictures go in the new folder.
  6. Go to admin/user/settings, verify the users pictures path and save.
  7. Go to admin/build/themes/settings/garland and save. It’ll create a “color” folder in the new system path, regenerating the theme.
  8. If you use image cache, you have to go to admin/settings/imagecache and update all your presets. Check any other module that uses the files directory.
  9. Put online your website. Now you can reactivate CSS compression.

Use this tutorial at your own risk.

Important: if you have a shared user table, avatars will be only visible in the site where users uploaded them, due to the (questionable?) choice to store a relative path in user tables.

UPDATE: to solve the latest problem, you’ve to patch user.module:

Old string:

$picture = file_create_url($account->picture);

New string:

#patch to multisite user picture de-linked

$picture = $account->picture;

If you use site user list, you’ve to change on admin/settings/site_user_list/fields the template value from:

<img src=”@_base/@picture” alt=”" />

to:

<img src=”@picture” alt=”" />

suppressing @_base value. Note: giving an “alt” value is good for accessibility, so do it. You can also link user profile wrapping image in a “<a href=”user/@uid”>” or “<a href=”user/@name”>” (if you use URL rewrite).

Data remains

Yesterday I took some old floppy disks and, one by one, started to copy their content on my HD. Once a time, I used to back up my web discussion on floppy like that in simple text files and many other things. Even Sim City 2000 saved cities. I found files with 1996-01-31 17:53:32 as timestamp, old holiday homework papers, documents, even some leaflets I’ve written when my university try to close a free access Informatics laboratory. When I had only a 56k, that laboratory was my window on the web, and I collected 116 signatures, a good number for a small provincial branch.

This year, that branch closed enrolment for the student of the 1st year, and probably it’ll be closed soon. I’ve lost contact with my old colleagues, even theirs blogs are freezed for months. I back to some of that discussion, and I found forum closed some years ago.

If data are ephemeral, what of our relations? Infrastructure survives to the scope, data remains.