groupdocs 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +4 -0
- data/CHANGELOG.md +32 -0
- data/examples/api-samples/public/css/style.css +123 -67
- data/examples/api-samples/public/images/help.png +0 -0
- data/examples/api-samples/public/images/info.png +0 -0
- data/examples/api-samples/public/templates/base-simple_source.html +192 -0
- data/examples/api-samples/public/templates/testdocument.html +101 -0
- data/examples/api-samples/public/templates/welcome.htm +137 -0
- data/examples/api-samples/samples/sample18.rb +134 -31
- data/examples/api-samples/views/sample18.haml +127 -9
- data/lib/groupdocs/api/request.rb +1 -1
- data/lib/groupdocs/document.rb +6 -3
- data/lib/groupdocs/signature.rb +6 -0
- data/lib/groupdocs/signature/contact.rb +42 -0
- data/lib/groupdocs/signature/envelope.rb +71 -0
- data/lib/groupdocs/signature/field.rb +21 -2
- data/lib/groupdocs/signature/form.rb +162 -9
- data/lib/groupdocs/signature/role.rb +5 -31
- data/lib/groupdocs/signature/shared/document_methods.rb +2 -1
- data/lib/groupdocs/signature/shared/entity_fields.rb +6 -16
- data/lib/groupdocs/signature/shared/entity_methods.rb +2 -2
- data/lib/groupdocs/signature/shared/field_methods.rb +56 -2
- data/lib/groupdocs/storage.rb +1 -0
- data/lib/groupdocs/storage/provider.rb +32 -0
- data/lib/groupdocs/user.rb +66 -0
- data/lib/groupdocs/version.rb +1 -1
- data/spec/groupdocs/signature/contact_spec.rb +21 -0
- data/spec/groupdocs/signature/envelope_spec.rb +53 -1
- data/spec/groupdocs/signature/field_spec.rb +19 -1
- data/spec/groupdocs/signature/form_spec.rb +47 -11
- data/spec/groupdocs/signature/role_spec.rb +4 -47
- data/spec/groupdocs/signature_spec.rb +4 -0
- data/spec/groupdocs/storage/provider_spec.rb +22 -0
- data/spec/groupdocs/user_spec.rb +54 -0
- data/spec/support/json/user_embed_key.json +39 -0
- data/spec/support/json/user_providers.json +31 -0
- data/spec/support/json/user_roles.json +25 -0
- data/spec/support/shared_examples/signature/shared/entity_fields.rb +14 -26
- data/spec/support/shared_examples/signature/shared/field_methods.rb +58 -34
- metadata +18 -4
@@ -0,0 +1,101 @@
|
|
1
|
+
<!-- Sample Content to Plugin to Template -->
|
2
|
+
<h1>CSS Basic Elements</h1>
|
3
|
+
|
4
|
+
<p>The purpose of this HTML is to help determine what default settings are with CSS and to make sure that all possible HTML Elements are included in this HTML so as to not miss any possible Elements when designing a site.</p>
|
5
|
+
|
6
|
+
<hr />
|
7
|
+
|
8
|
+
<h1 id="headings">Headings</h1>
|
9
|
+
|
10
|
+
<h1>Heading 1</h1>
|
11
|
+
<h2>Heading 2</h2>
|
12
|
+
<h3>Heading 3</h3>
|
13
|
+
<h4>Heading 4</h4>
|
14
|
+
<h5>Heading 5</h5>
|
15
|
+
<h6>Heading 6</h6>
|
16
|
+
|
17
|
+
<small><a href="#wrapper">[top]</a></small>
|
18
|
+
<hr />
|
19
|
+
|
20
|
+
|
21
|
+
<h1 id="paragraph">Paragraph</h1>
|
22
|
+
|
23
|
+
|
24
|
+
<p>Lorem ipsum dolor sit amet, <a href="#" title="test link">test link</a> adipiscing elit. Nullam dignissim convallis est. Quisque aliquam. Donec faucibus. Nunc iaculis suscipit dui. Nam sit amet sem. Aliquam libero nisi, imperdiet at, tincidunt nec, gravida vehicula, nisl. Praesent mattis, massa quis luctus fermentum, turpis mi volutpat justo, eu volutpat enim diam eget metus. Maecenas ornare tortor. Donec sed tellus eget sapien fringilla nonummy. Mauris a ante. Suspendisse quam sem, consequat at, commodo vitae, feugiat in, nunc. Morbi imperdiet augue quis tellus.</p>
|
25
|
+
|
26
|
+
<p>Lorem ipsum dolor sit amet, <em>emphasis</em> consectetuer adipiscing elit. Nullam dignissim convallis est. Quisque aliquam. Donec faucibus. Nunc iaculis suscipit dui. Nam sit amet sem. Aliquam libero nisi, imperdiet at, tincidunt nec, gravida vehicula, nisl. Praesent mattis, massa quis luctus fermentum, turpis mi volutpat justo, eu volutpat enim diam eget metus. Maecenas ornare tortor. Donec sed tellus eget sapien fringilla nonummy. Mauris a ante. Suspendisse quam sem, consequat at, commodo vitae, feugiat in, nunc. Morbi imperdiet augue quis tellus.</p>
|
27
|
+
|
28
|
+
<small><a href="#wrapper">[top]</a></small>
|
29
|
+
<hr />
|
30
|
+
|
31
|
+
<h1 id="list_types">List Types</h1>
|
32
|
+
|
33
|
+
<h3>Definition List</h3>
|
34
|
+
<dl>
|
35
|
+
<dt>Definition List Title</dt>
|
36
|
+
<dd>This is a definition list division.</dd>
|
37
|
+
</dl>
|
38
|
+
|
39
|
+
<h3>Ordered List</h3>
|
40
|
+
<ol>
|
41
|
+
<li>List Item 1</li>
|
42
|
+
<li>List Item 2</li>
|
43
|
+
<li>List Item 3</li>
|
44
|
+
</ol>
|
45
|
+
|
46
|
+
<h3>Unordered List</h3>
|
47
|
+
<ul>
|
48
|
+
<li>List Item 1</li>
|
49
|
+
<li>List Item 2</li>
|
50
|
+
<li>List Item 3</li>
|
51
|
+
</ul>
|
52
|
+
|
53
|
+
<small><a href="#wrapper">[top]</a></small>
|
54
|
+
<hr />
|
55
|
+
|
56
|
+
<h1 id="form_elements">Fieldsets, Legends, and Form Elements</h1>
|
57
|
+
|
58
|
+
<fieldset>
|
59
|
+
<legend>Legend</legend>
|
60
|
+
|
61
|
+
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nullam dignissim convallis est. Quisque aliquam. Donec faucibus. Nunc iaculis suscipit dui. Nam sit amet sem. Aliquam libero nisi, imperdiet at, tincidunt nec, gravida vehicula, nisl. Praesent mattis, massa quis luctus fermentum, turpis mi volutpat justo, eu volutpat enim diam eget metus.</p>
|
62
|
+
|
63
|
+
|
64
|
+
</fieldset>
|
65
|
+
|
66
|
+
<small><a href="#wrapper">[top]</a></small>
|
67
|
+
<hr />
|
68
|
+
|
69
|
+
<h1 id="tables">Tables</h1>
|
70
|
+
|
71
|
+
<table cellspacing="0" cellpadding="0">
|
72
|
+
<tr>
|
73
|
+
<th>Table Header 1</th><th>Table Header 2</th><th>Table Header 3</th>
|
74
|
+
</tr>
|
75
|
+
<tr>
|
76
|
+
<td>Division 1</td><td>Division 2</td><td>Division 3</td>
|
77
|
+
</tr>
|
78
|
+
<tr class="even">
|
79
|
+
<td>Division 1</td><td>Division 2</td><td>Division 3</td>
|
80
|
+
</tr>
|
81
|
+
<tr>
|
82
|
+
<td>Division 1</td><td>Division 2</td><td>Division 3</td>
|
83
|
+
</tr>
|
84
|
+
|
85
|
+
</table>
|
86
|
+
|
87
|
+
<small><a href="#wrapper">[top]</a></small>
|
88
|
+
<hr />
|
89
|
+
|
90
|
+
<h1 id="misc">Misc Stuff - abbr, acronym, pre, code, sub, sup, etc.</h1>
|
91
|
+
|
92
|
+
<p>Lorem <sup>superscript</sup> dolor <sub>subscript</sub> amet, consectetuer adipiscing elit. Nullam dignissim convallis est. Quisque aliquam. <cite>cite</cite>. Nunc iaculis suscipit dui. Nam sit amet sem. Aliquam libero nisi, imperdiet at, tincidunt nec, gravida vehicula, nisl. Praesent mattis, massa quis luctus fermentum, turpis mi volutpat justo, eu volutpat enim diam eget metus. Maecenas ornare tortor. Donec sed tellus eget sapien fringilla nonummy. <acronym title="National Basketball Association">NBA</acronym> Mauris a ante. Suspendisse quam sem, consequat at, commodo vitae, feugiat in, nunc. Morbi imperdiet augue quis tellus. <abbr title="Avenue">AVE</abbr></p>
|
93
|
+
|
94
|
+
<pre><p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nullam dignissim convallis est. Quisque aliquam. Donec faucibus. Nunc iaculis suscipit dui. Nam sit amet sem. Aliquam libero nisi, imperdiet at, tincidunt nec, gravida vehicula, nisl. Praesent mattis, massa quis luctus fermentum, turpis mi volutpat justo, eu volutpat enim diam eget metus. Maecenas ornare tortor. Donec sed tellus eget sapien fringilla nonummy. <acronym title="National Basketball Association">NBA</acronym> Mauris a ante. Suspendisse quam sem, consequat at, commodo vitae, feugiat in, nunc. Morbi imperdiet augue quis tellus. <abbr title="Avenue">AVE</abbr></p></pre>
|
95
|
+
|
96
|
+
<blockquote>
|
97
|
+
"This stylesheet is going to help so freaking much." <br />-Blockquote
|
98
|
+
</blockquote>
|
99
|
+
|
100
|
+
<small><a href="#wrapper">[top]</a></small>
|
101
|
+
<!-- End of Sample Content -->
|
@@ -0,0 +1,137 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
5
|
+
<title>Powered by {{ @VERSION }}</title>
|
6
|
+
<style type="text/css">
|
7
|
+
{{ Web::minify('templates/',array('style.css'),FALSE) }}
|
8
|
+
</style>
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<div class="header">
|
12
|
+
<h4>On this site will rise another Web masterpiece powered by</h4>
|
13
|
+
<h1>{{ @VERSION }}</h1>
|
14
|
+
</div>
|
15
|
+
<div class="content">
|
16
|
+
<h3>Dynamic PHP Applications The Fast and Easy Way</h3>
|
17
|
+
<p>The first thing you might want to do is visualize your directory structures. Fat-Free gives you total control over your Web site. Organize your folders in any way that pleases you. Decide where you want to store the following:</p>
|
18
|
+
<ul>
|
19
|
+
<li>HTML templates</li>
|
20
|
+
<li>Graphics, Flash and media files</li>
|
21
|
+
<li>Javascript and CSS files</li>
|
22
|
+
<li>Fat-Free import files, code libraries, and PHP includes</li>
|
23
|
+
<li>OOP classes</li>
|
24
|
+
<li>Database (if you plan to use an embedded DB like SQLite)</li>
|
25
|
+
<li>Configuration files</li>
|
26
|
+
<li>Uploads/Downloads</li>
|
27
|
+
<li>Fonts (optional)</li>
|
28
|
+
</ul>
|
29
|
+
<p>For security reasons, consider relocating the <code>lib/</code> folder to a path that's not Web-accessible. If you decide to move this folder, just change the line in <code>index.php</code> containing <code>require 'lib/base.php';</code> The <code>lib/</code> folder also contains framework plug-ins that extend F3's capabilities. You can change the default location of all plug-ins by moving the files to your desired subdirectory. Then, it's just a matter of pointing the <code>PLUGINS</code> global variable to the new location. You may delete the plug-ins that you don't need. You can always restore them later.</p>
|
30
|
+
<p>The <code>IMPORTS</code> global variable should point to the location of Fat-Free import files, code libraries, and PHP includes. On the other hand, F3 can autoload your OOP classes for you. Just add the path to the <code>AUTOLOAD</code> variable. The rest of the above-listed items do not require configuration of a framework global variable, so you may store them anywhere.</p>
|
31
|
+
<blockquote>
|
32
|
+
<h4>Important</h4>
|
33
|
+
<p>The distribution package contains a file named <code>htaccess</code>. It's saved that way in the archive because some ZIP extraction tools may not be configured to display hidden files like <code>.htaccess</code>. You should rename the file if you're using Apache.</p>
|
34
|
+
</blockquote>
|
35
|
+
<p>When you're ready to write your F3-enabled site, you can start editing the rest of the code contained in the <code>index.php</code> file that displayed this Web page. Developing PHP applications will never be the same!</p>
|
36
|
+
<h3>PHP Dependencies</h3>
|
37
|
+
<p>Some framework features will not be available if PHP is not configured with the modules needed by your application.</p>
|
38
|
+
<table>
|
39
|
+
<tr>
|
40
|
+
<th>PHP Module</th>
|
41
|
+
<th>Installed</th>
|
42
|
+
<th>Required by</th>
|
43
|
+
</tr>
|
44
|
+
<repeat group="{{@modules}}" key="{{ @mod }}" value="{{ @dep }}" counter="{{ @counter }}">
|
45
|
+
<tr class="{{ @counter%2?'odd':'even' }}">
|
46
|
+
<td>{{ @mod }}</td>
|
47
|
+
<td class="{{ extension_loaded(@mod)?'pass':'fail' }}">{{ extension_loaded(@mod)?'Yes':'No' }}</td>
|
48
|
+
<td>{{ @dep }}</td>
|
49
|
+
</tr>
|
50
|
+
</repeat>
|
51
|
+
</table>
|
52
|
+
<h3>Need Help?</h3>
|
53
|
+
<p>Technical support is available at: <code><a href="https://groups.google.com/forum/?fromgroups#!forum/f3-framework">https://groups.google.com/forum/?fromgroups#!forum/f3-framework</a></code>. If you need live support, you can talk to the development team and the rest of the Fat-Free community via IRC. We're on the FreeNode <code>#fatfree</code> channel (<code>chat.freenode.net</code>).</p>
|
54
|
+
<p>The help file included in the distribution (<code>lib/f3.chm</code>) is at your disposal if you need to take a close look at the Fat-Free API. However, the online documentation at <code><a href="http://fatfree.sourceforge.net" onclick="window.open(this.href); return false;">http://fatfree.sourceforge.net</a></code> provides the latest and most comprehensive information about the framework.</p>
|
55
|
+
<h3>Fair Licensing</h3>
|
56
|
+
<p>If you intend to use this software for business or commercial gain: permissive and "closed-source" licensing terms are available. For academic and personal use, the PHP Fat-Free Framework and other files included in the distribution are subject to the terms of the GPL v3. You may not use the software, documentation, and samples except in compliance with the license.</p>
|
57
|
+
<h3>Support F3</h3>
|
58
|
+
<p>F3 is community-driven open-source software. Support the development of the Fat-Free Framework. Your contributions help keep this project alive.</p>
|
59
|
+
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
|
60
|
+
<input type="hidden" name="cmd" value="_s-xclick">
|
61
|
+
<input type="hidden" name="hosted_button_id" value="WPFRKQY9HDMML">
|
62
|
+
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
|
63
|
+
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
|
64
|
+
</form>
|
65
|
+
<p/>
|
66
|
+
<p>The framework won't be what it is today without the help and support from the following people and organizations:</p>
|
67
|
+
<ul style="column-count:3; column-gap:15px; -moz-column-count:3; -moz-column-gap:15px; -webkit-column-count:3; -webkit-column-gap:15px;">
|
68
|
+
<li>GitHub</li>
|
69
|
+
<li>Sascha Ohms</li>
|
70
|
+
<li>Jermaine Maree</li>
|
71
|
+
<li>Sergey Zaretsky</li>
|
72
|
+
<li>Daniel Kloke</li>
|
73
|
+
<li>Brian Nelson</li>
|
74
|
+
<li>Roberts Lapins</li>
|
75
|
+
<li>Boris Gurevich</li>
|
76
|
+
<li>Eyðun Lamhauge</li>
|
77
|
+
<li>Jose Maria Garrido Diaz</li>
|
78
|
+
<li>Dawn Comfort</li>
|
79
|
+
<li>Johan Viberg</li>
|
80
|
+
<li>Povilas Musteikis</li>
|
81
|
+
<li>Andrew Snook</li>
|
82
|
+
<li>Jafar Amjad</li>
|
83
|
+
<li>Taylor McCall</li>
|
84
|
+
<li>Raymond Kirkland</li>
|
85
|
+
<li>Yuriy Gerassimenko</li>
|
86
|
+
<li>William Stam</li>
|
87
|
+
<li>Sam George</li>
|
88
|
+
<li>Steve Wasiura</li>
|
89
|
+
<li>Andreas Ljunggren</li>
|
90
|
+
<li>Sashank Tadepalli</li>
|
91
|
+
<li>Chad Bishop</li>
|
92
|
+
<li>Bradley Slavik</li>
|
93
|
+
<li>Lee Blue</li>
|
94
|
+
<li>Alexander Shatilo</li>
|
95
|
+
<li>Justin Noel</li>
|
96
|
+
<li>Ivan Kovac</li>
|
97
|
+
<li>Tony's Internet Solutions</li>
|
98
|
+
<li>Charles Stigler</li>
|
99
|
+
<li>Attila van der Velde</li>
|
100
|
+
<li>Indoblo Commerce Limited</li>
|
101
|
+
<li>Jens Níemeyer</li>
|
102
|
+
<li>Raghu Veer Dendukuri</li>
|
103
|
+
<li>NovelLead B.V.</li>
|
104
|
+
<li>Emir Alp</li>
|
105
|
+
<li>Dominic Schwarz</li>
|
106
|
+
<li>Sven Zahrend</li>
|
107
|
+
<li>LucidStorm</li>
|
108
|
+
<li>Nevatech</li>
|
109
|
+
<li>Matt Wielgos</li>
|
110
|
+
<li>Christian Knuth</li>
|
111
|
+
<li>Maximilian Summe</li>
|
112
|
+
<li>Caspar Frey</li>
|
113
|
+
<li>G Holdings, LLC</li>
|
114
|
+
<li>FocusHeart</li>
|
115
|
+
<li>Philip Lawrence</li>
|
116
|
+
<li>Peter Beverwyk</li>
|
117
|
+
<li>Randal Hintz</li>
|
118
|
+
<li>Franz Josef</li>
|
119
|
+
<li>Biswajit Nayak</li>
|
120
|
+
<li>R Mohan</li>
|
121
|
+
<li>Michael Messner</li>
|
122
|
+
<li>Florent Racineux</li>
|
123
|
+
<li>Jason Borseth</li>
|
124
|
+
<li>Dmitrij Chernov</li>
|
125
|
+
<li>Marek Toman</li>
|
126
|
+
<li>Simone Cociancich</li>
|
127
|
+
<li>Tecnilógica</li>
|
128
|
+
<li>Alan Holding</li>
|
129
|
+
<li>Mirosystems</li>
|
130
|
+
</ul>
|
131
|
+
<p>Special thanks to the selfless others who expressed their desire to remain anonymous, yet share their time, contribute code, send donations, promote the framework to a wider audience, as well as provide encouragement and regular financial assistance. Their generosity is F3's prime motivation.</p>
|
132
|
+
</div>
|
133
|
+
<div class="footer">
|
134
|
+
<h5>Fat-Free Framework is licensed under the terms of the GPL v3. Copyright © 2009-2011 F3::Factory</h5>
|
135
|
+
</div>
|
136
|
+
</body>
|
137
|
+
</html>
|
@@ -3,6 +3,118 @@ get '/sample18' do
|
|
3
3
|
haml :sample18
|
4
4
|
end
|
5
5
|
|
6
|
+
post '/sample18/test_callback' do
|
7
|
+
downloads_path = "#{File.dirname(__FILE__)}/../public/downloads"
|
8
|
+
unless File.directory?(downloads_path)
|
9
|
+
Dir::mkdir(downloads_path)
|
10
|
+
else
|
11
|
+
Dir.foreach(downloads_path) {|f| fn = File.join(downloads_path, f); File.delete(fn) if f != '.' && f != '..'}
|
12
|
+
end
|
13
|
+
|
14
|
+
SourceId = nil
|
15
|
+
client_key = nil
|
16
|
+
private_key = nil
|
17
|
+
|
18
|
+
data = JSON.parse(request.body.read)
|
19
|
+
data.each do |key, value|
|
20
|
+
if key == 'SourceId'
|
21
|
+
SourceId = value
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
if File.exist?("#{File.dirname(__FILE__)}/../public/user_info.txt")
|
26
|
+
contents = File.read("#{File.dirname(__FILE__)}/../public/user_info.txt")
|
27
|
+
contents = contents.split(' ')
|
28
|
+
client_key = contents.first
|
29
|
+
private_key = contents.last
|
30
|
+
end
|
31
|
+
|
32
|
+
outFile = File.new("#{File.dirname(__FILE__)}/../public/downloads/signed", "w")
|
33
|
+
outFile.write("private_key: #{private_key} \n")
|
34
|
+
outFile.write("client_key: #{client_key} \n")
|
35
|
+
outFile.write("SourceId: #{SourceId} \n")
|
36
|
+
outFile.close
|
37
|
+
|
38
|
+
job = GroupDocs::Job.new({:id=>SourceId})
|
39
|
+
documents = job.documents!({:client_id => client_key, :private_key => private_key})
|
40
|
+
tttt = documents[:inputs].first.file.download!(downloads_path, {:client_id => client_key, :private_key => private_key})
|
41
|
+
|
42
|
+
outFile = File.new("#{File.dirname(__FILE__)}/../public/downloads/t", "w")
|
43
|
+
outFile.write("documents: #{documents} \n")
|
44
|
+
outFile.write("tttt: #{tttt} \n")
|
45
|
+
outFile.close
|
46
|
+
end
|
47
|
+
|
48
|
+
# GET request to check if envelop was signed
|
49
|
+
get '/sample18/test_check' do
|
50
|
+
if File.exist?("#{File.dirname(__FILE__)}/../public/downloads/signed")
|
51
|
+
File.readlines("#{File.dirname(__FILE__)}/../public/downloads/signed").each do |line|
|
52
|
+
end
|
53
|
+
else
|
54
|
+
'not yet'
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
#
|
59
|
+
post '/sample18/convert_callback' do
|
60
|
+
downloads_path = "#{File.dirname(__FILE__)}/../public/downloads"
|
61
|
+
unless File.directory?(downloads_path)
|
62
|
+
Dir::mkdir(downloads_path)
|
63
|
+
else
|
64
|
+
Dir.foreach(downloads_path) {|f| fn = File.join(downloads_path, f); File.delete(fn) if f != '.' && f != '..'}
|
65
|
+
end
|
66
|
+
|
67
|
+
data = JSON.parse(request.body.read)
|
68
|
+
begin
|
69
|
+
raise "Empty params!" if data.empty?
|
70
|
+
SourceId = nil
|
71
|
+
client_key = nil
|
72
|
+
private_key = nil
|
73
|
+
|
74
|
+
|
75
|
+
data.each do |key, value|
|
76
|
+
if key == 'SourceId'
|
77
|
+
SourceId = value
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
if File.exist?("#{File.dirname(__FILE__)}/../public/user_info.txt")
|
82
|
+
contents = File.read("#{File.dirname(__FILE__)}/../public/user_info.txt")
|
83
|
+
contents = contents.split(' ')
|
84
|
+
client_key = contents.first
|
85
|
+
private_key = contents.last
|
86
|
+
end
|
87
|
+
|
88
|
+
job = GroupDocs::Job.new({:id=>SourceId})
|
89
|
+
documents = job.documents!({:client_id => client_key, :private_key => private_key})
|
90
|
+
documents[:inputs].first.file.download!(downloads_path, {:client_id => client_key, :private_key => private_key})
|
91
|
+
|
92
|
+
rescue Exception => e
|
93
|
+
err = e.message
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
|
98
|
+
#
|
99
|
+
get '/sample18/check' do
|
100
|
+
|
101
|
+
unless File.directory?("#{File.dirname(__FILE__)}/../public/downloads")
|
102
|
+
return "Directory was not found."
|
103
|
+
end
|
104
|
+
|
105
|
+
name = nil
|
106
|
+
Dir.entries("#{File.dirname(__FILE__)}/../public/downloads").each do |file|
|
107
|
+
name = file if file != '.' && file != '..'
|
108
|
+
end
|
109
|
+
|
110
|
+
if name
|
111
|
+
return name
|
112
|
+
else
|
113
|
+
return "File was not found."
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
|
6
118
|
# POST request
|
7
119
|
post '/sample18' do
|
8
120
|
# set variables
|
@@ -10,54 +122,45 @@ post '/sample18' do
|
|
10
122
|
set :private_key, params[:private_key]
|
11
123
|
set :file_id, params[:fileId]
|
12
124
|
set :convert_type, params[:convert_type]
|
125
|
+
set :callback, params[:callback]
|
13
126
|
|
14
127
|
begin
|
15
128
|
# check required variables
|
16
129
|
raise "Please enter all required parameters" if settings.client_id.empty? or settings.private_key.empty? or settings.file_id.empty?
|
130
|
+
|
131
|
+
if settings.callback[0]
|
132
|
+
outFile = File.new("#{File.dirname(__FILE__)}/../public/user_info.txt", "w")
|
133
|
+
outFile.write("#{settings.client_id} ")
|
134
|
+
outFile.write("#{settings.private_key}")
|
135
|
+
outFile.close
|
136
|
+
end
|
17
137
|
|
18
138
|
# make a request to API using client_id and private_key
|
19
139
|
files_list = GroupDocs::Storage::Folder.list!('/', {}, { :client_id => settings.client_id, :private_key => settings.private_key})
|
20
|
-
|
140
|
+
file = nil
|
21
141
|
|
22
142
|
# get document by file ID
|
23
143
|
files_list.each do |element|
|
24
144
|
if element.respond_to?('guid') == true and element.guid == settings.file_id
|
25
|
-
|
145
|
+
file = element
|
26
146
|
end
|
27
147
|
end
|
28
148
|
|
29
|
-
message = ""
|
30
|
-
|
31
|
-
unless document.instance_of? String
|
149
|
+
message = "No file with such GUID"
|
150
|
+
unless file.nil?
|
32
151
|
|
152
|
+
document = file.to_document
|
33
153
|
# convert file
|
34
|
-
convert = document.
|
35
|
-
sleep(
|
36
|
-
|
37
|
-
if convert.instance_of? GroupDocs::Job
|
38
|
-
# get all jobs
|
39
|
-
jobs = GroupDocs::Job::all!({}, {:client_id => settings.client_id, :private_key => settings.private_key})
|
40
|
-
|
41
|
-
# get job by job ID
|
42
|
-
job = ''
|
43
|
-
jobs.each do |element|
|
44
|
-
if element.id == convert.id
|
45
|
-
job = element
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
if job.status == :archived
|
50
|
-
# get job by ID
|
51
|
-
job = GroupDocs::Job.new(id: convert.id)
|
52
|
-
# get all job documents
|
53
|
-
documents = job.documents!({:client_id => settings.client_id, :private_key => settings.private_key})
|
54
|
-
# get compared file giud
|
55
|
-
guid = documents[:inputs].first.outputs.first.guid
|
56
|
-
# construct result iframe
|
57
|
-
iframe = "<iframe src='https://apps.groupdocs.com/document-viewer/embed/#{guid}' frameborder='0' width='100%' height='600'></iframe>"
|
58
|
-
message = "<p>Converted file saved successfully."
|
59
|
-
end
|
154
|
+
convert = document.convert!(settings.convert_type, {:callback=>settings.callback}, {:client_id => settings.client_id, :private_key => settings.private_key})
|
155
|
+
sleep(10)
|
60
156
|
|
157
|
+
original_document = convert.documents!({:client_id => settings.client_id, :private_key => settings.private_key})
|
158
|
+
# TODO: add Exception if not enough time for convertation
|
159
|
+
guid = original_document[:inputs].first.outputs.first.guid
|
160
|
+
|
161
|
+
if guid
|
162
|
+
iframe = "<iframe src='https://apps.groupdocs.com/document-viewer/embed/#{guid}' frameborder='0' width='100%' height='600'></iframe>"
|
163
|
+
message = "<p>Converted file saved successfully."
|
61
164
|
end
|
62
165
|
end
|
63
166
|
|
@@ -2,13 +2,21 @@
|
|
2
2
|
%a{:href => "/"} GroupDocs Ruby SDK Samples
|
3
3
|
\- Sample18
|
4
4
|
.samplecontent{:style => "padding:10px;"}
|
5
|
-
%
|
5
|
+
%span.description
|
6
|
+
%i
|
7
|
+
This sample will show how to use
|
8
|
+
%b ConvertFile
|
9
|
+
method to convert Doc to Docx, Docx to Doc, Docx and DOC to PDF and PPT to PDF, HTML to DOC and DOCX using GroupDocs Ruby SDK. When you use optional parameter "Callback URL" - additional logic will be involved: POST request from GroupDocs API server will be handled by convert_callback action. Also from result page an AJAX request will be sent to backend to check if callback was handled and result file was downloaded. If yes, then AJAX request will return a link to the file.
|
10
|
+
%br/
|
11
|
+
%br/
|
12
|
+
%span.documentation
|
13
|
+
%a{:href => "/docs/sample18.html"} Builtin documentation for this sample
|
6
14
|
%br/
|
7
15
|
%br/
|
8
16
|
%p
|
9
17
|
You entered:
|
10
18
|
%p
|
11
|
-
|
19
|
+
ClientID = #{(defined? userId) ? userId : ""}
|
12
20
|
%p
|
13
21
|
PrivateKey = #{(defined? privateKey) ? privateKey : ""}
|
14
22
|
%p
|
@@ -29,24 +37,66 @@
|
|
29
37
|
%br/
|
30
38
|
%label{:for => "file_id"} GroupDocs FileID
|
31
39
|
%br/
|
32
|
-
|
40
|
+
|
41
|
+
|
42
|
+
%input{:type=>"radio", :name=>"sourse", :value=>"guid", :id=>"id", :onClick=>"display('guid');", :checked=>"checked"} File ID (GUID)
|
43
|
+
%br/
|
44
|
+
%input{:type=>"radio", :name=>"sourse", :value=>"local", :id=>"localField", :onClick=>"display('local');"}Upload local file
|
45
|
+
%br/
|
46
|
+
%input{:type=>"radio", :name=>"sourse", :value=>"url", :id=>"urlField", :onClick=>"display('url');"} Upload file from URL
|
47
|
+
%br/
|
48
|
+
|
49
|
+
%label{:for=>'fileId', :id=>"guid"} File ID (GUID)
|
50
|
+
%br/
|
51
|
+
%input{:type=>'text', :name=>'fileId', :id=>"guidfield", :value=>""}
|
52
|
+
|
53
|
+
%label{:for=>'url', :style=>"display:none;", :id=>"url"} Upload file from URL
|
33
54
|
%br/
|
34
|
-
%input{:type => "
|
35
|
-
|
55
|
+
%input{:type=>'text', :name=>'url', :value=>"", :id=>"urlfield", :style=>"display:none;"}
|
56
|
+
|
57
|
+
%label{:for=>'file', :id=>"file", :style=>"display:none;"} Upload local file
|
58
|
+
%br/
|
59
|
+
%input{:type=>'file', :name=>'file', :id=>"filefield", :style=>"display:none;"}
|
60
|
+
|
61
|
+
%br/
|
62
|
+
%label{:for=>"convert_type"} Result file type
|
63
|
+
%select{:name=>"convert_type", :id=>"convert_type"}
|
36
64
|
%option{:value => "doc"}Doc
|
37
|
-
%option{:value => "pdf"}PDF
|
38
65
|
%option{:value => "docx"}Docx
|
66
|
+
%option{:value => "pdf"}PDF
|
39
67
|
%option{:value => "ppt"}PPT
|
68
|
+
%option{:value => "txt"}TXT
|
69
|
+
|
70
|
+
%br/
|
71
|
+
%br/
|
72
|
+
%label{:for=>"callback"}
|
73
|
+
Callback URL
|
74
|
+
%span.optional (Optional)
|
75
|
+
%br/
|
76
|
+
%font{:color=>"grey"} (For test Callback you can use this URL: http://groupdocs-ruby-samples.herokuapp.com/sample18/convert_callback)
|
77
|
+
%input{:type=>"text", :size=>"70", :value=>"", :name=>"callback"}
|
78
|
+
|
79
|
+
%br/
|
80
|
+
%br/
|
81
|
+
|
82
|
+
%input{:type => "submit", :value => "Make request"}
|
83
|
+
|
84
|
+
%br/
|
85
|
+
%a{:href=>"/templates/testdocument.html"} Download sample HTML file 1
|
86
|
+
%br/
|
87
|
+
%a{:href=>"/templates/base-simple_source.html"} Download sample HTML file 2
|
88
|
+
%br/
|
89
|
+
%a{:href=>"/templates/sampledoc3.html"} Download sample HTML file 3
|
90
|
+
%br/
|
40
91
|
%br/
|
41
92
|
%div{:style => "padding:20px; border:1px solid black;"}
|
42
93
|
%p
|
43
94
|
Results:
|
44
|
-
#{(defined? message) ? message : ""}
|
45
95
|
#{(defined? iframe) ? iframe : ""}
|
96
|
+
%div#result
|
97
|
+
#{(defined? message) ? message : ""}
|
46
98
|
|
47
99
|
|
48
|
-
= render_file('/samples_list.haml')
|
49
|
-
|
50
100
|
%div{:style => "padding:10px;"}
|
51
101
|
Choose another one sample:
|
52
102
|
%ul
|
@@ -96,3 +146,71 @@
|
|
96
146
|
%a{:href => "/sample22"}Sample22 - How create or update user and add him to collaborators using PHP SDK
|
97
147
|
%li
|
98
148
|
%a{:href => "/envelope-sample"}Envelope sample - How to use envelope and signature API
|
149
|
+
|
150
|
+
%script{:src=>"//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"}
|
151
|
+
:javascript
|
152
|
+
$(document).ready(setTimeout(check, 5000));
|
153
|
+
|
154
|
+
function check() {
|
155
|
+
|
156
|
+
if (($("input[name=callbackUrl]").val() != "")) {
|
157
|
+
$.ajax({
|
158
|
+
type: 'GET',
|
159
|
+
url: '/sample18/check',
|
160
|
+
success: function (data) {
|
161
|
+
$('#result').html( data );
|
162
|
+
},
|
163
|
+
dataType: "text"
|
164
|
+
});
|
165
|
+
}
|
166
|
+
}
|
167
|
+
|
168
|
+
function display(_element_id) {
|
169
|
+
|
170
|
+
if (_element_id == "guid") {
|
171
|
+
var element1 = document.getElementById("file");
|
172
|
+
var element2 = document.getElementById("filefield");
|
173
|
+
var element3 = document.getElementById("url");
|
174
|
+
var element4 = document.getElementById("urlfield");
|
175
|
+
var element5 = document.getElementById("guid");
|
176
|
+
var element6 = document.getElementById("guidfield");
|
177
|
+
element1.style.display = "none";
|
178
|
+
element2.style.display = "none";
|
179
|
+
element3.style.display = "none";
|
180
|
+
element4.style.display = "none";
|
181
|
+
element5.style.display = "inline";
|
182
|
+
element6.style.display = "inline";
|
183
|
+
|
184
|
+
}
|
185
|
+
|
186
|
+
if (_element_id == "local") {
|
187
|
+
var element1 = document.getElementById("file");
|
188
|
+
var element2 = document.getElementById("filefield");
|
189
|
+
var element3 = document.getElementById("url");
|
190
|
+
var element4 = document.getElementById("urlfield");
|
191
|
+
var element5 = document.getElementById("guid");
|
192
|
+
var element6 = document.getElementById("guidfield");
|
193
|
+
element1.style.display = "inline";
|
194
|
+
element2.style.display = "inline";
|
195
|
+
element3.style.display = "none";
|
196
|
+
element4.style.display = "none";
|
197
|
+
element5.style.display = "none";
|
198
|
+
element6.style.display = "none";
|
199
|
+
}
|
200
|
+
|
201
|
+
if (_element_id == "url") {
|
202
|
+
var element1 = document.getElementById("url");
|
203
|
+
var element2 = document.getElementById("urlfield");
|
204
|
+
var element3 = document.getElementById("file");
|
205
|
+
var element4 = document.getElementById("filefield");
|
206
|
+
var element5 = document.getElementById("guid");
|
207
|
+
var element6 = document.getElementById("guidfield");
|
208
|
+
element1.style.display = "inline";
|
209
|
+
element2.style.display = "inline";
|
210
|
+
element3.style.display = "none";
|
211
|
+
element4.style.display = "none";
|
212
|
+
element5.style.display = "none";
|
213
|
+
element6.style.display = "none";
|
214
|
+
}
|
215
|
+
|
216
|
+
}
|