Make archive list in output script more readable/diffable and robust against backticks.

This commit is contained in:
ccd0 2016-04-16 08:33:20 -07:00
parent b3d654f655
commit ab2c778c91

View File

@ -27,7 +27,13 @@ Redirect =
Redirect.data = o
archives: `<%= JSON.stringify(readJSON('src/Archive/archives.json')) %>`
archives:
`<%=
JSON.stringify(readJSON('src/Archive/archives.json'), null, 2)
.replace(/\n {2,}(?!{)/g, ' ')
.replace(/\n/g, '\n ')
.replace(/`/g, '\\`')
%>`
to: (dest, data) ->
archive = (if dest in ['search', 'board'] then Redirect.data.thread else Redirect.data[dest])[data.boardID]