mirror of https://gitgud.io/fatchan/jschan.git
v0.9.1 Closes #489 and #495 See merge request fatchan/jschan!270indiachan-spamvector v0.9.1
commit
aed1abf36a
18 changed files with 110 additions and 69 deletions
Binary file not shown.
@ -1,21 +1,25 @@ |
|||||||
'use strict'; |
'use strict'; |
||||||
|
|
||||||
const fontList = require('child_process') |
const { debugLogs } = require(__dirname+'/../../configs/secrets.js') |
||||||
.execSync('fc-list -f "%{file}:%{family[0]} %{style[0]}\n"') |
, fontList = require('child_process') |
||||||
.toString() |
.execSync('fc-list -f "%{file}:%{family[0]} %{style[0]}\n"') |
||||||
.split('\n') //split by newlines, like here ^
|
.toString() |
||||||
.filter(line => line) //filter empty lines
|
.split('\n') //split by newlines, like here ^
|
||||||
.map(line => { |
.filter(line => line) //filter empty lines
|
||||||
//map to an object with path and name
|
.map(line => { |
||||||
const [path, name] = line.split(':'); |
//map to an object with path and name
|
||||||
return { path, name }; |
const [path, name] = line.split(':'); |
||||||
}) |
return { path, name }; |
||||||
.sort((a, b) => { |
}) |
||||||
//alphabetical name sort
|
.sort((a, b) => { |
||||||
return a.name.localeCompare(b.name); |
//alphabetical name sort
|
||||||
}); |
return a.name.localeCompare(b.name); |
||||||
|
}); |
||||||
|
|
||||||
|
debugLogs && console.log(`${fontList.length} system fonts available`); |
||||||
|
|
||||||
module.exports = { |
module.exports = { |
||||||
fontList, |
fontList, |
||||||
fontPaths: new Set(['default', ...fontList.map(f => f.path)]), //memoize paths
|
fontPaths: new Set(['default', ...fontList.map(f => f.path)]), //memoize paths
|
||||||
|
DejaVuSans: fontList.find(f => f.name === 'DejaVu Sans Book'), //default for grid captchas
|
||||||
}; |
}; |
||||||
|
@ -0,0 +1,15 @@ |
|||||||
|
'use strict'; |
||||||
|
|
||||||
|
module.exports = async(db, redis) => { |
||||||
|
console.log('make captcha font option apply to grid captcha too'); |
||||||
|
await db.collection('globalsettings').updateOne({ _id: 'globalsettings' }, { |
||||||
|
'$unset': { |
||||||
|
'captchaOptions.text.font': '', |
||||||
|
}, |
||||||
|
'$set': { |
||||||
|
'captchaOptions.font': 'default', |
||||||
|
} |
||||||
|
}); |
||||||
|
console.log('Clearing globalsettings cache'); |
||||||
|
await redis.deletePattern('globalsettings'); |
||||||
|
}; |
Loading…
Reference in new issue