Skip to content
This repository was archived by the owner on Dec 15, 2019. It is now read-only.

Commit 43a55d2

Browse files
committed
Respond with sample files in demo mode
1 parent 7a2b6a9 commit 43a55d2

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

config/config.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
{
22
"demo": false,
3+
"demoContent": [
4+
{
5+
"regex": "\\.(gif|jpe?g|tiff|png)$",
6+
"url": "https://raw.githubusercontent.com/Simonwep/vue-cloudfront/master/public/img/icons/android-chrome-512x512.png"
7+
},
8+
{
9+
"regex": "\\.(mp3|adts|ogg|webp|flac)$",
10+
"url": "https://github.com/9530f/stuff/blob/master/music_for_programming_1-datassette.mp3?raw=true"
11+
},
12+
{
13+
"regex": "\\.(mp4|wav|webm)$",
14+
"url": "https://github.com/9530f/stuff/blob/master/Spinning%20Levers%201936%20-%20How%20A%20Transmission%20Works.mp4?raw=true"
15+
},
16+
{
17+
"regex": "\\.(ttf|otf|woff|woff2|eot)$",
18+
"url": "https://fonts.gstatic.com/s/roboto/v18/KFOlCnqEu92Fr1MmEU9fCRc4EsA.woff2"
19+
}
20+
],
321
"server": {
422
"port": 8080,
523
"storagePath": "./_storage",

src/api/endpoints/data/static.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ module.exports = async (req, res) => {
2020
return res.status(404).send();
2121
}
2222

23+
// Check if in demo mode
24+
if (_config.demo) {
25+
const {name} = node;
26+
27+
for (const {regex, url} of _config.demoContent) {
28+
if (name.match(new RegExp(regex, 'i'))) {
29+
return res.redirect(url);
30+
}
31+
}
32+
}
33+
2334
// Make sure the file exists
2435
const path = `${_config.server.storagePath}/${node.id}`;
2536
if (fs.existsSync(path)) {

0 commit comments

Comments
 (0)