mirror of
https://github.com/prometheus/alertmanager
synced 2024-12-29 09:32:16 +00:00
c0a7b75c9c
* Automate CSS-inlining for default HTML email template The original HTML email template was added in `template/email.html`. It looks like the CSS was manually inlined. Most likely using the premailer.dialect.ca web form, which is mentioned in the README for the Mailgun transactional-email-templates project. The resulting HTML with inlined CSS was then copied into `template/default.tmpl`. This has resulted in `email.html` and `default.tmpl` diverging at times. This commit adds build automation to inline the CSS automatically using [juice][1]. The Go template containing the resulting HTML has been moved into its own file to avoid the script that performs the CSS inlining having to parse the `default.tmpl` file to insert it there. Fixes #1939. [1]: https://www.npmjs.com/package/juice Signed-off-by: Brad Ison <bison@xvdf.io> * Update asset/assets_vfsdata.go Signed-off-by: Brad Ison <bison@xvdf.io>
41 lines
1.1 KiB
JavaScript
Executable File
41 lines
1.1 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
// Copyright 2021 The Prometheus Authors
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
const juice = require('juice')
|
|
const fs = require('fs')
|
|
|
|
const inputFile = 'email.html'
|
|
const outputFile = 'email.tmpl'
|
|
|
|
var inputData = ''
|
|
|
|
try {
|
|
inputData = fs.readFileSync(inputFile, 'utf8')
|
|
} catch (err) {
|
|
console.error(err)
|
|
process.exit(1)
|
|
}
|
|
|
|
var templateData = juice(inputData)
|
|
|
|
const outputData = `
|
|
{{ define "email.default.subject" }}{{ template "__subject" . }}{{ end }}
|
|
{{ define "email.default.html" }}
|
|
${templateData}
|
|
{{ end }}
|
|
`
|
|
|
|
fs.writeFileSync(outputFile, outputData)
|