mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #3706 from overleaf/msm-jlm-configurable-text-extensions
New ADDITIONAL_TEXT_EXTENSIONS env to support extra editable files GitOrigin-RevId: 03bec0a1a9dbd303754f0b90377d1b7d1ec3f528
This commit is contained in:
parent
d346172819
commit
b2b9a05e3c
5 changed files with 66 additions and 60 deletions
|
@ -2,38 +2,10 @@ const fs = require('fs')
|
|||
const Path = require('path')
|
||||
const isUtf8 = require('utf-8-validate')
|
||||
const { promisifyAll } = require('../../util/promises')
|
||||
const Settings = require('settings-sharelatex')
|
||||
|
||||
const FileTypeManager = {
|
||||
TEXT_EXTENSIONS: [
|
||||
'.tex',
|
||||
'.latex',
|
||||
'.sty',
|
||||
'.cls',
|
||||
'.bst',
|
||||
'.bib',
|
||||
'.bibtex',
|
||||
'.txt',
|
||||
'.tikz',
|
||||
'.mtx',
|
||||
'.rtex',
|
||||
'.md',
|
||||
'.asy',
|
||||
'.latexmkrc',
|
||||
'.lbx',
|
||||
'.bbx',
|
||||
'.cbx',
|
||||
'.m',
|
||||
'.lco',
|
||||
'.dtx',
|
||||
'.ins',
|
||||
'.ist',
|
||||
'.def',
|
||||
'.clo',
|
||||
'.ldf',
|
||||
'.rmd',
|
||||
'.lua',
|
||||
'.gv'
|
||||
],
|
||||
TEXT_EXTENSIONS: Settings.textExtensions.map(ext => `.${ext}`),
|
||||
|
||||
IGNORE_EXTENSIONS: [
|
||||
'.dvi',
|
||||
|
|
|
@ -360,6 +360,7 @@ module.exports = function(webRouter, privateApiRouter, publicApiRouter) {
|
|||
Settings.recaptcha != null ? Settings.recaptcha.siteKeyV3 : undefined,
|
||||
recaptchaDisabled:
|
||||
Settings.recaptcha != null ? Settings.recaptcha.disabled : undefined,
|
||||
textExtensions: Settings.textExtensions,
|
||||
validRootDocExtensions: Settings.validRootDocExtensions,
|
||||
sentryAllowedOriginRegex: Settings.sentry.allowedOriginRegex,
|
||||
sentryDsn: Settings.sentry.publicDSN,
|
||||
|
|
|
@ -32,6 +32,43 @@ intFromEnv = (name, defaultValue) ->
|
|||
throw new Error("Bad default integer value for setting: #{name}, #{defaultValue}")
|
||||
parseInt(process.env[name], 10) || defaultValue
|
||||
|
||||
defaultTextExtensions = [
|
||||
'tex',
|
||||
'latex',
|
||||
'sty',
|
||||
'cls',
|
||||
'bst',
|
||||
'bib',
|
||||
'bibtex',
|
||||
'txt',
|
||||
'tikz',
|
||||
'mtx',
|
||||
'rtex',
|
||||
'md',
|
||||
'asy',
|
||||
'latexmkrc',
|
||||
'lbx',
|
||||
'bbx',
|
||||
'cbx',
|
||||
'm',
|
||||
'lco',
|
||||
'dtx',
|
||||
'ins',
|
||||
'ist',
|
||||
'def',
|
||||
'clo',
|
||||
'ldf',
|
||||
'rmd',
|
||||
'lua',
|
||||
'gv'
|
||||
]
|
||||
|
||||
parseTextExtensions = (extensions) ->
|
||||
if extensions
|
||||
extensions.split(',').map((ext) => ext.trim())
|
||||
else
|
||||
[]
|
||||
|
||||
module.exports = settings =
|
||||
|
||||
allowAnonymousReadAndWriteSharing:
|
||||
|
@ -641,6 +678,8 @@ module.exports = settings =
|
|||
|
||||
compileBodySizeLimitMb: process.env['COMPILE_BODY_SIZE_LIMIT_MB'] or 5
|
||||
|
||||
textExtensions: defaultTextExtensions.concat(parseTextExtensions(process.env["ADDITIONAL_TEXT_EXTENSIONS"]))
|
||||
|
||||
validRootDocExtensions: ['tex', 'Rtex', 'ltx']
|
||||
|
||||
emailConfirmationDisabled: (process.env['EMAIL_CONFIRMATION_DISABLED'] == "true") or false
|
||||
|
|
|
@ -16,36 +16,7 @@ export default App.controller('BinaryFileController', function(
|
|||
const TAIL_OF_URL_LENGTH =
|
||||
MAX_URL_LENGTH - FRONT_OF_URL_LENGTH - FILLER.length
|
||||
|
||||
const textExtensions = [
|
||||
'tex',
|
||||
'latex',
|
||||
'sty',
|
||||
'cls',
|
||||
'bst',
|
||||
'bib',
|
||||
'bibtex',
|
||||
'txt',
|
||||
'tikz',
|
||||
'mtx',
|
||||
'rtex',
|
||||
'md',
|
||||
'asy',
|
||||
'latexmkrc',
|
||||
'lbx',
|
||||
'bbx',
|
||||
'cbx',
|
||||
'm',
|
||||
'lco',
|
||||
'dtx',
|
||||
'ins',
|
||||
'ist',
|
||||
'def',
|
||||
'clo',
|
||||
'ldf',
|
||||
'rmd',
|
||||
'lua',
|
||||
'gv'
|
||||
]
|
||||
const textExtensions = window.ExposedSettings.textExtensions
|
||||
const imageExtensions = ['png', 'jpg', 'jpeg', 'gif']
|
||||
const previewableExtensions = []
|
||||
|
||||
|
|
23
services/web/test/unit/src/Settings/SettingsTests.js
Normal file
23
services/web/test/unit/src/Settings/SettingsTests.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
const chai = require('chai')
|
||||
const { expect } = chai
|
||||
|
||||
function clearSettingsCache() {
|
||||
delete require.cache[
|
||||
require.resolve('../../../../config/settings.defaults.coffee')
|
||||
]
|
||||
const settingsDeps = Object.keys(require.cache).filter(x =>
|
||||
x.includes('/settings-sharelatex/')
|
||||
)
|
||||
settingsDeps.forEach(dep => delete require.cache[dep])
|
||||
}
|
||||
|
||||
describe('settings.defaults', function() {
|
||||
it('additional text extensions can be added via config', function() {
|
||||
clearSettingsCache()
|
||||
process.env.ADDITIONAL_TEXT_EXTENSIONS = 'abc, xyz'
|
||||
const settings = require('settings-sharelatex')
|
||||
expect(settings.textExtensions).to.include('tex') // from the default list
|
||||
expect(settings.textExtensions).to.include('abc')
|
||||
expect(settings.textExtensions).to.include('xyz')
|
||||
})
|
||||
})
|
Loading…
Reference in a new issue