From d0c8df41efc560616686a382281bb277ef725e8a Mon Sep 17 00:00:00 2001 From: Daniel Quimper Date: Wed, 6 Apr 2011 11:26:03 -0400 Subject: [PATCH 1/5] adding scribd_reader helper --- lib/rscribd_helper.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 lib/rscribd_helper.rb diff --git a/lib/rscribd_helper.rb b/lib/rscribd_helper.rb new file mode 100644 index 0000000..bb44813 --- /dev/null +++ b/lib/rscribd_helper.rb @@ -0,0 +1,27 @@ +module RscribdHelper + def display_scribd_reader(doc_id, doc_key, options = {}) + opts = { + :width => "100%", + :height => "600", + :hide_disabled_buttons => true, + :mode => "slide" + }.merge(options) + + str = [] + str << "
Scribd
" + str << "" + return content_tag("div", str.join("\n").html_safe, :class => "scribd_reader") + end +end \ No newline at end of file From 9d65f20212a651bd405c3992e9ec518802883f92 Mon Sep 17 00:00:00 2001 From: Daniel Quimper Date: Wed, 6 Apr 2011 15:11:11 -0400 Subject: [PATCH 2/5] adding doc and helper options --- README | 22 ++++++++++++++++++++++ lib/rscribd_helper.rb | 43 ++++++++++++++++++++++++------------------- 2 files changed, 46 insertions(+), 19 deletions(-) diff --git a/README b/README index 787a8f8..f3bfa58 100644 --- a/README +++ b/README @@ -15,6 +15,7 @@ h2. FEATURES: * Upload local files or from remote web sites * Search, tag, and organize documents * Associate documents with your users' accounts +* Display Scribd Reader on your views h2. SYNOPSIS: @@ -49,6 +50,27 @@ For more information, please see the documentation for the Scribd::API, Scribd::User, and Scribd::Document classes. (You can also check out the docs for the other classes for a more in-depth look at this gem's features). +To display a Scribd reader on your view, simply include RscribdHelper to your view's helper. + +

+module PdfFileHelper
+  include RscribdHelper
+end
+
+ +Then in your view, you can display your document like so: + +

+  <%= display_scribd_reader(@pdffile.scribd_doc_id, @pdffile.scribd_doc_access_key) %>
+
+or with options: +

+  <%= display_scribd_reader(@pdffile.scribd_doc_id, @pdffile.scribd_doc_access_key, :width => 300, :height => 500) %>
+
+ +Available options are : +http://www.scribd.com/developers/api?method_name=Javascript+API#parameters + h2. REQUIREMENTS: * A Scribd API account diff --git a/lib/rscribd_helper.rb b/lib/rscribd_helper.rb index bb44813..468ea37 100644 --- a/lib/rscribd_helper.rb +++ b/lib/rscribd_helper.rb @@ -1,27 +1,32 @@ module RscribdHelper - def display_scribd_reader(doc_id, doc_key, options = {}) + def display_scribd_reader(doc_id, doc_key, options = {}) opts = { - :width => "100%", - :height => "600", + :jsapi_version => 1, :hide_disabled_buttons => true, :mode => "slide" }.merge(options) - str = [] - str << "" - str << "" - return content_tag("div", str.join("\n").html_safe, :class => "scribd_reader") + if doc_id and doc_key + str = [] + str << "" + str << "" + return content_tag("div", str.join("\n").html_safe, :class => "scribd_reader") + else + return "Scribd document not found." + end end end \ No newline at end of file From 8a42e6956467643c797565911b790ababe52d5b2 Mon Sep 17 00:00:00 2001 From: Daniel Quimper Date: Wed, 6 Apr 2011 15:12:01 -0400 Subject: [PATCH 3/5] fixed typo --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index f3bfa58..e301d8e 100644 --- a/README +++ b/README @@ -15,7 +15,7 @@ h2. FEATURES: * Upload local files or from remote web sites * Search, tag, and organize documents * Associate documents with your users' accounts -* Display Scribd Reader on your views +* Display Scribd Reader in your views h2. SYNOPSIS: From 0beea1d929853c589877d6c74a9e1893b2fc9356 Mon Sep 17 00:00:00 2001 From: Daniel Quimper Date: Thu, 7 Apr 2011 15:26:01 -0400 Subject: [PATCH 4/5] update gemspec --- rscribd.gemspec | 1 + 1 file changed, 1 insertion(+) diff --git a/rscribd.gemspec b/rscribd.gemspec index 6665811..2023653 100644 --- a/rscribd.gemspec +++ b/rscribd.gemspec @@ -22,6 +22,7 @@ Gem::Specification.new do |s| "Rakefile", "VERSION", "lib/rscribd.rb", + "lib/rscribd_helper.rb", "lib/scribd/api.rb", "lib/scribd/category.rb", "lib/scribd/collection.rb", From fdea0e2641b1185eae2d95794e545e957ea0f00a Mon Sep 17 00:00:00 2001 From: Daniel Quimper Date: Sun, 10 Apr 2011 02:31:43 -0400 Subject: [PATCH 5/5] added require for rscribd_helper --- lib/rscribd.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/rscribd.rb b/lib/rscribd.rb index 2839b41..171ea3c 100644 --- a/lib/rscribd.rb +++ b/lib/rscribd.rb @@ -15,3 +15,4 @@ module Scribd require 'scribd/document' require 'scribd/user' require 'scribd/security' +require 'rscribd_helper' \ No newline at end of file