Sortable Wiki Tables

Today I was reading an old comment from someone who had tried to update the CPF wiki with a table of flashlights and what kinds of batteries they use. To me this is something of fairly limited value because there are hundreds, if not thousands, of flashlights. And keeping a list up-to-date would be a lot of work. Plus I think most doing research on lights will know what their options are.

But the table this guy was trying to put in (he was stopped by the moderator for some reason) was pretty interesting. It lets you click on the headings of the table to sort by that column. I didn’t realize such a thing existed, but it is pretty neat. Anyway, the guy had posted a few rows of the code he had written, so I made a new entry here to see how it works. It puts a funky symbol in the heading that looks kind of like an elevator Door Close button (><). Then you click to sort by that column, which then toggles for ascending and descending. Pretty neat. And while there are all kinds of things that Wikipedia can do through add-on templates, the sortable table is built-in to the default installation of MediaWiki.

I added in a row of my own, but it's kind of a pain writing Wiki tables (though easier than in HTML). If I ever really develop this page, I think I would make an Excel spreadsheet and then export from Excel to Wiki using this online tool.

Wiki Customization

The Flashlight Wiki that I set up recently is doing pretty well so far (though it isn’t showing up in my webserver statistics so I don’t know how many visitors I’m getting; well, it shows a total on the wiki page). But I have made a lot of changes to the default installation in order to get things the way I want them. So I thought I would make a record of that in case I have to reinstall from scratch. These changes are for MediaWiki 1.16.0. Later I upgraded to 1.18.0 and made a new entry about customizations.

Things done in LocalSettings.php file:

Change path to new 135×135 logo that I made (from FAQ):

$wgLogo = "http://igirder.com/led.png";

Put in new line for favicon path (from FAQ):

$wgFavicon = "http://flashlightwiki.com/backup/favicon.ico";

Restrict edits to registered users who have been confirmed by the admin (from FAQ):
// Prevent anonymous users from editing
$wgGroupPermissions['*']['edit'] = false;
$wgGroupPermissions['*']['createpage'] = false;
$wgGroupPermissions['*']['createtalk'] = false;

// Prevent registered, non-confirmed users from editing (from FAQ):
$wgGroupPermissions['user' ]['move'] = false;
$wgGroupPermissions['user' ]['edit'] = false;
$wgGroupPermissions['user' ]['createpage'] = false;
$wgGroupPermissions['user' ]['createtalk'] = false;
$wgGroupPermissions['user' ]['upload'] = false;
$wgGroupPermissions['user' ]['reupload'] = false;
$wgGroupPermissions['user' ]['reupload-shared'] = false;
$wgGroupPermissions['user' ]['minoredit'] = false;
$wgGroupPermissions['user' ]['delete'] = false;

// Allow confirmed users to edit
$wgGroupPermissions['confirmed' ]['move'] = true; // Only add this line if you want all users to be able to move
$wgGroupPermissions['confirmed' ]['edit'] = true;
$wgGroupPermissions['confirmed' ]['createpage'] = true;
$wgGroupPermissions['confirmed' ]['createtalk'] = true;
$wgGroupPermissions['confirmed' ]['upload'] = true;
$wgGroupPermissions['confirmed' ]['reupload'] = true;
$wgGroupPermissions['confirmed' ]['reupload-shared'] = true;
$wgGroupPermissions['confirmed' ]['minoredit'] = true;
$wgGroupPermissions['confirmed' ]['delete'] = true;

Enabled image uploads by making this statement true:

$wgEnableUploads = true;

Added a line to allow the wiki to generate thumbnails.

$wgMaxShellMemory = 524288;

Added a line to run a meta tag extension (also needed to add the meta.php file to the Extensions folder). Lets me include a meta tag for the main page description, but doesn’t seem to work for the page title (wiki uses TITLE tag anyway, not META):

require_once('extensions/meta.php');

Cached pages for quicker rendering (only does this for unregistered visitors, but I guess that would be most of the traffic).

$wgUseFileCache = true; /* default: false */
$wgFileCacheDirectory = "$IP/cache";
$wgShowIPinHeader = false;

When setting up the Wiki originally, I could pick a type of license, but picked none. To add a Creative Commons license, I configured these lines as follows (and put a logo image in my backup folder):

# $wgEnableCreativeCommonsRdf = true;
$wgRightsPage = ""; # Set to the title of a wiki page that describes your license/copyright
$wgRightsUrl = "http://creativecommons.org/licenses/by-nc-sa/3.0/";
$wgRightsText = "a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License";
$wgRightsIcon = "http://flashlightwiki.com/backup/creative-commons-icon.png";

I wanted to be able to do footnotes like they do in Wikipedia, so I had to add the Cite extension by downloading a compressed file, putting it in my extensions folder, and extracting it. Then I had to add this line to the end of localsettings:

require_once("$IP/extensions/Cite/Cite.php");

I decided to add some AdSense ads to the page just to see if I get any revenue. There is a MediaWiki extension set up for it, so I unzipped that in the Extensions folder. I also needed to set up a new ad in AdSense that was 120×240. This generated some code for the ad, but I only needed a few key parts of the code, adding the following to localsettings.php. The last line is an option that hides ads from registered users, but I’d like to see what ads are showing up, so it is commented out. The instructions said to make a change to main.css, but I didn’t do that (couldn’t find main.css at first, but it is in skins/monobook) and it seems to work fine:

require_once( "$IP/extensions/GoogleAdSense/GoogleAdSense.php" );
$wgGoogleAdSenseClient = 'ca-pub-8914738878891900';
$wgGoogleAdSenseSlot = '2337837216';
$wgGoogleAdSenseID = 'flashlight';
// Show the AdSense box only for anonymous users
#$wgGoogleAdSenseAnonOnly = true;

I wanted to have some kind of filter to keep bots from registering, so I installed the extensions ConfirmEdit and ASIRRA, adding the following lines to the end of the file (also modified ConfirmEdit.php to act only for new user registrations):

require_once( "$IP/extensions/ConfirmEdit/ConfirmEdit.php" );
require_once( "$IP/extensions/ConfirmEdit/Asirra.php");
$wgCaptchaClass = 'Asirra';

Once I prevented bots from registering, I wanted to delete the bots that had signed up already, but you aren’t supposed to just delete users, so instead you can merge the users and then delete them (this probably matters more if users had made any edits, but the bots were never confirmed, still better safe than sorry). So I downloaded and installed the User Merge and Delete Extension, adding the following lines to localsettings, and then commenting them out once I had merged everyone.

# require_once( "$IP/extensions/UserMerge/UserMerge.php" );
# $wgGroupPermissions['bureaucrat']['usermerge'] = true;

Lastly, I had to add these two lines to allow short URL’s (using unrecommended method (also had to modify .htaccess to make this work, see next section):

$wgArticlePath = "/$1";
$wgUsePathInfo = false;

Modifications to .htaccess file

First, when using an add-on domain like this, there are a lot of ways to see the web pages, and I only want people to be able to see them as http://flashlightwiki.com/stuff

But since it is a subdomain *and* and add-on domain, people could get to by seeing the subfolder on igirder http://igirder.com/flashlightwiki/stuff as well as http://flashlightwiki.igirder.com/stuff, so these lines in my .htaccess file redirect both of those (code from here, but I adapted it to get rid of the www. prefix on the destination):

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?flashlightwiki\.igirder\.com [NC,OR]
RewriteCond %{HTTP_HOST} ^!www\.flashlightwiki\.com [NC]
RewriteRule ^(.*)$ http://flashlightwiki.com/$1 [R=301,L]

After that add these lines to redirect www.flashlightwiki.com to flashlightwiki.com (not sure what the second two lines do):

RewriteCond %{HTTP_HOST} ^www.flashlightwiki.com [NC]
RewriteRule ^(.*)$ http://flashlightwiki.com/$1 [R=301,L]
RewriteCond %{REQUEST_URI} ^/flashlightwiki($|/.*$)
RewriteRule ^.* http://flashlightwiki.com%1 [R=301,L]

To get short URL’s to work, I had to make the changes shown just above to localsettings, but I also had to add this to the .htaccess file (for Wiki’s installed to root directory, which is what I did originally, not knowing any better). I did this after the stuff above so as to at least hopefully get people in close to the right format of URL before attempting any of this:

RewriteRule ^[^:]*\. - [L]
RewriteRule ^[^:]*\/ - [L]
RewriteRule ^/*$ /index.php?title=Main_Page [L,QSA]
RewriteRule ^(.+)$ /index.php?title=$1 [L,QSA]

Changes to Main.css

I thought it would be good to have internal links one color and external links the traditional blue (purple if a link has been visited before). Wiki also has red links for links to pages that don’t exist yet (dark red if you’ve tried to visit the page before). So I thought green would be good, but it was kind of hard to do light green and dark green, so I did dark green for unvisited internal links and brown for visited links. To do this, I had to change the main.css file under the skins/monobook folder. Technically you aren’t supposed to change main.css because it is part of the installation and this should be done with a separate css file. So if I upgrade or change the skin, I will have to make these changes again. There doesn’t seem to be a special class for internal links, so instead I set the general links to green and brown and then set new external links to blue and purple. So I revised these existing lines to read:

a {
text-decoration: none;
/* was color: #002bb8; */
color: #006600; /* dark green */
background: none;
}
a:visited {
/* was color: #5a3696; */
color: #663300; /*brown*/
}

Then I added these lines after that:

:link.external {
color: #002bb8;
}
:link.external:visited {
color: #5a3696;
}

Somewhere I read that when changing link colors you should use :link instead of A because A can be anchors, not just links. While I was messing around with colors, I also made the background color an off white (light yellow) by modify this line near the top of main.css:

#content {
background: #ffffdd; /*was white*/

Prefs that I modified
http://***/MediaWiki:Prefs-help-realname

Changed this to warn people registering that their accounts will not be activated until they send me an e-mail or PM at CPF or BLF.

Things I still want to do:

Enable multiple languages or at least a translation button. A guy from a Spanish language flashlight site said he would do some translating if I could enable other languages like Wikipedia does. The only way to get true multi-language support is to install a wiki for each language and have a “family” of wikis.

Change the title of the main page from Main Page – Flashlight Wiki to just Flashlight Wiki to maybe help search engine ranking. I think this will require changes to a javascript file (since it only applies to the Main Page, it has to be written as an IF statement), but I couldn’t find out where to do that.

I’d like to set up support for equations, but my first try to do that wasn’t successful (see comment of Jan. 2, 2011).

File size uploads are restricted to 2MB by default, but I’d like to change that to 500kb or smaller so people don’t upload giant images. This might require tweaking server settings that I don’t have access to though.

New Flashlight Wiki

I have been learning a lot about flashlights over the last couple of years. As a way of keeping all of the information straight, I wrote a lot of articles for CandlePowerForum’s Wiki. Their Wiki was pretty sad, but it became a really good resource that I could refer to. I don’t know if that many people were using it, but it was helpful to me at least.

But the problem with the CPF Wiki was that it was under constant spam attacks. The administrator there took some steps to stop the spam but last week almost all of their pages were vandalized. I reported this to the admin and the user that had damaged the pages was blocked, but the vandalism was not undone. I certainly didn’t want to fix all of those pages. I have offered to help administer the wiki in the past, but the administrator does not want any help. Also some pages are locked and the ability to upload images, which could be really helpful, has been turned off.

Continue reading “New Flashlight Wiki”

Favicon

A lot of web pages include a very small icon that will show up in the URL when you are visiting the site and in your bookmarks when you bookmark that page. This feature was first introduced by Microsoft for Internet Explorer but other browsers picked it up. The icon file itself is usually called favicon.ico (“favicon” being short for favorites icon, since it shows up in your favorites). The one for this website is this:

mac5ico.png

Continue reading “Favicon”

Wikipedia Templates

Today I was reading my Wikipedia Offline about the Japanese bullet trains. I was doing this because I had read an article that asked if the US would ever get high-speed rail. And it seems like Japan has had it for an awfully long time, so it’s not like it’s all that high tech anymore. Anyway, it quickly became obvious that I wasn’t getting the whole article. Here is what I read:

The , also known as the bullet train, is a network of high-speed railway lines in Japan operated by four Japan Railways Group

companies. Starting with the Tōkaidō Shinkansen in 1964, the now long network has expanded to link most major cities on the islands of Honshū and Kyūshū at speeds up to . Test runs have reached for conventional rail in 1996, and up to a world record for maglev trainsets in 2003.

Here is the original article, which has a lot more facts in it, including the name of the train, the speed of the train, and the length of the rail lines:

The Shinkansen (新幹線?, new main line), also known as the bullet train, is a network of high-speed railway lines in Japan operated by four Japan Railways Group companies. Starting with the 210 km/h (130 mph) Tōkaidō Shinkansen in 1964, the now 2,459 km (1,528 mi) long network has expanded to link most major cities on the islands of Honshū and Kyūshū at speeds up to 300 km/h (186 mph). Test runs have reached 443 km/h (275 mph) for conventional rail in 1996, and up to a world record 581 km/h (361 mph) for maglev trainsets in 2003.

Continue reading “Wikipedia Templates”