alchemy-media 0.5.1 → 0.6.1

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 (54) hide show
  1. package/CHANGELOG.md +7 -2
  2. package/assets/fonts/fontawesome5.15/fa-brands-400.eot +0 -0
  3. package/assets/fonts/fontawesome5.15/fa-brands-400.svg +3717 -0
  4. package/assets/fonts/fontawesome5.15/fa-brands-400.ttf +0 -0
  5. package/assets/fonts/fontawesome5.15/fa-brands-400.woff +0 -0
  6. package/assets/fonts/fontawesome5.15/fa-brands-400.woff2 +0 -0
  7. package/assets/fonts/fontawesome5.15/fa-regular-400.eot +0 -0
  8. package/assets/fonts/fontawesome5.15/fa-regular-400.svg +801 -0
  9. package/assets/fonts/fontawesome5.15/fa-regular-400.ttf +0 -0
  10. package/assets/fonts/fontawesome5.15/fa-regular-400.woff +0 -0
  11. package/assets/fonts/fontawesome5.15/fa-regular-400.woff2 +0 -0
  12. package/assets/fonts/fontawesome5.15/fa-solid-900.eot +0 -0
  13. package/assets/fonts/fontawesome5.15/fa-solid-900.svg +5028 -0
  14. package/assets/fonts/fontawesome5.15/fa-solid-900.ttf +0 -0
  15. package/assets/fonts/fontawesome5.15/fa-solid-900.woff +0 -0
  16. package/assets/fonts/fontawesome5.15/fa-solid-900.woff2 +0 -0
  17. package/assets/stylesheets/alchemy_icons.scss +60 -0
  18. package/assets/stylesheets/alchemy_svg.scss +9 -0
  19. package/assets/stylesheets/chimera/mediafield.less +0 -0
  20. package/assets/stylesheets/element/alchemy_file.scss +3 -0
  21. package/assets/stylesheets/fontawesome5.15/_animated.scss +20 -0
  22. package/assets/stylesheets/fontawesome5.15/_bordered-pulled.scss +20 -0
  23. package/assets/stylesheets/fontawesome5.15/_core.scss +21 -0
  24. package/assets/stylesheets/fontawesome5.15/_fixed-width.scss +6 -0
  25. package/assets/stylesheets/fontawesome5.15/_icons.scss +1462 -0
  26. package/assets/stylesheets/fontawesome5.15/_larger.scss +23 -0
  27. package/assets/stylesheets/fontawesome5.15/_list.scss +18 -0
  28. package/assets/stylesheets/fontawesome5.15/_mixins.scss +56 -0
  29. package/assets/stylesheets/fontawesome5.15/_rotated-flipped.scss +24 -0
  30. package/assets/stylesheets/fontawesome5.15/_screen-reader.scss +5 -0
  31. package/assets/stylesheets/fontawesome5.15/_shims.scss +2066 -0
  32. package/assets/stylesheets/fontawesome5.15/_stacked.scss +31 -0
  33. package/assets/stylesheets/fontawesome5.15/_variables.scss +1479 -0
  34. package/assets/stylesheets/fontawesome5.15/brands.scss +23 -0
  35. package/assets/stylesheets/fontawesome5.15/fontawesome.scss +16 -0
  36. package/assets/stylesheets/fontawesome5.15/regular.scss +23 -0
  37. package/assets/stylesheets/fontawesome5.15/solid.scss +24 -0
  38. package/assets/stylesheets/fontawesome5.15/v4-shims.scss +6 -0
  39. package/bootstrap.js +1 -0
  40. package/controller/media_files_controller.js +20 -0
  41. package/controller/media_gallery_chimera_controller.js +1 -0
  42. package/element/al_file.js +195 -0
  43. package/element/al_ico_element.js +17 -0
  44. package/element/al_svg.js +81 -0
  45. package/helper/media_helper.js +50 -10
  46. package/helper/widgets/image_widget.js +46 -0
  47. package/{lib/field_type → helper_field}/file_field_type.js +5 -3
  48. package/lib/media_types/image_media_type.js +34 -9
  49. package/model/media_file_model.js +9 -3
  50. package/model/media_raw_model.js +529 -529
  51. package/package.json +6 -6
  52. package/view/element/al_file.hwk +7 -0
  53. package/view/form/inputs/edit/file.hwk +8 -0
  54. package/assets/scripts/chimera/mediafield.js +0 -451
@@ -35,7 +35,7 @@ ImageMedia.setProperty('typeMap', {
35
35
  *
36
36
  * @author Jelle De Loecker <jelle@develry.be>
37
37
  * @since 0.0.1
38
- * @version 0.4.1
38
+ * @version 0.6.0
39
39
  *
40
40
  * @param {Conduit} conduit
41
41
  * @param {Object} record
@@ -49,6 +49,13 @@ ImageMedia.setMethod(function thumbnail(conduit, record) {
49
49
  return conduit.notFound('Image could not be found');
50
50
  }
51
51
 
52
+ if (record.MediaRaw && record.MediaRaw.mimetype == 'image/svg') {
53
+ return conduit.serveFile(record.path, {
54
+ mimetype : 'image/svg+xml',
55
+ disposition : false
56
+ });
57
+ }
58
+
52
59
  dimension = 100 * this.getDpr(conduit);
53
60
  options = {};
54
61
 
@@ -77,20 +84,31 @@ ImageMedia.setMethod(function thumbnail(conduit, record) {
77
84
  *
78
85
  * @author Jelle De Loecker <jelle@develry.be>
79
86
  * @since 0.0.1
80
- * @version 0.5.0
87
+ * @version 0.6.1
81
88
  *
82
89
  * @param {Conduit} conduit
83
90
  * @param {Object} record
84
91
  */
85
92
  ImageMedia.setMethod(function serve(conduit, record, options) {
86
93
 
87
- var that = this,
88
- query = conduit.url.query,
94
+ const that = this;
95
+
96
+ if (!record) {
97
+ return onError('Empty file record', 404);
98
+ }
99
+
100
+ if (record.MediaRaw && record.MediaRaw.mimetype == 'image/svg') {
101
+ return conduit.serveFile(record.path, {
102
+ mimetype : 'image/svg+xml',
103
+ disposition : false
104
+ });
105
+ }
106
+
107
+ let query = conduit.url.query,
89
108
  dpr = this.getDpr(conduit),
90
109
  path,
91
110
  width,
92
111
  height,
93
- onError,
94
112
  baseWidth,
95
113
  resolution,
96
114
  baseHeight,
@@ -100,7 +118,7 @@ ImageMedia.setMethod(function serve(conduit, record, options) {
100
118
  options = {};
101
119
  }
102
120
 
103
- onError = function onError(message, status) {
121
+ function onError(message, status) {
104
122
 
105
123
  if (!status) {
106
124
  status = 404;
@@ -209,8 +227,7 @@ ImageMedia.setMethod(function serve(conduit, record, options) {
209
227
 
210
228
  if (resizeOptions) {
211
229
 
212
- // @todo: make it possible to disable webp
213
- if (this.supportsWebp(conduit)) {
230
+ if (this.supportsWebp(conduit) && alchemy.plugins.media.cwebp) {
214
231
  resizeOptions.type = 'webp';
215
232
  }
216
233
 
@@ -373,6 +390,10 @@ ImageMedia.setMethod(function getSize(conduit, filePath, options, callback) {
373
390
 
374
391
  tempPath = PATH_TEMP + '/' + alchemy.ObjectId() + '.webp';
375
392
 
393
+ if (!alchemy.plugins.media.cwebp) {
394
+ return callback(new Error('Unable to get size: cwebp not found'));
395
+ }
396
+
376
397
  child.exec(alchemy.plugins.media.cwebp + ' ' + [resizeOptions, '-q 80', filePath, '-o', tempPath].join(' '), function(err, out) {
377
398
 
378
399
  if (err) {
@@ -392,12 +413,16 @@ ImageMedia.setMethod(function getSize(conduit, filePath, options, callback) {
392
413
  *
393
414
  * @author Jelle De Loecker <jelle@develry.be>
394
415
  * @since 0.0.1
395
- * @version 0.2.0
416
+ * @version 0.6.0
396
417
  */
397
418
  ImageMedia.setMethod(function normalize(filePath, baseInfo, callback) {
398
419
 
399
420
  var that = this;
400
421
 
422
+ if (baseInfo && baseInfo.mimetype == 'image/svg') {
423
+ return callback(null, filePath);
424
+ }
425
+
401
426
  this.getImageInfo(filePath, function gotFileInfo(err, info, extra) {
402
427
 
403
428
  if (err) {
@@ -24,13 +24,17 @@ MediaFile.setProperty('types', alchemy.shared('Media.types'));
24
24
  *
25
25
  * @author Jelle De Loecker <jelle@develry.be>
26
26
  * @since 0.2.0
27
- * @version 0.5.0
27
+ * @version 0.5.1
28
28
  */
29
29
  MediaFile.constitute(function addFields() {
30
30
 
31
31
  this.addField('name', 'String');
32
32
  this.addField('filename', 'String');
33
- this.addField('type', 'Enum');
33
+
34
+ this.addField('type', 'Enum', {
35
+ values: alchemy.getClassGroup('media_type')
36
+ });
37
+
34
38
  this.addField('extra', 'Object');
35
39
 
36
40
  let options = {};
@@ -50,7 +54,7 @@ MediaFile.constitute(function addFields() {
50
54
  *
51
55
  * @author Jelle De Loecker <jelle@develry.be>
52
56
  * @since 0.2.0
53
- * @version 0.2.0
57
+ * @version 0.5.1
54
58
  */
55
59
  MediaFile.constitute(function chimeraConfig() {
56
60
 
@@ -77,6 +81,8 @@ MediaFile.constitute(function chimeraConfig() {
77
81
  edit.addField('name');
78
82
  edit.addField('filename');
79
83
  edit.addField('type');
84
+ edit.addField('title');
85
+ edit.addField('alt');
80
86
 
81
87
  // Get the galery group
82
88
  gallery = this.chimera.getActionFields('gallery');