Sunday, November 22, 2009

Previous and Next links on posts

I use blogger to publish this site. my goal was to have a posting ui that wasn't on the site that somebody else looked after that could publish to my own servers. Blogger does this, but it's still lacking in a lot of features and I end up doing a bunch of hacky stuff with php to get it to work how I want. Case in point: it would be nice to have previous and next links at the top or bottom of every post. but blogger doesn't support that. At least not with the 'old' templates, the only ones available if you want to publish to your own site via sftp.

So here you go. prevnext.py goes around your blogger directory and makes little .prevnext files for every php file it finds that there is a previous or next one for. It' a little complicated by the fact you might post more than one post a day. It also makes a calendar in your archives directory called index.html that you can use CSS to style how you want it displayed.

Here is the css I use.

.code {
  overflow:auto; white-space: pre;
}

.prev {
  float: left;
}
.next {
 float: right;
}
.prevnext {
  clear: both;
}

.archive_calendar {}
.archive_calendar_start {}
.archive_calendar_year {
  color: #B8A80D;
  display: block;
}
.archive_calendar_month {
  padding-left: 3px;
}
.archive_calendar_end {
  display: block;
  margin:0px 0px 14px 0px;
}
.archive_calendar_half_year {
  display: block;
}

Here is how I include the .prevnext files in my templates

  $pn =  str_replace('.php', '.prevnext', $_SERVER['SCRIPT_FILENAME']);
  if (strpos( $_SERVER['SCRIPT_FILENAME'], 'index.php') === False &&
      file_exists($pn)) {
    include($pn);
  }
 }

and I run this from my crontab
1-59/5 * * * * cd /home/blogger/scripts; $HOME/bin/share/prevnext.py -b /scripts
works o.k. every time I try and play with templates and whatnot, I always feel like redoing the whole thing, but then decide it's a huge waste of time, I should concentrate on getting the info out there rather than prettying it up for the 3 people who might actually read this blog, and most of them read it in an rss reader anyway!

Friday, November 20, 2009

my first google chrome extension

here is fix-style.crx tah dah. It makes the article text in Google Reader and Slashdot larger (and readable). Here is the source.

Since I wrote that I've also ported over some of my other greasemonkey scripts. I still need to polish them up a lot but they're working and that's cool. I'm looking forward to playing with settings pages and auto updates and what not.

I also made a Makefile (my first in about 7 years) to make the .crx file automatically using a python program I found on the intertubes (and modified slightly)

I'm mostly using the dev channel Chrome on Linux and Mac and they just added extensions support, it's really nice and is now my primary browser.


Mailman and Google Apps For Your Domain conflict

the recent addition of x-beenthere mail headers for Google Apps For Your Domain (gafyd)  groups stopped my mailman setup working. I thought I'd share it here in case anyone else is asking about it.

I have mailman running on server.example.com
I have example.com set up as google apps for your domain with gmail

I have a 'group' created to send mail from list@example.com to list@server.example.com

on my server I had list@server.example.com run the mailman binary with post to list whose email address is listed as list@exmaple.com

this was working perfectly however since Sep 17th 2009 gafyd is inserting x-beenthere: list@example.com which /var/lib/mailman/Mailman/Handlers/Approve.py detects as a loop and mailman mysteriously drops the message with a log in
/var/lib/mailman/logs/vette " (3902) Message discarded, msgid: ...."

the solution to me was to move the list to a non gafyd domain :(

My last greasemonkey script: blog picasa images

I got so fed up with picasaweb breaking web conventions and stealing an onMouseDown rather than an onClick. This prevented me from dragging images from a picasa album into my blogger posting window and made it a pain to add images to my blogs. I'd have to right click, copy image location, new tab, select all, copy, close tab, tab over to my bloger window and then paste (and hope I was in compose mode rather than edit html mode).

I wrote this greasemonkey script to add a blog button at the top, clicking it made a new window with all your images in it and a link back to the original album.

blog_picasa_images.user.js

Right after I did this blogger in draft added better image linking support and it works great. So this script is kind of useless to me know. but thought I'd post incase it helps someone out.