Current Status of the Code Viewer WordPress Plugin
This site has been neglected for a long time, and that negligence has carried over to the development of the Code Viewer WordPress plugin as well. While I’ve been away, Code Viewer has been picked up/enhanced by a few other developers — namely AJ and Håkan Carlström — and has gained many new features…
Code Viewer now supports syntax highlighting using GeSHi, can display specific line numbers, and has user-configurable scrollbars (among a few other niceties). On top of those changes, the default code path variable can now be configured directly in WordPress’s admin interface rather than editing the plugin code by hand…very nice!
I don’t agree with all of the design choices they made with the new changes, but my qualms are minor. Specifically, I don’t like some of the chosen defaults, nor the new format when specifying viewcode tags:
[viewcode ] src=/code/example.txt link=yes[/viewcode]
…in comparison to the original:
<viewcode src="/code/example.txt" link="yes" />
That said, it is a cool feeling to find out that other people appreciate your work and chose to carry on with its development in your absence.
Passing the Torch
With the latest design incarnation here at ElasticDog, I decided to no longer use Code Viewer for displaying code snippets. Instead, I went with the plugin Code Markup, which allows me to easily embed custom markup within code blocks. It’s a completely different way of going about displaying code in blog entries when compared to Code Viewer, but it does the job well and suits my needs for the time being.
Although I haven’t actually worked on the development of Code Viewer since late 2004, I did register to have it hosted at the WordPress Plugin Repository. Unfortunately, I never got around to packaging it up for general consumption.
Trying to not be a slacker anymore, I have contacted Håkan in hopes of persuading him to take the reins and officially manage the plugin at the centralized WordPress repository. If he agrees, you should be able to download the plugin here very shortly: https://wordpress.org/extend/plugins/code-viewer/
In the mean time, you can find the most up to date version of Code Viewer at Håkan’s site. Happy coding!
Optimal Title Functionality Now in WordPress Core
I wrote Optimal Title three and a half years ago to help fix a blatant flaw in WordPress’s default usability and search engine optimization (SEO). Since then, the plugin has been downloaded by tens of thousands of people and written about by hundreds of bloggers. Soon, the plugin will become obsolete…
A Change in WordPress v2.5
As of the beginning of this year, a changeset was checked in to WordPress’s SVN repository which adds a “separator location” argument to the built-in
wp_title() function. What that means, is that when WordPress v2.5 is released around March 10th of this year, users will be able to change the ordering of their HTML title tags without having to use a third-party plugin.
The developers decided not to change the default behavior of
wp_title(), and instead added the additional argument to the function in order to prevent breaking existing themes that rely on the current behavior.
How to Make the Change
If you’re currently using Optimal Title and want to change your template back to using
wp_title() after upgrading to WordPress v2.5 (and you should), here’s what you need to do…
Using the simplified example from the original Optimal Title article, you should currently have something like this in your theme’s header.php file:
<title><?php optimal_title(); ?> <?php bloginfo('name'); ?></title>
Just replace the function call
optimal_title() with a call to
wp_title('»',TRUE,'right'), and you’ll end up with something like this:
<title><?php wp_title('»',TRUE,'right'); ?> <?php bloginfo('name'); ?></title>
The wp_title codex page won’t be updated until the next release, however, here is how
wp_title() will work after WordPress v2.5 is out:
<?php wp_title('separator', display, 'seplocation'); ?>
- 'separator' – string – The text to place between portions of the page title, such as the blog name and the category. Defaults to
- display – boolean – Should the title be displayed (
TRUE) or returned for use in PHP (
FALSE). Defaults to
- 'seplocation' – string – The location of the separator in relation to the title. All values default to the standard left position, with the exception of
'right', which will place the separator after the title rather than before.
Even though it took so long to get this done, I’m glad WordPress finally came around to the idea and added Optimal Title’s functionality to the core. Regardless of whether or not you were using Optimal Title before, I’d highly recommend that all users make this simple change to their templates in order to take advantage of the many benefits that a proper title tag has to offer.
HOWTO: Have Multiple Users Share an iTunes Library on One Machine
I recently purchased a new MacBook (never having owned a Mac before), and have been reading up on keeping things secure. Per one of those security-related suggestions, once everything was set up to my liking, I stopped using the admin account for everyday use and started forcing myself to log in as a regular user. I’ve also created a user account for my live-in girlfriend so she can go wild customizing her desktop with pictures of flowers, Hugh Jackman, Hugh Jackman laying in a bed of flowers, and so on, without making my eyes bleed.
The trouble is, we both buy music from iTunes on a regular basis using our own individual Apple ID accounts, and there isn’t an easy way to share our music seamlessly with one another. We have similar tastes in music and we’d like it so that when one person buys a new song, it is immediately available for the other person to listen to. Ideally, we’d also be able to create our own unique playlists and assign ratings to the various songs to reflect our own personal likes/dislikes. This article lays out the details of how I accomplished that goal…
The main problem with assigning two iTunes Libraries to the same location comes down to permissions. By default, when you download music through iTunes, it assigns permissions based on the user that’s logged in. It only allows that user and people in the UNIX group “wheel” to read the music file (if you’re UNIX-literate, that means it has 640 file permissions). Since a different user (in this case, my girlfriend) would not fit into those categories, she doesn’t have the proper permissions to read any of the music I download. To put it simply…music needs to be world readable.
These permissions can be easily fixed by running a simple script that uses the
chmod command to modify your music so anyone can play it. To give you a breakdown, the script runs a few safety checks to ensure that you have the proper permissions to modify the files, it then checks that your specified library actually exists, and then it recursively looks at all of your music making sure it is world readable.
The trick is getting the script to run only when necessary as not to waste resources. You could set up a cron job, but then it would have to run on a fixed time table. Either it would run more often than necessary, or not often enough…so cron is out. You could set up a launchd/launchctl configuration file and specify it to run when your Library folder is modified, but unfortunately that doesn’t get triggered when a sub-folder gets modified…so launchd is out.
The key ends up being something called a “LoginHook” that is configured in the
/etc/ttys file. Creating a LoginHook will ensure that whenever any user logs in to the machine, the script will be run and proper permissions will be set on the entire library.
Putting it All Together
This should go without saying, but I’m saying it…back up all of your music files before doing anything else! Once that’s done, proceed with the following steps:
- First you must pick a centralized location that all your users have access to and make sure the directory exists. I picked /Users/Shared/Music/iTunes and created it on the command-line using:
mkdir -p /Users/Shared/Music/iTunes
- Next, you must adjust your iTunes settings to point to the new location. You do this by launching iTunes, then navigate to iTunes » Preferences… » Advanced, and under the General tab, click the Change… button next to the “iTunes Music folder location” box. Navigate to your newly-created centralized folder (in my case /Users/Shared/Music/iTunes), and click Choose.
- For ease of maintenance and to prevent duplicate files from being generated, make sure the checkbox labeled “Copy files to iTunes Music folder when adding to library” is not selected (this is also under the Advanced section of the Preferences dialog box).
- Click OK to accept the changes you made to your preferences.
- To copy your current library to the new location, navigate to Advanced » Consolidate Library… then proceed by clicking Consolidate. This step only needs to be performed one time per user to ensure that everything gets moved over to the new location.
- Repeat these configuration steps for all users that you wish to consolidate libraries for.
At this point, you’ve done all that is necessary to do within iTunes, and all that is left is fixing the file permissions. To do that, log in as a user with administrator privileges and follow these steps:
- Download the script and put it anywhere you want. I made another directory called
/Users/Shared/bin/and put the script there, but the location doesn’t really matter.
- Modify the script’s
LIBRARYvariable (in the
CONSTANTSsection) to point to the centralized music directory you created above.
- Ensure that the script is executable by running:
$ chmod 755 /Users/Shared/bin/share-itunes
- Then edit the
/etc/ttysfile with your favorite text editor, and change the line starting with “console” to add:
right after the “loginwindow” declaration. Make sure you actually point it to the location where you downloaded the script to. The line should have looked something like this before you edited it:
…and look like this after you edit it:
console "/System/Library/CoreServices/loginwindow.app/Contents/MacOS/loginwindow" vt100 on secure onoption="/usr/libexec/getty std.9600"
console "/System/Library/CoreServices/loginwindow.app/Contents/MacOS/loginwindow -LoginHook /Users/Shared/bin/share-itunes" vt100 on secure onoption="/usr/libexec/getty std.9600"
- Save the file, and close your text editor.
That’s it! Everything should be all set to go and your permissions will be checked each time you log in to the computer.
The only thing I wasn’t able to automate was adding new music purchased by my girlfriend in to my library so it actually shows up when I launch iTunes. For all I know, there may be an easy way to automate it, but I haven’t found one at this time. Luckily it’s a fast/easy procedure to do by hand…
To actually have new music purchased by another user show up in your library, all you have to do is launch iTunes, go to File » Add to Library…, then navigate to your shared music folder and click Choose. It will take a few seconds to parse through your library, but after it’s done, all of the music should be available for you to play. You will have to do that every time you know that music has been added by another user, but everything else should be automated for you.
Why it Works
Unless you get tricky, iTunes always stores your album artwork, playlists, and song rating information in a file under your home directory (well, in ~/Music/iTunes, to be precise). It also stores a meta file with information regarding what it thinks should be included in your library. These files will be unique to the user even if you choose to share your actual music collections. So when you update your iTunes preferences to move the location of your Library, you still retain the ability to have all your own custom settings regardless of what other users add to the common music folder.
By periodically telling iTunes to add the common music directory in to your library, you’re simply forcing it to update the library meta file so it reflects whatever actually exists in that directory…regardless of whether or not you were the person to purchase the music.
Hopefully these steps will be able to help someone else out there having a similar issue. When I first started looking in to how to accomplish this configuration, I though surely it would be easy and done before, but alas, things got a bit more complicated than I had hoped. If you know of a better way, please do leave a comment and let us know what works for you. If you have any trouble understanding these procedures or getting it to work, let me know and I’ll see what I can do to help out…happy listening!