Skip to content
This repository was archived by the owner on Oct 24, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -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 in your views

h2. SYNOPSIS:

Expand Down Expand Up @@ -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.

<pre><code>
module PdfFileHelper
include RscribdHelper
end
</code></pre>

Then in your view, you can display your document like so:

<pre><code>
<%= display_scribd_reader(@pdffile.scribd_doc_id, @pdffile.scribd_doc_access_key) %>
</code></pre>
or with options:
<pre><code>
<%= display_scribd_reader(@pdffile.scribd_doc_id, @pdffile.scribd_doc_access_key, :width => 300, :height => 500) %>
</code></pre>

Available options are :
http://www.scribd.com/developers/api?method_name=Javascript+API#parameters

h2. REQUIREMENTS:

* A Scribd API account
Expand Down
1 change: 1 addition & 0 deletions lib/rscribd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ module Scribd
require 'scribd/document'
require 'scribd/user'
require 'scribd/security'
require 'rscribd_helper'
32 changes: 32 additions & 0 deletions lib/rscribd_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module RscribdHelper
def display_scribd_reader(doc_id, doc_key, options = {})
opts = {
:jsapi_version => 1,
:hide_disabled_buttons => true,
:mode => "slide"
}.merge(options)

if doc_id and doc_key
str = []
str << "<div id='embedded_flash'><a href='http://www.scribd.com'>Scribd</a></div>"
str << "<script type='text/javascript'>"
str << " var scribd_doc = scribd.Document.getDoc( #{doc_id}, '#{doc_key}' );"
str << " var oniPaperReady = function(e){"
str << " // scribd_doc.api.setPage(3);"
str << " }"
opts.each do |k,v|
if v.is_a?(String)
str << "scribd_doc.addParam( '#{k}', '#{v}' );"
else
str << "scribd_doc.addParam( '#{k}', #{v} );"
end
end
str << "scribd_doc.addEventListener( 'iPaperReady', oniPaperReady );"
str << "scribd_doc.write( 'embedded_flash' );"
str << "</script>"
return content_tag("div", str.join("\n").html_safe, :class => "scribd_reader")
else
return "Scribd document not found."
end
end
end
1 change: 1 addition & 0 deletions rscribd.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down