Half-Elf on Tech

Thoughts From a Professional Lesbian

Tag: mediawiki

  • SOPA Blackout

    SOPA Blackout

    I’m lazy and I don’t want to write a plugin, so I asked on Twitter if someone had one to black out a site for SOPA on the 18th of January. If you don’t get why this is a thing, please read WordPress.org’s post on SOPA. A lot of sites are going black from 8am to 8pm. I am, and I to didn’t want to use a plugin.

    My solution for this involves two files and is all thanks to Pete!

    To do this is really simple. Go in and make a file called .maintenance in the top level of your WP install. For most people, it’s the same folder as your .htaccess and wp-config.php files.

    Now edit that file and put in the following content:

    <?php
     
    // Let's make sure you're not an admin/logged in!
     
    function is_user_logged_in() {
        $loggedin = false;
        foreach ( (array) $_COOKIE as $cookie => $value ) {
            if ( stristr($cookie, 'wordpress_logged_in_') )
                $loggedin = true;
        }
        return $loggedin;
    }
     
    if ( ! stristr($_SERVER['REQUEST_URI'], '/wp-admin') &amp;&amp; ! stristr($_SERVER['REQUEST_URI'], '/wp-login.php') &amp;&amp; ! is_user_logged_in() )
     
    // If it's after 8:00:00 on the 18th, we're going to show the blackout page
     
    if ( time() >= mktime(8,0,0,1,18,2012) ) {
    	// When we hit 8pm (20), we're back.
    	$upgrading = mktime(20,0,0,1,18,2012);
    }
    ?>
    

    What does this do? It’s pretty simple. First it checks to see if you’re logged in and, if so, lets you get where you need to go. If you’re not logged in, though, it checks the date and if it’s after 8am on the 18th, you get a maintenance page. After 8pm on the 18th, it swings back. (All this code, except for the date stuff which I wrote, is from Matt (Sivel):
    WordPress Maintenance Mode Without a Plugin and WordPress Maintenance Mode Without a Plugin Part 3/ ) Pretty cool right? And the 8am to 8pm is based on your server’s time, so it’s all local. It’s also pretty easy to see how you change that for your own time. I would say pick your busiest time to go black.

    But if you want it to look pretty, you need to do a little extra. (Code from WordPress Maintenance Mode Without a Plugin Part 2 and text from Blaccupy) Make a file called maintenance.php and put it in your wp-content folder. Here’s an example:

    <?php
    /* Tell search engines that the site is temporarily unavilable */
    $protocol = $_SERVER&#91;"SERVER_PROTOCOL"&#93;;
    if ( 'HTTP/1.1' != $protocol &amp;&amp; 'HTTP/1.0' != $protocol ) $protocol = 'HTTP/1.0';
    header( "$protocol 503 Service Unavailable", true, 503 );
    header( 'Content-Type: text/html; charset=utf-8' );
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
            <title>BLACKED OUT</title>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            <style type="text/css">
            body {
                    background: black;
                    text-align:center;
                    color: #eee;
                    font-family: Helvetica;
                    font-size: 2.2em;
                    }
            </style>
    </head>
    <body>
    
    <div style="width: 960px; margin: 0 auto;">
    <h2>This website is..</h2>
    
    <h1>BLACKED OUT!</h1>
    
    <p>In protest of pending US legislation, which threatens the freedoms of websites like this one and the freedoms of the people who use them, this website is offline on January 18th, 2012 from 8am to 8pm EST.</p>
    
    <p>Please <a href="http://americancensorship.org/">help protect our free speech</a> against the corporate and political interests which seek to take them away!</p>
    
    <p>(And don't worry, we'll be back in business tomorrow!)</p>
    </div>
    
    <?php
    die();
    ?>
    

    Which means your site will look like this on January 18th. You’ll notice I made some tweaks on mine. This is a default feature of WordPress, by the way. You can design your own maintenance mode page just with this one file, so y’know, party time.

    Now there’s only one catch. If you update WP via the automatic updater between now and then, you lose the .maintenance file. I don’t have a fix for that, but if you do, please comment!

    And yes, my sites are going dark on the 18th.

    ETA: If you have a Multisite and only want SOME sites dark, use Customize the Suspended blog page from WordPress Must-Use Tutorials. Suspend the sites and boom goes the dynamite.

    ETA 2: If you’re using MediaWiki (like I am on another site) I came up with this idea to go dark for SOPA. Its just a normal extension that, between those hours, redirects to the same page I use for WordPress. You could have it point to any page, of course.

    <?php
    
    if ( !defined( 'MEDIAWIKI' ) ) die();
    
    if ( time() >= mktime(8,0,0,1,18,2012)  &amp;&amp; time() <= mktime(20,0,0,1,18,2012) ) {
         
            include('/location-of/wp-content/maintenance.php');
        exit();
    }
    ?>

    That code, sans the Mediawiki line, will also work as an extension for ZenPhoto, so pass it on.

  • MediaWiki – All Powerful, All Annoying

    Don’t get me wrong, I love MediaWiki. It’s ‘overkill’ for what I need, but then again, I wanted a stand-alone ‘encyclopedia’ where primarily text based articles were listed, without the ability to comment. And until someone can trim WordPress to run as fast as MediaWiki, I’m sticking with it. Well, that and they need an ‘import from MediaWiki’ tool, cause at 700-odd pages, I’m not doing it by hand. It’s a static website, and it does it’s job well.

    But right now, and every time I need to update it, I hate it.

    I don’t mind using command line to wget the latest version and unzip it, overlaying the new files atop the old ones. What I mind is having to manually visit the pages for all my extensions, and determine if I need to upgrade or not. It makes me wish for WordPress with the happy ‘Hey, that plugin needs updating!’

    See, there’s no admin ‘side’ to MediaWiki, like there is for WordPress, or ZenGallery, or anything else I run on my sites. MediaWiki is for the hardcore people who don’t mind getting their hands dirty. And as a user, I think this is the real problem with the whole thing. Until they make a user friendly admin side of the whole thing, MediaWiki will remain used by the nerdy, the geeky and the techie, rather than the whole world. Part of why WordPress became so popular is they made it not easy, but easier to run your own blog. It’s still got problems, sure, but they made it so you could easily learn how to manage your own site.

    And then there’s MediaWiki.

    MediaWiki sucks to admin. Like today I found out I could turn on File Caching. That’s great new, I think! I use it for my gallery and my blogs (runs faster among other things). Except that, unlike WordPress (where Donncha’s freakin’ amazing WP Super Cache can clear out files on a scheduled basis) or ZenPhoto (where it runs once a day, or whenever I press ‘clear!’), MediaWiki has no cache expiry. That blew my mind, but seeing as MediaWikis are ‘mostly’ static content, it makes a little sense.

    So I turned it on and ran $php maintenance/rebuildFileCache.php which force caches everything. All at once. This is awesome to get your site ‘started’ and all told, it took up about a moderate, but not huge, bit of space.

    Also, I was told ‘When you edit a page, the cache is refreshed’ except I did, and it didn’t. Then I was told ‘Add this to your page URL and it will prompt you to recache.’ (this being ?action=purge) except that didn’t either. If I was logged in, it did nothing. If I was logged out, it did, but then I went back and it was still the old page. Finally I sorted out that the cache pages had to be owned by ‘nobody:nobody’ (this isn’t too weird, BTW). The problem NOW is that if they were owned by that, then the script rebuildFileCache.php didn’t work!

    So, great, it now works, it now flushs when I edit and save a page. If I run the rebuild command, I’ll have to manually go in and chown the files to nobody, which annoys me, but I have godlike access to the server and I can always fix it. But what if I want to delete everything in the cache? Basically I have to dump the entire folder. Which is annoying, but at least it’s working now.

    Why would I have to flush the whole cache? Because I make a formatting change, let’s say. Also, I have advertising on my sites. How does this get affected?

    In the end, I’m going to keep the cache running for a month, see how it goes. But it still annoys me how much of this is lacking because of no admin ‘dashboard.’

    Then again, that’s MediaWiki. Function over form. All powerful, all annoying.

  • Why Wiki?

    I like the site I have for my RPG a lot, but it’s very big and often unwieldy.

    So I started to think about the ways I could simplify it, make it easier to use and easier to navigate. The first idea I had was a Wiki. I want to point out that when I started with a CMS (which I still love for what it is), I spent a lot of days going ‘Oh, my head! I’ll never get this.’ So I expected the same here.

    What ended up happening, over the course of a month, was the realization that while the CMS is a little pain in the ass to navigate, it works better for what it needs to be. Everyone who uses it has a blog, and I’ve put so much effort into customizing it that really, the only part that would be helpful is if the ‘encyclopedia’ for the site was a Wiki. At that point, however, it wouldn’t be ‘linked’ with the CMS I have so I’m fucked. Not in a bad way, just in the ‘this works, it works 90% of the way I want, and there’s no reason to screw with it.’ If Slayer ‘reboots’ and we start a new game, I may try something different. CMS was an experiment, and it was successful.

    But … I do have another site that might benefit from an encyclopedia. About 150 individual pages of information, contextual and informational. Okay that was a little redundant, I’ve had a long week. But still 150 pages. And maybe, just maybe, updating it all, by hand, alone, is a bad idea. After all, there’s stuff I’ve never finished because I don’t have gobs of free time. And as proved by the forums on that page, people want to talk and help. So how can I combine that with an ‘easy’ to use back end, and a not-terrifying to use front end?

    Wiki.

    Okay, so it’s got a crappy admin side and if you’re not a coder you’re going to cry setting up MediaWiki, which I did and I am one. And some users are skeptical about how to create pages and … it’s been 2.5 months and of my 32 users (yes! 32!) four people (besides me) have added information. Hell, having one person add information is helpful to me, so I call it a success.

    There are 1314 total pages in the database. This includes pages about the Wiki, minimal “stub” pages, redirects, and others that probably don’t qualify as content pages. Excluding those, there are 291 pages that are probably legitimate content pages. Of the 291 pages, 150 or so came over as a direct copy/paste import (and some clean up), and 140 or so were added special to the wiki because I had more ‘flexible’ room.

    That flexibility is what drove me to Wiki. You know, when you make a new website, it’s a pain in the ass to link everything up the way you want it, and you have to come up with some sort of structure that will make sense to everyone and you hope they can follow it?

    Wikis piss that out the window and laugh at your ancestors.

    That’s a joke, son.

    Wikis aren’t linear. Wikis are fluid and organic. They grow in the direction they grow because there is information to grow in that path. Not to say there’s isn’t a rhyme and reason to the site, but a Wiki accepts the fact that things criss-cross and double back and take weirdo curves and twists when you’re not looking. Of my 291 pages, only 61 don’t link back to something else, and even so, I’m taking the time to go through those pages and cross-reference. Yes! That pain in the ass, time consuming project of ‘Doesn’t X refer to something over on Z?’ A Wiki links all those up with a simple, easy code [[Page Name]]. Thats it.

    Okay, if you’re an HTML coder (guilty), your brain has a moment of pain looking at this. Another fsking pseudo code language to learn? First HTML, then BB code and now Wiki Code? 90% of the HTML I’d want to use work on a Wiki. The only ‘argh!’ moment I have is with headers, and even then it was easy to fall into that code mind-frame.

    So what did I learn?

    To run a Wiki you have to let go of control. And that’s really hard. If you have a ‘normal’, let’s say traditional, website, you have a small number of people who can update the site. You have a set design the site maintains. You have templates and standards and such. For a Wiki, you have to step back and say ‘This is the site, this is how it looks. Please add more information, but we’d like to keep the feel we have.’ Yeah, you can follow along behind people and clean up what they do (some people use wacky grammar, others use l33t speak), but essentially you’re giving room for their voice.

    You can’t take that away once given.

    Well, you can, but you’d be an asshole.

    Running the Wiki has made me a ‘kinder’ person, sort of. I’m more laid back with people who post in perplexing grammar on the forums. I’m not going to be a firm rule-mistress. Okay, maybe on the Wiki I’ll be a little more the enforcer, but there’s no reason not to give people chances.

    Of course, I still can’t figure out what the hell “I love to but deberia to allow him grissom sara to love it also” means!

    By the way, why did I choose MediaWiki, over something more use friendly like TikiWiki or something ‘prettier’ or something easier to hack? Well, I actually tried out a handful of Wiki’s before I settled on this one. I’d load them, make a couple pages, toggle around and see what I thought. The one I picked was the one that felt right to me. You might think differently.