groupdocs 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. data/CHANGELOG.md +41 -0
  2. data/examples/README.md +2 -3
  3. data/examples/api-samples/Gemfile +5 -0
  4. data/examples/api-samples/Gemfile.lock +27 -0
  5. data/examples/api-samples/README.md +12 -0
  6. data/examples/api-samples/app.rb +17 -0
  7. data/examples/api-samples/public/css/style.css +166 -0
  8. data/examples/api-samples/samples/sample1.rb +17 -0
  9. data/examples/api-samples/samples/sample10.rb +36 -0
  10. data/examples/api-samples/samples/sample2.rb +19 -0
  11. data/examples/api-samples/samples/sample3.rb +23 -0
  12. data/examples/api-samples/samples/sample4.rb +31 -0
  13. data/examples/api-samples/samples/sample5.rb +44 -0
  14. data/examples/api-samples/samples/sample6.rb +3 -0
  15. data/examples/api-samples/samples/sample7.rb +33 -0
  16. data/examples/api-samples/samples/sample8.rb +40 -0
  17. data/examples/api-samples/samples/sample9.rb +22 -0
  18. data/examples/api-samples/views/index.haml +23 -0
  19. data/examples/api-samples/views/layout.haml +7 -0
  20. data/examples/api-samples/views/sample1.haml +71 -0
  21. data/examples/api-samples/views/sample10.haml +69 -0
  22. data/examples/api-samples/views/sample2.haml +59 -0
  23. data/examples/api-samples/views/sample3.haml +62 -0
  24. data/examples/api-samples/views/sample4.haml +58 -0
  25. data/examples/api-samples/views/sample5.haml +62 -0
  26. data/examples/api-samples/views/sample6.haml +145 -0
  27. data/examples/api-samples/views/sample7.haml +59 -0
  28. data/examples/api-samples/views/sample8.haml +75 -0
  29. data/examples/api-samples/views/sample9.haml +61 -0
  30. data/examples/{annotations → viewer}/Gemfile +0 -0
  31. data/examples/viewer/app.rb +52 -0
  32. data/groupdocs.gemspec +5 -4
  33. data/lib/groupdocs/api.rb +1 -0
  34. data/lib/groupdocs/api/entity.rb +2 -0
  35. data/lib/groupdocs/api/helpers.rb +2 -0
  36. data/lib/groupdocs/api/helpers/accessor_helper.rb +30 -0
  37. data/lib/groupdocs/api/helpers/mime_helper.rb +21 -0
  38. data/lib/groupdocs/api/helpers/rest_helper.rb +3 -2
  39. data/lib/groupdocs/api/request.rb +1 -3
  40. data/lib/groupdocs/datasource.rb +1 -2
  41. data/lib/groupdocs/document.rb +133 -3
  42. data/lib/groupdocs/document/annotation.rb +14 -13
  43. data/lib/groupdocs/document/annotation/reply.rb +4 -8
  44. data/lib/groupdocs/document/annotation/reviewer.rb +2 -4
  45. data/lib/groupdocs/document/field.rb +10 -8
  46. data/lib/groupdocs/document/rectangle.rb +10 -18
  47. data/lib/groupdocs/job.rb +1 -1
  48. data/lib/groupdocs/questionnaire.rb +138 -44
  49. data/lib/groupdocs/questionnaire/collector.rb +262 -0
  50. data/lib/groupdocs/questionnaire/execution.rb +93 -10
  51. data/lib/groupdocs/questionnaire/question.rb +1 -2
  52. data/lib/groupdocs/signature.rb +16 -24
  53. data/lib/groupdocs/signature/contact.rb +2 -4
  54. data/lib/groupdocs/signature/envelope.rb +3 -6
  55. data/lib/groupdocs/signature/envelope/log.rb +2 -4
  56. data/lib/groupdocs/signature/field.rb +21 -42
  57. data/lib/groupdocs/signature/field/location.rb +18 -36
  58. data/lib/groupdocs/signature/form.rb +9 -18
  59. data/lib/groupdocs/signature/list.rb +1 -2
  60. data/lib/groupdocs/signature/recipient.rb +3 -6
  61. data/lib/groupdocs/signature/role.rb +4 -8
  62. data/lib/groupdocs/signature/shared/entity_fields.rb +12 -20
  63. data/lib/groupdocs/signature/template.rb +1 -2
  64. data/lib/groupdocs/storage/file.rb +3 -1
  65. data/lib/groupdocs/storage/folder.rb +7 -1
  66. data/lib/groupdocs/subscription.rb +6 -12
  67. data/lib/groupdocs/subscription/limit.rb +4 -8
  68. data/lib/groupdocs/user.rb +3 -6
  69. data/lib/groupdocs/version.rb +1 -1
  70. data/spec/groupdocs/api/helpers/accessor_helper_spec.rb +16 -0
  71. data/spec/groupdocs/api/helpers/mime_helper_spec.rb +16 -0
  72. data/spec/groupdocs/api/helpers/rest_helper_spec.rb +4 -0
  73. data/spec/groupdocs/api/request_spec.rb +3 -5
  74. data/spec/groupdocs/datasource/field_spec.rb +3 -6
  75. data/spec/groupdocs/datasource_spec.rb +8 -15
  76. data/spec/groupdocs/document/annotation/reply_spec.rb +13 -24
  77. data/spec/groupdocs/document/annotation/reviewer_spec.rb +5 -9
  78. data/spec/groupdocs/document/annotation_spec.rb +35 -40
  79. data/spec/groupdocs/document/change_spec.rb +6 -11
  80. data/spec/groupdocs/document/field_spec.rb +13 -13
  81. data/spec/groupdocs/document/metadata_spec.rb +5 -10
  82. data/spec/groupdocs/document/rectangle_spec.rb +6 -18
  83. data/spec/groupdocs/document/view_spec.rb +3 -6
  84. data/spec/groupdocs/document_spec.rb +123 -10
  85. data/spec/groupdocs/job_spec.rb +9 -18
  86. data/spec/groupdocs/questionnaire/collector_spec.rb +201 -0
  87. data/spec/groupdocs/questionnaire/execution_spec.rb +91 -23
  88. data/spec/groupdocs/questionnaire/page_spec.rb +3 -6
  89. data/spec/groupdocs/questionnaire/question/answer_spec.rb +2 -4
  90. data/spec/groupdocs/questionnaire/question_spec.rb +7 -14
  91. data/spec/groupdocs/questionnaire_spec.rb +117 -41
  92. data/spec/groupdocs/signature/contact_spec.rb +9 -17
  93. data/spec/groupdocs/signature/envelope/log_spec.rb +8 -16
  94. data/spec/groupdocs/signature/envelope_spec.rb +9 -17
  95. data/spec/groupdocs/signature/field/location_spec.rb +32 -65
  96. data/spec/groupdocs/signature/field_spec.rb +48 -95
  97. data/spec/groupdocs/signature/form_spec.rb +22 -43
  98. data/spec/groupdocs/signature/list_spec.rb +6 -11
  99. data/spec/groupdocs/signature/recipient_spec.rb +11 -22
  100. data/spec/groupdocs/signature/role_spec.rb +11 -21
  101. data/spec/groupdocs/signature/template_spec.rb +2 -4
  102. data/spec/groupdocs/signature_spec.rb +28 -54
  103. data/spec/groupdocs/storage/file_spec.rb +14 -26
  104. data/spec/groupdocs/storage/folder_spec.rb +16 -22
  105. data/spec/groupdocs/storage/package_spec.rb +2 -4
  106. data/spec/groupdocs/subscription/limit_spec.rb +8 -16
  107. data/spec/groupdocs/subscription_spec.rb +11 -22
  108. data/spec/groupdocs/user_spec.rb +21 -41
  109. data/spec/groupdocs_spec.rb +4 -8
  110. data/spec/spec_helper.rb +12 -0
  111. data/spec/support/files/signature.png +0 -0
  112. data/spec/support/json/annotation_list.json +6 -6
  113. data/spec/support/json/comparison_changes.json +8 -8
  114. data/spec/support/json/document_fields.json +8 -8
  115. data/spec/support/json/document_page_images_get.json +20 -0
  116. data/spec/support/json/questionnaire_collector.json +17 -0
  117. data/spec/support/json/questionnaire_collectors.json +38 -0
  118. data/spec/support/json/questionnaire_collectors_add.json +10 -0
  119. data/spec/support/json/questionnaire_create.json +3 -1
  120. data/spec/support/json/{questionnaire_execution_create.json → questionnaire_execution_add.json} +1 -1
  121. data/spec/support/json/questionnaire_get.json +3 -0
  122. data/spec/support/json/questionnaires_get.json +36 -18
  123. data/spec/support/json/sign_documents.json +16 -0
  124. data/spec/support/json/templates_get.json +21 -0
  125. data/spec/support/shared_examples/api/entity.rb +2 -0
  126. data/spec/support/shared_examples/api/helpers/access_mode_helper.rb +1 -2
  127. data/spec/support/shared_examples/api/helpers/status_helper.rb +1 -2
  128. data/spec/support/shared_examples/signature/shared/entity_fields.rb +22 -43
  129. metadata +82 -16
  130. data/examples/annotations/app.rb +0 -67
@@ -0,0 +1,62 @@
1
+ %h3{:style => "text-align:center;"}
2
+ %a{:href => "/"} GroupDocs Ruby SDK Samples
3
+ \- Sample5
4
+ .samplecontent{:style => "padding:10px;"}
5
+ %i This sample will show how to Copy/Move particular file in your GroupDocs account using Ruby SDK
6
+ %br/
7
+ %br/
8
+ %p
9
+ You entered:
10
+ %p
11
+ UserId = #{(defined? userId) ? userId : ""}
12
+ %p
13
+ PrivateKey = #{(defined? privateKey) ? privateKey : ""}
14
+ %p
15
+ %font{:color => "red"} #{(defined? err) ? err : ""}
16
+ #requestForm{:style => "padding:20px; border:1px solid black;"}
17
+ %p Enter data for request and press "Copy" button
18
+ %form{:action => "/sample5", :enctype => "multipart/form-data", :method => "post"}
19
+ %label{:for => "client_id"} GroupDocs ClientID
20
+ %br/
21
+ %input{:type=>"text", :name=>"client_id"}
22
+ %br/
23
+ %label{:for => "private_key"} GroupDocs PrivateKey
24
+ %br/
25
+ %input{:type=>"text", :name=>"private_key"}
26
+ %br/
27
+ %label{:for => "private_key"} FileID
28
+ %br/
29
+ %input{:type=>"text", :name=>"file_id"}
30
+ %br/
31
+ %label{:for => "private_key"} Destination folder name in which you want to copy/move file
32
+ %br/
33
+ %input{:type=>"text", :name=>"dest_path"}
34
+ %br/
35
+ %input{:name => "copy", :type => "submit", :value => "Copy"}/
36
+ %input{:name => "move", :type => "submit", :value => "Move"}/
37
+ %h4
38
+ %font{:color => "green"} #{(defined? massage) ? massage : ""}
39
+ %br/
40
+ %div{:style => "padding:10px;"}
41
+ Choose another one sample:
42
+ %ul
43
+ %li
44
+ %a{:href => "/sample1"} Sample1 - How to login to GroupDocs using the API
45
+ %li
46
+ %a{:href => "/sample2"} Sample2 - How to list files within GroupDocs Storage using the Storage API
47
+ %li
48
+ %a{:href => "/sample3"} Sample3 - How to upload a file to GroupDocs using the Storage API
49
+ %li
50
+ %a{:href => "/sample4"} Sample4 - How to download a file from GroupDocs Storage using the Storage API
51
+ %li
52
+ %a{:href => "/sample5"} Sample5 - How to copy / move a file using the GroupDocs Storage API
53
+ %li
54
+ %a{:href => "/sample6"} Sample6 - How to add a Signature to a document in GroupDocs Signature
55
+ %li
56
+ %a{:href => "/sample7"} Sample7 - How to create a list of thumbnails for a document
57
+ %li
58
+ %a{:href => "/sample8"} Sample8 - How to return a URL representing a single page of a Document
59
+ %li
60
+ %a{:href => "/sample9"} Sample9 - How to generate an embedded Viewer URL for a Document
61
+ %li
62
+ %a{:href => "/sample10"} Sample10 - How to share a document to other users
@@ -0,0 +1,145 @@
1
+ %script{:src => "http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js", :type => "text/javascript"}
2
+ %script{:src => "https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js", :type => "text/javascript"}
3
+ %script{:src => "http://dev-apps.groupdocs.com/content/signaturewidgets/groupdocs.sign.js", :type => "text/javascript"}
4
+
5
+ %h3{:style => "text-align:center;"}
6
+ %a{:href => "/"} GroupDocs Ruby SDK Samples
7
+ \- Sample6
8
+ .samplecontent{:style => "padding:10px;"}
9
+ %i This sample will show how to add provided signature to provided document using Ruby SDK. Signed file will be uploaded to GroupDocs account and its GUID will be returned and embed into webpage with GroupDocs Ebedded Viewer.
10
+ %br/
11
+ #files_form
12
+ %form{:action => "#", :onsubmit => "return false;"}
13
+ %br/
14
+ %label{:for => "client_id"} GroupDocs ClientID
15
+ %br/
16
+ %input{:type=>'text', :id=>'client_id'}
17
+ %br/
18
+ %label{:for => "private_key"} GroupDocs PrivateKey
19
+ %br/
20
+ %input{:type=>'text', :id=>'private_key'}
21
+ %br/
22
+ %label{:for => "file_document"} Document to sign
23
+ %br/
24
+ %input#fi_document{:type => "file"}/
25
+ %br/
26
+ %label{:for => "file_signature"} Signature
27
+ %br/
28
+ %input#fi_signature{:type => "file"}/
29
+ %br/
30
+ %br/
31
+ %input#btnLoad{:onclick => "load();", :type => "button", :value => "Upload and sign the document"}
32
+ %br/
33
+ %br/
34
+ %div{:style => "padding:20px; border:1px solid black;"}
35
+ %p
36
+ Results:
37
+ %span#results_status{:style => "color:red;display:none;"} (Please wait for ajax response)
38
+ %iframe#viewer{:frameborder => "0", :height => "500", :src => "", :width => "600"}
39
+ %div{:style => "padding:10px;"}
40
+ Choose another one sample:
41
+ %ul
42
+ %li
43
+ %a{:href => "/sample1"} Sample1 - How to login to GroupDocs using the API
44
+ %li
45
+ %a{:href => "/sample2"} Sample2 - How to list files within GroupDocs Storage using the Storage API
46
+ %li
47
+ %a{:href => "/sample3"} Sample3 - How to upload a file to GroupDocs using the Storage API
48
+ %li
49
+ %a{:href => "/sample4"} Sample4 - How to download a file from GroupDocs Storage using the Storage API
50
+ %li
51
+ %a{:href => "/sample5"} Sample5 - How to copy / move a file using the GroupDocs Storage API
52
+ %li
53
+ %a{:href => "/sample6"} Sample6 - How to add a Signature to a document in GroupDocs Signature
54
+ %li
55
+ %a{:href => "/sample7"} Sample7 - How to create a list of thumbnails for a document
56
+ %li
57
+ %a{:href => "/sample8"} Sample8 - How to return a URL representing a single page of a Document
58
+ %li
59
+ %a{:href => "/sample9"} Sample9 - How to generate an embedded Viewer URL for a Document
60
+ %li
61
+ %a{:href => "/sample10"} Sample10 - How to share a document to other users
62
+ :javascript
63
+ function load() {
64
+ var inputDocument, inputSignature, fileDocument, fileSignature, frDocument, frSignature;
65
+
66
+ if (typeof window.FileReader !== 'function') {
67
+ $("body").append("p", "The file API isn't supported on this browser yet.");
68
+ return;
69
+ }
70
+
71
+ inputDocument = document.getElementById('fi_document');
72
+ if (!inputDocument) {
73
+ $("body").append("p", "Um, couldn't find the fileinput element.");
74
+ }
75
+ else if (!inputDocument.files) {
76
+ $("body").append("p", "This browser doesn't seem to support the `files` property of file inputs.");
77
+ }
78
+ else if (!inputDocument.files[0]) {
79
+ $("#files_form").append("Please select a file before clicking 'Load'");
80
+ }
81
+ else {
82
+ $('#results_status').fadeIn("slow");
83
+ $('#sample6').fadeOut("slow");
84
+
85
+ fileDocument = inputDocument.files[0];
86
+ frDocument = new FileReader();
87
+ frDocument.onload = receivedDocument;
88
+ frDocument.readAsDataURL(fileDocument);
89
+ }
90
+
91
+ function receivedDocument() {
92
+
93
+ inputSignature = document.getElementById('fi_signature');
94
+ if (!inputSignature) {
95
+ $("body").append("Um, couldn't find the fileinput element.");
96
+ }
97
+ else if (!inputSignature.files) {
98
+ $("body").append("p", "This browser doesn't seem to support the `files` property of file inputs.");
99
+ }
100
+ else if (!inputSignature.files[0]) {
101
+ $("body").append("Please select a file before clicking 'Load'");
102
+ }
103
+ else {
104
+ fileSignature = inputSignature.files[0];
105
+ frSignature = new FileReader();
106
+ frSignature.onload = receivedSignature;
107
+ frSignature.readAsDataURL(fileSignature);
108
+ }
109
+ }
110
+
111
+ function receivedSignature() {
112
+ var span = document.createElement('span');
113
+ span.innerHTML = [''].join('');
114
+ signDocument();
115
+ }
116
+
117
+ function signDocument() {
118
+ $("body").sign({
119
+ userId: $('#client_id').val(),
120
+ privateKey: $('#private_key').val(),
121
+ signMethod: "/sample6",
122
+ onerr: function (e, data) {
123
+ alert(data);
124
+ },
125
+ onSigned: function (e, data) {
126
+ $("#viewer").attr("src", "https://apps.groupdocs.com/document-viewer/Embed/" + data.documentId);
127
+ $('#results_status').fadeOut("slow");
128
+ $('#viewer').fadeIn("slow");
129
+ }
130
+ });
131
+ $("body").sign("addDocument", {
132
+ name: fileDocument.name,
133
+ data: frDocument.result
134
+ });
135
+ $("body").sign("addSigner", {
136
+ name: 'Marketplace Team',
137
+ top: 0.03319,
138
+ left: 0.52171,
139
+ width: 100,
140
+ height: 40,
141
+ data: frSignature.result
142
+ });
143
+ $("body").sign("sign");
144
+ }
145
+ }
@@ -0,0 +1,59 @@
1
+ %h3{:style => "text-align:center;"}
2
+ %a{:href => "/"} GroupDocs Ruby SDK Samples
3
+ \- Sample7
4
+ .samplecontent{:style => "padding:10px;"}
5
+ %i This sample will show how to list thumbnails for documents in the GroupDocs account using Ruby SDK
6
+ %br/
7
+ %br/
8
+ %p
9
+ You entered:
10
+ %p
11
+ UserId = #{(defined? userId) ? userId : ""}
12
+ %p
13
+ PrivateKey = #{(defined? privateKey) ? privateKey : ""}
14
+ %p
15
+ %font{:color => "red"} #{(defined? err) ? err : ""}
16
+ #requestForm{:style => "padding:20px; border:1px solid black;"}
17
+ %p Enter data for request and press "Make request" button
18
+ %form{:action => "/sample7", :enctype => "multipart/form-data", :method => "post"}
19
+ %label{:for => "client_id"} GroupDocs ClientID
20
+ %br/
21
+ %input{:type=>"text", :name=>"client_id"}
22
+ %br/
23
+ %label{:for => "private_key"} GroupDocs PrivateKey
24
+ %br/
25
+ %input{:type=>"text", :name=>"private_key"}
26
+ %br/
27
+ %input{:type => "submit", :value => "Make Request"}/
28
+ %div{:style => "padding:20px; border:1px solid black;"}
29
+ %p Results:
30
+ %table{:style => "border:1px double black;"}
31
+ %tr
32
+ %th Field
33
+ %th Value
34
+ %tr
35
+ %td #{(defined? thumbnailList) ? thumbnailList : ""} #{(defined? file_List) ? file_List : ""}
36
+ %br/
37
+ %div{:style => "padding:10px;"}
38
+ Choose anothe one sample:
39
+ %ul
40
+ %li
41
+ %a{:href => "/sample1"} Sample1 - How to login to GroupDocs using the API
42
+ %li
43
+ %a{:href => "/sample2"} Sample2 - How to list files within GroupDocs Storage using the Storage API
44
+ %li
45
+ %a{:href => "/sample3"} Sample3 - How to upload a file to GroupDocs using the Storage API
46
+ %li
47
+ %a{:href => "/sample4"} Sample4 - How to download a file from GroupDocs Storage using the Storage API
48
+ %li
49
+ %a{:href => "/sample5"} Sample5 - How to copy / move a file using the GroupDocs Storage API
50
+ %li
51
+ %a{:href => "/sample6"} Sample6 - How to add a Signature to a document in GroupDocs Signature
52
+ %li
53
+ %a{:href => "/sample7"} Sample7 - How to create a list of thumbnails for a document
54
+ %li
55
+ %a{:href => "/sample8"} Sample8 - How to return a URL representing a single page of a Document
56
+ %li
57
+ %a{:href => "/sample9"} Sample9 - How to generate an embedded Viewer URL for a Document
58
+ %li
59
+ %a{:href => "/sample10"} Sample10 - How to share a document to other users
@@ -0,0 +1,75 @@
1
+ %h3{:style => "text-align:center;"}
2
+ %a{:href => "/"} GroupDocs Ruby SDK Samples
3
+ \- Sample8
4
+ .samplecontent{:style => "padding:10px;"}
5
+ %i This sample will show how to return a URL representing a single page of particular Document in the GroupDocs account using Ruby SDK
6
+ %br/
7
+ %br/
8
+ %p
9
+ You entered:
10
+ %p
11
+ UserId = #{(defined? userId) ? userId : ""}
12
+ %p
13
+ PrivateKey = #{(defined? privateKey) ? privateKey : ""}
14
+ %p
15
+ File Id = #{(defined? guid) ? guid : ""}
16
+ %p
17
+ Page number = #{(defined? page_number) ? page_number : ""}
18
+ %p
19
+ %font{:color => "red"} #{(defined? err) ? err : ""}
20
+ #requestForm{:style => "padding:20px; border:1px solid black;"}
21
+ %p Enter data for request and press "Make request" button
22
+ %form{:action => "/sample8", :enctype => "multipart/form-data", :method => "post"}
23
+ %label{:for => "client_id"} GroupDocs ClientID
24
+ %br/
25
+ %input{:type=>"text", :name=>"client_id"}
26
+ %br/
27
+ %label{:for => "private_key"} GroupDocs PrivateKey
28
+ %br/
29
+ %input{:type=>"text", :name=>"private_key"}
30
+ %br/
31
+ %label{:for => "private_key"} GroupDocs GUID
32
+ %br/
33
+ %input{:type=>"text", :name=>"guid"}
34
+ %br/
35
+ %label{:for => "private_key"} GroupDocs page number (starts from zero)
36
+ %br/
37
+ %input{:type=>"text", :name=>"page_number"}
38
+ %br/
39
+ %input{:type => "submit", :value => "Make Request"}/
40
+ %div{:style => "padding:20px; border:1px solid black;"}
41
+ %p Results:
42
+ %table{:style => "border:1px double black;"}
43
+ %tr
44
+ %th Field
45
+ %th Value
46
+ %tr
47
+ %td Page URL
48
+ %td #{(defined? image) ? image : ""}
49
+ %font{:color => "green"} The page you requested:
50
+ %br/
51
+ %img{:src => "#{(defined? image) ? image : ""}"}
52
+ %br/
53
+ %div{:style => "padding:10px;"}
54
+ Choose anothe one sample:
55
+ %ul
56
+ %li
57
+ %a{:href => "/sample1"} Sample1 - How to login to GroupDocs using the API
58
+ %li
59
+ %a{:href => "/sample2"} Sample2 - How to list files within GroupDocs Storage using the Storage API
60
+ %li
61
+ %a{:href => "/sample3"} Sample3 - How to upload a file to GroupDocs using the Storage API
62
+ %li
63
+ %a{:href => "/sample4"} Sample4 - How to download a file from GroupDocs Storage using the Storage API
64
+ %li
65
+ %a{:href => "/sample5"} Sample5 - How to copy / move a file using the GroupDocs Storage API
66
+ %li
67
+ %a{:href => "/sample6"} Sample6 - How to add a Signature to a document in GroupDocs Signature
68
+ %li
69
+ %a{:href => "/sample7"} Sample7 - How to create a list of thumbnails for a document
70
+ %li
71
+ %a{:href => "/sample8"} Sample8 - How to return a URL representing a single page of a Document
72
+ %li
73
+ %a{:href => "/sample9"} Sample9 - How to generate an embedded Viewer URL for a Document
74
+ %li
75
+ %a{:href => "/sample10"} Sample10 - How to share a document to other users
@@ -0,0 +1,61 @@
1
+ %h3{:style => "text-align:center;"}
2
+ %a{:href => "/"} GroupDocs Ruby SDK Samples
3
+ \- Sample9
4
+ .samplecontent{:style => "padding:10px;"}
5
+ %i This sample will show how to generate an embedded Viewer URL for particular Document in the GroupDocs account using Ruby SDK
6
+ %br/
7
+ %br/
8
+ %p
9
+ You entered:
10
+ %p
11
+ File GUID = #{(defined? guid) ? guid : ""}
12
+ %p
13
+ Height = #{(defined? height) ? height : ""}
14
+ %p
15
+ Width = #{(defined? width) ? width : ""}
16
+ %p
17
+ Viewer URL = #{(defined? v_url) ? v_url : ""}
18
+ %p
19
+ %font{:color => "red"} #{(defined? err) ? err : ""}
20
+ #requestForm{:style => "padding:20px; border:1px solid black;"}
21
+ %p Enter data for request and press "Make request" button
22
+ %form{:action => "/sample9", :enctype => "multipart/form-data", :method => "post"}
23
+ %label{:for => "private_key"} GroupDocs File GUID
24
+ %br/
25
+ %input{:type=>"text", :name=>"guid"}
26
+ %br/
27
+ %label{:for => "private_key"} Width
28
+ %br/
29
+ %input{:type=>"text", :name=>"width"}
30
+ %br/
31
+ %label{:for => "private_key"} Height
32
+ %br/
33
+ %input{:type=>"text", :name=>"height"}
34
+ %br/
35
+ %input{:type => "submit", :value => "Make Request"}/
36
+ %div{:style => "padding:20px; border:1px solid black;"}
37
+ %iframe{:src => "#{(defined? v_url) ? v_url : ""}", :width=> "#{(defined? width) ? width : ""}", :height=>"#{(defined? height) ? height : ""}"}
38
+ %br/
39
+ %div{:style => "padding:10px;"}
40
+ Choose anothe one sample:
41
+ %ul
42
+ %li
43
+ %a{:href => "/sample1"} Sample1 - How to login to GroupDocs using the API
44
+ %li
45
+ %a{:href => "/sample2"} Sample2 - How to list files within GroupDocs Storage using the Storage API
46
+ %li
47
+ %a{:href => "/sample3"} Sample3 - How to upload a file to GroupDocs using the Storage API
48
+ %li
49
+ %a{:href => "/sample4"} Sample4 - How to download a file from GroupDocs Storage using the Storage API
50
+ %li
51
+ %a{:href => "/sample5"} Sample5 - How to copy / move a file using the GroupDocs Storage API
52
+ %li
53
+ %a{:href => "/sample6"} Sample6 - How to add a Signature to a document in GroupDocs Signature
54
+ %li
55
+ %a{:href => "/sample7"} Sample7 - How to create a list of thumbnails for a document
56
+ %li
57
+ %a{:href => "/sample8"} Sample8 - How to return a URL representing a single page of a Document
58
+ %li
59
+ %a{:href => "/sample9"} Sample9 - How to generate a embedded Viewer URL for a DocumentI
60
+ %li
61
+ %a{:href => "/sample10"} Sample10 - How to share a document to other users
File without changes
@@ -0,0 +1,52 @@
1
+ require 'sinatra'
2
+ require 'groupdocs'
3
+ require 'haml'
4
+
5
+ GroupDocs.api_version = '2.0'
6
+
7
+ get '/' do
8
+ haml :upload
9
+ end
10
+
11
+ post '/upload' do
12
+ set :client_id, params[:client_id]
13
+ set :private_key, params[:private_key]
14
+ filepath = "#{Dir.tmpdir}/#{params[:file][:filename]}"
15
+ File.open(filepath, 'wb') { |f| f.write(params[:file][:tempfile].read) }
16
+ @@file = GroupDocs::Storage::File.upload!(filepath, {}, client_id: options.client_id, private_key: options.private_key)
17
+
18
+ haml :viewer
19
+ end
20
+
21
+
22
+ __END__
23
+
24
+ @@layout
25
+ %html
26
+ %head
27
+ %title GroupDocs Ruby SDK Viewer Sample App
28
+ %body
29
+ = yield
30
+
31
+ @@upload
32
+ %h4 Upload file
33
+ %form{ action: '/upload', method: 'post', enctype: 'multipart/form-data' }
34
+ %label{ for: 'client_id' } GroupDocs Client ID
35
+ %br
36
+ %input{ type: 'text', name: 'client_id' }
37
+ %br
38
+ %label{ for: 'private_key' } GroupDocs Private Key
39
+ %br
40
+ %input{ type: 'text', name: 'private_key' }
41
+ %br
42
+ %label{ for: 'file' } File
43
+ %br
44
+ %input{ type: 'file', name: 'file' }
45
+ %br
46
+ %br
47
+ %input{ type: 'submit', value: 'Upload' }
48
+
49
+ @@viewer
50
+ %iframe{ src: "https://apps.groupdocs.com/document-viewer/Embed/#{@@file.guid}", frameborder: 0, width: 720, height: 600 }
51
+ %br
52
+ %br