Permalink
Browse files

Initial Commit

  • Loading branch information...
0 parents commit 040af553771fd452c74cac40b6a2c69e13ffc12a @davglass committed Dec 20, 2008
Showing with 192 additions and 0 deletions.
  1. +27 −0 README
  2. +46 −0 src/js/bp-paste.js
  3. +58 −0 src/service/PBoard.rb
  4. +10 −0 src/service/README
  5. +9 −0 src/service/ascript.scpt
  6. +16 −0 src/service/manifest.json
  7. +5 −0 src/service/test.rb
  8. +21 −0 tests/index.html
@@ -0,0 +1,27 @@
+This only works on OSX ;)
+
+First install BrowserPlus:
+http://browserplus.yahoo.com/install/
+
+Then Download the SDK:
+http://browserplus.yahoo.com/developer/service/sdk/
+
+Unzip it.
+
+From this directory:
+
+cd src/service
+[path to sdk]/bin/ServiceInstaller -v .
+
+Example:
+
+../../../bpsdk/bin/ServiceInstaller -v .
+
+That will install the Service on your machine..
+
+"You may need to restart your browser"
+
+The visit:
+tests/index.html
+
+
@@ -0,0 +1,46 @@
+(function() {
+
+ BrowserPlus.init(function(res) {
+ if (res.success) {
+ BrowserPlus.require({
+ services: [
+ {
+ service: "PBPaste",
+ version: "0",
+ minversion: "0.0.1"
+ },
+ {
+ service: 'FileAccess',
+ version: "1"
+ }
+
+ ]
+ }, function(r) {
+ if (r.success) {
+ YAHOO.util.Event.on('getBuffer', 'click', function() {
+ BrowserPlus.PBPaste.get({ callback: function() {
+ }}, function(x) {
+ var path = x.value;
+ if (path === false) {
+ alert('No image in buffer, please take a screen shot..');
+ } else {
+ BrowserPlus.FileAccess.GetURL( {file: path}, function(r) {
+ if (r.success) {
+ document.getElementById("result").innerHTML = '<img src=\"' + r.value + '\" height="300" width="300">';
+ }
+
+ });
+ }
+ });
+ });
+ } else {
+ alert('BP-PBPaste failed to load..');
+ }
+ });
+ } else {
+ alert('Browser Plus failed to load...');
+ }
+ });
+
+
+})();
@@ -0,0 +1,58 @@
+require('Pathname')
+
+
+class PBPaste
+
+ def initialize(args)
+ @dir = args['service_dir']
+
+ end
+
+ def _getImage()
+ return `osascript "#{@dir}/ascript.scpt"`.chomp
+ end
+
+ def get(bp, args)
+ file = _getImage()
+ if file == ''
+ file = false
+ else
+ file = Pathname.new(file)
+ end
+ if args['callback']
+ @callback = args['callback']
+ args['callback'].invoke(file)
+ end
+ bp.complete(file)
+ end
+
+
+end
+
+
+rubyCoreletDefinition = {
+ 'class' => "PBPaste",
+ 'name' => "PBPaste",
+ 'major_version' => 0,
+ 'minor_version' => 0,
+ 'micro_version' => 1,
+ 'documentation' =>
+ 'This plugin grabs an image from your clipboard and returns it to the browser',
+
+ 'functions' =>
+ [
+ {
+ 'name' => 'get',
+ 'documentation' => "Gets the image that in the clipboard.",
+ 'arguments' =>
+ [
+ {
+ 'name' => 'callback',
+ 'type' => 'callback',
+ 'required' => false,
+ 'documentation' => 'the callback to send a hello message to'
+ }
+ ]
+ }
+ ]
+ }
@@ -0,0 +1,10 @@
+
+Download the SDK:
+http://browserplus.yahoo.com/developer/service/sdk/
+
+
+
+[Uses the path to the sdk]
+From the src/service directory in this project
+
+../../../bpsdk/bin/ServiceInstaller -v .
@@ -0,0 +1,9 @@
+try
+ set png_image to «class PNGf» of (the clipboard as record)
+ set file_name to ((path to temporary items from user domain as string) & (time of (current date) as string) & ".png")
+ set the_file to open for access file file_name with write permission
+ write png_image to the_file
+ close access the_file
+ return POSIX path of file_name
+end try
+
@@ -0,0 +1,16 @@
+{
+ "type": "dependent",
+ "uses": {
+ "corelet": "RubyInterpreter",
+ "version": "4"
+ },
+ "arguments": {
+ "ScriptFile": "PBoard.rb"
+ },
+ "strings": {
+ "en": {
+ "title": "PBPaste",
+ "summary": "This plugin grabs an image from your clipboard and returns it to the browser."
+ }
+ }
+}
@@ -0,0 +1,5 @@
+require 'PBoard'
+
+
+t = PBPaste.new('./')
+puts t._getImage()
@@ -0,0 +1,21 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <title>browser photos test</title>
+ <style>
+ </style>
+</head>
+<body class="yui-skin-sam">
+
+<h2>Pull an image from the clipboard</h2>
+<p>From this page issue this keyboard shortcut: <pre>Command + Control + Shift + 3</pre>Then click the button below, your screenshot will appear ;)</p>
+<p><button id="getBuffer">Get Image from Buffer</button></p>
+
+<div id="result"></div>
+
+<script type="text/javascript" charset="utf-8" src="http://yui.yahooapis.com/2.6.0/build/yahoo-dom-event/yahoo-dom-event.js"></script>
+<script src="http://bp.yahooapis.com/2.1.11/browserplus.js"></script>
+<script type="text/javascript" src="../src/js/bp-paste.js"></script>
+</body>
+</html>

0 comments on commit 040af55

Please sign in to comment.