You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.4 KiB
56 lines
1.4 KiB
// Generated by CoffeeScript 1.6.3
|
|
var balUtil, docpadUtil, pathUtil, typeChecker;
|
|
|
|
pathUtil = require('path');
|
|
|
|
typeChecker = require('typechecker');
|
|
|
|
balUtil = require('bal-util');
|
|
|
|
module.exports = docpadUtil = {
|
|
getBasename: function(filename) {
|
|
var basename;
|
|
if (filename[0] === '.') {
|
|
basename = filename.replace(/^(\.[^\.]+)\..*$/, '$1');
|
|
} else {
|
|
basename = filename.replace(/\..*$/, '');
|
|
}
|
|
return basename;
|
|
},
|
|
getExtensions: function(filename) {
|
|
var extensions;
|
|
extensions = filename.split(/\./g).slice(1);
|
|
return extensions;
|
|
},
|
|
getExtension: function(extensions) {
|
|
var extension;
|
|
if (!typeChecker.isArray(extensions)) {
|
|
extensions = docpadUtil.getExtensions(extensions);
|
|
}
|
|
if (extensions.length !== 0) {
|
|
extension = extensions.slice(-1)[0] || null;
|
|
} else {
|
|
extension = null;
|
|
}
|
|
return extension;
|
|
},
|
|
getDirPath: function(path) {
|
|
return pathUtil.dirname(path) || '';
|
|
},
|
|
getFilename: function(path) {
|
|
return pathUtil.basename(path);
|
|
},
|
|
getOutFilename: function(basename, extension) {
|
|
if (basename === '.' + extension) {
|
|
return basename;
|
|
} else {
|
|
return basename + (extension ? '.' + extension || '' : void 0);
|
|
}
|
|
},
|
|
getUrl: function(relativePath) {
|
|
return '/' + relativePath.replace(/[\\]/g, '/');
|
|
},
|
|
getSlug: function(relativeBase) {
|
|
return balUtil.generateSlugSync(relativeBase);
|
|
}
|
|
};
|