Class: Onebox::Engine::GoogleDocsOnebox
- Inherits:
-
Object
- Object
- Onebox::Engine::GoogleDocsOnebox
show all
- Includes:
- Onebox::Engine
- Defined in:
- lib/onebox/engine/google_docs_onebox.rb
Constant Summary
DEFAULT
Instance Attribute Summary
#cache, #timeout, #uri, #url
Class Method Summary
collapse
Instance Method Summary
collapse
engines, included, #initialize, #options, #options=
Class Method Details
.embed_heights ⇒ Object
20
21
22
23
24
25
26
27
|
# File 'lib/onebox/engine/google_docs_onebox.rb', line 20
def embed_heights
@embed_heights ||= {
spreadsheets: 600,
document: 600,
presentation: 749,
forms: 500,
}
end
|
.embed_widths ⇒ Object
11
12
13
14
15
16
17
18
|
# File 'lib/onebox/engine/google_docs_onebox.rb', line 11
def embed_widths
@embed_widths ||= {
spreadsheets: 800,
document: 800,
presentation: 960,
forms: 760,
}
end
|
.short_types ⇒ Object
29
30
31
32
33
34
35
36
|
# File 'lib/onebox/engine/google_docs_onebox.rb', line 29
def short_types
@shorttypes ||= {
spreadsheets: :sheets,
document: :docs,
presentation: :slides,
forms: :forms,
}
end
|
.supported_endpoints ⇒ Object
7
8
9
|
# File 'lib/onebox/engine/google_docs_onebox.rb', line 7
def supported_endpoints
%w(spreadsheets document forms presentation)
end
|
Instance Method Details
#placeholder_html ⇒ Object
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/onebox/engine/google_docs_onebox.rb', line 54
def placeholder_html
<<HTML
<div placeholder><div class='gdocs-onebox gdocs-onebox-splash' style='display:table-cell;vertical-align:middle;width:#{width}px;height:#{height}px'>
<div style='text-align:center;'>
<div class='gdocs-onebox-logo g-#{shorttype}-logo'></div>
<p>Google #{shorttype.capitalize}</p>
<p><a href="https://docs.google.com/#{doc_type}/d/#{key}">#{key}</a></p>
</div></div></div>
HTML
end
|
#to_html ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/onebox/engine/google_docs_onebox.rb', line 42
def to_html
if document?
"<iframe class='gdocs-onebox document-onebox' src='https://docs.google.com/document/d/#{key}/pub?embedded=true' style='border: 0' width='#{width}' height='#{height}' frameborder='0' scrolling='yes'>#{placeholder_html}</iframe>"
elsif spreadsheet?
"<iframe class='gdocs-onebox spreadsheet-onebox' src='https://docs.google.com/spreadsheet/ccc?key=#{key}&usp=sharing&rm=minimal' style='border: 0' width='#{width}' height='#{height}' frameborder='0' scrolling='yes'>#{placeholder_html}</iframe>"
elsif presentation?
"<iframe class='gdocs-onebox presentation-onebox' src='https://docs.google.com/presentation/d/#{key}/embed?start=false&loop=false&delayms=3000' frameborder='0' width='#{width}' height='#{height}' allowfullscreen='true' mozallowfullscreen='true' webkitallowfullscreen='true'>#{placeholder_html}</iframe>"
elsif forms?
"<iframe class='gdocs-onebox forms-onebox' src='https://docs.google.com/forms/d/#{key}/viewform?embedded=true' width='#{width}' height='#{height}' frameborder='0' marginheight='0' marginwidth='0' scrolling='yes'>#{placeholder_html}</iframe>"
end
end
|