diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000000000000000000000000000000000000..f85dbcc886fa0c4a20c37b702d2ba86de5c58cd2 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,34 @@ +{ + // JSHint Default Configuration File (as on JSHint website) + // See http://jshint.com/docs/ for more details + + "maxerr" : 50, // {int} Maximum error before stopping + + // Enforcing + "camelcase" : true, // true: Identifiers must be in camelCase + "curly" : false, // true: Require {} for every new block or scope + "nonew" : true, // true: Prohibit use of constructors for side-effects (without assignment) + "quotmark" : "single", // Quotation mark consistency + "strict" : false, // true: Requires all functions run in ES5 Strict Mode + + "maxparams" : 5, // {int} Max number of formal params allowed per function + "maxdepth" : 5, // {int} Max depth of nested blocks (within functions) + "maxstatements" : 40, // {int} Max number statements per function + "maxcomplexity" : 10, // {int} Max cyclomatic complexity per function + "maxlen" : 120, // {int} Max number of characters per line + + // Relaxing + "asi" : true, // true: Tolerate Automatic Semicolon Insertion (no semicolons) + "esversion" : 6, // {int} Specify the ECMAScript version to which the code must adhere. + "funcscope" : true, // true: Tolerate defining variables inside control statements + + // Environments + "browser" : false, // Web Browser (window, document, etc) + "devel" : true, // Development/debugging (alert, confirm, etc) + "jquery" : false, // jQuery + "mocha" : true, // Mocha + "node" : true, // Node.js + + // Custom Globals + "globals" : {} // additional predefined global variables +} diff --git a/index.js b/index.js index 243f658518836c063f02bf6a8d1bc4de712af310..bd93f3970ca8ca0a6c8636f67454e038b8c2cd60 100755 --- a/index.js +++ b/index.js @@ -34,23 +34,23 @@ var sitegin = function(config) { var startTime = moment(); runAgain = false; if(isRunning) { - console.log("Generator is still running. Queing another run after it finishes.") + console.log('Generator is still running. Queing another run after it finishes.') runAgain = true; return; } - console.log("================================================================================") - console.log("Running generator") + console.log('================================================================================') + console.log('Running generator') isRunning = true; jobs.run('pipeline',jobs) .then(function() { isRunning = false; - console.log("Generator finished in",moment().diff(startTime,'seconds'),'seconds') + console.log('Generator finished in',moment().diff(startTime,'seconds'),'seconds') doSync(); if(runAgain) run(); }) .catch(function(e) { isRunning = false; - console.log("Generator crashed in",moment().diff(startTime,'seconds'),'seconds') + console.log('Generator crashed in',moment().diff(startTime,'seconds'),'seconds') if(runAgain) run(); if(e.stack) console.log(e.stack) @@ -89,7 +89,7 @@ var sitegin = function(config) { // sitegin reload jobs.onReload(function() { - console.log("Sitegin reloaded"); + console.log('Sitegin reloaded'); run(); }) } @@ -106,19 +106,19 @@ var copyStaticFiles = function(builddir) { fsextra.copy( 'static', builddir, - function(file){ return !(file.match(".git") || file.match("static/articles")); }, - function(){console.log("copy static done");} + function(file){ return !(file.match('.git') || file.match('static/articles')); }, + function(){console.log('copy static done');} ); fsextra.copy( 'static/articles', - builddir+"/clanek", - function(){console.log("copy static/articles done");} + builddir+'/clanek', + function(){console.log('copy static/articles done');} ); fsextra.copy( 'theme/static', builddir, - function(file){ return !file.match("\\.git") }, - function(){console.log("copy theme/static done");} + function(file){ return !file.match('\\.git') }, + function(){console.log('copy theme/static done');} ); } @@ -127,10 +127,10 @@ var rendersass = function(builddir) { var sass = require('node-sass'); var fs = require('fs'); - sass.render ({file: "theme/sass/style.scss"},function(err, result) { - if(err == null) { - console.log("compiled sass"); - fs.writeFile(builddir+"/theme/style.css",result.css); - } else console.log("error ", err); + sass.render ({file: 'theme/sass/style.scss'},function(err, result) { + if(err === null) { + console.log('compiled sass'); + fs.writeFile(builddir+'/theme/style.css',result.css); + } else console.log('error ', err); }); }; diff --git a/sitegin/config.js b/sitegin/config.js index 02378ba8a51e34e13d4f5a859f22f01aa778ccfc..ebc1e18aa3958cc4fd14c1c521e9afa1ae1af4ca 100644 --- a/sitegin/config.js +++ b/sitegin/config.js @@ -13,9 +13,9 @@ var options = cli.parse({ }); module.exports = function() { - var builddir = "build"; - if(!options.noserver) builddir = "build-debug"; - + var builddir = 'build'; + if(!options.noserver) builddir = 'build-debug'; + if(options.uiport == 'port+1') { options.uiport = options.port+1; } diff --git a/sitegin/gitInfo.js b/sitegin/gitInfo.js index 076fce51bd1856db1d422c97d85eafef7b0d4fa6..d92815322e50fd5095c5d5a616d097ae1512ac2b 100644 --- a/sitegin/gitInfo.js +++ b/sitegin/gitInfo.js @@ -8,22 +8,22 @@ var git = require('nodegit-kit'); var path = require('path'); var moment = require('moment'); -var pathToRepo = path.resolve("content"); +var pathToRepo = path.resolve('content'); // Returns promise for patch of single commit -var gitShow = function(repo, commit_data) { +var gitShow = function(repo, commitData) { var commit, tree, parentTree; - return nodegit.Revparse.single(repo, commit_data.commit) + return nodegit.Revparse.single(repo, commitData.commit) .then((obj) => { return nodegit.Commit.lookup(repo, obj.id()); }) .then((_commit) => { commit = _commit; if(commit.parentcount() < 1) return null; - return parent = commit.getParents(1); + return commit.getParents(1); }) .then((parents) => { - if(parents == null) return null; + if(parents === null) return null; return parents[0].getTree(); }) .then((_parentTree) => { @@ -40,7 +40,7 @@ var gitShow = function(repo, commit_data) { .then((patches) => { return [ patches, - commit_data + commitData ]; }); } @@ -90,10 +90,10 @@ module.exports = function(obj) { var newestCommit = commits[0]; var oldestCommit = commits[commits.length-1]; - if(article.metadata.date == undefined) + if(article.metadata.date === undefined) article.metadata.date = {}; - if(article.metadata.date.creation == undefined) + if(article.metadata.date.creation === undefined) article.metadata.date.creation = oldestCommit.date; article.metadata.date.modification = newestCommit.date; @@ -101,9 +101,9 @@ module.exports = function(obj) { if(article.metadata.author === undefined) article.metadata.author = {} - if(article.metadata.author.name == undefined) + if(article.metadata.author.name === undefined) article.metadata.author.name = oldestCommit.author.name - if(article.metadata.author.email == undefined) + if(article.metadata.author.email === undefined) article.metadata.author.email = oldestCommit.author.email article.commits = commits; diff --git a/sitegin/jobs.js b/sitegin/jobs.js index bf4ed3e409398a7f185c5fbbc1bfbb6d058115e0..89e1217f389f87ea55b115b5c4766b224d9bd33c 100644 --- a/sitegin/jobs.js +++ b/sitegin/jobs.js @@ -1,7 +1,9 @@ +'use strict'; + var syntaxError = require('syntax-error'); var fs = require('fs'); var chokidar = require('chokidar'); -var eventEmitter = new (require('events').EventEmitter); +var eventEmitter = new (require('events').EventEmitter)(); var jobList = {}; var watchers = []; @@ -16,15 +18,16 @@ function JobError(message, name) { var onReload = function() {} var requireError = function(e, jobName, module, reject) { if(e instanceof SyntaxError) { + console.log(module+': '+e); var resolved = require.resolve(module); fs.readFile(resolved, 'utf8', function(err, content) { console.log(syntaxError(content,resolved)); - reject(new JobError('Failed to register job '+jobName,'Require')) + reject(new JobError('Failed to register job '+jobName+' (SyntaxError)','Require')) }) } else { if(e.code === 'MODULE_NOT_FOUND') console.log(e.toString()); - reject(new JobError('Failed to register job '+jobName,'Require')) + reject(new JobError('Failed to register job '+jobName+' ('+e+')','Require')) } } @@ -91,9 +94,10 @@ var jobs = { registerMultiple: function() { var regs = []; var watch = true; + var i; for(i in arguments) { var job = arguments[i]; - if(i == 0) { + if(i === '0') { if(job.watch !== undefined) watch = job.watch; } else { regs.push(jobs.register(job[0], job[1], watch)); @@ -109,14 +113,14 @@ var jobs = { try { return jobList[jobName].f.apply(null, Array.prototype.slice.call(arguments, 1)); } catch(e) { - console.log("Error running job",jobName); + console.log('Error running job',jobName); console.log(jobList[jobName]); throw e; } }, runSequence: function() { var prom; - console.log("Running",Array.prototype.slice.call(arguments, 0)) + console.log('Running',Array.prototype.slice.call(arguments, 0)) var jobSequence = [].splice.call(arguments, 0); jobSequence.forEach(function(job){ if(prom === undefined) { diff --git a/sitegin/markdown.js b/sitegin/markdown.js index 81b2bd272680d24a5271084680d13d2407ce2f41..083be8fe1b409c35d3f23416e4b2b1a97f0d8c0b 100644 --- a/sitegin/markdown.js +++ b/sitegin/markdown.js @@ -13,15 +13,15 @@ var toURL = function(url) { } renderer.heading = function(text, level, raw) { - return '<h' - + (level+2) - + ' id="' - + toURL(raw) - + '">' - + text - + '</h' - + (level+2) - + '>\n'; + return '<h' + + (level+2) + + ' id="' + + toURL(raw) + + '">' + + text + + '</h' + + (level+2) + + '>\n'; } renderer.paragraph = function(text) { @@ -43,8 +43,8 @@ marked.setOptions({ module.exports = function(obj) { obj.pages.forEach(function(article) { renderer.image = function(href, title, text) { - href = href.split(path.sep).join("/"); - href = href.split(" ="); + href = href.split(path.sep).join('/'); + href = href.split(' ='); var size = href[1]; href = href[0]; var rel = path.relative(process.cwd(),path.resolve(article.filename,href)); diff --git a/sitegin/nunjucks.js b/sitegin/nunjucks.js index aa87c04145ec7fa8971ff4ebf5fdfde20ca9ca46..7534dffe2c63d9497ebc4398cf4f8aed8e590b62 100644 --- a/sitegin/nunjucks.js +++ b/sitegin/nunjucks.js @@ -1,3 +1,4 @@ +'use strict'; /* * This job renders `data` using nunjucks template `type` */ @@ -26,7 +27,7 @@ env.addFilter('paginationList', function(page, count) { } curPage = page; - for(var i = 0; i < count; i++) { + for(let i = 0; i < count; i++) { curPage = curPage.metadata.nextpage; if(curPage === undefined) break; pages.push(curPage); diff --git a/sitegin/parseHugo.js b/sitegin/parseHugo.js index 43af577af8a6a926e919e45a19320225dcfa0387..cbcc984d5c14e57d27c1f17be03709dc41f5038a 100644 --- a/sitegin/parseHugo.js +++ b/sitegin/parseHugo.js @@ -4,23 +4,23 @@ var path = require('path'); var jsesc = require('jsesc') var readPageWorker = function(content, obj) { - if(content === undefined) throw new Error("content is undefined"); + if(content === undefined) throw new Error('content is undefined'); var head = content.substring(0,4) if(head !== '+++\n') throw new Error('Failed to parse file '+obj.filename+':\n'+ 'Wrong header (expected "+++\\n" got "'+jsesc(head)+'")') content = content.substring(4); - var fm_end = content.indexOf("+++\n"); - if(fm_end < 0) { + var fmEnd = content.indexOf('+++\n'); + if(fmEnd < 0) { console.log(jsesc(content)); throw new Error('Cannot find terminating +++\n in file '+obj.filename); } - obj.content = content.substring(fm_end+4); + obj.content = content.substring(fmEnd+4); try { - obj.metadata = toml.parse(content.substring(0,fm_end-1)+"\n"); + obj.metadata = toml.parse(content.substring(0,fmEnd-1)+'\n'); } catch(e) { - console.log(obj.filename+": Failed to parse metadata"); + console.log(obj.filename+': Failed to parse metadata'); throw e; } if(obj.metadata.date && obj.metadata.date.creation) obj.metadata.date.creation = moment(obj.metadata.date.creation); diff --git a/sitegin/tags.js b/sitegin/tags.js index 2e27c8dcef14b13b184f105d321f72fb3c987809..3041b3c0e57293153aea7a50c59b102789cb3757 100644 --- a/sitegin/tags.js +++ b/sitegin/tags.js @@ -1,3 +1,5 @@ +'use strict'; + var moment = require('moment'); var jobs = require('./jobs'); @@ -7,7 +9,7 @@ var toURL = function(url) { module.exports = function(obj) { return new Promise(function(resolve, reject) { - var tags = new Array(); + var tags = []; var tagPages = {}; obj.pages.forEach(function(article) { if(article.metadata.tags) { @@ -20,7 +22,7 @@ module.exports = function(obj) { ntags.push(tag); if(tags.map(function(e) { return e.url; }).indexOf(tag.url) < 0) tags.push(tag) - if(tagPages[tag.url] == undefined) tagPages[tag.url] = new Array(); + if(tagPages[tag.url] === undefined) tagPages[tag.url] = []; tagPages[tag.url].push(article) }) article.metadata.tags = ntags; @@ -31,11 +33,11 @@ module.exports = function(obj) { obj.redirects = []; var generateTagPages = function(file, pageList) { - var p = {}; - p.type = "redirect"; - p.file = file; - p.content = file+"/1"; - obj.redirects.push(p); + var pg = {}; + pg.type = 'redirect'; + pg.file = file; + pg.content = file+'/1'; + obj.redirects.push(pg); pageList.sort(function (a, b) { var rhs = a.metadata.date.creation; @@ -43,18 +45,18 @@ module.exports = function(obj) { return lhs > rhs ? 1 : lhs < rhs ? -1 : 0; }) var c = 0; - var p = 0; + let p = 0; var tagPage; var prevurl; var prevpage; var firstpage; var lastpage; - tagPageList = []; + var tagPageList = []; pageList.forEach(function(page) { - if(c == 0) { + if(c === 0) { p++; if(tagPage !== undefined) { - tagPage.metadata.nexturl = file+"/"+p; + tagPage.metadata.nexturl = file+'/'+p; obj.tags.push(tagPage); tagPageList.push(tagPage); } @@ -62,15 +64,15 @@ module.exports = function(obj) { if(firstpage === undefined) firstpage = tagPage; lastpage = tagPage; - tagPage.file = file+"/"+p; - tagPage.type = "tag"; + tagPage.file = file+'/'+p; + tagPage.type = 'tag'; tagPage.metadata.firstpage = firstpage; tagPage.metadata.prevpage = prevpage; tagPage.metadata.prevurl = prevurl; tagPage.metadata.thispage = tagPage; tagPage.metadata.pagenumber = p; - tagPage.content = new Array(); + tagPage.content = []; if(prevpage !== undefined) prevpage.metadata.nextpage = tagPage; prevurl = tagPage.file; @@ -89,7 +91,7 @@ module.exports = function(obj) { } tags.forEach(function(tag) { - generateTagPages("tag/"+tag.url, tagPages[tag.url]) + generateTagPages('tag/'+tag.url, tagPages[tag.url]) }) resolve(obj); }) diff --git a/sitegin/toURL.js b/sitegin/toURL.js index d94e805607e69fe72284b8645b79b9c6711426ba..997e3c0718518e8a037d631d1357de3dfc9de0ad 100644 --- a/sitegin/toURL.js +++ b/sitegin/toURL.js @@ -1,10 +1,11 @@ -var Latinise={};Latinise.latin_map={"Ã":"A","Ä‚":"A","Ắ":"A","Ặ":"A","Ằ":"A","Ẳ":"A","Ẵ":"A","Ç":"A","Â":"A","Ấ":"A","Ậ":"A","Ầ":"A","Ẩ":"A","Ẫ":"A","Ä":"A","Çž":"A","Ȧ":"A","Ç ":"A","Ạ":"A","È€":"A","À":"A","Ả":"A","È‚":"A","Ä€":"A","Ä„":"A","Ã…":"A","Ǻ":"A","Ḁ":"A","Ⱥ":"A","Ã":"A","Ꜳ":"AA","Æ":"AE","Ǽ":"AE","Ç¢":"AE","Ꜵ":"AO","Ꜷ":"AU","Ꜹ":"AV","Ꜻ":"AV","Ꜽ":"AY","Ḃ":"B","Ḅ":"B","Æ":"B","Ḇ":"B","Ƀ":"B","Æ‚":"B","Ć":"C","ÄŒ":"C","Ç":"C","Ḉ":"C","Ĉ":"C","ÄŠ":"C","Ƈ":"C","È»":"C","ÄŽ":"D","á¸":"D","Ḓ":"D","Ḋ":"D","Ḍ":"D","ÆŠ":"D","Ḏ":"D","Dz":"D","Ç…":"D","Ä":"D","Æ‹":"D","DZ":"DZ","Ç„":"DZ","É":"E","Ä”":"E","Äš":"E","Ȩ":"E","Ḝ":"E","Ê":"E","Ế":"E","Ệ":"E","Ề":"E","Ể":"E","Ễ":"E","Ḙ":"E","Ë":"E","Ä–":"E","Ẹ":"E","È„":"E","È":"E","Ẻ":"E","Ȇ":"E","Ä’":"E","Ḗ":"E","Ḕ":"E","Ę":"E","Ɇ":"E","Ẽ":"E","Ḛ":"E","êª":"ET","Ḟ":"F","Æ‘":"F","Ç´":"G","Äž":"G","Ǧ":"G","Ä¢":"G","Äœ":"G","Ä ":"G","Æ“":"G","Ḡ":"G","Ǥ":"G","Ḫ":"H","Èž":"H","Ḩ":"H","Ĥ":"H","Ⱨ":"H","Ḧ":"H","Ḣ":"H","Ḥ":"H","Ħ":"H","Ã":"I","Ĭ":"I","Ç":"I","ÃŽ":"I","Ã":"I","Ḯ":"I","Ä°":"I","Ị":"I","Ȉ":"I","ÃŒ":"I","Ỉ":"I","ÈŠ":"I","Ī":"I","Ä®":"I","Æ—":"I","Ĩ":"I","Ḭ":"I","ê¹":"D","ê»":"F","ê½":"G","êž‚":"R","êž„":"S","Ꞇ":"T","ê¬":"IS","Ä´":"J","Ɉ":"J","Ḱ":"K","Ǩ":"K","Ķ":"K","Ⱪ":"K","ê‚":"K","Ḳ":"K","Ƙ":"K","Ḵ":"K","ê€":"K","ê„":"K","Ĺ":"L","Ƚ":"L","Ľ":"L","Ä»":"L","Ḽ":"L","Ḷ":"L","Ḹ":"L","â± ":"L","êˆ":"L","Ḻ":"L","Ä¿":"L","â±¢":"L","Lj":"L","Å":"L","LJ":"LJ","Ḿ":"M","á¹€":"M","Ṃ":"M","â±®":"M","Ń":"N","Ň":"N","Å…":"N","Ṋ":"N","Ṅ":"N","Ṇ":"N","Ǹ":"N","Æ":"N","Ṉ":"N","È ":"N","Ç‹":"N","Ñ":"N","ÇŠ":"NJ","Ó":"O","ÅŽ":"O","Ç‘":"O","Ô":"O","á»":"O","Ộ":"O","á»’":"O","á»”":"O","á»–":"O","Ö":"O","Ȫ":"O","È®":"O","È°":"O","Ọ":"O","Å":"O","ÈŒ":"O","Ã’":"O","Ỏ":"O","Æ ":"O","Ớ":"O","Ợ":"O","Ờ":"O","Ở":"O","á» ":"O","ÈŽ":"O","êŠ":"O","êŒ":"O","ÅŒ":"O","á¹’":"O","á¹":"O","ÆŸ":"O","Ǫ":"O","Ǭ":"O","Ø":"O","Ǿ":"O","Õ":"O","Ṍ":"O","Ṏ":"O","Ȭ":"O","Æ¢":"OI","êŽ":"OO","Æ":"E","Ɔ":"O","È¢":"OU","á¹”":"P","á¹–":"P","ê’":"P","Ƥ":"P","ê”":"P","â±£":"P","ê":"P","ê˜":"Q","ê–":"Q","Å”":"R","Ř":"R","Å–":"R","Ṙ":"R","Ṛ":"R","Ṝ":"R","È":"R","È’":"R","Ṟ":"R","ÉŒ":"R","Ɽ":"R","Ꜿ":"C","ÆŽ":"E","Åš":"S","Ṥ":"S","Å ":"S","Ṧ":"S","Åž":"S","Åœ":"S","Ș":"S","á¹ ":"S","á¹¢":"S","Ṩ":"S","Ť":"T","Å¢":"T","á¹°":"T","Èš":"T","Ⱦ":"T","Ṫ":"T","Ṭ":"T","Ƭ":"T","á¹®":"T","Æ®":"T","Ŧ":"T","Ɐ":"A","Ꞁ":"L","Æœ":"M","É…":"V","Ꜩ":"TZ","Ú":"U","Ŭ":"U","Ç“":"U","Û":"U","Ṷ":"U","Ãœ":"U","Ç—":"U","Ç™":"U","Ç›":"U","Ç•":"U","á¹²":"U","Ụ":"U","Å°":"U","È”":"U","Ù":"U","Ủ":"U","Ư":"U","Ứ":"U","á»°":"U","Ừ":"U","Ử":"U","á»®":"U","È–":"U","Ū":"U","Ṻ":"U","Ų":"U","Å®":"U","Ũ":"U","Ṹ":"U","á¹´":"U","êž":"V","á¹¾":"V","Ʋ":"V","á¹¼":"V","ê ":"VY","Ẃ":"W","Å´":"W","Ẅ":"W","Ẇ":"W","Ẉ":"W","Ẁ":"W","â±²":"W","Ẍ":"X","Ẋ":"X","Ã":"Y","Ŷ":"Y","Ÿ":"Y","Ẏ":"Y","á»´":"Y","Ỳ":"Y","Ƴ":"Y","Ỷ":"Y","Ỿ":"Y","Ȳ":"Y","ÉŽ":"Y","Ỹ":"Y","Ź":"Z","Ž":"Z","áº":"Z","Ⱬ":"Z","Å»":"Z","Ẓ":"Z","Ȥ":"Z","Ẕ":"Z","Ƶ":"Z","IJ":"IJ","Å’":"OE","á´€":"A","á´":"AE","Ê™":"B","á´ƒ":"B","á´„":"C","á´…":"D","á´‡":"E","ꜰ":"F","É¢":"G","Ê›":"G","Êœ":"H","ɪ":"I","Ê":"R","á´Š":"J","á´‹":"K","ÊŸ":"L","á´Œ":"L","á´":"M","É´":"N","á´":"O","ɶ":"OE","á´":"O","á´•":"OU","á´˜":"P","Ê€":"R","á´Ž":"N","á´™":"R","ꜱ":"S","á´›":"T","â±»":"E","á´š":"R","á´œ":"U","á´ ":"V","á´¡":"W","Ê":"Y","á´¢":"Z","á":"a","ă":"a","ắ":"a","ặ":"a","ằ":"a","ẳ":"a","ẵ":"a","ÇŽ":"a","â":"a","ấ":"a","áº":"a","ầ":"a","ẩ":"a","ẫ":"a","ä":"a","ÇŸ":"a","ȧ":"a","Ç¡":"a","ạ":"a","È":"a","à ":"a","ả":"a","ȃ":"a","Ä":"a","Ä…":"a","á¶":"a","ẚ":"a","Ã¥":"a","Ç»":"a","á¸":"a","â±¥":"a","ã":"a","ꜳ":"aa","æ":"ae","ǽ":"ae","Ç£":"ae","ꜵ":"ao","ꜷ":"au","ꜹ":"av","ꜻ":"av","ꜽ":"ay","ḃ":"b","ḅ":"b","É“":"b","ḇ":"b","ᵬ":"b","ᶀ":"b","Æ€":"b","ƃ":"b","ɵ":"o","ć":"c","Ä":"c","ç":"c","ḉ":"c","ĉ":"c","É•":"c","Ä‹":"c","ƈ":"c","ȼ":"c","Ä":"d","ḑ":"d","ḓ":"d","È¡":"d","ḋ":"d","á¸":"d","É—":"d","ᶑ":"d","á¸":"d","áµ":"d","á¶":"d","Ä‘":"d","É–":"d","ÆŒ":"d","ı":"i","È·":"j","ÉŸ":"j","Ê„":"j","dz":"dz","dž":"dz","é":"e","Ä•":"e","Ä›":"e","È©":"e","á¸":"e","ê":"e","ế":"e","ệ":"e","á»":"e","ể":"e","á»…":"e","ḙ":"e","ë":"e","Ä—":"e","ẹ":"e","È…":"e","è":"e","ẻ":"e","ȇ":"e","Ä“":"e","ḗ":"e","ḕ":"e","ⱸ":"e","Ä™":"e","ᶒ":"e","ɇ":"e","ẽ":"e","ḛ":"e","ê«":"et","ḟ":"f","Æ’":"f","áµ®":"f","ᶂ":"f","ǵ":"g","ÄŸ":"g","ǧ":"g","Ä£":"g","Ä":"g","Ä¡":"g","É ":"g","ḡ":"g","ᶃ":"g","Ç¥":"g","ḫ":"h","ÈŸ":"h","ḩ":"h","Ä¥":"h","ⱨ":"h","ḧ":"h","ḣ":"h","ḥ":"h","ɦ":"h","ẖ":"h","ħ":"h","Æ•":"hv","Ã":"i","Ä":"i","Ç":"i","î":"i","ï":"i","ḯ":"i","ị":"i","ȉ":"i","ì":"i","ỉ":"i","È‹":"i","Ä«":"i","į":"i","ᶖ":"i","ɨ":"i","Ä©":"i","á¸":"i","êº":"d","ê¼":"f","áµ¹":"g","ꞃ":"r","êž…":"s","ꞇ":"t","ê":"is","Ç°":"j","ĵ":"j","Ê":"j","ɉ":"j","ḱ":"k","Ç©":"k","Ä·":"k","ⱪ":"k","êƒ":"k","ḳ":"k","Æ™":"k","ḵ":"k","ᶄ":"k","ê":"k","ê…":"k","ĺ":"l","Æš":"l","ɬ":"l","ľ":"l","ļ":"l","ḽ":"l","È´":"l","ḷ":"l","ḹ":"l","ⱡ":"l","ê‰":"l","ḻ":"l","Å€":"l","É«":"l","ᶅ":"l","É":"l","Å‚":"l","lj":"lj","Å¿":"s","ẜ":"s","ẛ":"s","áº":"s","ḿ":"m","á¹":"m","ṃ":"m","ɱ":"m","ᵯ":"m","ᶆ":"m","Å„":"n","ň":"n","ņ":"n","ṋ":"n","ȵ":"n","á¹…":"n","ṇ":"n","ǹ":"n","ɲ":"n","ṉ":"n","Æž":"n","áµ°":"n","ᶇ":"n","ɳ":"n","ñ":"n","ÇŒ":"nj","ó":"o","Å":"o","Ç’":"o","ô":"o","ố":"o","á»™":"o","ồ":"o","ổ":"o","á»—":"o","ö":"o","È«":"o","ȯ":"o","ȱ":"o","á»":"o","Å‘":"o","È":"o","ò":"o","á»":"o","Æ¡":"o","á»›":"o","ợ":"o","á»":"o","ở":"o","ỡ":"o","È":"o","ê‹":"o","ê":"o","ⱺ":"o","Å":"o","ṓ":"o","ṑ":"o","Ç«":"o","Ç":"o","ø":"o","Ç¿":"o","õ":"o","á¹":"o","á¹":"o","È":"o","Æ£":"oi","ê":"oo","É›":"e","ᶓ":"e","É”":"o","ᶗ":"o","È£":"ou","ṕ":"p","á¹—":"p","ê“":"p","Æ¥":"p","áµ±":"p","ᶈ":"p","ê•":"p","áµ½":"p","ê‘":"p","ê™":"q","Ê ":"q","É‹":"q","ê—":"q","Å•":"r","Å™":"r","Å—":"r","á¹™":"r","á¹›":"r","á¹":"r","È‘":"r","ɾ":"r","áµ³":"r","È“":"r","ṟ":"r","ɼ":"r","áµ²":"r","ᶉ":"r","É":"r","ɽ":"r","ↄ":"c","ꜿ":"c","ɘ":"e","É¿":"r","Å›":"s","á¹¥":"s","Å¡":"s","ṧ":"s","ÅŸ":"s","Å":"s","È™":"s","ṡ":"s","á¹£":"s","ṩ":"s","Ê‚":"s","áµ´":"s","ᶊ":"s","È¿":"s","É¡":"g","á´‘":"o","á´“":"o","á´":"u","Å¥":"t","Å£":"t","á¹±":"t","È›":"t","ȶ":"t","ẗ":"t","ⱦ":"t","ṫ":"t","á¹":"t","Æ":"t","ṯ":"t","áµµ":"t","Æ«":"t","ʈ":"t","ŧ":"t","ᵺ":"th","É":"a","á´‚":"ae","Ç":"e","áµ·":"g","É¥":"h","Ê®":"h","ʯ":"h","á´‰":"i","Êž":"k","êž":"l","ɯ":"m","É°":"m","á´”":"oe","ɹ":"r","É»":"r","ɺ":"r","â±¹":"r","ʇ":"t","ÊŒ":"v","Ê":"w","ÊŽ":"y","ꜩ":"tz","ú":"u","Å":"u","Ç”":"u","û":"u","á¹·":"u","ü":"u","ǘ":"u","Çš":"u","Çœ":"u","Ç–":"u","á¹³":"u","ụ":"u","ű":"u","È•":"u","ù":"u","ủ":"u","Æ°":"u","ứ":"u","á»±":"u","ừ":"u","á»":"u","ữ":"u","È—":"u","Å«":"u","á¹»":"u","ų":"u","ᶙ":"u","ů":"u","Å©":"u","á¹¹":"u","á¹µ":"u","ᵫ":"ue","ê¸":"um","â±´":"v","êŸ":"v","ṿ":"v","Ê‹":"v","ᶌ":"v","â±±":"v","á¹½":"v","ê¡":"vy","ẃ":"w","ŵ":"w","ẅ":"w","ẇ":"w","ẉ":"w","áº":"w","â±³":"w","ẘ":"w","áº":"x","ẋ":"x","á¶":"x","ý":"y","Å·":"y","ÿ":"y","áº":"y","ỵ":"y","ỳ":"y","Æ´":"y","á»·":"y","ỿ":"y","ȳ":"y","ẙ":"y","É":"y","ỹ":"y","ź":"z","ž":"z","ẑ":"z","Ê‘":"z","ⱬ":"z","ż":"z","ẓ":"z","È¥":"z","ẕ":"z","ᵶ":"z","ᶎ":"z","Ê":"z","ƶ":"z","É€":"z","ff":"ff","ffi":"ffi","ffl":"ffl","ï¬":"fi","fl":"fl","ij":"ij","Å“":"oe","st":"st","â‚":"a","â‚‘":"e","áµ¢":"i","â±¼":"j","â‚’":"o","áµ£":"r","ᵤ":"u","áµ¥":"v","â‚“":"x"}; -String.prototype.latinise=function(){return this.replace(/[^A-Za-z0-9\[\] ]/g,function(a){return Latinise.latin_map[a]||a})}; -String.prototype.latinize=String.prototype.latinise; -String.prototype.isLatin=function(){return this==this.latinise()} + +/* jshint ignore:start */ +var Latinise={};Latinise.latin_map={'Ã':'A','Ä‚':'A','Ắ':'A','Ặ':'A','Ằ':'A','Ẳ':'A','Ẵ':'A','Ç':'A','Â':'A','Ấ':'A','Ậ':'A','Ầ':'A','Ẩ':'A','Ẫ':'A','Ä':'A','Çž':'A','Ȧ':'A','Ç ':'A','Ạ':'A','È€':'A','À':'A','Ả':'A','È‚':'A','Ä€':'A','Ä„':'A','Ã…':'A','Ǻ':'A','Ḁ':'A','Ⱥ':'A','Ã':'A','Ꜳ':'AA','Æ':'AE','Ǽ':'AE','Ç¢':'AE','Ꜵ':'AO','Ꜷ':'AU','Ꜹ':'AV','Ꜻ':'AV','Ꜽ':'AY','Ḃ':'B','Ḅ':'B','Æ':'B','Ḇ':'B','Ƀ':'B','Æ‚':'B','Ć':'C','ÄŒ':'C','Ç':'C','Ḉ':'C','Ĉ':'C','ÄŠ':'C','Ƈ':'C','È»':'C','ÄŽ':'D','á¸':'D','Ḓ':'D','Ḋ':'D','Ḍ':'D','ÆŠ':'D','Ḏ':'D','Dz':'D','Ç…':'D','Ä':'D','Æ‹':'D','DZ':'DZ','Ç„':'DZ','É':'E','Ä”':'E','Äš':'E','Ȩ':'E','Ḝ':'E','Ê':'E','Ế':'E','Ệ':'E','Ề':'E','Ể':'E','Ễ':'E','Ḙ':'E','Ë':'E','Ä–':'E','Ẹ':'E','È„':'E','È':'E','Ẻ':'E','Ȇ':'E','Ä’':'E','Ḗ':'E','Ḕ':'E','Ę':'E','Ɇ':'E','Ẽ':'E','Ḛ':'E','êª':'ET','Ḟ':'F','Æ‘':'F','Ç´':'G','Äž':'G','Ǧ':'G','Ä¢':'G','Äœ':'G','Ä ':'G','Æ“':'G','Ḡ':'G','Ǥ':'G','Ḫ':'H','Èž':'H','Ḩ':'H','Ĥ':'H','Ⱨ':'H','Ḧ':'H','Ḣ':'H','Ḥ':'H','Ħ':'H','Ã':'I','Ĭ':'I','Ç':'I','ÃŽ':'I','Ã':'I','Ḯ':'I','Ä°':'I','Ị':'I','Ȉ':'I','ÃŒ':'I','Ỉ':'I','ÈŠ':'I','Ī':'I','Ä®':'I','Æ—':'I','Ĩ':'I','Ḭ':'I','ê¹':'D','ê»':'F','ê½':'G','êž‚':'R','êž„':'S','Ꞇ':'T','ê¬':'IS','Ä´':'J','Ɉ':'J','Ḱ':'K','Ǩ':'K','Ķ':'K','Ⱪ':'K','ê‚':'K','Ḳ':'K','Ƙ':'K','Ḵ':'K','ê€':'K','ê„':'K','Ĺ':'L','Ƚ':'L','Ľ':'L','Ä»':'L','Ḽ':'L','Ḷ':'L','Ḹ':'L','â± ':'L','êˆ':'L','Ḻ':'L','Ä¿':'L','â±¢':'L','Lj':'L','Å':'L','LJ':'LJ','Ḿ':'M','á¹€':'M','Ṃ':'M','â±®':'M','Ń':'N','Ň':'N','Å…':'N','Ṋ':'N','Ṅ':'N','Ṇ':'N','Ǹ':'N','Æ':'N','Ṉ':'N','È ':'N','Ç‹':'N','Ñ':'N','ÇŠ':'NJ','Ó':'O','ÅŽ':'O','Ç‘':'O','Ô':'O','á»':'O','Ộ':'O','á»’':'O','á»”':'O','á»–':'O','Ö':'O','Ȫ':'O','È®':'O','È°':'O','Ọ':'O','Å':'O','ÈŒ':'O','Ã’':'O','Ỏ':'O','Æ ':'O','Ớ':'O','Ợ':'O','Ờ':'O','Ở':'O','á» ':'O','ÈŽ':'O','êŠ':'O','êŒ':'O','ÅŒ':'O','á¹’':'O','á¹':'O','ÆŸ':'O','Ǫ':'O','Ǭ':'O','Ø':'O','Ǿ':'O','Õ':'O','Ṍ':'O','Ṏ':'O','Ȭ':'O','Æ¢':'OI','êŽ':'OO','Æ':'E','Ɔ':'O','È¢':'OU','á¹”':'P','á¹–':'P','ê’':'P','Ƥ':'P','ê”':'P','â±£':'P','ê':'P','ê˜':'Q','ê–':'Q','Å”':'R','Ř':'R','Å–':'R','Ṙ':'R','Ṛ':'R','Ṝ':'R','È':'R','È’':'R','Ṟ':'R','ÉŒ':'R','Ɽ':'R','Ꜿ':'C','ÆŽ':'E','Åš':'S','Ṥ':'S','Å ':'S','Ṧ':'S','Åž':'S','Åœ':'S','Ș':'S','á¹ ':'S','á¹¢':'S','Ṩ':'S','Ť':'T','Å¢':'T','á¹°':'T','Èš':'T','Ⱦ':'T','Ṫ':'T','Ṭ':'T','Ƭ':'T','á¹®':'T','Æ®':'T','Ŧ':'T','Ɐ':'A','Ꞁ':'L','Æœ':'M','É…':'V','Ꜩ':'TZ','Ú':'U','Ŭ':'U','Ç“':'U','Û':'U','Ṷ':'U','Ãœ':'U','Ç—':'U','Ç™':'U','Ç›':'U','Ç•':'U','á¹²':'U','Ụ':'U','Å°':'U','È”':'U','Ù':'U','Ủ':'U','Ư':'U','Ứ':'U','á»°':'U','Ừ':'U','Ử':'U','á»®':'U','È–':'U','Ū':'U','Ṻ':'U','Ų':'U','Å®':'U','Ũ':'U','Ṹ':'U','á¹´':'U','êž':'V','á¹¾':'V','Ʋ':'V','á¹¼':'V','ê ':'VY','Ẃ':'W','Å´':'W','Ẅ':'W','Ẇ':'W','Ẉ':'W','Ẁ':'W','â±²':'W','Ẍ':'X','Ẋ':'X','Ã':'Y','Ŷ':'Y','Ÿ':'Y','Ẏ':'Y','á»´':'Y','Ỳ':'Y','Ƴ':'Y','Ỷ':'Y','Ỿ':'Y','Ȳ':'Y','ÉŽ':'Y','Ỹ':'Y','Ź':'Z','Ž':'Z','áº':'Z','Ⱬ':'Z','Å»':'Z','Ẓ':'Z','Ȥ':'Z','Ẕ':'Z','Ƶ':'Z','IJ':'IJ','Å’':'OE','á´€':'A','á´':'AE','Ê™':'B','á´ƒ':'B','á´„':'C','á´…':'D','á´‡':'E','ꜰ':'F','É¢':'G','Ê›':'G','Êœ':'H','ɪ':'I','Ê':'R','á´Š':'J','á´‹':'K','ÊŸ':'L','á´Œ':'L','á´':'M','É´':'N','á´':'O','ɶ':'OE','á´':'O','á´•':'OU','á´˜':'P','Ê€':'R','á´Ž':'N','á´™':'R','ꜱ':'S','á´›':'T','â±»':'E','á´š':'R','á´œ':'U','á´ ':'V','á´¡':'W','Ê':'Y','á´¢':'Z','á':'a','ă':'a','ắ':'a','ặ':'a','ằ':'a','ẳ':'a','ẵ':'a','ÇŽ':'a','â':'a','ấ':'a','áº':'a','ầ':'a','ẩ':'a','ẫ':'a','ä':'a','ÇŸ':'a','ȧ':'a','Ç¡':'a','ạ':'a','È':'a','à ':'a','ả':'a','ȃ':'a','Ä':'a','Ä…':'a','á¶':'a','ẚ':'a','Ã¥':'a','Ç»':'a','á¸':'a','â±¥':'a','ã':'a','ꜳ':'aa','æ':'ae','ǽ':'ae','Ç£':'ae','ꜵ':'ao','ꜷ':'au','ꜹ':'av','ꜻ':'av','ꜽ':'ay','ḃ':'b','ḅ':'b','É“':'b','ḇ':'b','ᵬ':'b','ᶀ':'b','Æ€':'b','ƃ':'b','ɵ':'o','ć':'c','Ä':'c','ç':'c','ḉ':'c','ĉ':'c','É•':'c','Ä‹':'c','ƈ':'c','ȼ':'c','Ä':'d','ḑ':'d','ḓ':'d','È¡':'d','ḋ':'d','á¸':'d','É—':'d','ᶑ':'d','á¸':'d','áµ':'d','á¶':'d','Ä‘':'d','É–':'d','ÆŒ':'d','ı':'i','È·':'j','ÉŸ':'j','Ê„':'j','dz':'dz','dž':'dz','é':'e','Ä•':'e','Ä›':'e','È©':'e','á¸':'e','ê':'e','ế':'e','ệ':'e','á»':'e','ể':'e','á»…':'e','ḙ':'e','ë':'e','Ä—':'e','ẹ':'e','È…':'e','è':'e','ẻ':'e','ȇ':'e','Ä“':'e','ḗ':'e','ḕ':'e','ⱸ':'e','Ä™':'e','ᶒ':'e','ɇ':'e','ẽ':'e','ḛ':'e','ê«':'et','ḟ':'f','Æ’':'f','áµ®':'f','ᶂ':'f','ǵ':'g','ÄŸ':'g','ǧ':'g','Ä£':'g','Ä':'g','Ä¡':'g','É ':'g','ḡ':'g','ᶃ':'g','Ç¥':'g','ḫ':'h','ÈŸ':'h','ḩ':'h','Ä¥':'h','ⱨ':'h','ḧ':'h','ḣ':'h','ḥ':'h','ɦ':'h','ẖ':'h','ħ':'h','Æ•':'hv','Ã':'i','Ä':'i','Ç':'i','î':'i','ï':'i','ḯ':'i','ị':'i','ȉ':'i','ì':'i','ỉ':'i','È‹':'i','Ä«':'i','į':'i','ᶖ':'i','ɨ':'i','Ä©':'i','á¸':'i','êº':'d','ê¼':'f','áµ¹':'g','ꞃ':'r','êž…':'s','ꞇ':'t','ê':'is','Ç°':'j','ĵ':'j','Ê':'j','ɉ':'j','ḱ':'k','Ç©':'k','Ä·':'k','ⱪ':'k','êƒ':'k','ḳ':'k','Æ™':'k','ḵ':'k','ᶄ':'k','ê':'k','ê…':'k','ĺ':'l','Æš':'l','ɬ':'l','ľ':'l','ļ':'l','ḽ':'l','È´':'l','ḷ':'l','ḹ':'l','ⱡ':'l','ê‰':'l','ḻ':'l','Å€':'l','É«':'l','ᶅ':'l','É':'l','Å‚':'l','lj':'lj','Å¿':'s','ẜ':'s','ẛ':'s','áº':'s','ḿ':'m','á¹':'m','ṃ':'m','ɱ':'m','ᵯ':'m','ᶆ':'m','Å„':'n','ň':'n','ņ':'n','ṋ':'n','ȵ':'n','á¹…':'n','ṇ':'n','ǹ':'n','ɲ':'n','ṉ':'n','Æž':'n','áµ°':'n','ᶇ':'n','ɳ':'n','ñ':'n','ÇŒ':'nj','ó':'o','Å':'o','Ç’':'o','ô':'o','ố':'o','á»™':'o','ồ':'o','ổ':'o','á»—':'o','ö':'o','È«':'o','ȯ':'o','ȱ':'o','á»':'o','Å‘':'o','È':'o','ò':'o','á»':'o','Æ¡':'o','á»›':'o','ợ':'o','á»':'o','ở':'o','ỡ':'o','È':'o','ê‹':'o','ê':'o','ⱺ':'o','Å':'o','ṓ':'o','ṑ':'o','Ç«':'o','Ç':'o','ø':'o','Ç¿':'o','õ':'o','á¹':'o','á¹':'o','È':'o','Æ£':'oi','ê':'oo','É›':'e','ᶓ':'e','É”':'o','ᶗ':'o','È£':'ou','ṕ':'p','á¹—':'p','ê“':'p','Æ¥':'p','áµ±':'p','ᶈ':'p','ê•':'p','áµ½':'p','ê‘':'p','ê™':'q','Ê ':'q','É‹':'q','ê—':'q','Å•':'r','Å™':'r','Å—':'r','á¹™':'r','á¹›':'r','á¹':'r','È‘':'r','ɾ':'r','áµ³':'r','È“':'r','ṟ':'r','ɼ':'r','áµ²':'r','ᶉ':'r','É':'r','ɽ':'r','ↄ':'c','ꜿ':'c','ɘ':'e','É¿':'r','Å›':'s','á¹¥':'s','Å¡':'s','ṧ':'s','ÅŸ':'s','Å':'s','È™':'s','ṡ':'s','á¹£':'s','ṩ':'s','Ê‚':'s','áµ´':'s','ᶊ':'s','È¿':'s','É¡':'g','á´‘':'o','á´“':'o','á´':'u','Å¥':'t','Å£':'t','á¹±':'t','È›':'t','ȶ':'t','ẗ':'t','ⱦ':'t','ṫ':'t','á¹':'t','Æ':'t','ṯ':'t','áµµ':'t','Æ«':'t','ʈ':'t','ŧ':'t','ᵺ':'th','É':'a','á´‚':'ae','Ç':'e','áµ·':'g','É¥':'h','Ê®':'h','ʯ':'h','á´‰':'i','Êž':'k','êž':'l','ɯ':'m','É°':'m','á´”':'oe','ɹ':'r','É»':'r','ɺ':'r','â±¹':'r','ʇ':'t','ÊŒ':'v','Ê':'w','ÊŽ':'y','ꜩ':'tz','ú':'u','Å':'u','Ç”':'u','û':'u','á¹·':'u','ü':'u','ǘ':'u','Çš':'u','Çœ':'u','Ç–':'u','á¹³':'u','ụ':'u','ű':'u','È•':'u','ù':'u','ủ':'u','Æ°':'u','ứ':'u','á»±':'u','ừ':'u','á»':'u','ữ':'u','È—':'u','Å«':'u','á¹»':'u','ų':'u','ᶙ':'u','ů':'u','Å©':'u','á¹¹':'u','á¹µ':'u','ᵫ':'ue','ê¸':'um','â±´':'v','êŸ':'v','ṿ':'v','Ê‹':'v','ᶌ':'v','â±±':'v','á¹½':'v','ê¡':'vy','ẃ':'w','ŵ':'w','ẅ':'w','ẇ':'w','ẉ':'w','áº':'w','â±³':'w','ẘ':'w','áº':'x','ẋ':'x','á¶':'x','ý':'y','Å·':'y','ÿ':'y','áº':'y','ỵ':'y','ỳ':'y','Æ´':'y','á»·':'y','ỿ':'y','ȳ':'y','ẙ':'y','É':'y','ỹ':'y','ź':'z','ž':'z','ẑ':'z','Ê‘':'z','ⱬ':'z','ż':'z','ẓ':'z','È¥':'z','ẕ':'z','ᵶ':'z','ᶎ':'z','Ê':'z','ƶ':'z','É€':'z','ff':'ff','ffi':'ffi','ffl':'ffl','ï¬':'fi','fl':'fl','ij':'ij','Å“':'oe','st':'st','â‚':'a','â‚‘':'e','áµ¢':'i','â±¼':'j','â‚’':'o','áµ£':'r','ᵤ':'u','áµ¥':'v','â‚“':'x'}; +var latinise = function(l){return l.replace(/[^A-Za-z0-9\[\] ]/g,function(a){return Latinise.latin_map[a]||a})}; +/* jshint ignore:end */ module.exports = function(tag) { - if(tag == undefined) return undefined; - return tag.toLowerCase().latinise().replace(/ /g,"-");; + if(tag === undefined) return undefined; + return latinise(tag.toLowerCase()).replace(/ /g,'-'); } diff --git a/sitegin/writeFiles.js b/sitegin/writeFiles.js index 04a17fd0a6e11e9989250e7f189c0e7e3e9e3d01..295a6fea9de2510aa04c9eb402a9ca9f995cfad6 100644 --- a/sitegin/writeFiles.js +++ b/sitegin/writeFiles.js @@ -9,7 +9,7 @@ module.exports = function(obj) { var todo = 0; var writeFile = function(article) { - var filename = path.join(builddir,article.file,"index.html"); + var filename = path.join(builddir,article.file,'index.html'); mkdirp(path.dirname(filename), function() { fs.writeFile(filename, article.content, function(err) { if(err) reject(err);