examples/api-samples/public/docs/sample09.html in groupdocs-2.2.0 vs examples/api-samples/public/docs/sample09.html in groupdocs-2.3.0
- old
+ new
@@ -1,314 +1,314 @@
-<!DOCTYPE html>
-
-<html>
-<head>
- <title>sample09.rb</title>
- <meta http-equiv="content-type" content="text/html; charset=UTF-8">
- <meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
- <link rel="stylesheet" media="all" href="docco.css" />
-</head>
-<body>
- <div id="container">
- <div id="background"></div>
-
- <ul class="sections">
-
- <li id="title">
- <div class="annotation">
- <h1>sample09.rb</h1>
- </div>
- </li>
-
-
-
- <li id="section-1">
- <div class="annotation">
-
- <div class="pilwrap ">
- <a class="pilcrow" href="#section-1">¶</a>
- </div>
- <p>GET request</p>
-
- </div>
-
- <div class="content"><div class='highlight'><pre>get <span class="hljs-string">'/sample-9-how-to-generate-an-embedded-viewer-url-for-a-document'</span> <span class="hljs-keyword">do</span>
- haml <span class="hljs-symbol">:sample09</span>
-<span class="hljs-keyword">end</span></pre></div></div>
-
- </li>
-
-
- <li id="section-2">
- <div class="annotation">
-
- <div class="pilwrap ">
- <a class="pilcrow" href="#section-2">¶</a>
- </div>
- <p>POST request</p>
-
- </div>
-
- <div class="content"><div class='highlight'><pre>post <span class="hljs-string">'/sample-9-how-to-generate-an-embedded-viewer-url-for-a-document'</span> <span class="hljs-keyword">do</span></pre></div></div>
-
- </li>
-
-
- <li id="section-3">
- <div class="annotation">
-
- <div class="pilwrap ">
- <a class="pilcrow" href="#section-3">¶</a>
- </div>
- <p>Set variables</p>
-
- </div>
-
- <div class="content"><div class='highlight'><pre> set <span class="hljs-symbol">:file_id</span>, params[<span class="hljs-symbol">:fileId</span>]
- set <span class="hljs-symbol">:width</span>, params[<span class="hljs-symbol">:width</span>]
- set <span class="hljs-symbol">:height</span>, params[<span class="hljs-symbol">:height</span>]
- set <span class="hljs-symbol">:source</span>, params[<span class="hljs-symbol">:source</span>]
- set <span class="hljs-symbol">:client_id</span>, params[<span class="hljs-symbol">:clientId</span>]
- set <span class="hljs-symbol">:private_key</span>, params[<span class="hljs-symbol">:privateKey</span>]
- set <span class="hljs-symbol">:check</span>, params[<span class="hljs-symbol">:check</span>]
- set <span class="hljs-symbol">:url</span>, params[<span class="hljs-symbol">:url</span>]
- set <span class="hljs-symbol">:base_path</span>, params[<span class="hljs-symbol">:basePath</span>]
-
- <span class="hljs-keyword">begin</span></pre></div></div>
-
- </li>
-
-
- <li id="section-4">
- <div class="annotation">
-
- <div class="pilwrap ">
- <a class="pilcrow" href="#section-4">¶</a>
- </div>
- <p>Check required variables</p>
-
- </div>
-
- <div class="content"><div class='highlight'><pre> raise <span class="hljs-string">'Please enter all required parameters'</span> <span class="hljs-keyword">if</span> settings.client_id.empty? <span class="hljs-keyword">or</span> settings.private_key.empty? <span class="hljs-keyword">or</span> settings.width.empty? <span class="hljs-keyword">or</span> settings.height.empty?</pre></div></div>
-
- </li>
-
-
- <li id="section-5">
- <div class="annotation">
-
- <div class="pilwrap ">
- <a class="pilcrow" href="#section-5">¶</a>
- </div>
- <p>Prepare base path</p>
-
- </div>
-
- <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> settings.base_path.empty?
- base_path = <span class="hljs-string">'https://api.groupdocs.com'</span>
- <span class="hljs-keyword">elsif</span> settings.base_path.match(<span class="hljs-string">'/v2.0'</span>)
- base_path = settings.base_path.split(<span class="hljs-string">'/v2.0'</span>)[<span class="hljs-number">0</span>]
- <span class="hljs-keyword">else</span>
- base_path = settings.base_path
- <span class="hljs-keyword">end</span></pre></div></div>
-
- </li>
-
-
- <li id="section-6">
- <div class="annotation">
-
- <div class="pilwrap ">
- <a class="pilcrow" href="#section-6">¶</a>
- </div>
- <p>Configure your access to API server</p>
-
- </div>
-
- <div class="content"><div class='highlight'><pre> <span class="hljs-constant">GroupDocs</span>.configure <span class="hljs-keyword">do</span> |groupdocs|
- groupdocs.client_id = settings.client_id
- groupdocs.private_key = settings.private_key</pre></div></div>
-
- </li>
-
-
- <li id="section-7">
- <div class="annotation">
-
- <div class="pilwrap ">
- <a class="pilcrow" href="#section-7">¶</a>
- </div>
- <p>Optionally specify API server and version</p>
-
- </div>
-
- <div class="content"><div class='highlight'><pre> groupdocs.api_server = base_path <span class="hljs-comment"># default is 'https://api.groupdocs.com'</span>
- <span class="hljs-keyword">end</span></pre></div></div>
-
- </li>
-
-
- <li id="section-8">
- <div class="annotation">
-
- <div class="pilwrap ">
- <a class="pilcrow" href="#section-8">¶</a>
- </div>
- <p>Get document by file GUID</p>
-
- </div>
-
- <div class="content"><div class='highlight'><pre> file = <span class="hljs-keyword">nil</span>
- <span class="hljs-keyword">case</span> settings.source
- <span class="hljs-keyword">when</span> <span class="hljs-string">'guid'</span>
- file = <span class="hljs-constant">GroupDocs::Storage::File</span>.new({<span class="hljs-symbol">:guid</span> => settings.file_id})
- <span class="hljs-keyword">when</span> <span class="hljs-string">'local'</span></pre></div></div>
-
- </li>
-
-
- <li id="section-9">
- <div class="annotation">
-
- <div class="pilwrap ">
- <a class="pilcrow" href="#section-9">¶</a>
- </div>
- <p>Construct path</p>
-
- </div>
-
- <div class="content"><div class='highlight'><pre> filepath = <span class="hljs-string">"<span class="hljs-subst">#{<span class="hljs-constant">Dir</span>.tmpdir}</span>/<span class="hljs-subst">#{params[<span class="hljs-symbol">:file</span>][<span class="hljs-symbol">:filename</span>]}</span>"</span></pre></div></div>
-
- </li>
-
-
- <li id="section-10">
- <div class="annotation">
-
- <div class="pilwrap ">
- <a class="pilcrow" href="#section-10">¶</a>
- </div>
- <p>Open file</p>
-
- </div>
-
- <div class="content"><div class='highlight'><pre> <span class="hljs-constant">File</span>.open(filepath, <span class="hljs-string">'wb'</span>) { |f| f.write(params[<span class="hljs-symbol">:file</span>][<span class="hljs-symbol">:tempfile</span>].read) }</pre></div></div>
-
- </li>
-
-
- <li id="section-11">
- <div class="annotation">
-
- <div class="pilwrap ">
- <a class="pilcrow" href="#section-11">¶</a>
- </div>
- <p>Make a request to API using client_id and private_key</p>
-
- </div>
-
- <div class="content"><div class='highlight'><pre> file = <span class="hljs-constant">GroupDocs::Storage::File</span>.upload!(filepath, {})
- <span class="hljs-keyword">when</span> <span class="hljs-string">'url'</span>
- file = <span class="hljs-constant">GroupDocs::Storage::File</span>.upload_web!(settings.url)
- <span class="hljs-keyword">else</span>
- raise <span class="hljs-string">'Wrong GUID source.'</span>
- <span class="hljs-keyword">end</span>
- url = <span class="hljs-keyword">nil</span>
-
- <span class="hljs-keyword">case</span> settings.check
- <span class="hljs-keyword">when</span> <span class="hljs-string">'viewer'</span></pre></div></div>
-
- </li>
-
-
- <li id="section-12">
- <div class="annotation">
-
- <div class="pilwrap ">
- <a class="pilcrow" href="#section-12">¶</a>
- </div>
- <p>Prepare to sign url</p>
-
- </div>
-
- <div class="content"><div class='highlight'><pre> iframe = <span class="hljs-string">"/document-viewer/embed/<span class="hljs-subst">#{file.guid}</span>?frameborder='0' width='<span class="hljs-subst">#{settings.width}</span>' height='<span class="hljs-subst">#{settings.height}</span>'"</span>
- <span class="hljs-keyword">when</span> <span class="hljs-string">'annotation'</span></pre></div></div>
-
- </li>
-
-
- <li id="section-13">
- <div class="annotation">
-
- <div class="pilwrap ">
- <a class="pilcrow" href="#section-13">¶</a>
- </div>
- <p>Prepare to sign url</p>
-
- </div>
-
- <div class="content"><div class='highlight'><pre> iframe = <span class="hljs-string">"/document-annotation2/embed/<span class="hljs-subst">#{file.guid}</span>?frameborder='0' width='<span class="hljs-subst">#{settings.width}</span>' height='<span class="hljs-subst">#{settings.height}</span>'"</span>
- <span class="hljs-keyword">end</span></pre></div></div>
-
- </li>
-
-
- <li id="section-14">
- <div class="annotation">
-
- <div class="pilwrap ">
- <a class="pilcrow" href="#section-14">¶</a>
- </div>
- <p>Sign url</p>
-
- </div>
-
- <div class="content"><div class='highlight'><pre> url = <span class="hljs-constant">GroupDocs::Api::Request</span>.new(<span class="hljs-symbol">:path</span> => iframe).prepare_and_sign_url</pre></div></div>
-
- </li>
-
-
- <li id="section-15">
- <div class="annotation">
-
- <div class="pilwrap ">
- <a class="pilcrow" href="#section-15">¶</a>
- </div>
- <p>Generate iframe URL</p>
-
- </div>
-
- <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">case</span> settings.base_path
- <span class="hljs-keyword">when</span> <span class="hljs-string">'https://stage-api-groupdocs.dynabic.com'</span>
- iframe = <span class="hljs-string">"https://stage-api-groupdocs.dynabic.com<span class="hljs-subst">#{url}</span>"</span>
- <span class="hljs-keyword">when</span> <span class="hljs-string">'https://dev-api-groupdocs.dynabic.com'</span>
- iframe = <span class="hljs-string">"https://dev-apps.groupdocs.com<span class="hljs-subst">#{url}</span>"</span>
- <span class="hljs-keyword">else</span>
- iframe = <span class="hljs-string">"https://apps.groupdocs.com<span class="hljs-subst">#{url}</span>"</span>
- <span class="hljs-keyword">end</span>
-
- <span class="hljs-keyword">rescue</span> <span class="hljs-constant">Exception</span> => e
- err = e.message
- <span class="hljs-keyword">end</span></pre></div></div>
-
- </li>
-
-
- <li id="section-16">
- <div class="annotation">
-
- <div class="pilwrap ">
- <a class="pilcrow" href="#section-16">¶</a>
- </div>
- <p>Set variables for template</p>
-
- </div>
-
- <div class="content"><div class='highlight'><pre> haml <span class="hljs-symbol">:sample09</span>, <span class="hljs-symbol">:locals</span> => {<span class="hljs-symbol">:guid</span> => file.guid, <span class="hljs-symbol">:width</span> => settings.width, <span class="hljs-symbol">:height</span> => settings.height, <span class="hljs-symbol">:v_url</span> => iframe, <span class="hljs-symbol">:err</span> => err}
-<span class="hljs-keyword">end</span></pre></div></div>
-
- </li>
-
- </ul>
- </div>
-</body>
-</html>
+<!DOCTYPE html>
+
+<html>
+<head>
+ <title>sample09.rb</title>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+ <meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
+ <link rel="stylesheet" media="all" href="docco.css" />
+</head>
+<body>
+ <div id="container">
+ <div id="background"></div>
+
+ <ul class="sections">
+
+ <li id="title">
+ <div class="annotation">
+ <h1>sample09.rb</h1>
+ </div>
+ </li>
+
+
+
+ <li id="section-1">
+ <div class="annotation">
+
+ <div class="pilwrap ">
+ <a class="pilcrow" href="#section-1">¶</a>
+ </div>
+ <p>GET request</p>
+
+ </div>
+
+ <div class="content"><div class='highlight'><pre>get <span class="hljs-string">'/sample-9-how-to-generate-an-embedded-viewer-url-for-a-document'</span> <span class="hljs-keyword">do</span>
+ haml <span class="hljs-symbol">:sample09</span>
+<span class="hljs-keyword">end</span></pre></div></div>
+
+ </li>
+
+
+ <li id="section-2">
+ <div class="annotation">
+
+ <div class="pilwrap ">
+ <a class="pilcrow" href="#section-2">¶</a>
+ </div>
+ <p>POST request</p>
+
+ </div>
+
+ <div class="content"><div class='highlight'><pre>post <span class="hljs-string">'/sample-9-how-to-generate-an-embedded-viewer-url-for-a-document'</span> <span class="hljs-keyword">do</span></pre></div></div>
+
+ </li>
+
+
+ <li id="section-3">
+ <div class="annotation">
+
+ <div class="pilwrap ">
+ <a class="pilcrow" href="#section-3">¶</a>
+ </div>
+ <p>Set variables</p>
+
+ </div>
+
+ <div class="content"><div class='highlight'><pre> set <span class="hljs-symbol">:file_id</span>, params[<span class="hljs-symbol">:fileId</span>]
+ set <span class="hljs-symbol">:width</span>, params[<span class="hljs-symbol">:width</span>]
+ set <span class="hljs-symbol">:height</span>, params[<span class="hljs-symbol">:height</span>]
+ set <span class="hljs-symbol">:source</span>, params[<span class="hljs-symbol">:source</span>]
+ set <span class="hljs-symbol">:client_id</span>, params[<span class="hljs-symbol">:clientId</span>]
+ set <span class="hljs-symbol">:private_key</span>, params[<span class="hljs-symbol">:privateKey</span>]
+ set <span class="hljs-symbol">:check</span>, params[<span class="hljs-symbol">:check</span>]
+ set <span class="hljs-symbol">:url</span>, params[<span class="hljs-symbol">:url</span>]
+ set <span class="hljs-symbol">:base_path</span>, params[<span class="hljs-symbol">:basePath</span>]
+
+ <span class="hljs-keyword">begin</span></pre></div></div>
+
+ </li>
+
+
+ <li id="section-4">
+ <div class="annotation">
+
+ <div class="pilwrap ">
+ <a class="pilcrow" href="#section-4">¶</a>
+ </div>
+ <p>Check required variables</p>
+
+ </div>
+
+ <div class="content"><div class='highlight'><pre> raise <span class="hljs-string">'Please enter all required parameters'</span> <span class="hljs-keyword">if</span> settings.client_id.empty? <span class="hljs-keyword">or</span> settings.private_key.empty? <span class="hljs-keyword">or</span> settings.width.empty? <span class="hljs-keyword">or</span> settings.height.empty?</pre></div></div>
+
+ </li>
+
+
+ <li id="section-5">
+ <div class="annotation">
+
+ <div class="pilwrap ">
+ <a class="pilcrow" href="#section-5">¶</a>
+ </div>
+ <p>Prepare base path</p>
+
+ </div>
+
+ <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> settings.base_path.empty?
+ base_path = <span class="hljs-string">'https://api.groupdocs.com'</span>
+ <span class="hljs-keyword">elsif</span> settings.base_path.match(<span class="hljs-string">'/v2.0'</span>)
+ base_path = settings.base_path.split(<span class="hljs-string">'/v2.0'</span>)[<span class="hljs-number">0</span>]
+ <span class="hljs-keyword">else</span>
+ base_path = settings.base_path
+ <span class="hljs-keyword">end</span></pre></div></div>
+
+ </li>
+
+
+ <li id="section-6">
+ <div class="annotation">
+
+ <div class="pilwrap ">
+ <a class="pilcrow" href="#section-6">¶</a>
+ </div>
+ <p>Configure your access to API server</p>
+
+ </div>
+
+ <div class="content"><div class='highlight'><pre> <span class="hljs-constant">GroupDocs</span>.configure <span class="hljs-keyword">do</span> |groupdocs|
+ groupdocs.client_id = settings.client_id
+ groupdocs.private_key = settings.private_key</pre></div></div>
+
+ </li>
+
+
+ <li id="section-7">
+ <div class="annotation">
+
+ <div class="pilwrap ">
+ <a class="pilcrow" href="#section-7">¶</a>
+ </div>
+ <p>Optionally specify API server and version</p>
+
+ </div>
+
+ <div class="content"><div class='highlight'><pre> groupdocs.api_server = base_path <span class="hljs-comment"># default is 'https://api.groupdocs.com'</span>
+ <span class="hljs-keyword">end</span></pre></div></div>
+
+ </li>
+
+
+ <li id="section-8">
+ <div class="annotation">
+
+ <div class="pilwrap ">
+ <a class="pilcrow" href="#section-8">¶</a>
+ </div>
+ <p>Get document by file GUID</p>
+
+ </div>
+
+ <div class="content"><div class='highlight'><pre> file = <span class="hljs-keyword">nil</span>
+ <span class="hljs-keyword">case</span> settings.source
+ <span class="hljs-keyword">when</span> <span class="hljs-string">'guid'</span>
+ file = <span class="hljs-constant">GroupDocs::Storage::File</span>.new({<span class="hljs-symbol">:guid</span> => settings.file_id})
+ <span class="hljs-keyword">when</span> <span class="hljs-string">'local'</span></pre></div></div>
+
+ </li>
+
+
+ <li id="section-9">
+ <div class="annotation">
+
+ <div class="pilwrap ">
+ <a class="pilcrow" href="#section-9">¶</a>
+ </div>
+ <p>Construct path</p>
+
+ </div>
+
+ <div class="content"><div class='highlight'><pre> filepath = <span class="hljs-string">"<span class="hljs-subst">#{<span class="hljs-constant">Dir</span>.tmpdir}</span>/<span class="hljs-subst">#{params[<span class="hljs-symbol">:file</span>][<span class="hljs-symbol">:filename</span>]}</span>"</span></pre></div></div>
+
+ </li>
+
+
+ <li id="section-10">
+ <div class="annotation">
+
+ <div class="pilwrap ">
+ <a class="pilcrow" href="#section-10">¶</a>
+ </div>
+ <p>Open file</p>
+
+ </div>
+
+ <div class="content"><div class='highlight'><pre> <span class="hljs-constant">File</span>.open(filepath, <span class="hljs-string">'wb'</span>) { |f| f.write(params[<span class="hljs-symbol">:file</span>][<span class="hljs-symbol">:tempfile</span>].read) }</pre></div></div>
+
+ </li>
+
+
+ <li id="section-11">
+ <div class="annotation">
+
+ <div class="pilwrap ">
+ <a class="pilcrow" href="#section-11">¶</a>
+ </div>
+ <p>Make a request to API using client_id and private_key</p>
+
+ </div>
+
+ <div class="content"><div class='highlight'><pre> file = <span class="hljs-constant">GroupDocs::Storage::File</span>.upload!(filepath, {})
+ <span class="hljs-keyword">when</span> <span class="hljs-string">'url'</span>
+ file = <span class="hljs-constant">GroupDocs::Storage::File</span>.upload_web!(settings.url)
+ <span class="hljs-keyword">else</span>
+ raise <span class="hljs-string">'Wrong GUID source.'</span>
+ <span class="hljs-keyword">end</span>
+ url = <span class="hljs-keyword">nil</span>
+
+ <span class="hljs-keyword">case</span> settings.check
+ <span class="hljs-keyword">when</span> <span class="hljs-string">'viewer'</span></pre></div></div>
+
+ </li>
+
+
+ <li id="section-12">
+ <div class="annotation">
+
+ <div class="pilwrap ">
+ <a class="pilcrow" href="#section-12">¶</a>
+ </div>
+ <p>Prepare to sign url</p>
+
+ </div>
+
+ <div class="content"><div class='highlight'><pre> iframe = <span class="hljs-string">"/document-viewer/embed/<span class="hljs-subst">#{file.guid}</span>?frameborder='0' width='<span class="hljs-subst">#{settings.width}</span>' height='<span class="hljs-subst">#{settings.height}</span>'"</span>
+ <span class="hljs-keyword">when</span> <span class="hljs-string">'annotation'</span></pre></div></div>
+
+ </li>
+
+
+ <li id="section-13">
+ <div class="annotation">
+
+ <div class="pilwrap ">
+ <a class="pilcrow" href="#section-13">¶</a>
+ </div>
+ <p>Prepare to sign url</p>
+
+ </div>
+
+ <div class="content"><div class='highlight'><pre> iframe = <span class="hljs-string">"/document-annotation2/embed/<span class="hljs-subst">#{file.guid}</span>?frameborder='0' width='<span class="hljs-subst">#{settings.width}</span>' height='<span class="hljs-subst">#{settings.height}</span>'"</span>
+ <span class="hljs-keyword">end</span></pre></div></div>
+
+ </li>
+
+
+ <li id="section-14">
+ <div class="annotation">
+
+ <div class="pilwrap ">
+ <a class="pilcrow" href="#section-14">¶</a>
+ </div>
+ <p>Sign url</p>
+
+ </div>
+
+ <div class="content"><div class='highlight'><pre> url = <span class="hljs-constant">GroupDocs::Api::Request</span>.new(<span class="hljs-symbol">:path</span> => iframe).prepare_and_sign_url</pre></div></div>
+
+ </li>
+
+
+ <li id="section-15">
+ <div class="annotation">
+
+ <div class="pilwrap ">
+ <a class="pilcrow" href="#section-15">¶</a>
+ </div>
+ <p>Generate iframe URL</p>
+
+ </div>
+
+ <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">case</span> settings.base_path
+ <span class="hljs-keyword">when</span> <span class="hljs-string">'https://stage-api-groupdocs.dynabic.com'</span>
+ iframe = <span class="hljs-string">"https://stage-api-groupdocs.dynabic.com<span class="hljs-subst">#{url}</span>"</span>
+ <span class="hljs-keyword">when</span> <span class="hljs-string">'https://dev-api-groupdocs.dynabic.com'</span>
+ iframe = <span class="hljs-string">"https://dev-apps.groupdocs.com<span class="hljs-subst">#{url}</span>"</span>
+ <span class="hljs-keyword">else</span>
+ iframe = <span class="hljs-string">"https://apps.groupdocs.com<span class="hljs-subst">#{url}</span>"</span>
+ <span class="hljs-keyword">end</span>
+
+ <span class="hljs-keyword">rescue</span> <span class="hljs-constant">Exception</span> => e
+ err = e.message
+ <span class="hljs-keyword">end</span></pre></div></div>
+
+ </li>
+
+
+ <li id="section-16">
+ <div class="annotation">
+
+ <div class="pilwrap ">
+ <a class="pilcrow" href="#section-16">¶</a>
+ </div>
+ <p>Set variables for template</p>
+
+ </div>
+
+ <div class="content"><div class='highlight'><pre> haml <span class="hljs-symbol">:sample09</span>, <span class="hljs-symbol">:locals</span> => {<span class="hljs-symbol">:guid</span> => file.guid, <span class="hljs-symbol">:width</span> => settings.width, <span class="hljs-symbol">:height</span> => settings.height, <span class="hljs-symbol">:v_url</span> => iframe, <span class="hljs-symbol">:err</span> => err}
+<span class="hljs-keyword">end</span></pre></div></div>
+
+ </li>
+
+ </ul>
+ </div>
+</body>
+</html>