Skip to content

Commit d63e678

Browse files
committed
Adds PDF export via config
1 parent c794412 commit d63e678

6 files changed

Lines changed: 22 additions & 8 deletions

File tree

app.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@
127127
"HMD_IMGUR_CLIENTID": {
128128
"description": "Imgur API client id",
129129
"required": false
130+
},
131+
"HMD_ALLOW_PDF_EXPORT": {
132+
"description": "Enable or disable PDF exports",
133+
"required": false
130134
}
131135
},
132136
"addons": [

lib/config/default.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,6 @@ module.exports = {
9494
tlsca: undefined
9595
},
9696
email: true,
97-
allowemailregister: true
97+
allowemailregister: true,
98+
allowpdfexport: true
9899
}

lib/config/environment.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,6 @@ module.exports = {
6969
tlsca: process.env.HMD_LDAP_TLS_CA
7070
},
7171
email: toBooleanConfig(process.env.HMD_EMAIL),
72-
allowemailregister: toBooleanConfig(process.env.HMD_ALLOW_EMAIL_REGISTER)
72+
allowemailregister: toBooleanConfig(process.env.HMD_ALLOW_EMAIL_REGISTER),
73+
allowpdfexport: toBooleanConfig(process.env.HMD_ALLOW_PDF_EXPORT)
7374
}

lib/config/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
'use strict'
23

34
const fs = require('fs')
@@ -90,6 +91,7 @@ config.isEmailEnable = config.email
9091
config.isGitHubEnable = config.github.clientID && config.github.clientSecret
9192
config.isGitLabEnable = config.gitlab.clientID && config.gitlab.clientSecret
9293
config.isLDAPEnable = config.ldap.url
94+
config.isPDFExportEnable = config.allowpdfexport
9395

9496
// generate correct path
9597
config.sslcapath = path.join(appRootPath, config.sslcapath)
@@ -106,7 +108,7 @@ config.errorpath = path.join(appRootPath, config.errorpath)
106108
config.prettypath = path.join(appRootPath, config.prettypath)
107109
config.slidepath = path.join(appRootPath, config.slidepath)
108110

109-
// maek config readonly
111+
// make config readonly
110112
config = deepFreeze(config)
111113

112114
module.exports = config

lib/response.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ function showIndex (req, res, next) {
6969
ldap: config.isLDAPEnable,
7070
email: config.isEmailEnable,
7171
allowemailregister: config.allowemailregister,
72+
allowpdfexport: config.allowpdfexport,
7273
signin: req.isAuthenticated(),
7374
infoMessage: req.flash('info'),
7475
errorMessage: req.flash('error')
@@ -98,7 +99,8 @@ function responseHackMD (res, note) {
9899
google: config.isGoogleEnable,
99100
ldap: config.isLDAPEnable,
100101
email: config.isEmailEnable,
101-
allowemailregister: config.allowemailregister
102+
allowemailregister: config.allowemailregister,
103+
allowpdfexport: config.allowpdfexport
102104
})
103105
}
104106

public/views/hackmd/header.ejs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,10 @@
7070
</li>
7171
<li role="presentation"><a role="menuitem" class="ui-download-raw-html" tabindex="-1" href="#" target="_self"><i class="fa fa-file-code-o fa-fw"></i> <%= __('Raw HTML') %></a>
7272
</li>
73-
<li role="presentation"><a role="menuitem" class="ui-download-pdf-beta" tabindex="-1" href="#" target="_self"><i class="fa fa-file-pdf-o fa-fw"></i> PDF (Beta)</a>
74-
</li>
73+
<% if(allowpdfexport) {%>
74+
<li role="presentation"><a role="menuitem" class="ui-download-pdf-beta" tabindex="-1" href="#" target="_self"><i class="fa fa-file-pdf-o fa-fw"></i> PDF (Beta)</a>
75+
</li>
76+
<% } %>
7577
<li class="divider"></li>
7678
<li role="presentation"><a role="menuitem" class="ui-help" href="#" data-toggle="modal" data-target=".help-modal"><i class="fa fa-question-circle fa-fw"></i> Help</a>
7779
</li>
@@ -169,8 +171,10 @@
169171
</li>
170172
<li role="presentation"><a role="menuitem" class="ui-download-raw-html" tabindex="-1" href="#" target="_self"><i class="fa fa-file-code-o fa-fw"></i> <%= __('Raw HTML') %></a>
171173
</li>
172-
<li role="presentation"><a role="menuitem" class="ui-download-pdf-beta" tabindex="-1" href="#" target="_self"><i class="fa fa-file-pdf-o fa-fw"></i> PDF (Beta)</a>
173-
</li>
174+
<% if(allowpdfexport) {%>
175+
<li role="presentation"><a role="menuitem" class="ui-download-pdf-beta" tabindex="-1" href="#" target="_self"><i class="fa fa-file-pdf-o fa-fw"></i> PDF (Beta)</a>
176+
</li>
177+
<% } %>
174178
</ul>
175179
</li>
176180
</ul>

0 commit comments

Comments
 (0)