lcms-engine 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/CHANGELOG.md +17 -1
  4. data/Dockerfile +28 -0
  5. data/Gemfile +2 -1
  6. data/README.md +23 -17
  7. data/app/assets/config/lcms_engine_manifest.js +1 -8
  8. data/app/assets/javascripts/lcms/engine/admin/application.js +6 -3
  9. data/app/assets/javascripts/lcms/engine/application.js +0 -2
  10. data/app/assets/javascripts/lcms/engine/application_lti.js +0 -2
  11. data/app/assets/stylesheets/lcms/engine/components/_instruction-cards.scss +0 -3
  12. data/app/controllers/lcms/engine/admin/admin_controller.rb +4 -4
  13. data/app/helpers/lcms/engine/view_helper.rb +0 -4
  14. data/app/javascript/components/admin/association-picker/AssociationPickerItem.jsx +2 -0
  15. data/app/javascript/components/admin/association-picker/AssociationPickerResults.jsx +2 -0
  16. data/app/javascript/components/admin/association-picker/AssociationPickerWindow.jsx +1 -1
  17. data/app/javascript/components/admin/picker/pickerWindowWrapper.jsx +1 -1
  18. data/app/javascript/components/admin/resource-picker/ResourcePicker.jsx +2 -2
  19. data/app/javascript/components/paginate/PaginationBoxView.jsx +1 -1
  20. data/app/javascript/components/paginate/PaginationListView.jsx +1 -1
  21. data/app/jobs/concerns/lcms/engine/nested_resque_job.rb +1 -1
  22. data/app/jobs/lcms/engine/material_generate_job.rb +1 -1
  23. data/app/models/concerns/lcms/engine/partable.rb +27 -0
  24. data/app/models/lcms/engine/document.rb +3 -7
  25. data/app/models/lcms/engine/document_part.rb +1 -1
  26. data/app/models/lcms/engine/material.rb +2 -6
  27. data/app/presenters/lcms/engine/content_presenter.rb +9 -5
  28. data/app/presenters/lcms/engine/document_presenter.rb +7 -11
  29. data/app/presenters/lcms/engine/material_presenter.rb +1 -11
  30. data/app/services/lcms/engine/document_build_service.rb +1 -17
  31. data/app/services/lcms/engine/material_build_service.rb +3 -12
  32. data/app/views/layouts/lcms/engine/application.html.erb +0 -4
  33. data/app/views/layouts/lcms/engine/lti.html.erb +0 -4
  34. data/db/migrate/20200217160930_change_document_parts_to_polymorphic.rb +36 -0
  35. data/db/migrate/20200218144849_drop_material_parts_table.rb +7 -0
  36. data/db/schema.rb +9 -22
  37. data/docker-compose.yml +29 -0
  38. data/lcms-engine.gemspec +25 -26
  39. data/lib/doc_template/tags/base_tag.rb +1 -1
  40. data/lib/document_exporter/base.rb +1 -4
  41. data/lib/lcms/engine/engine.rb +5 -4
  42. data/lib/lcms/engine/version.rb +1 -1
  43. data/lib/lt/lcms/metadata/context.rb +1 -1
  44. data/spec/controllers/admin/admin_controller_spec.rb +31 -0
  45. data/spec/dummy/.env.docker +5 -0
  46. data/spec/dummy/config/database.yml +1 -1
  47. data/spec/dummy/config/lcms-admin.yml +3 -3
  48. data/spec/dummy/config/routes.rb +2 -0
  49. data/spec/dummy/db/schema.rb +10 -23
  50. data/spec/factories/document_parts.rb +1 -1
  51. data/spec/lib/doc_template/tags/base_tag_spec.rb +36 -0
  52. data/yarn.lock +3 -3
  53. metadata +131 -121
  54. data/app/assets/javascripts/lcms/engine/generated/translations.js +0 -40
  55. data/app/assets/javascripts/lcms/engine/pdf_js_preview.js +0 -52
  56. data/vendor/assets/javascripts/pdf.js +0 -10902
  57. data/vendor/assets/javascripts/pdf.worker.js +0 -43104
  58. data/vendor/assets/javascripts/pdfobject.js +0 -254
@@ -1,254 +0,0 @@
1
- /*global ActiveXObject, window, console, define, module, jQuery */
2
- //jshint unused:false, strict: false
3
-
4
- /*
5
- PDFObject v2.0.201604172
6
- https://github.com/pipwerks/PDFObject
7
- Copyright (c) 2008-2016 Philip Hutchison
8
- MIT-style license: http://pipwerks.mit-license.org/
9
- UMD module pattern from https://github.com/umdjs/umd/blob/master/templates/returnExports.js
10
- */
11
-
12
- (function (root, factory) {
13
- if (typeof define === 'function' && define.amd) {
14
- // AMD. Register as an anonymous module.
15
- define([], factory);
16
- } else if (typeof module === 'object' && module.exports) {
17
- // Node. Does not work with strict CommonJS, but
18
- // only CommonJS-like environments that support module.exports,
19
- // like Node.
20
- module.exports = factory();
21
- } else {
22
- // Browser globals (root is window)
23
- root.PDFObject = factory();
24
- }
25
- }(this, function () {
26
-
27
- "use strict";
28
- //jshint unused:true
29
-
30
- //PDFObject is designed for client-side (browsers), not server-side (node)
31
- //Will choke on undefined navigator and window vars when run on server
32
- //Return boolean false and exit function when running server-side
33
-
34
- if(typeof window === "undefined" || typeof navigator === "undefined"){ return false; }
35
-
36
- var pdfobjectversion = "2.0.201604172",
37
- supportsPDFs,
38
-
39
- //declare functions
40
- createAXO,
41
- isIE,
42
- supportsPdfMimeType = (typeof navigator.mimeTypes['application/pdf'] !== "undefined"),
43
- supportsPdfActiveX,
44
- buildFragmentString,
45
- log,
46
- embedError,
47
- embed,
48
- getTargetElement,
49
- generatePDFJSiframe,
50
- isIOS = (function (){ return (/iphone|ipad|ipod/i.test(navigator.userAgent.toLowerCase())); })(),
51
- generateEmbedElement;
52
-
53
-
54
- /* ----------------------------------------------------
55
- Supporting functions
56
- ---------------------------------------------------- */
57
-
58
- createAXO = function (type){
59
- var ax;
60
- try {
61
- ax = new ActiveXObject(type);
62
- } catch (e) {
63
- ax = null; //ensure ax remains null
64
- }
65
- return ax;
66
- };
67
-
68
- //IE11 still uses ActiveX for Adobe Reader, but IE 11 doesn't expose
69
- //window.ActiveXObject the same way previous versions of IE did
70
- //window.ActiveXObject will evaluate to false in IE 11, but "ActiveXObject" in window evaluates to true
71
- //so check the first one for older IE, and the second for IE11
72
- //FWIW, MS Edge (replacing IE11) does not support ActiveX at all, both will evaluate false
73
- //Constructed as a method (not a prop) to avoid unneccesarry overhead -- will only be evaluated if needed
74
- isIE = function (){ return !!(window.ActiveXObject || "ActiveXObject" in window); };
75
-
76
- //If either ActiveX support for "AcroPDF.PDF" or "PDF.PdfCtrl" are found, return true
77
- //Constructed as a method (not a prop) to avoid unneccesarry overhead -- will only be evaluated if needed
78
- supportsPdfActiveX = function (){ return !!(createAXO("AcroPDF.PDF") || createAXO("PDF.PdfCtrl")); };
79
-
80
- //Determines whether PDF support is available
81
- supportsPDFs = (supportsPdfMimeType || (isIE() && supportsPdfActiveX()));
82
-
83
- //Create a fragment identifier for using PDF Open parameters when embedding PDF
84
- buildFragmentString = function(pdfParams){
85
-
86
- var string = "",
87
- prop;
88
-
89
- if(pdfParams){
90
-
91
- for (prop in pdfParams) {
92
- if (pdfParams.hasOwnProperty(prop)) {
93
- string += encodeURIComponent(prop) + "=" + encodeURIComponent(pdfParams[prop]) + "&";
94
- }
95
- }
96
-
97
- //The string will be empty if no PDF Params found
98
- if(string){
99
-
100
- string = "#" + string;
101
-
102
- //Remove last ampersand
103
- string = string.slice(0, string.length - 1);
104
-
105
- }
106
-
107
- }
108
-
109
- return string;
110
-
111
- };
112
-
113
- log = function (msg){
114
- if(typeof console !== "undefined" && console.log){
115
- console.log("[PDFObject] " + msg);
116
- }
117
- };
118
-
119
- embedError = function (msg){
120
- log(msg);
121
- return false;
122
- };
123
-
124
- getTargetElement = function (targetSelector){
125
-
126
- //Default to body for full-browser PDF
127
- var targetNode = document.body;
128
-
129
- //If a targetSelector is specified, check to see whether
130
- //it's passing a selector, jQuery object, or an HTML element
131
-
132
- if(typeof targetSelector === "string"){
133
-
134
- //Is CSS selector
135
- targetNode = document.querySelector(targetSelector);
136
-
137
- } else if (typeof jQuery !== "undefined" && targetSelector instanceof jQuery && targetSelector.length) {
138
-
139
- //Is jQuery element. Extract HTML node
140
- targetNode = targetSelector.get(0);
141
-
142
- } else if (typeof targetSelector.nodeType !== "undefined" && targetSelector.nodeType === 1){
143
-
144
- //Is HTML element
145
- targetNode = targetSelector;
146
-
147
- }
148
-
149
- return targetNode;
150
-
151
- };
152
-
153
- generatePDFJSiframe = function (targetNode, url, pdfOpenFragment, PDFJS_URL, id){
154
-
155
- var fullURL = PDFJS_URL + "?file=" + encodeURIComponent(url) + pdfOpenFragment;
156
- var scrollfix = (isIOS) ? "-webkit-overflow-scrolling: touch; overflow-y: scroll; " : "overflow: hidden; ";
157
- var iframe = "<div style='" + scrollfix + "position: absolute; top: 0; right: 0; bottom: 0; left: 0;'><iframe " + id + " src='" + fullURL + "' style='border: none; width: 100%; height: 100%;' frameborder='0'></iframe></div>";
158
- targetNode.className += " pdfobject-container";
159
- targetNode.style.position = "relative";
160
- targetNode.style.overflow = "auto";
161
- targetNode.innerHTML = iframe;
162
- return targetNode.getElementsByTagName("iframe")[0];
163
-
164
- };
165
-
166
- generateEmbedElement = function (targetNode, targetSelector, url, pdfOpenFragment, width, height, id){
167
-
168
- var style = "";
169
-
170
- if(targetSelector && targetSelector !== document.body){
171
- style = "width: " + width + "; height: " + height + ";";
172
- } else {
173
- style = "position: absolute; top: 0; right: 0; bottom: 0; left: 0; width: 100%; height: 100%;";
174
- }
175
-
176
- targetNode.className += " pdfobject-container";
177
- targetNode.innerHTML = "<embed " + id + " class='pdfobject' src='" + url + pdfOpenFragment + "' type='application/pdf' style='overflow: auto; " + style + "'/>";
178
-
179
- return targetNode.getElementsByTagName("embed")[0];
180
-
181
- };
182
-
183
- embed = function(url, targetSelector, options){
184
-
185
- //Ensure URL is available. If not, exit now.
186
- if(typeof url !== "string"){ return embedError("URL is not valid"); }
187
-
188
- //If targetSelector is not defined, convert to boolean
189
- targetSelector = (typeof targetSelector !== "undefined") ? targetSelector : false;
190
-
191
- //Ensure options object is not undefined -- enables easier error checking below
192
- options = (typeof options !== "undefined") ? options : {};
193
-
194
- //Get passed options, or set reasonable defaults
195
- var id = (options.id && typeof options.id === "string") ? "id='" + options.id + "'" : "",
196
- page = (options.page) ? options.page : false,
197
- pdfOpenParams = (options.pdfOpenParams) ? options.pdfOpenParams : {},
198
- fallbackLink = (typeof options.fallbackLink !== "undefined") ? options.fallbackLink : true,
199
- width = (options.width) ? options.width : "100%",
200
- height = (options.height) ? options.height : "100%",
201
- forcePDFJS = (typeof options.forcePDFJS === "boolean") ? options.forcePDFJS : false,
202
- PDFJS_URL = (options.PDFJS_URL) ? options.PDFJS_URL : false,
203
- targetNode = getTargetElement(targetSelector),
204
- fallbackHTML = "",
205
- pdfOpenFragment = "",
206
- fallbackHTML_default = "<p>This browser does not support inline PDFs. Please download the PDF to view it: <a href='[url]'>Download PDF</a></p>";
207
-
208
- //If target element is specified but is not valid, exit without doing anything
209
- if(!targetNode){ return embedError("Target element cannot be determined"); }
210
-
211
-
212
- //page option overrides pdfOpenParams, if found
213
- if(page){
214
- pdfOpenParams.page = page;
215
- }
216
-
217
- //Stringify optional Adobe params for opening document (as fragment identifier)
218
- pdfOpenFragment = buildFragmentString(pdfOpenParams);
219
-
220
- //Do the dance
221
- if(forcePDFJS && PDFJS_URL){
222
-
223
- return generatePDFJSiframe(targetNode, url, pdfOpenFragment, PDFJS_URL, id);
224
-
225
- } else if(supportsPDFs){
226
-
227
- return generateEmbedElement(targetNode, targetSelector, url, pdfOpenFragment, width, height, id);
228
-
229
- } else {
230
-
231
- if(PDFJS_URL){
232
-
233
- return generatePDFJSiframe(targetNode, url, pdfOpenFragment, PDFJS_URL, id);
234
-
235
- } else if(fallbackLink){
236
-
237
- fallbackHTML = (typeof fallbackLink === "string") ? fallbackLink : fallbackHTML_default;
238
- targetNode.innerHTML = fallbackHTML.replace(/\[url\]/g, url);
239
-
240
- }
241
-
242
- return embedError("This browser does not support embedded PDFs");
243
-
244
- }
245
-
246
- };
247
-
248
- return {
249
- embed: function (a,b,c){ return embed(a,b,c); },
250
- pdfobjectversion: (function () { return pdfobjectversion; })(),
251
- supportsPDFs: (function (){ return supportsPDFs; })()
252
- };
253
-
254
- }));