Archive for June, 2006

general fun with themes

I know I’ve been quiet — it’s been busy at work and lethargy-inducingly humid once I get home. Plus I’ve been working on a new plugin and setting up a phpbb forum (and working on a skin for that: why is it I can never leave well enough alone?). In any case, I worked out a rather convenient way of being able to drop in a new theme and standardize its sidebar pretty quickly. A new theme has a vanilla sidebar which besides not including all my cool perks, most importantly does not include a theme switcher. Meaning that when I install it, if I didn’t add at least the theme switcher hook, a visitor could wind up trapped in that theme. Ugh. At the same time, dropping in a new sidebar got tedious, especially when there were a few cases I added or changed something and had to migrate those changes across the board.

So I came up with this solution, which is working well for me, though it’s not 100% adaptable to everything (it’s best suited for two column formats with sidebar on left or right, although it seems to be okay when the sidebar is the footer, as the latest trend of single column themes is taking hold). It’s a tinker-under-the-hood process, though, so if you’re not comfortable rooting around in your wordpress files, you may want to pass this up. For the rest of you, if this sounds interesting, roll your sleeves up!

First of all in any theme (or most standard ones), there will be a sidebar.php file. In themes set for WordPress 2.0 and onward, these seem to be wrapped in a div with a sidebar id and using a basic ul for formatting. They’re not completely identical, especially older themes seem to have some kind of menu or other class/id in use. Plus, some themes seem to have an annoying format where the first line (I kid you not) in the sidebar.php file is a </div>!! I haven't dug into this issue deeply enough to determine whether it's an unfortunate necessity, or crappy formatting. The upshot of all this, though, meant that I couldn't use my first solution, which was to move a copy of sidebar.php up to the general themes directory and softlink back to it from within each specific theme directory.

What I did instead was isolate the common elements within the wrappers in the sidebar file and yank those out into the general themes directory in a file I called sidebar-contents.php. I then replaced that part of the code with an include file. So for example, my default theme's sidebar file looks like this:


<div id="sidebar">
<ul>

<?php include (TEMPLATEPATH . '/../sidebar-content.php'); ?>

</ul>
</div>

And this has been working a treat. Now when I play around with the format of my sidebar, I change items in the included file, and all changes are instantly available to all the themes.

Told you I was a lazy programmer ;-)

del.icio.us:general fun with themes  digg:general fun with themes

Comments (2)

untangling regional dvd restrictions

Overview

So in Windows and Mac, there’s this so-called regional settings that only “allows” you to change your regional settings five times before “locking” it in, courtesy of the entertainment industry determined to dictate every choice to their customers and squeeze every penny out of them into the bargain. Ah, the fresh smell of capitalism in the morning. ;-)

The way it works is that DVDs which are “Region 1″ (2, 3, etc) are CSS (content scramble system) encrypted. The settings on the computer indicate which “region” it is, and that will refuse to play those DVDs not matching the set region. This is a result of collusion between OS companies (eg, Microsoft, Apple), DVD drive companies (Panasonic, Sony, etc), and assorted software programs. It’s an ongoing legal tangle, and also when OpenSource is tossed in, gets interesting fast, as OpenSource will not generally “respect” the encryption and simply play DVDs regardless, although such a user generally will need to install a few extra programs and such to make it all work so in the end, everyone winds up having to work around this issue.

Oddly enough, it’s almost simpler when discussing DVD players. For these, just google up the brand name of the player, along with the terms ‘region free” etc, and it’s possible to find, for most players, the codes necessary to convert the player into multiregional or region free players. Once that’s done and it’s hooked up to the TV set, playing any DVD is not a problem.

Approaches

But back to DVD drives in computers: there are several ways around regional restrictions. One has been to hack the firmware on the DVD drive. This isn’t an especially good idea since such hacking can render the drive dead a certain percentage of time. So I’d toss that out.

A second option is to copy the DVD first, stripping out the CSS, and burning the altered copy to a blank disk and using that DVD instead. This works, but is a little cumbersome — having to copy each encrypted DVD before viewing it.

Finally, there are software programs that simply bypass the operating system restrictions. These can be built into the dvd players themselves, or be a separate program functioning on its own, allowing the user to use whichever favorite software for viewing the disc’s contents.

Windows

For Windows users, most of the options center around the third one, although a number include the ability to use the second approach as well. For example DVD Region + CSS Free and DVD Region Free Master (both very reasonably priced shareware). The programs work at the software level to bypass any restriction on the computer’s dvd drive, whether or not it has been locked (changed more than five times) and without altering its allowable changes.

DVD Shrink allows users to copy commercial dvds to blanks. The program allows for copying and compressing and/or eliminating parts of the original dvd, including stripping the CSS encryption.

Mac

For Mac users, the picture is a little different. There are some programs out there but there don’t seem to be that many (and which seem to be for older versions), which puzzles me because OSX is Linux based, more or less. Some of the issues seem to revolve around which Mac one has, and which dvd drivers it has. VLC may work for some Mac users, but does not work for all. I did find this article which summed up the issues for mac users and described one solution the author worked out. I have also seen speculation that Mac’s new Bootcamp software might allow Mac users to run the Windows region free software + dvd playback to obtain similar results (but I did not find anything written up by anyone who’d tried it to see).

There’s a program called MacTheRipper which allows copying of DVD’s minus the encryption. Also check out DVDBackup to back the DVD up on the computer.

Of course with the new Intel chips, a dual boot WinXP and mac, or dual boot with Linux and Mac and move back and forth as needed. :-D

Linux

As an Open Source operating system, Linux’s difficulties with CSS encryption stem from the proprietary nature of the software. In most cases, what a Linux user needs to do is download the additional software and codecs to view DVD’s. Most distributions will have instructions available somewhere on how to do this: googling on the distribution name and region free will in most cases uncover instructions specific to the distribution. For example, googling on “ubuntu dvd region free” (without the quotes) will uncover tutorials such as this.

There are a wide variety of players, such as mplayer, Xine, Kaffeine, Ogle, and Totem. Most distributions will come with one or more of these, the trick is enabling the play for encrypted DVDs as covered in the previous paragraph. Of these, Kaffeine is generally considered the best of the lot. The rest may not have a full gui interface, or sync properly, be somewhat buggy, or have other limitations.

As for creating region free DVD’s: one method is outlined here and another nice overview is here. The basic idea is as with the mac: create a copy or backup on the computer, and then burn selected portions to the blank disc.

Cross Platform

One name that kept popping up was VLC which has versions for Linux, Windows, and Mac. I have not tried this myself, but the user feedback/ratings look pretty good.

Further Information

Check wiki for more overall information on DVDs, DVD software, and dealing with CSS.
For complete informatin overload (but well written and easy to skim for specific questions), check out the DVD faq.

Legal Issues

Notes about legality. It’s becoming a bit more common to find notices such as this one even outside the U.S. Not only do laws vary from country to country but they appear to be in the process of changing, as more attention is paid to this issue. I should stress that this article is provided for informational purposes.

Also, I am not a lawyer, but this is my view: When I purchase a book, I am entitled to read it, whenever and whereever I want to. I can read it as many times as I want to. I can do anything to the book itself — write in it, tear pages out, laminate it, store it, throw it away, give it away, or sell it. I may not make copies of it, with the exception of small excerpts and such under “Fair Use” doctrine (eg, quoting passages in a review, that kind of thing). Extending that concept to a DVD, I personally find the encryption and regional restrictions problematic, as these may prevent me from enjoying something I have paid for the right to view. I therefore view getting around the encryption to be a legitimate exercise in being able to make rightful use of a product I’ve paid for.

The gray area is, obviously, when DVD’s are copied. And here it’s unclear: for example it’s been established as acceptable for users to make personal copies of audio tapes or CD’s — for example making a cassette tape for personal use, because one’s car does not have a CD player, or “timeshifting” where one makes a VHS copy of a broadcast to view later. No reselling is involved. So making a copy of a DVD for personal viewing ought to fall into similar categories (watch a DVD on laptop), but the companies are nervous because at this point, redistribution of copies is ridiculously easy over the Internet (not as easy to make VHS tape copies and distribute, nor audio cassette copies and distribute). That, in a nutshell, is why DVD copying is an “issue” and why the conventions are inconsistent between book, tape, and CD/DVD.

del.icio.us:untangling regional dvd restrictions  digg:untangling regional dvd restrictions

Comments (2)

the horror that is MSIE 6

I know this is a bad browser. But when I’m on the user end, it’s easy enough to ignore, especially when I use Firefox or Opera or even Konqueror. However on the web author side, it really makes me tear my hair out. And I just found a beaut of a bug, where it doesn’t like plaintext http in certain situations. I played around with it for a while, and finally just excluded the call to the plugin based on browsers. So, if you’re reading this with MSIE 6, you are not seeing the recent comments in the sidebar. (And if you’ve got XPSP2 and/or plan to upgrade to Vista, definitely snag IE7. I’ve been pleasantly surprised with how many standards compliance issues they actually fixed…)

My coworker isn’t very helpful: telling me I should put in an activex control that shuts down IE6 if someone tries to open DR in it :-D Oh, the temptation…

del.icio.us:the horror that is MSIE 6  digg:the horror that is MSIE 6

Comments

wp-CaTT modifications

I use the wp-CaTT plugin for a simple Technorati hook. All it does is add Technorati links straight off the WordPress categories I choose for each article. I like it because it is simple, focused, and fast. I don’t have to do anything extra — always a bonus, I’m very lazy — to get it to work, and it doesn’t slow down my website either (generally, DreamHost does that just fine all by itself). Other plugins I looked at got all complicated with specialty tags where I’d have to remember not only the syntax, but to do it at all while scribbling my notes down. Or, they had so many (admittedly very impressive) bells and whistles that I simply wasn’t utilizing all of them which always seems a waste. Or worse of all, they slowed the site down.

However, in my mad theme-a-thon of yesterday and in my subsequent tweaking of each theme to standardize them a little bit and so on, I noticed this plugin really didn’t handle different theme’s varying separators. When I print out the categories for each post, I do so via a call like this:


<?php the_category('<br />') ?>

What this does is it prints out the list of category links (linked to my own WP’s database of categorized posts). The parameter tells it how to separate each category, in the above case with br’s, so in that example, all the categories will be on their separate lines (this is from the Barthelme theme). There are all kinds of possibilities: Chocolate Bar uses vertical bars as separators, and DR’s default theme uses commas.

The wp-CaTT plugin, however, is set up so that when I drop it in and use it, I need to edit its php file to set a variable to the same value used in the call to the_category.

Obviously when I started using multiple themes, that became a problem. So I went poking about in the plugin’s code, and found this:


    // 1. SET THE Delimiter TO THE CHARACTER YOU'RE USING TO SEPARATE MULTIPLE CATEGORIES APPLIED TO THE SAME POST.
    // FOR EXAMPLE, IF YOUR INDEX.PHP FILE CONTAINS the_category(', ') YOUR Delimiter IS ", ".
$Delimiter=", ";

which I replaced with (after tinkering with several other ideas):

    if (preg_match("/,/", $url))
            $Delimiter = ", ";
    else if (preg_match("/<br ?\/>/", $url))
            $Delimiter = "<br />";
    else if (preg_match("/ \| /", $url))
            $Delimiter = " | ";
    else
            $Delimiter = ", ";

There’s probably a better way to gracefully handle it if none of the matches work. I thought of defaulting to a simple space, but the problem is the $url variable is basically a list of href’s so there’s plenty of spaces, and such a default if it got used would result in a mess on my screen. I suppose that would be one way to alert me to the need to add another check.

I’ve been trying to think of a nice way to allow wp-CaTT to be flexible about what it can recognize and match against. One issue is that the $Delimiter variable needs to be set to whatever the actual delimiter is. I can’t just use a longer regexp that combines all the terms, because the plugin reassembles the original href’s with the added Technorati tags, using the delimiter. In addition, I can’t just use the list of delimiters straight, I have to regexp-ify them. In other words, the delimiter " | " has to be escaped because the vertical bar carries special meaning in regexp’s. Or the br took an optional space (" ?") because some people put down <br /> and others <br>. Hmmm…I suppose people also put down just <br>, too… ‘k…


   else if (preg_match("/<br ?\/?>/", $url))

that fixes that…

I suppose I could take the tack that the Technorati bubbles themselves become the separators, and leave the delimiter empty. But then a theme like Barthelme points out the need to preserve it anyway, because Barthelme prints each category out on its own line and the cleanness of that presentation is spoiled if the categories start wrapping instead.

del.icio.us:wp-CaTT modifications  digg:wp-CaTT modifications

Comments

theme-a-thon!

Having MUCH too much fun with theme rotation… :-D

Actually though, I think every theme developer should play around with something like this. Because I’m starting to develop some very strong preferences for basic setups, such as:

  1. always package up your theme in a directory so when I unzip it, it keeps everything tidy in it’s own directory, ‘k?
  2. don’t make your sidebars (or other .php files) so weird I can’t drop in copies of my already tweaked sidebars in! (I found one theme that closed off a div before starting the sidebar div — which meant it didn’t play well with anyone else!)
  3. make sure they use the right hooks and such…I found some that didn’t incorporate some of my auto-plugins (ones that didn’t need stuff added to files in the theme directories) — those went buh-bye though I liked them…

Note that the only mods I did to these themes was to ensure that they all had a theme handler in the side bar so that no one gets stuck in a theme with no exit. But in the longer run, I want to set them all up with soft links to the same sidebar.php file. I’ll also need to tweak some a bit for the category/technorati tags to come out right and such. But this is fun…

Okay, enough lunch time play…back to work!

del.icio.us:theme-a-thon!  digg:theme-a-thon!

Comments

« Previous entries Next Page » Next Page »

Bad Behavior has blocked 452 access attempts in the last 7 days.