2016-08-26 14:19:03 +02:00
|
|
|
'use strict';
|
|
|
|
|
2016-11-24 16:19:01 +01:00
|
|
|
const fs = require('fs');
|
2016-08-26 14:19:03 +02:00
|
|
|
const path = require('path');
|
2016-11-24 16:19:01 +01:00
|
|
|
|
2016-08-26 14:19:03 +02:00
|
|
|
/**
|
|
|
|
* A set of functions called "actions" for `Admin`
|
|
|
|
*/
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
2017-03-20 22:08:49 +01:00
|
|
|
index: async(ctx) => {
|
2017-01-04 18:28:47 +01:00
|
|
|
try {
|
|
|
|
// Send the HTML file with injected scripts
|
|
|
|
ctx.body = strapi.admin.services.admin.generateAdminIndexFile();
|
|
|
|
} catch (err) {
|
|
|
|
ctx.body = err;
|
|
|
|
}
|
2016-08-26 14:19:03 +02:00
|
|
|
},
|
|
|
|
|
2017-05-17 11:21:03 +02:00
|
|
|
pluginFile: async ctx => {
|
|
|
|
try {
|
2017-09-27 15:09:46 +02:00
|
|
|
const file = fs.readFileSync(path.resolve(process.cwd(), 'plugins', ctx.params.plugin, 'admin', 'build', `${ctx.params.file}`));
|
2017-05-17 11:21:03 +02:00
|
|
|
ctx.body = file;
|
|
|
|
} catch (err) {
|
|
|
|
ctx.body = ctx.notFound();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2016-12-01 16:44:03 +01:00
|
|
|
file: async ctx => {
|
2016-11-24 16:19:01 +01:00
|
|
|
try {
|
2017-08-18 14:17:15 +02:00
|
|
|
const file = fs.readFileSync(path.resolve(__dirname, '..', 'admin', 'build', ctx.params.file));
|
2016-11-24 16:19:01 +01:00
|
|
|
ctx.body = file;
|
|
|
|
} catch (err) {
|
2017-08-18 14:21:09 +02:00
|
|
|
// Fallback, render admin page
|
|
|
|
ctx.body = strapi.admin.services.admin.generateAdminIndexFile();
|
2016-11-24 16:19:01 +01:00
|
|
|
}
|
2016-08-26 14:19:03 +02:00
|
|
|
}
|
|
|
|
};
|