Skip to content

Commit b6033d8

Browse files
committed
Option forceSsl added
1 parent 5ee33c3 commit b6033d8

File tree

5 files changed

+18
-1
lines changed

5 files changed

+18
-1
lines changed

app/source/classes/Controller/APIController.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,8 @@ public function updateSettings($request, $response, $args) {
11331133
'hbs_cache' => $params['hbs-cache'] === 'on' ? 'on' : 'off',
11341134
'mailer' => $params['mailer'],
11351135
'showDashboard' => $params['showDashboard'] === 'on' ? 'on' : 'off',
1136-
'amp' => $params['amp'] === 'on' ? 'on' : 'off'
1136+
'amp' => $params['amp'] === 'on' ? 'on' : 'off',
1137+
'forceSsl' => $params['forceSsl'] === 'on' ? 'on' : 'off',
11371138
];
11381139

11391140
// Update settings

app/source/classes/Leafpub.php

+3
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,9 @@ public static function isProtectedSlug($slug) {
308308
*
309309
**/
310310
public static function isSsl() {
311+
if (Setting::getOne('forceSsl') == 'on'){
312+
return true;
313+
}
311314
// Some servers (e.g. Cloud9) don't populate $_SERVER[HTTPS], so we have to check the value
312315
// of $_SERVER[REQUEST_SCHEME] instead.
313316
if($_SERVER['REQUEST_SCHEME'] === 'https') return true;

app/source/installer/install.php

+1
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@
230230
Models\Setting::create(['name' => 'mailer', 'value' => 'default']);
231231
Models\Setting::create(['name' => 'schemeVersion', 'value' => LEAFPUB_SCHEME_VERSION]);
232232
Models\Setting::create(['name' => 'updateTime', 'value' => '03:00:00']);
233+
Models\Setting::create(['name' => 'forceSsl', 'value' => 'off']);
233234

234235
// Insert owner
235236
try {

app/source/languages/en-us.php

+1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
'feed' => 'Feed',
8282
'file_edited_successfully' => 'File edited successfully',
8383
'file_deleted_successfully' => 'File deleted successfully',
84+
'forceSsl' => 'Deliver Leafpub with https',
8485
'full_name' => 'Full Name',
8586
'general' => 'General',
8687
'generator_enabled' => 'Show some love and add generator meta to head',

app/source/templates/settings.hbs

+11
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@
238238
</label>
239239
</div>
240240
</div>
241+
{{!-- showDashboard --}}
241242
<div class="form-group">
242243
<div class="checkbox">
243244
<label>
@@ -246,6 +247,7 @@
246247
</label>
247248
</div>
248249
</div>
250+
{{!-- AMP --}}
249251
<div class="form-group">
250252
<div class="checkbox">
251253
<label>
@@ -254,6 +256,15 @@
254256
</label>
255257
</div>
256258
</div>
259+
{{!-- forceSSL --}}
260+
<div class="form-group">
261+
<div class="checkbox">
262+
<label>
263+
<input type="checkbox" name="forceSsl" value="on"{{#is @settings.forceSsl 'on'}} checked{{/is}}>
264+
{{L 'forceSsl'}}<br>
265+
</label>
266+
</div>
267+
</div>
257268
{{!-- Mail --}}
258269
<h3 class="m-t-3">{{L 'mail'}}</h3>
259270
{{!-- Mailers --}}

0 commit comments

Comments
 (0)