Category Archives: Coding

How To Make Your MediaWiki Private

USE THIS INFORMATION AT YOUR OWN RISK. Any information found on this website is offered only as informational and includes no warranty, guarantees or support. The author claims no authority on any subject whatsoever.

I've been using an amalgamation of hacks to track all the information I want to be able to recall later: del.icio.us for bookmarks, gmail for contacts and random notes, private blog entries for some organized content, and tracks for tracking projects. Blech. It's just too much. My memory is too weak. What I really want is a comprehensive PIM (Personal Informatio Manager). And so I installed MediaWiki because that's what Wikipedia uses and that's what Dreamhost offers as a One-Click Install (e.g. the path of least resistance).

I thought I'd share with you all the the process of customizing the default install to create a private wiki. Following are the specifics to my install but this will probably be helpful to many with a different host or newer version.

  • Create a subdomain for your MediaWiki install, such as, wiki.yourdomain.com. Select PHP 5.x (not 4.4.2) and leave Extra Web Security.
  • Install MediaWiki. Dreamhost walks you through this and it's also covered at the Dreamhost Wiki so I'm not going to go into detail here. But be sure to move the newly generated LocalSettings.php to the parent directory, and delete the config directory with its content.
  • Chmod LocalSettings.php to 600
  • Create a backup copy of LocalSettings.php, rename it something like .BAK instead of .PHP or something. Put it back in your Wiki install directory right away so it's safe and available if you need it later.

Restrict Wiki Access

Before bothering to put up our own cute logo or other fun stuff like enabling image linking and using clean urls, we're going to lock down our install. I didn't find a lot for this particular intent on the official MediaWiki Docs or the Dreamhost Wiki, but I did find this old Meta Wiki Article

  • Prevent new user registrations. Add the following line to the bottom of LocalSettings.PHP:
    # This snippet prevents new registrations from anonymous users
    # (Sysops can still create user accounts)
    $wgGroupPermissions['*']['createaccount'] = false;
  • Make sure it's working by trying to create an account. You should receive an error message that says username not found, please create an account. To change the message login as yourself (you should have set up a Sysop login when you configured your wiki) and point your browser to wiki.yourdomain.com/index.php?title=MediaWiki:Nosuchuser&action=edit.
    I changed my message to:
    There is no user by the name "$1". This wiki is private and therefore closed to new accounts. Please contact Mahalie if you have any questions.
    I intentionally failed to provide contact information. If a user doesn't even know how to contact me, they really don't need an account on my private wiki!
  • Prevent anonymous users from reading by adding the following to LocalSettings.php: # Disable reading line, for anonymous (not-logged-in => * ) :
    $wgGroupPermissions['*']['read'] = false;

    # ... and enable anonymous to read the followings pages :
    $wgWhitelistRead = array( "Main Page", "Special:Userlogin", "-", "MediaWiki:Monobook.css" );

    # ... same in an other language (French, with one UTF-8 special characteres) :
    # $wgWhitelistRead = array( "Page Principale", "Special:Userlogin", utf8_encode('Aide en français'));
  • Verify setting by logging out of your wiki and attempting to browse. You should get a 'Login Required. You must login to view other pages.' when clicking on any local link and the page should redirect to the main page after a few seconds.
  • If you want to hide the side navigation if the user isn't logged in (because, perhaps you have private project names or something) edit includes/Skin.php and change the function buildSidebar(). Add these lines near the very top, after the globals.: global $wgUser; if (! $wgUser->isLoggedIn()) { return array(); } This will hide the navigation on sup-pages (not the default main page)

p.s. WebWorkerDaily just published 15 Productive Uses for a Wiki in case you're wondering why someone would want to do this!

Update: Check out a new tutorial on Lifehacker, Customize Mediawiki Into Your Ultimate Collaborative Website - it's not a PIM implementation but it offers some good information on quickly re-skinning and mods to consider.

Google Code Search

Google Code Search

Google Code Search indexes contents of zip and tarball files and best of all, you can use regular expressions in the query field when searching, as seen in the screenshot from the search page (above).  One thing I noticed was the conventient search language feature, but it’s convenient only for certain languages. All the expected big boys work, searching for lang: and c, c++, c#, java, jsp and even javascript return plenty of hits.  Oddly lang:asp works but lang:vb, vb.net, or visualbasic all return nada. I guess there’s another reason to use c# instead of vb. via: techcrunch

State of Web Development

SitePoint, a great web development resource, posted survey results from over 5,000 web designers on the State of Web Development. An interesting read, I was amazed at how there was no clear lead in platform.  Also, the sheer numbers of PHP vs. .NET developers was suprising but I think this is a testament to their readership…if they had poled 5,000 web developers via ASP.NET forums they’d get entirely different results.

Classic ASP vs. ASP.NET 2.0 Productivity

I’ve been doing a lot of .NET tutorials but hadn’t yet applied much to the real world. The one .NET app I’ve done for work so far was largely designed to the constraints of my experience, unfortunately. I was curious to see how difficult it would be to design a dynamic ASPX page that lived up to my usual standards – aesthetically, usability-wise and functionally. In this case, I wanted to add a summary table of all the data collected from a web form that was written in classic ASP, XHTML/CSS and Javascript.

Easier than I thought! I created a “new website” in the location of the old asp pages, Visual Studio automatically adds server extensions (an isolated app pool) and, though VS actually warned me, I had to manually set the directory to use ASP.NET 2.0 framework. The solution explorer view automatically included all of the content in the website project. I created a new web form page, copied the framework xhtml from another page in the directory (sans ASP) by viewing the source in a browser (there were a lot of logic loops so it was much easier this way), fixed a couple small errors that VS 2005′s intellisense picked up right away, and then went into design view – dropped an Access (OLEDB) datasource and a datagrid to consume it on the page, configured that, added CSS classes to make it pretty, and walah! I couldn’t flippin believe it
It’s so easy to expose database data and include paging and sorting automatically. That’s the power of the datagrid – displaying data from a database in ASP is no big deal (once you’ve worked out security issues and connection strings in your environment) but extra things like paging and sorting, while certainly doable, are no where near as easy. What surprised me the most, other than the shocking ease of creating a more or less XHTML compliant page using asp.net datacontrols, was how nice Visual Studio 2005 was as a general editor for old ASP pages and CSS files.

Kentucky Horse race, photo by flickr user Gearhart

It was timely coincidence that an article called Microsoft Visual Studio 2005: Productivity Study appeared on the top of the article stack that is presented to you on opening VS 2005. The article had a big callout stating:

ASP.NET 2.0 developers accomplished 113% more tasks in the same amount of time as ASP developers; ASP.NET 2.0 developers created web content pages up to 357% faster than ASP developers.

I actually thought the first number was low, if in fact they were using experienced .NET developers, as so much is automated, you have a full programming language to use and a plethora of built-in objects to leverage. But then the article continued:

The approach to this study was to recruit experienced developers in each of the development disciplines, ASP and ASP.NET 2.0. This resulted in two equal-sized developer groups, four developers in each group.

And then I stopped reading. I mean, why bother? A total of 8 developers made up their test case? WTF?! This is a pseudoscientific approach that is more like a raffle than a real study you can actually derive meaning from.

From my personal and to date, somewhat limited, perspective – I think it’s the paradigm shift and learning curve that makes new developers (like me) slow as molasses on .NET. There are a lot of developers who are really comfy in classic ASP and having gone from PHP to ASP for work, I can say it’s much easier than going to .NET…initially.

Once a developer has a good grasp on OOP and resources available in .NET framework I would guess the numbers are likely more disparate. Throw in a few different types of programming challenges, a larger test case, and make sure to include some projects the devs don’t already know how to do…then you start to see how much more (or less) developing in .NET is. I would like to read that report when and if it becomes available.

Learn Web Design

Web Design is not what it used to be. It’s now a sort of nebulous term that encompasses a LOT of technologies. No matter what sort of sites you plan on designing, I feel there’s no substition for a good understanding of standards-compliant xhtml and css. Of course, it helps if you know some graphics programs too, like Photoshop or the cheaper alternative, Paintshop Pro. Notice I didn’t mention any web design programs…well, I said learn web design not make a website real quick and dirty like.

Here’s some of my advice under ‘Learn Web Design‘ at 43things…a place where people tag, discuss and connect about things they’ve done and would like to do.

Getting started.
A word on web standards.

Unrealized CSS Selectors

I just finished reading the Selectutorial. (Actually, I’ve read it before but my CSS skills were not developed enough at the time to make any of it relevant enough to me to remember.) I must say, now that I fully understand it, it’s an different sort of excercise in frustration. Why? There are a lot of really, really useful CSS selectors that can’t be used. At least, not on a client’s site. With every new selector my excitement would build, until the summary: "…not supported by Windows Internet Explorer 5, 5.5 and 6, but are supported by most other standards-compliant browsers."

Think child selectors, adjacent sibling selectors, attribute selectors and the :before and :after pseudo-classes are just for CSS geeks? They could be regular part of your web-design diet, simplifying things like adjusting spacing conditionally depending on whether an element is right next to another. I could have used the attribute selectors to make only my little ‘off-site link’ images inline for a recent site instead of applying a class in the structural code to every freggin image tag!

It’s a shame that the worlds richest software company, fueled with hiring power and a presumably very well-educated and/or skilled workforce can’t make their browser standards compliant. If it wasn’t for Internet Explorer’s bad but predominant browser, things could be so much more efficient for everyone. Though I’ve applauded the relative dissapearance of "This site is best viewed in…" statement, I think I would now welcome "Best viewed in a standards compliant browser (Internet Explorer, try Firefox ).