examples/api-samples/public/docs/sample09.html in groupdocs-1.5.8 vs examples/api-samples/public/docs/sample09.html in groupdocs-1.5.9
- old
+ new
@@ -86,23 +86,42 @@
</div>
<p>Check required variables</p>
</div>
- <div class="content"><div class='highlight'><pre> raise <span class="string">'Please enter all required parameters'</span> <span class="keyword">if</span> settings.client_id.empty? <span class="keyword">or</span> settings.private_key.empty? <span class="keyword">or</span> settings.width.empty? <span class="keyword">or</span> settings.height.empty?
-
- <span class="keyword">if</span> settings.base_path.empty? <span class="keyword">then</span> settings.base_path = <span class="string">'https://api.groupdocs.com'</span> <span class="keyword">end</span></pre></div></div>
+ <div class="content"><div class='highlight'><pre> raise <span class="string">'Please enter all required parameters'</span> <span class="keyword">if</span> settings.client_id.empty? <span class="keyword">or</span> settings.private_key.empty? <span class="keyword">or</span> settings.width.empty? <span class="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="keyword">if</span> settings.base_path.empty?
+ base_path = <span class="string">'https://api.groupdocs.com'</span>
+ <span class="keyword">elsif</span> settings.base_path.match(<span class="string">'/v2.0'</span>)
+ base_path = settings.base_path.split(<span class="string">'/v2.0'</span>)[<span class="number">0</span>]
+ <span class="keyword">else</span>
+ base_path = settings.base_path
+ <span class="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="constant">GroupDocs</span>.configure <span class="keyword">do</span> |groupdocs|
@@ -110,31 +129,31 @@
groupdocs.private_key = settings.private_key</pre></div></div>
</li>
- <li id="section-6">
+ <li id="section-7">
<div class="annotation">
<div class="pilwrap ">
- <a class="pilcrow" href="#section-6">¶</a>
+ <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 = settings.base_path <span class="comment"># default is 'https://api.groupdocs.com'</span>
+ <div class="content"><div class='highlight'><pre> groupdocs.api_server = base_path <span class="comment"># default is 'https://api.groupdocs.com'</span>
<span class="keyword">end</span></pre></div></div>
</li>
- <li id="section-7">
+ <li id="section-8">
<div class="annotation">
<div class="pilwrap ">
- <a class="pilcrow" href="#section-7">¶</a>
+ <a class="pilcrow" href="#section-8">¶</a>
</div>
<p>Get document by file GUID</p>
</div>
@@ -145,45 +164,45 @@
<span class="keyword">when</span> <span class="string">'local'</span></pre></div></div>
</li>
- <li id="section-8">
+ <li id="section-9">
<div class="annotation">
<div class="pilwrap ">
- <a class="pilcrow" href="#section-8">¶</a>
+ <a class="pilcrow" href="#section-9">¶</a>
</div>
<p>Construct path</p>
</div>
<div class="content"><div class='highlight'><pre> filepath = <span class="string">"<span class="subst">#{<span class="constant">Dir</span>.tmpdir}</span>/<span class="subst">#{params[<span class="symbol">:file</span>][<span class="symbol">:filename</span>]}</span>"</span></pre></div></div>
</li>
- <li id="section-9">
+ <li id="section-10">
<div class="annotation">
<div class="pilwrap ">
- <a class="pilcrow" href="#section-9">¶</a>
+ <a class="pilcrow" href="#section-10">¶</a>
</div>
<p>Open file</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="constant">File</span>.open(filepath, <span class="string">'wb'</span>) { |f| f.write(params[<span class="symbol">:file</span>][<span class="symbol">:tempfile</span>].read) }</pre></div></div>
</li>
- <li id="section-10">
+ <li id="section-11">
<div class="annotation">
<div class="pilwrap ">
- <a class="pilcrow" href="#section-10">¶</a>
+ <a class="pilcrow" href="#section-11">¶</a>
</div>
<p>Make a request to API using client_id and private_key</p>
</div>
@@ -194,63 +213,98 @@
raise <span class="string">'Wrong GUID source.'</span>
<span class="keyword">end</span>
url = <span class="keyword">nil</span>
<span class="keyword">case</span> settings.check
- <span class="keyword">when</span> <span class="string">'viewer'</span>
- <span class="keyword">case</span> settings.base_path
- <span class="keyword">when</span> <span class="string">'https://stage-api-groupdocs.dynabic.com'</span>
- url = <span class="string">"http://stage-apps-groupdocs.dynabic.com/document-viewer/embed/<span class="subst">#{file.guid}</span>?frameborder='0' width='<span class="subst">#{settings.width}</span>' height='<span class="subst">#{settings.height}</span>'"</span>
- <span class="keyword">when</span> <span class="string">'https://dev-api-groupdocs.dynabic.com'</span>
- url = <span class="string">"http://dev-apps-groupdocs.dynabic.com/document-viewer/embed/<span class="subst">#{file.guid}</span>?frameborder='0' width='<span class="subst">#{settings.width}</span>' height='<span class="subst">#{settings.height}</span>'"</span>
- <span class="keyword">else</span>
- url = <span class="string">"https://apps.groupdocs.com/document-viewer/embed/<span class="subst">#{file.guid}</span>?frameborder='0' width='<span class="subst">#{settings.width}</span>' height='<span class="subst">#{settings.height}</span>'"</span>
- <span class="keyword">end</span>
+ <span class="keyword">when</span> <span class="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>
- <span class="keyword">when</span> <span class="string">'annotation'</span>
- <span class="keyword">case</span> settings.base_path
- <span class="keyword">when</span> <span class="string">'https://stage-api-groupdocs.dynabic.com'</span>
- url = <span class="string">"http://stage-apps-groupdocs.dynabic.com/document-annotation2/embed/<span class="subst">#{file.guid}</span>?frameborder='0' width='<span class="subst">#{settings.width}</span>' height='<span class="subst">#{settings.height}</span>'"</span>
- <span class="keyword">when</span> <span class="string">'https://dev-api-groupdocs.dynabic.com'</span>
- url = <span class="string">"http://dev-apps-groupdocs.dynabic.com/document-annotation2/embed/<span class="subst">#{file.guid}</span>?frameborder='0' width='<span class="subst">#{settings.width}</span>' height='<span class="subst">#{settings.height}</span>'"</span>
- <span class="keyword">else</span>
- url = <span class="string">"https://apps.groupdocs.com/document-annotation2/embed/<span class="subst">#{file.guid}</span>?frameborder='0' width='<span class="subst">#{settings.width}</span>' height='<span class="subst">#{settings.height}</span>'"</span>
- <span class="keyword">end</span>
+ </div>
+
+ <div class="content"><div class='highlight'><pre> iframe = <span class="string">"/document-viewer/embed/<span class="subst">#{file.guid}</span>?frameborder='0' width='<span class="subst">#{settings.width}</span>' height='<span class="subst">#{settings.height}</span>'"</span>
+ <span class="keyword">when</span> <span class="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="string">"/document-annotation2/embed/<span class="subst">#{file.guid}</span>?frameborder='0' width='<span class="subst">#{settings.width}</span>' height='<span class="subst">#{settings.height}</span>'"</span>
<span class="keyword">end</span></pre></div></div>
</li>
- <li id="section-11">
+ <li id="section-14">
<div class="annotation">
<div class="pilwrap ">
- <a class="pilcrow" href="#section-11">¶</a>
+ <a class="pilcrow" href="#section-14">¶</a>
</div>
- <p>Construct result string</p>
+ <p>Sign url</p>
</div>
- <div class="content"><div class='highlight'><pre> url = <span class="constant">GroupDocs::Api::Request</span>.new(<span class="symbol">:path</span> => url).prepare_and_sign_url
+ <div class="content"><div class='highlight'><pre> url = <span class="constant">GroupDocs::Api::Request</span>.new(<span class="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="keyword">case</span> settings.base_path
+ <span class="keyword">when</span> <span class="string">'https://stage-api-groupdocs.dynabic.com'</span>
+ iframe = <span class="string">"https://stage-api-groupdocs.dynabic.com<span class="subst">#{url}</span>"</span>
+ <span class="keyword">when</span> <span class="string">'https://dev-api-groupdocs.dynabic.com'</span>
+ iframe = <span class="string">"https://dev-apps.groupdocs.com<span class="subst">#{url}</span>"</span>
+ <span class="keyword">else</span>
+ iframe = <span class="string">"https://apps.groupdocs.com<span class="subst">#{url}</span>"</span>
+ <span class="keyword">end</span>
+
<span class="keyword">rescue</span> <span class="constant">Exception</span> => e
err = e.message
<span class="keyword">end</span></pre></div></div>
</li>
- <li id="section-12">
+ <li id="section-16">
<div class="annotation">
<div class="pilwrap ">
- <a class="pilcrow" href="#section-12">¶</a>
+ <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="symbol">:sample09</span>, <span class="symbol">:locals</span> => {<span class="symbol">:guid</span> => file.guid, <span class="symbol">:width</span> => settings.width, <span class="symbol">:height</span> => settings.height, <span class="symbol">:v_url</span> => url, <span class="symbol">:err</span> => err}
+ <div class="content"><div class='highlight'><pre> haml <span class="symbol">:sample09</span>, <span class="symbol">:locals</span> => {<span class="symbol">:guid</span> => file.guid, <span class="symbol">:width</span> => settings.width, <span class="symbol">:height</span> => settings.height, <span class="symbol">:v_url</span> => iframe, <span class="symbol">:err</span> => err}
<span class="keyword">end</span></pre></div></div>
</li>
</ul>