summaryrefslogtreecommitdiff
path: root/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'controllers')
-rw-r--r--controllers/controllers.php18
-rw-r--r--controllers/editor.php10
2 files changed, 26 insertions, 2 deletions
diff --git a/controllers/controllers.php b/controllers/controllers.php
index b3e23a7..70e84cf 100644
--- a/controllers/controllers.php
+++ b/controllers/controllers.php
@@ -271,6 +271,24 @@ $app->get('/settings', function() use($app) {
}
});
+$app->post('/settings/html-content', function() use($app) {
+ if($user=require_login($app)) {
+ $params = $app->request()->params();
+ $user->micropub_optin_html_content = $params['html'] ? 1 : 0;
+ $user->save();
+ $app->response()->body(json_encode(array(
+ 'html' => $user->micropub_optin_html_content
+ )));
+ }
+});
+$app->get('/settings/html-content', function() use($app) {
+ if($user=require_login($app)) {
+ $app->response()->body(json_encode(array(
+ 'html' => $user->micropub_optin_html_content
+ )));
+ }
+});
+
$app->get('/favorite-popup', function() use($app) {
if($user=require_login($app)) {
$params = $app->request()->params();
diff --git a/controllers/editor.php b/controllers/editor.php
index 71d9f4b..077adcb 100644
--- a/controllers/editor.php
+++ b/controllers/editor.php
@@ -11,10 +11,16 @@ $app->post('/editor/publish', function() use($app) {
if($user=require_login($app)) {
$params = $app->request()->params();
+ $content = $params['body'];
+
+ if($user->micropub_optin_html_content) {
+ $content = ['html' => $params['body']];
+ }
+
$micropub_request = array(
'h' => 'entry',
'name' => $params['name'],
- 'content' => $params['body']
+ 'content' => $content
);
$r = micropub_post_for_user($user, $micropub_request);
@@ -62,7 +68,7 @@ $app->post('/editor/test-login', function() use($app) {
});
$app->get('/appcache.manifest', function() use($app) {
- $content = partial('partials/appcache');
+ $content = partial('-partials/appcache');
$app->response()['Content-type'] = 'text/cache-manifest';
$app->response()->body($content);