-
Notifications
You must be signed in to change notification settings - Fork 0
/
cannon.yml
89 lines (75 loc) · 4.37 KB
/
cannon.yml
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
settings:
# specify server address and port (select an unused port above 1023)
server: http://localhost
port: 8888
# specify command and args to start the preview browser
# use browser.default to specify the default command for all platforms
# use browser.<platform> to specify per-platform exceptions using the names in the $GOOS list: https://go.dev/doc/install/source#environment
# specify the {url} placeholder arg in the correct position so cannon can insert the server url
# specify the appropriate argument for the browser to enable auto-play for media previews
# on Windows, it may be required to specify the full path to the command
browser:
default: ['google-chrome', '--autoplay-policy=no-user-gesture-required', '{url}']
windows: ['C:\Program Files (x86)\Google\Chrome\Application\chrome.exe', '--autoplay-policy=no-user-gesture-required', '{url}']
# browser polling time in milliseconds
interval: 33
# specify command and args to detect a file's mime-type
# use mime.default to specify the default command for all platforms
# use mime.<platform> to specify per-platform exceptions using the names in the $GOOS list: https://go.dev/doc/install/source#environment
# specify the {file} placeholder arg in the correct position so cannon can insert the selected file
# on Windows, it may be required to specify the full path to the command
mime:
default: ['file', '-b', '--mime-type', '{file}']
windows: ['C:\Program Files\Git\usr\bin\file', '-b', '--mime-type', '{file}']
# cannon will set this exit value at the command line: $ cannon <file>
# lf requires a non-zero return value to prevent it from trying to cache the preview
exit: 255
file_conversion_rules:
#
# specify rules to convert each file type into its web-equivalent for display in the browser
# ext|mime: specify patterns to match either the file extension or mime type
# command: specify the file conversion command to run when a matching input file is found
# use command.default to specify the default command
# use command.<platform> to specify per-platform exceptions using the names in the $GOOS list: https://go.dev/doc/install/source#environment
# specify {input} and {output} placeholders in the right positions so cannon can insert the filenames
# the output param may specify an extension: {output}.jpg
# on Windows, it may be required to specify the full path to the command
# tag: specify the html tag to display the output file in the browser
# specify the {src} placeholder arg in the correct position so cannon can insert the converted file
#
- # native html5 image formats do not need conversion
ext: [apng, avif, gif, jpg, jpeg, jfif, pjpeg, pjp, png, svg, webp]
tag: <img src='{src}'>
- # native html5 video formats do not need conversion
ext: [mp4, ogg, ogv, webm]
tag: <video autoplay loop controls src='{src}'>
- # native html5 audio formats do not need conversion
ext: [mp3, wav]
tag: <audio autoplay loop controls src='{src}'>
- # native html5 text formats do not need conversion
ext: [html, htm]
tag: <iframe src='{src}'>
- # use image magick to convert non-native image formats
mime: [image]
command:
default: ['convert', '{input}', '{output}.jpg']
windows: ['magick', 'convert', '{input}', '{output}.jpg']
tag: <img src='{src}'>
- # use mupdf to sample the first page of common document formats
ext: [pdf, xps, cbz, epub, fb2]
command:
default: ['mutool', 'convert', '-o', '{output}.png', '{input}', '1']
windows: ['mutool', 'convert', '-o', '{output}.png', '{input}', '1']
tag: <img src='{src}'>
- # use ffmpeg to sample the first keyframe of non-native video format
mime: [video]
command:
default: ['ffmpeg', '-skip_frame', 'nokey', '-i', '{input}', '-frames:v', '1', '{output}.jpg']
windows: ['ffmpeg', '-skip_frame', 'nokey', '-i', '{input}', '-frames:v', '1', '{output}.jpg']
tag: <img src='{src}'>
- # use ffmpeg to sample the first few seconds of non-native audio formats
mime: [audio]
command:
default: ['ffmpeg', '-ss', '0', '-i', '{input}', '-t', '5', '{output}.wav']
windows: ['ffmpeg', '-ss', '0', '-i', '{input}', '-t', '5', '{output}.wav']
tag: <audio autoplay loop controls src='{src}'>