Permalink
Browse files

Moving

  • Loading branch information...
0 parents commit d0e62f5b793718e5e2b6b1f549d4342523635ffc @fdv fdv committed Aug 30, 2008
Showing with 84 additions and 0 deletions.
  1. +22 −0 Rakefile
  2. +4 −0 init.rb
  3. +21 −0 lib/aimpresence_sidebar.rb
  4. +33 −0 test/aimpresence_sidebar_test.rb
  5. +4 −0 views/content.rhtml
22 Rakefile
@@ -0,0 +1,22 @@
+require 'rake'
+require 'rake/testtask'
+require 'rake/rdoctask'
+
+desc 'Default: run unit tests.'
+task :default => :test
+
+desc 'Test the aimpresence_sidebar plugin.'
+Rake::TestTask.new(:test) do |t|
+ t.libs << 'lib'
+ t.pattern = 'test/**/*_test.rb'
+ t.verbose = true
+end
+
+desc 'Generate documentation for the aimpresence_sidebar plugin.'
+Rake::RDocTask.new(:rdoc) do |rdoc|
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = 'AimpresenceSidebar'
+ rdoc.options << '--line-numbers' << '--inline-source'
+ rdoc.rdoc_files.include('README')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
4 init.rb
@@ -0,0 +1,4 @@
+require 'sidebar'
+require 'aimpresence_sidebar'
+
+AimpresenceSidebar.view_root = File.dirname(__FILE__) + '/views'
21 lib/aimpresence_sidebar.rb
@@ -0,0 +1,21 @@
+class AimpresenceSidebar < Sidebar
+ display_name _("AIM Presence")
+
+ description <<EOS
+Displays the Online presence of an AOL Instant Messenger screen name<br/>
+If you don\'t have a key, register <a href="http://www.aim.com/presence">here</a>.
+EOS
+
+ setting :sn, '', :label => 'Screen Name'
+ setting :devkey, '', :label => 'Key'
+
+
+ def parse_request(contents, params)
+ # contents is a list of the items being rendered on the current page
+ # params is the params hash for the current request
+
+ # Take a look at (eg) the amazon sidebar for examples of what gets done here
+ # If your sidebar doesn't depend on the request or the contents, you don't
+ # need to do anything here.
+ end
+end
33 test/aimpresence_sidebar_test.rb
@@ -0,0 +1,33 @@
+require 'test/unit'
+require File.dirname(__FILE__) + '/../../../../test/test_helper'
+
+class AimpresenceSidebarTest < Test::Unit::TestCase
+ def setup
+ @sidebar = AimpresenceSidebar.new
+ end
+
+ def test_sidebar_is_available
+ assert Sidebar.available_sidebars.include?( AimpresenceSidebar )
+ end
+
+ def test_display_name
+ assert_equal 'AIM Presence', AimpresenceSidebar.display_name
+ end
+
+ def test_description
+ assert_equal <<EOS, AimpresenceSidebar.description
+Displays the Online presence of an AOL Instant Messenger screen name<br/>
+If you don\'t have a key, register <a href="http://www.aim.com/presence">here</a>.
+EOS
+ end
+
+ def test_sn
+ assert_equal '', @sidebar.sn
+ assert_equal 'Screen Name', @sidebar.fieldmap(:sn).label
+ end
+
+ def test_devkey
+ assert_equal '', @sidebar.devkey
+ assert_equal 'Key', @sidebar.fieldmap(:devkey).label
+ end
+end
4 views/content.rhtml
@@ -0,0 +1,4 @@
+<h3><%= _("AIM Status")%></h3>
+<a class="im" href="aim:GoIM?screenname=<%= @sidebar.sn %>">
+<img alt=" " src="http://api.oscar.aol.com/SOA/key=<%= @sidebar.devkey %>/presence/<%= @sidebar.sn %>" border="0" /> <%= @sidebar.sn %>
+</a>

0 comments on commit d0e62f5

Please sign in to comment.