Posts Tagged ‘google reader’

Update: Google Reader AIR app

Wednesday, October 31st, 2007

Download GReader-0_1_2.air

I updated the app to work in Leopard. I have no idea why but using the url, http://www.google.com/reader/view, instead of http://reader.google.com fixed it. I think that might mean there is a redirect issue? I changed the dock icon unread count to just show the number in the top right. Also I added an option to enable the hicksdesign google reader theme. I had to mess with it since apparently AIR webkit doesn’t support the css data uri scheme, which is annoying.

I apply the style through the javascript bridge:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
    [Embed(source="/assets/styles/greader/greader.css", mimeType="application/octet-stream")]
    private var cssClass:Class;

    private var html:HTML;
    ...

    public function applyStyle(e:Event):void {
      var cssByteArray:ByteArrayAsset = ByteArrayAsset(new cssClass());
      var css:String = cssByteArray.readUTFBytes(cssByteArray.length);
      
      var document:JavaScriptObject = html.htmlControl.window.document;
      
      var head:JavaScriptObject = document.getElementsByTagName("head")[0];
      var node:JavaScriptObject = document.createElement("style");
      node.type = "text/css";
      node.appendChild(document.createTextNode(css));
      head.appendChild(node); 
    }

Google Reader AIR app

Monday, October 29th, 2007

Download GReader-0_1.air

I was playing around with the actionscript to javascript bridge and built this Google Reader AIR app:

I find the unread count from ‘reading-list-unread-count’:

1
2
3
var html:HTML = ...
var window:JavaScriptObject = html.htmlControl.window;
var unread:String = window.document.getElementById("reading-list-unread-count").innerHTML.toString();

Then I generate a dock icon (ignore all the hard coded pixel math):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
[Embed(source="/assets/app_icons/greader/icon_128.png")]
private var iconClass:Class;

[Embed(source="/assets/fonts/Verdana.ttf", fontName="GReaderDockIconFont", mimeType="application/x-font-truetype")]
private var fontClass:Class;
....

private function draw():void {  
  var icon:BitmapAsset = BitmapAsset(new iconClass()); 
      
  var shape:Shape = new Shape();
  shape.graphics.beginBitmapFill(icon.bitmapData, new Matrix(), true, false);
  shape.graphics.drawRect(0, 0, dimensions, dimensions);
  shape.graphics.endFill();
  
  shape.graphics.beginFill(0xDF0013);
  shape.graphics.drawCircle(32, dimensions - 32, 32);
  shape.graphics.endFill();
  addChild(shape);
  
  if (unreadCount > 0) addChild(buildText());      
}

public function buildText():Bitmap {
  var countText:TextField = new TextField();
  countText.embedFonts = true;

  var format:TextFormat = new TextFormat();
  format.font = new fontClass().fontName;
  format.color = 0xFFFFFF;      
  format.size = 26;
  format.align = TextFormatAlign.CENTER;
  
  countText.defaultTextFormat = format;
  countText.selectable = false;      
  countText.text = unreadCount.toString();
  countText.height = 32;
  countText.width = 54;
  
  var bitmapData:BitmapData = new BitmapData(64, 32, true, 0x00000000);
  bitmapData.draw(countText);      
  var bitmap:Bitmap = new Bitmap(bitmapData);
  bitmap.smoothing = true;
  bitmap.y = 128 - 52;
  bitmap.x = 4;
  return bitmap;
}

Set the dock icon with the generated bitmap data:

1
2
if (Shell.shell.icon is InteractiveIcon) 
  InteractiveIcon(Shell.shell.icon).bitmaps = icons;

For more info on dynamic dock icons, see Generating Dynamic Dock and System Tray Icons in AIR

I think the next step is taking a bunch of greasemonkey js scripts and adding them in. This might be how you would do that:

1
2
3
4
5
6
7
8
var html:HTML = ...
var window:JavaScriptObject = html.htmlControl.window;      
var head:JavaScriptObject = window.document.getElementsByTagName("head")[0];         
var script:JavaScriptObject = window.document.createElement('script');
script.type = 'text/javascript';
//script.src = 'http://lolcats.com/script.js';
script.innerHTML = "alert('HAI.. KTHXBYE');";
head.appendChild(script);

Update: I’ve seen it tack the CPU when interacting in a couple places so I will try to figure out if its AIR webkit being buggy or me. Also will fix the external link lameness at some point.

Update: Oops. Looks like it doesn’t work in Leopard.

browsair – Letting sites live in your dock

Saturday, October 13th, 2007

I wrote an AIR project generator for airake called browsair. It will build you a AIR webkit browser app targeted at a web site, so you can let it live in you dock (or tray whatever), instead of that 4th tab on the 2nd firefox window.

Theoretically someone could make a packaged browser + greasemonkey + stylish AIR app for particular web sites that growl notifies and lives in the dock and be more in your face; but this scaffold right now is pretty basic.

I should also mention there is a website called airifier which does this as well, except I think they give you a packaged app only, without the source.

I also got a bunch of fixes into this version of airake; packaging is fixed, and there is a task for creating certificates, among other things. I just deployed version 0.2.4 to rubyforge so it should be up by the time you read this.

The usage:

browsair GReader http://reader.google.com path/to/rss_icon_128x128.png

Creates an AIR project for a google reader AIR app. In the GReader project, run:

rake air:package CERTIFICATE=path/to/cert.pfx

If you need to generate a certificate:

rake air:certificate CERTIFICATE=../ducktyper.pfx

I built a couple already if you want to bypass all that compiling:

(If you don’t have the AIR runtime installed, get it here)