-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
config-node.js
73 lines (63 loc) · 1.91 KB
/
config-node.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
const config = require('./config')
const fs = require('fs')
const path = require('path')
/**
* Paths to different folders in this project. Used everywhere, so define them
* once here.
* @type {String}
*/
exports.root = __dirname
exports.out = path.join(exports.root, 'out')
const month = new Date().getMonth() + 1
/**
* Number of "first click, free" essays that a given session can view before
* requesting that they subscribe. The user can always view if they have
* a referrer from an external site.
* @type {Number}
*/
exports.numFree = month === 1 || month === 12
? 1 // Dec-Jan, 1 essay
: month <= 9
? 3 // Feb-Sep, 3 essays
: 2 // Oct-Nov, 2 essays
/**
* Is it college essay season? Used to determine whether to show in-house ads for
* essay editing services vs. third-party ads.
*/
exports.essaySeason = false
/**
* Maximum time to cache static resources (in milliseconds). This value is
* sent in the HTTP cache-control header.
*
* @type {number}
*/
exports.maxAge = config.isProd
? 7 * 24 * 3600000 // 7 days
: 0
/**
* Maximum number of characters in a note/essay slug.
* @type {Number}
*/
exports.maxSlugLength = 40
let MD5_JS
let MD5_CSS
if (config.isProd) {
MD5_JS = fs.readFileSync(exports.out + '/MD5_JS', 'utf8')
MD5_CSS = fs.readFileSync(exports.out + '/MD5_CSS', 'utf8')
}
/**
* Final paths for JS and CSS files. Uniquely named using the MD5 hash of the
* file contents, for cache busting.
*/
exports.jsPath = '/main' + (MD5_JS ? '-' + MD5_JS : '') + '.js'
exports.cssPath = '/main' + (MD5_CSS ? '-' + MD5_CSS : '') + '.css'
/**
* String to append to the end of all emails
*/
exports.emailFooter = 'Study Notes LLC, PO Box 19678, Stanford, CA 94305'
if (config.isProd) {
exports.inline = {
css: fs.readFileSync(exports.out + exports.cssPath, 'utf8'),
heroBodyMask: 'data:image/png;base64,' + fs.readFileSync(exports.root + '/static/images/hero-body-mask.png', 'base64')
}
}