Sunday, February 21, 2010

Google Buzz Icon

I found this Google Buzz icon somewhere, but alas, I found it AFTER I'd already made a lame Google Buzz Icon for the apple script app that launches Chrome with a fake useragent to access the mobile version of Buzz.

Perhaps I'll fix up my lame icon to use this new one, otherwise you'll just have to make do with: buzz.icn. I didn't even make a nice mask, sorry.

To get this to show up for your app just replace applet.icns in Contents/Resources under your "Google Buzz.app" directory (You might need to click show bundle contents or something). Make sure you call it applet.icns. Finder is slow about updating icons, so you can quit it from activity monitor if you're impatient.

I used Icon Composer which I guess is part of XCode under /Developer/Applications/Utilities.

Tuesday, February 16, 2010

notes from moving to blogger custom domains

I've been moving my blogs over to blogger's custom domains since blogger will be stopping support for ftp sometime soon (now later than they announced). Here's some of the good and the bad experiences I had during the move.

1. No way to customize the 'request access to this private blog page'.

Some of my blogs are private. I used to implement this with some php wrapper in the template that set a cookie based on a really simple question. My main goal was keeping out robots not real people. With custom domains the option I chose was to have a private invite only blog. That's all cool, but the page when you go to the blog not logged in, or logged in without permission provides no way at all to request permission to read the blog, or to contact the blog author. Or any way to customize any of the text on the page to tell people how to get access to the blog.

2. No way to set the favicon

Favicons are important to me. I have too many tabs open in Google Chrome to not  use favicons. The default favicon is the blogger favicon, this is annoying since it's the same as the blogger compose favicon too. I tried adding 'link rel="icon"' higher or lower down in the header and Chrome just ignored it.

In the end I copied some javascript that replaces the favicon. It's not perfect but it works most of the time. Webmaster Central still uses the blogger icon which is annoying.

3. Alternative/Feed information in the header

The Blogger feed page is super confusing. I can put my feedburner url in there but alas it never seems to show up in the source of the served page. Then people will subscribe to the blog via the blogger url which I may want to change later. The subscribe gadget/buttons do this too. plus it also puts links to rss versions of the feed in the header, which I don't have feedburner versions of. It's horrible that so many years after Google bought feedburner it's still not integrated well.

Also I have lots of subscribers who are subscribed to a url on the old site. I can't have the new custom domain replace the old site since I still need these links to work. Don't tell me about the failover site, because that doesn't work when you have a private blog!

In the end I wrote more javascript to strip out all the old feed information and replace it with my feed information. I also use my own subscribe buttons with my own urls in them.
I had to move all my blogs to custom domains which were different than the original blog urls. Now I need to wait for Google to index my public blogs even though the content didn't really change.

4. Those annoying screwdriver/wrench icons to edit gadgets! I turned off quicklinks.

I turned off quicklinks and yet blogger still insists on showing me the quick edit tools for all my gadgets, this is especially annoying on my private blogs where I must be signed in!
I ended up getting rid of these by hand editing the expanded template html a terrifying experience.

5. oauth feeds have drafts

As I documented before I fetch the feeds to my private blogs and make restricted versions of those feeds available semi-publicly. I was surprised to find out that feeds fetched via oauth had the draft blog posts in them too! I should have made a google account with only read access and fetched the blog feed using that (then getting my oauth stored credentials would have only given you access to read the blog, not post to it too!).

6 search gadgets for label or subscribe

The tools to search the layout gadgets are awful. I searched for label or labels and didn't get the main google provided label gadget (or it was hard to find). same with trying to find a subscribe gadget (which ended up not working for me anyway (see my complaint about feeds).

7. Redirecting the Old Blog to the New Blog.

O.K. enough complaining. I've listed how I fixed a few issues. Here's some other fixes I found useful:
for my public blogs it was easy to modify .htaccess files to redirect traffic to the new blog. Here's some rules that worked for me. note that archives used to end with .php but now end with .html It seems blogger keeps the file extensions for old posts so they still have .php at the end.

RedirectMatch 301 /scripts/(2[0-9]*.*) http://blog.wtwf.com/$1
RedirectMatch 301 /scripts/labels/(.*)\.php http://blog.wtwf.com/search/label/$1
RedirectMatch 301 /scripts/archive/(.*)\.php http://blog.wtwf.com/$1.html
RedirectMatch 301 /scripts$ http://blog.wtwf.com/
RedirectMatch 301 /scripts/$ http://blog.wtwf.com/
RedirectMatch 301 /scripts/index\.php$ http://blog.wtwf.com/

For my private blogs I wanted to put up an alert that the blog had moved but give a way to contact me. I did it with the following php that I added to the template so it appeared on every page:

<style>
.alert {                                                                        
  background-color: #f00;                                                       
  color: #fff;                                                                  
  padding: 50px 0px 50px 5%;                                                    
  margin: 50px 0px 50px 5%;                                                     
  border: double 3px #000;                                                      
  font-weight: bold;                                                            
  text-align: center;                                                           
}                                                                               
                                                                                
.alert a, .alert a:hover {                                                      
  color: #fff;                                                                  
}                    
</style>
<div class="alert">
This blog has moved!

The new location of this page is:
<?php echo $newloc ?>

If you are unable to read that page then please Email us using the Email
link on the left.
</div>

I added email addresses using javascript so they're not easily harvestable.

I do like that I can add javascript to my new blogger template by adding a html/javascript gadget, that worked pretty well for me.

Monday, February 15, 2010

more private feeds

I've posted before about my little script to make atom feeds more private by expiring old posts by replacing the text, here and here. I've also posted about weak password protecting your sites. This was all that I did to have a blog that was private from the search engines but easy for people to read either in google reader or via email or in their browser. I did this using blogger.com's sftp support (I also ran a chrooted sftp server). Seems that my paranoia has fueled quite a few posts here in the past, eh! Well Blogger has decided to stop supporting sftp publishing so I've had t find another solution. Unlucky for me, I like the blogger posting UI and I think I found a good solution that will allow me to keep my content out of search engines and still make it accessible to folks that I want to read it. I'm not talking about this blog by the way, I'm talking about my daughter's blog and my personal blog. I'm going to have a blog that is invite only, you need to be specifically invited to read it, otherwise you end up at a rather unhelpful 'you need access' page with no way to contact me to ask for access. To make my blog readable in google reader all I needed to do was get the feed and make it available. I thought of a few ways to do this. First plan was to subscribe to the blog and then get some kind of email to rss gateway worked out. I wish mailman supported this but it doesn't. I did manage to get a patch to do it, but never worked on it because by the time I got the patch I also found my final solution. I wrote a Google AppEngine app that stored oauth credentials and fetched the feed from blogger, trimmed it and published it for all to see. I used code from the gdata python blogger oauth example and salmon protocol and ended up with my own 'Feed App' (Say it with a New Zealand accent) check out the source code at:

http://code.google.com/p/wtwf/source/browse/#svn/trunk/feeds/feedappwtwf

I plan to extend it to implement the expandRss functionality in a server that should be more reliable than my home network connection but for now it does the job and that makes me happy. I encountered a few problems while writing it. The oauth code required you to be logged in, but I wanted some of the urls to work without being logged in. I finally tracked it down and used users.create_login_url('/oauth/request_token') to make sure the user was logged in. The oauth.py code failed silently when the user wasn't logged in (very annoying!). I also found out that when you get the feed via oauth you end up getting all the draft blog posts too! so I had to write in a quick check to filter those out. I guess I really should make a google account that can only read the blogs then that might only get a feed with the real blog posts in it.

Now I'm off to work out how to point all my old blog posts at the new blog that's living in a subdomain and to play with the new fancy blogger templates, whee!

Tuesday, February 09, 2010

getting google buzz on your desktop

If you haven't yet got Google Buzz in your gmail, or like me you're using Google Apps For Your Domain (GAFYD) and you won't get it for a month or so there is a cunning trick you can use to get it on your desktop right now.

All you need to do is pretend to be a mobile phone, phones going to buzz.google.com see the phone version of the UI and it's serviceable for posting updates and managing friends. There's so much missing but it's a good start. Google Chrome accepts a --user-agent flag and the user agent for the Google Nexus One phone is Mozilla/5.0 (Linux; U; Android 2.1-update1; en-us; Nexus One). That's easy to add under Windows or Linux, on the Mac it's a little harder but the User Data Directory page gives you instructions on how to set up a different user-data-dir which is also a good idea. Here's the string I used.

do shell script "/Applications/Google\\ Chrome.app/Contents/MacOS/Google\\ Chrome --enable-udd-profiles --user-data-dir=/Users/$USER/Library/Application\\ Support/Google/Buzz --user-agent='Mozilla/5.0 (Linux; U; Android 2.1-update1; en-us; (Nexus One)'  > /dev/null 2>&1 &"
One day I'll work out a nice way to get the Buzz Icon in there, likely I'll spend days on it and finish the day before I get full featured buzz in my GAFYD mailbox!

Wednesday, December 30, 2009

mythtv and mythvideo

A while ago my main hard drive died. Of course I had lots of backups, but nothing that I could boot so I reinstalled the OS. Since I was reinstalling I took the opportunity to install the latest ubuntu Karmic Koala. It all went well and I slowly rebuilt my machine setting things up how I like. First I got mail (postfix) and my own version of Mailman set up. Then it was on to the websites and then I took a break. These last three days I've been battling trying to get all my movies back to a viewable state. I was using XBMC before. I was hampered by some of the magic tricks I had learned in the past to get tv out working on my cheap radeon card. Here's what I learned:

  • you need to dpkg --purge gdm to stop any kind of X starting when the machine boots
  • you no longer need fglrx - don't even think of trying it, it's a red herring
  • you need to add vga=789 to /etc/default/grub:GRUB_CMDLINE_LINUX_DEFAULT to get /dev/fb0
  • you need to usermod -a -G audio $USER and then log out an back in to be able to use the soundcard
  • aplay -l lists all your soundcards
  • lspci and lsusb are really useful too
  • ONLY gnome desktop appears to activate the TV out properly, any other window manager just seems to hang startx
  •  /usr/bin/xrandr --output S-video --set load_detection 1 --size 800x600 is also needed after the X server has started (10 seconds) to make TV out happen
  • xbmc is  slow useless monkey and dead to me
  • mythtv and mythvideo are the new hotness and my new best friend
  • mythtv and mythvideo just work and are awesome
  • you can run mythfrontend over X11 for setting up metadata but not play movies like that
  • when getting metadata hit 'w' to get it
  • if that fails enter some of the title
  • you can easily download coverart from amazon and upload it scp $(\ls -t | head -1)  server:/var/lib/mythtv/coverart/uploaded/
  • I have /Movies be only directories and symlinks to the real data files living on lots of mounted volumes.
  • If you move a symlink around all your metadata is lost. see below
  • I am way too anal about getting all my metadata set up - at least good titles and coverart
  • You can access the database directly and mess around with values
  • backup your database!
  • mysqldump --defaults-file=~/lib/mysql/.my.cnf.mythtv --opt mythconverg  >mtv.$(date +%F).sql
  • I must find all my old mame roms for the myth mame plugin to play things!
  • it works with lirc but you need a ~/.lircrc and then you symlink to that from ~/.mythtv/
  • you can run dvdshrink under wine and it actually works!
So I had most of my metadata set up but my directory structure was very flat. Moving symlinks around would loose my metadata so I wrote a quick program to allow me to move links around and keep the database up to date. Of course this little script may totally bork YOUR setup, so be careful. This is super pre-alpha at this point, I might polish it up later.
Have a look at mythvideomv.py you probably want to click on 'raw file' to get the actual file.

Saturday, December 05, 2009

sftp in a chroot environment

You can ignore all the code below and just go read this page about setting up a chroot sftp server with the standard openssh, it's built right in now and awesome!



I publish to my blog using sftp. Since I use blogger I had to give them a username and password. I wanted to restrict my exposure so I made a little program that would only run the sftp-server and run it in a chrooted environment, I then set this as the shell for the account. I'm not totally sure it's any more secure, but it makes me feel better.

Getting the files I needed to run a program in a chroot environment was harder than expected, ldd didn't give me all the info I needed, but it was a good start.

Check out the source code. with a README file and even an example of what files you'll need. At least in  Ubuntu 9.10.

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!