Posts Tagged ‘mt’

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.

LJ Comment Grabber: Getting Better

Monday, January 1st, 2007 at 1:14 pm

I don’t know if anyone besides Jym has tried the LJ Comment Grabber, but I fixed the comment parsing…sort of. Read the project page for more details. If you are using it, this is definitely an update you want to get.

LiveJournal Comments: Problem Solved

Sunday, December 17th, 2006 at 7:09 pm

Interested parties may remember my post about copying LiveJournal comments from a syndicated account to a Movable Type blog. Wes and Bob (I think?) recommended some LJ developer pages, but the closest I could get was retrieving comments from an LJ account for which I’m logged in. Since I was looking to get comments from a syndicated account, there is (as far as I know) no way to do that.

So I spent a few hours this weekend hacking together this monstrosity of PHP to scrape the LJ pages and insert comments into the MT database. You can get the code on the project page. It’s not that good and I wouldn’t even really recommend using it, but you’re welcome to it. If you have any problems, bug fixes, or ideas, shoot me an e-mail or leave a comment here.

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.

Tidy the Past

Sunday, March 19th, 2006 at 7:43 pm

I’ve spent most of my afternoon and evening cleaning up archives. For several years now, I’ve kept movie and concert ticket stubs. I used to write the names of the people I went with on the back of the ticket, but since the beginning of 2004, I’ve kept a spreadsheet with this information, because I like looking back to see what movies I watched when and with who (and occasionally compiling data). I went through my ticket collection, and added what I could from there, but it didn’t amount to much: 21 movies in 2003, and 10 in 2002. Obviously, I lost a lot along the way. I was surprised by how many of the movies I remembered so well - who I had seen it with and where, where we sat in the theater, things like that. I remember losing a contact when I went to see X-men 2 with FN, Brie, and Coo, and lost the other one a week later when I saw it a second time with my buddy Bill. In a lot of cases, I remember these weird little details better than I remember the movie, but I would argue that those are more important.

For the rest of the afternoon, I wrote a WebAudit script to check links on my site. I updated to MT 3.2 a month or two ago, and nuked my images directory while I was at it. There was a bunch of crap in there, so I went through it and only restored the files I knew would be used, missing a few in the process. I also didn’t realize until later that MT 3.2 uses longer file names than previous versions (this can be changed, but at the time I didn’t know it was going to be a problem). As such, a lot of the file names for my posts were different when I imported them, and any links to them broke. I didn’t even notice this until a week or two ago, so I wrote this script to go through and try every link on the pages. I’m not entirely convinced that it worked the way I wanted it to, but I found a lot of bad links that have been fixed.

Tonight, I’m going to make some dinner, pour a drink, and relax. A few of these Netflix discs have been here for weeks, so I think a movie is in order.

Movable Type Plugins

Saturday, January 28th, 2006 at 6:52 pm

You would think that writing a plugin for Movable Type would be pretty easy, especially if you’ve read that it is, in fact, pretty easy.

You would be wrong.

Based on what I’ve seen, writing a plugin for Movable Type is a colossal pain in the ass. I don’t even want to do anything complex - I just want to manage a list of movies I’ve seen recently, and display the last five in the sidebar. Previously, I posted an entry into a Recently Viewed category (which you can see here) that wasn’t displayed on the main or archive pages. The most recent five posts were put in the side bar, and linked to IMDB (through another hack - the Excerpt on every entry was just the URL for the movie’s page).

After spending a couple hours this afternoon reading information about plugins and trying to make sense of it, I’ve lost interest in finishing the site today. I DID get it upgraded to MT 3.2, which is a start, and means that you folks using news readers will probably be flooded (especially on LJ). Sooner or later, I’ll reign in my ridiculous category list, restore my portfolio and about page, and come up with a new design (which, you may recall, was the original goal for the day).

And dammit, writing a plugin can’t be THAT hard, right? I’ll probably take another crack at it soon, because it’s really irritating me that I had no luck with it today.

D’oh

Saturday, October 8th, 2005 at 10:40 am

I support two different classes during my Saturday job, but not at the same time. The classes meet every other week, so as far as I’m concerned, they just alternate.

The class that’s here this week has only 9 students, so I don’t have a lot to do. My plan was write that damn essay, but I forgot to grab the book I need to do it.

Also, I’ve been seeing a lot of fake comment spam lately. I don’t really know the motivation behind it, but they link to random blog posts and things like that (example). I’ve enable comment moderation, so comments won’t appear immediately. Apparently, MT 3.2 has pretty good built-in spam blocking, so I think I’m going to upgrade today.

BigPAPI

Sunday, July 31st, 2005 at 4:46 pm

I don’t remember where I found the link to BigPAPI, but it didn’t seem worth trying until I got halfway down the page. UpdateAuthoredOn is a BigPAPI plugin (which is itself an MT plugin) that adds a button to a Movable Type entry page to update the Authored On value to the current time. Since I frequently start a post and come back to it two or three times before publishing it, I’m always fiddling with the date and trying to figure out what 11:32 PM is in 24-hour time. Now, I just click the button and it’s done for me.

It doesn’t seem like something to get worked up about, but it’s the little things like this that make an interface pleasant to use.

Wait, Back Up

Monday, May 9th, 2005 at 7:12 pm

I don’t why it didn’t work last time, but a second attempt with CatEntries has turned out better than the first. I got tired of entries in the Reading and Recently Viewed categories appearing on the main page, when really, I only wanted them in the side bar.

I went looking for a way to do category exclusion with MTPerlScript, but when I’m the first hit, you know it’s not going to end well. I don’t know why I decided to try CatEntries again; I seem to remember reading that category exclusion wouldn’t work right because of the way MT works under the hood or something like that, but it seems to be OK now, so I’m happy. I can make posts in more than one category if I want them in the side bar and main page. It was worth the 20 minutes to play with it and get it all figured (sometimes I don’t mind waiting for Windows Update).

We’re having another BBQ tonight. I love spring.

UPDATE: So I was almost right. This only seems to work using lastn and not with days, which explains why my feeds all updated when I posted this, but my home page didn’t. Normally the home page would show the last 7 days; now it shows the last 10 entries. I don’t know why it only works this way, I’m just happy it’s working somehow.