This repository was archived by the owner on Jun 5, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.js
More file actions
70 lines (54 loc) · 1.92 KB
/
Copy pathbootstrap.js
File metadata and controls
70 lines (54 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
var path = alchemy.use('path'),
Veronica = alchemy.use('veronica');
// Define the default options
var options = {
// The path to use in the url
url: '/media/image',
// Where to store the files
path: path.resolve(PATH_ROOT, 'files'),
// Which hash function to use
hash: 'sha1',
// The location of the exiv2 binary
exiv2: '/usr/bin/exiv2',
// The location of cwebp
cwebp: '/usr/bin/cwebp',
// Enable webp
webp: true,
// Temporary map for intermediate file changes
scratch: path.resolve(PATH_TEMP, 'scratch'),
// The cache map for resized images & thumbnails
cache: path.resolve(PATH_TEMP, 'imagecache')
};
// Inject the user-overridden options
alchemy.plugins.media = alchemy.inject(options, alchemy.plugins.media);
// Make sure these folders exist
alchemy.createDir(options.scratch);
alchemy.createDir(options.cache);
// Create routes
alchemy.connect('media::image', options.url + '/:id', {controller: 'media_file', action: 'image'});
alchemy.connect('media::file', '/media/file/:id', {controller: 'media_file', action: 'file'});
alchemy.connect('media::file', '/media/thumbnail/:id', {controller: 'media_file', action: 'thumbnail'});
alchemy.connect('media::placeholder', '/media/placeholder', {controller: 'media_file', action: 'placeholder'});
alchemy.connect('media::upload', '/media/upload', {controller: 'media_file', action: 'upload'});
var profiles = alchemy.shared('Media.profiles');
// Create a new veronica instance
options.veronica = new Veronica({
cwebp: options.cwebp,
temp: options.scratch,
cache: options.cache
});
/**
* Register a profile under the given name
*
* @author Jelle De Loecker <jelle@codedor.be>
* @since 0.0.1
* @version 0.0.1
*
* @param {String} name
* @param {Object} settings
*/
options.addProfile = function addProfile(name, settings) {
profiles[name] = settings;
};
// Add the thumbnail profile
options.addProfile('thumbnail', {width: 100, height: 100});