Posts Tagged ‘movabletype’

Movable Type vs. WordPress

Friday, May 16th, 2008 at 4:51 pm

I’ve had this site on WordPress for a few days now, after using Movable Type for over three years.

So far, I love it.

I don’t want to place blame, but for the past couple months, Movable Type was giving me hell. I kept getting 500 Internal Server Errors on almost every other page load, and I don’t know if it was because of MT, 1&1 (my web host), or because my 650+ posts were too much for the system. According to the Google, a lot of other people were having this problem - long run times seemed to be the issue - but no one seemed to have any solutions. It was incredibly frustrating to do anything, and so I just avoided it.

Under those circumstances, MT was kind of like a rusted-out Oldsmobile that only fired on three cylinders and refused to start on cold mornings. In comparison, WordPress is like a brand new Vespa - quick, sleek, and kind of fun. And most importantly, it doesn’t stall in the middle of the highway.

Now that I think about it, maybe it was because of the language. Movable Type is mostly Perl, and WordPress is PHP. I don’t know enough about Perl to know if that could have been an issue, but whatever. I’m a big fan of Movable Type, but it just wasn’t working for me. I got all my posts and comments moved over, the permalinks seem to be alright, and I’m happy. I need to get my portfolio and project pages fixed up, but on the whole, the migration was easier and quicker than I thought it would be.

Of course, as I was editing this, brockli.com disappeared entirely for half an hour, then gave me a 500 error, then refused to connect to the database for a little while. Maybe I can blame 1&1 after all.

Movable Type: Update Entry Date

Thursday, January 24th, 2008 at 8:05 pm

My favorite plugin in MT3 was UpdateAuthoredOn. It didn’t do much: you got a button next to the entry date input, and clicking on it would update it to the current time and date. Simple, but very handy - especially if you’re the kind of person who writes an entry over the course of a couple days and want to post it with the current time.

The new version is called UpdateEntryDate, but it’s not working for me in MT4. So, I ripped out the part I needed and changed the MT template. If you want to try it out, you’ll need to modify tmpl/cms/edit_entry.tmpl in your MT directory. Go to line 1057 (give or take), or search for entry-time to find the date and time inputs.

First, the time input needs an ID. You can replace the whole entry-time input with this:

<input id="entry-time" class="entry-time" name="authored_on_time" tabindex="11" value="<$mt:var name="authored_on_time" escape="html"$>" />

Then insert this two lines down, after the closing span tag:

<input type="button" class="primary-button"
onclick="update_authored_on();" value="Update" />
<script type="text/javascript">
function zeropad(num) {
return (num < 10) ? '0' + num : num;
}
function update_authored_on() {
var now = new Date();
var y = now.getFullYear();
var m = zeropad(now.getMonth() + 1);
var d = zeropad(now.getDate());
var h = zeropad(now.getHours());
var min = zeropad(now.getMinutes());
var s = zeropad(now.getSeconds());
document.getElementById("created-on").value = y + '-' + m + '-' + d;
document.getElementById("entry-time").value = h + ':' + min + ':' + s;
}
</script>

Movable Type: Archives Location Change With Upgrade

Wednesday, January 23rd, 2008 at 10:19 pm

As I’ve mentioned here before, I upgraded to Movable Type 4 not too long ago. One of the changes that almost went unnoticed is the way archives are handled. In MT3, I wasn’t using the dynamic pages, so every post was generated into a file in the archives directory. For example, a post about new music in July wound up at /archives/2007/07/new_music.php.

In MT4 - or at least, MT4 with dynamic pages - there is no archives directory. Really, there aren’t any directories, since it’s all handled by mod_rewrite, but that’s not really the point I’m making. Under MT4, that post I mentioned above would be at /2007/07/new_music.php, with no /archives at the front.

Now, I could change the Archive Mapping on the Entry Archive Template in the admin, but I kind of like the shorter URLs. I don’t know much about mod_rewrite, but I found an answer a lot quicker than I expected to, thanks to askApache. I just added this to the .htaccess file in my site root, and now any requests to the non-existent archives directory are re-directed back into the root.

RedirectMatch ^/archives/(.*)$ http://www.brockli.com/$1

If you want to use this for your site, you’ll need to replace brockli.com with your own URL, but that should be it.

Movable Type QuickPost

Friday, January 18th, 2008 at 10:15 pm

I still haven’t finished putting the site back together after upgrading Movable Type, but I really like the new version. The admin interface is a lot cleaner and easier to use, and everything feels…sturdier, I guess.

I’m not sure if QuickPost was a feature in 3.2, but I didn’t know about it if it was. And really, calling it a “feature” is an overstatement. It’s just a bookmarklet that you drop in the bookmarks toolbar of your browser, and it allows you to quickly start a post about the web page you’re looking at. For those of you who ARE using Movable Type (and this post won’t be of much interest to anyone else), there’s a QuickPost link in the Write Entry page, down below the Save and Cancel buttons.

It’s a handy little bookmarklet, but by default, it doesn’t work the way I would like. It pops up a new window with a new blog post that contains the URL of the page you were looking at, two <br>’s, and then any text you had selected on the page.

That’s a good start, but clunkier than I would like, so I changed mine a fair bit. Here’s what I’m using - it’s one long line that won’t fit in your browser, so copying it might be a pain.

javascript:d=document;w=window;t='';if(d.selection)t=d.selection.createRange().text;else{if(d.getSelection)t=d.getSelection();else{if(w.getSelection)t=w.getSelection()}}entryTitle=encodeURIComponent(d.title);if(t=='')entryBody='';else entryBody=encodeURIComponent('<blockquote>') + encodeURIComponent(t) + encodeURIComponent('</blockquote>\n\n');entryBody+=encodeURIComponent('<a href="') + encodeURIComponent(d.location.href) + encodeURIComponent('">Link</a>');url='http://site.com/cgi-bin/mt.cgi?__mode=view&qp=1&_type=entry&blog_id=1&title=' + entryTitle + '&text=' + entryBody;void(w.open(url))

And here’s a more verbose version, so it’s easier to see what’s going on:

d = document;
w = window;
t = '';
if(d.selection) {
t = d.selection.createRange().text;
}
else {
if(d.getSelection) {
t = d.getSelection();
}
else {
if(w.getSelection) {
t = w.getSelection();
}
}
}
entryTitle = encodeURIComponent(d.title);
if(t == '') {
entryBody = '';
}
else {
entryBody = encodeURIComponent('<blockquote>') + encodeURIComponent(t) + encodeURIComponent('</blockquote>\n\n');
}
entryBody += encodeURIComponent('<a href="') + encodeURIComponent(d.location.href) + encodeURIComponent('">Link</a>');
url = 'http://site.com/cgi-bin/mt.cgi?__mode=view&qp=1&_type=entry&blog_id=1&title=';
url += entryTitle + '&text=' + entryBody;
void(w.open(url));

I changed a few things. For one, “_blank” is no longer included in the window open. Under my Firefox configuration, this means that it comes up in a new tab instead of a new window. I also changed the entry body; now, it turns the URL of the page into a link (with the text “Link”), and any selected text goes above that in a <blockquote>. Basically, you get a new post that’s in the format Boing Boing typically uses.

If you want to try it out, do the following:

  1. Drag the QuickPost link from the Write Entry screen into your bookmarks toolbar.
  2. Open your favorite text editor - Notepad will do - and copy that first block of code above into it.
  3. Right-click on the bookmark and select Properties. Copy the Location field into your text editor too.
  4. You need to pull the URL out of your QuickPost code and put it into mine. Obviously, the domain part won’t be site.com, and the blog_id might be different if you’re running more than one blog in your MT installation.
  5. Copy the new code with the correct URL into the Location field for the bookmarklet. Make sure there aren’t any line breaks in it.
  6. That’s it. Test it out by going to any web page, select some text, and click the QuickPost bookmark. You should get a new post that contains the text you had selected.

Drop me a note if you’ve got any questions or suggestions for improvements, or just post a comment here.

Upgrading Movable Type

Sunday, January 13th, 2008 at 9:59 am

I’m in the process of upgrading Movable Type, so things may be a little wonky for the next couple days. It was time for some spring cleaning, so I did a fresh install. I think MT is all set, and all my old posts are here, but I’ve still got some more content to move over from the old site - stuff like my Projects and Portfolio pages, the About Me page, that kind of stuff.

That, and in MT4, entry URLs use dashes for spaces instead of underscores. I have links to my own posts in the format “whats_so_great_about_christianity.php”, but if you actually go to that post, the URL is “whats-so-great-about-christianity.php”. I’m assuming that’s a setting I just haven’t found yet, but until I do, links within new posts to old posts will be broken.

If you find any gaping holes, please drop me a note.

LiveJournal Comments

Monday, November 27th, 2006 at 7:20 pm

LiveJournal can handle RSS/Atom feeds pretty much the same way it handles any other user or community: if someone creates a syndicated account for a feed, users can “friend” it and comment on posts there. This is convenient for people who already use LJ and want easy access to a couple site feeds (I don’t think it would be usable as a full-fledged newsreader, but I guess it depends on how many and what types of blogs).

As of this writing, 44 people read this blog via it’s syndicated account (wave!). It’s not a lot of people, but my readership is pretty low, so that probably accounts for most of my audience. Since the account acts like any other friend, these people see my posts smack in the middle of their friends page, and thus, can easily comment on posts there.

And people do, a lot more than they comment here. This is great, except for the fact that it’s on LJ. As far as I can tell, they list the most recent 15 posts there, but don’t give you any way to go further back. Unless you bookmark the post itself, there’s no way to see old comments (and that’s assuming that the pages don’t go away, too).

Much earlier this year, JR suggested that I write a script to import comments from LiveJournal into Movable Type. I’ve started looking into it at least three times, but keep getting discouraged. There doesn’t seem to be any easy way to get those comments - no RSS feed or API that I’ve found - so I’m going to have to screen scrape them. I keep putting it off because it’s going to be a pain in the ass and while I really want to pull in those comments, I also really want to not deal with regular expressions.

So, to the LJ and MT hackers out there (if there are any): have you ever seen a plugin that does this, or even an LJ data source that would make it easier? I’ve looked around and come up empty, but since it’s going to be at least another month before I really feel like dealing with it on my own, I figured I’d ask around.

MT As a DBMS

Tuesday, April 5th, 2005 at 7:25 pm

I don’t know what the hell I was thinking - that totally works. For some reason, I kept thinking that MT template tags wouldn’t work in a PHP file because they wouldn’t get updated. I created two categories just for the side bar: Recently Viewed and Reading. Then I made a new index template that contains everything in the side bar - since index templates are rebuilt when a new post is made (as far as I know, anyway), my side bar file is updated. The CatEntries plugin allows me to filter what categories are displayed. In the side bar, the last 5 posts from Recently Viewed are shown, and the most recent post from Reading. The index page excludes these two categories, but they still appear in monthly, daily, and category archives. It’s a neat way to use MT as a database management system.

Originally, I wanted to avoid a PHP include; I was so hell-bent on performance that I wanted to eliminate any PHP and make all pages static (because, you know, thousands of people are checking to see what I write EACH AND EVERY DAY). Realistically, a single file include isn’t going to affect performance in the slightest. I may add a couple while(1) loops just to be sure, though.

PIRATES ‘A THE SEVEN BLOGS

Tuesday, April 5th, 2005 at 1:14 am
Website Hijack

Sarah made the fatal mistake of telling me that she’d just moved her website and installed Movable Type. The DNS info hadn’t propagated yet, so she sent me the IP of the site (why, I’ll never know). She had already run mt-load.cgi, but hadn’t changed the default password yet (ironically, as I typed this, I thought It’s a good thing I remembered to delete mt-load.cgi! And then I went and deleted it).

So I changed her password and hijacked her blog, like any self-respecting ninja-pirate would.

She was less than pleased.

Her settings were all screwy-like (I think her CGIPATH was off), so it took a good ten minutes to get the password reset. I wasn’t thinking when I changed it and used one of my common ones, so I didn’t want to hand it over if I could avoid it. Thankfully, we managed to get it working so I could change it back to Nelson (don’t bother trying it now, I already checked).

(Click the image to see the big version)

Dynamic MT Sidebar

Monday, April 4th, 2005 at 7:05 pm

While reading an old article about MT, I thought of a way to maintain dynamic content in the sidebar without having to use PHP or service-side file includes.

Take the Recent Movies section, for example. Right now, it’s just a list in a PHP file that I update when I watch a movie - remove the oldest one, add the new. Alternatively, I could create a “Recent Movies” category, and make a post to it each time I see a movie - maybe I use the movie name as the title, short synopsis as the body, and the IMDB link as the keyword, or something like that. I could exclude this category from the main and archive pages (using the CatEntries plugin) so that they would never appear between actual posts. Similarly, I could use the same plugin to show only the “Recent Movies” category in the sidebar, and just display the title of the last five posts. It would be easy to use standard MT template tags to make it a list of links using <MTEntryTitle> and <MTEntryKeywords>.

The problem with this approach is rebuilding. If every page in my site has the same sidebar, which includes those MT tags, they would all have to be rebuilt when I added a new movie. Granted, it’s WAY faster on the new host than it ever was before, but I’ve only got a few dozen posts right now; it will become an issue when I start getting into hundreds of pages that will need rebuilding.

It’s too bad that an entire template can’t be included in another one, but that would basically be a server-side include. I haven’t got it solved yet, but at least I’ve got some ideas.

Web Hosting & MT Hacking

Sunday, April 3rd, 2005 at 7:19 pm

Live and learn, right? Well, I’ve learned a few things about web hosting.

GoDaddy sucks, straight up. I don’t like their admin pages, the server was slow, and half the things I wanted in MT didn’t work (TypeKey and e-mailing comments, for example).

I was only with them for a week and a half before I got fed up and switched to 1&1. I signed up for 3 months at $10/month and got a free domain name, so I got RBoland.com too (it points to this site). After playing with their admin panel for about an hour, I canceled my GoDaddy account and made the DNS changes to point BrockLi.com to their servers. I had no trouble getting MT working perfectly, it’s noticeably faster (even on static page loads), and the admin interface looks a lot better and is more intuitive. I can’t tell you how pleased I am with these guys right now.

Once I got everything up here, I set about importing my old entries. MT exports one long file with all the entries in it, so I went through it and made a lot of changes at one time - updating URLs to the new domain, fixing the way I do images in posts, moving all pictures to Flickr, and adding keywords to all the posts. Importing it went smoothly, so I’m pretty happy with MT.

I did a little tweaking to the design. I still want to make it look a lot better, but I like it a little better now. One thing I really like was a small script I found on John’s Jottings to make Technorati tag links out of entry keywords using Brad Choate’s MTPerlScript plugin. I haven’t found a good way to tag posts instead of categorizing them, but that can wait for now; for the time being, I’ve just removed the category list.

I also whipped up a blogroll real quick. I want to make the sidebar more flexible without using PHP to include another file or pull info from MySQL. I found out how to make custom template tags, but I haven’t got it to do what I want. I’d like to be able to make a tag like <MTSidebar> that will cover everything in the sidebar. Problem is, you can’t use other template tags (like <MTDate>) within the custom tag definition. After looking for half an hour, I finally found that the default MT tags are defined in MT::Template::Context. It’s not hard to figure out what functions there go with what template tags, but I’m not good enough with Perl to figure out what the arguments need to be. If I could figure out what they need, I could do things like call _hdlr_sys_date where <MTDate> would normally appear.

For the time being, I’m walking away from it. I may decided to play around with it some more later, but I’m pretty happy with how well everything has gone so far.