Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add search to list filters #316

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
cache bust scripts
allanchau committed Jul 16, 2021
commit ca88d115e59186c042470a562429b9a0433c186e
204 changes: 110 additions & 94 deletions lib/scripts.js
Original file line number Diff line number Diff line change
@@ -9,105 +9,121 @@ const { parseScriptsAndStyles } = require('./util');
* @param {Array} templateScripts An array of script objects.
* @return {Promise} Resolves to an array or scripts.
*/
const setTemplateScripts = (req, res, templateScripts) => new Promise((resolve, reject) => {
const setTemplateScripts = (req, res, templateScripts) =>
new Promise((resolve, reject) => {
const linz = require('../');

const linz = require('../');
const defaults = [
{
src: `${linz.get('admin path')}/public/js/pace.min.js`,
inHead: true,
},
{
crossorigin: 'anonymous',
inHead: true,
integrity:
'sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=',
src:
'//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js',
},
{
crossorigin: 'anonymous',
inHead: true,
integrity:
'sha256-JklDYODbg0X+8sPiKkcFURb5z7RvlNMIaE3RA2z97vw=',
src:
'//cdnjs.cloudflare.com/ajax/libs/jquery-migrate/3.0.0/jquery-migrate.min.js',
},
{
crossorigin: 'anonymous',
integrity:
'sha256-KM512VNnjElC30ehFwehXjx1YCHPiQkOPmqnrWtpccM=',
src:
'//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js',
},
{
crossorigin: 'anonymous',
inHead: true,
integrity:
'sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa',
src:
'//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js',
},
{
crossorigin: 'anonymous',
integrity:
'sha256-CutOzxCRucUsn6C6TcEYsauvvYilEniTXldPa6/wu0k=',
src:
'//cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js',
},
{
crossorigin: 'anonymous',
integrity:
'sha256-5YmaxAwMjIpMrVlK84Y/+NjCpKnFYa8bWWBbUHSBGfU=',
src:
'//cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js',
},
{
src: `${linz.get('admin path')}/public/js/utils.js`,
inHead: true,
},
{
src: `${linz.get('admin path')}/public/ckeditor/ckeditor.js`,
},
{
src: `${linz.get(
'admin path'
)}/public/js/modernizr.custom.min.js`,
},
{
src: `${linz.get('admin path')}/public/js/multiselect.min.js`,
},
{
src: `${linz.get('admin path')}/public/js/noty.min.js`,
},
{
src: `${linz.get('admin path')}/public/js/template.js`,
},
{
src: `${linz.get('admin path')}/public/js/ui.js?v8`,
},
{
src: `${linz.get('admin path')}/public/js/validator.min.js?v1`,
},
{
src: `${linz.get(
'admin path'
)}/public/js/views/model-export.js`,
},
{
src: `${linz.get('admin path')}/public/js/tz.js?v1`,
},
{
src: `${linz.get('admin path')}/public/js/offcanvas.min.js`,
},
{
inHead: true,
src: `${linz.get('admin path')}/public/js/csrf-submit.js?v3`,
},
];

const defaults = [
{
src: `${linz.get('admin path')}/public/js/pace.min.js`,
inHead: true,
},
{
crossorigin: 'anonymous',
inHead: true,
integrity: 'sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=',
src: '//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js',
},
{
crossorigin: 'anonymous',
inHead: true,
integrity: 'sha256-JklDYODbg0X+8sPiKkcFURb5z7RvlNMIaE3RA2z97vw=',
src: '//cdnjs.cloudflare.com/ajax/libs/jquery-migrate/3.0.0/jquery-migrate.min.js',
},
{
crossorigin: 'anonymous',
integrity: 'sha256-KM512VNnjElC30ehFwehXjx1YCHPiQkOPmqnrWtpccM=',
src: '//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js',
},
{
crossorigin: 'anonymous',
inHead: true,
integrity: 'sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa',
src: '//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js',
},
{
crossorigin: 'anonymous',
integrity: 'sha256-CutOzxCRucUsn6C6TcEYsauvvYilEniTXldPa6/wu0k=',
src: '//cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js',
},
{
crossorigin: 'anonymous',
integrity: 'sha256-5YmaxAwMjIpMrVlK84Y/+NjCpKnFYa8bWWBbUHSBGfU=',
src: '//cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js'
},
{
src: `${linz.get('admin path')}/public/js/utils.js`,
inHead: true,
},
{
src: `${linz.get('admin path')}/public/ckeditor/ckeditor.js`,
},
{
src: `${linz.get('admin path')}/public/js/modernizr.custom.min.js`,
},
{
src: `${linz.get('admin path')}/public/js/multiselect.min.js`,
},
{
src: `${linz.get('admin path')}/public/js/noty.min.js`,
},
{
src: `${linz.get('admin path')}/public/js/template.js`,
},
{
src: `${linz.get('admin path')}/public/js/ui.js?v7`,
},
{
src: `${linz.get('admin path')}/public/js/validator.min.js?v1`,
},
{
src: `${linz.get('admin path')}/public/js/views/model-export.js`,
},
{
src: `${linz.get('admin path')}/public/js/tz.js?v1`,
},
{
src: `${linz.get('admin path')}/public/js/offcanvas.min.js`,
},
{
inHead: true,
src: `${linz.get('admin path')}/public/js/csrf-submit.js?v3`
},
];
if (linz.app.locals.adminJSFile) {
defaults.push({ src: linz.app.locals.adminJSFile });
}

if (linz.app.locals.adminJSFile) {
defaults.push({ src: linz.app.locals.adminJSFile });
}
res.locals.scripts = []
.concat(defaults, templateScripts)
.filter((script) => script !== undefined);

res.locals.scripts = [].concat(defaults, templateScripts)
.filter(script => script !== undefined);
const customScripts = linz.get('scripts');

const customScripts = linz.get('scripts');
if (!customScripts) {
return resolve(parseScriptsAndStyles(res.locals.scripts));
}

if (!customScripts) {
return resolve(parseScriptsAndStyles(res.locals.scripts));
}

customScripts(req, res)
.then((result) => resolve(parseScriptsAndStyles(result)))
.catch(reject);

});
customScripts(req, res)
.then((result) => resolve(parseScriptsAndStyles(result)))
.catch(reject);
});

module.exports = { setTemplateScripts };
Loading