summaryrefslogtreecommitdiff
path: root/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'controllers')
-rw-r--r--controllers/controllers.php54
-rw-r--r--controllers/editor.php11
-rw-r--r--controllers/static.php19
3 files changed, 50 insertions, 34 deletions
diff --git a/controllers/controllers.php b/controllers/controllers.php
index 8ffaedb..1c3db83 100644
--- a/controllers/controllers.php
+++ b/controllers/controllers.php
@@ -44,11 +44,10 @@ function generate_login_token() {
$app->get('/dashboard', function() use($app) {
if($user=require_login($app)) {
- $html = render('dashboard', array(
+ render('dashboard', array(
'title' => 'Dashboard',
'authorizing' => false
));
- $app->response()->body($html);
}
});
@@ -73,7 +72,7 @@ $app->get('/new', function() use($app) {
}
}
- $html = render('new-post', array(
+ render('new-post', array(
'title' => 'New Post',
'in_reply_to' => $in_reply_to,
'micropub_endpoint' => $user->micropub_endpoint,
@@ -87,7 +86,6 @@ $app->get('/new', function() use($app) {
'user' => $user,
'authorizing' => false
));
- $app->response()->body($html);
}
});
@@ -109,7 +107,7 @@ $app->get('/bookmark', function() use($app) {
if(array_key_exists('content', $params))
$content = $params['content'];
- $html = render('new-bookmark', array(
+ render('new-bookmark', array(
'title' => 'New Bookmark',
'bookmark_url' => $url,
'bookmark_name' => $name,
@@ -119,7 +117,6 @@ $app->get('/bookmark', function() use($app) {
'syndication_targets' => json_decode($user->syndication_targets, true),
'authorizing' => false
));
- $app->response()->body($html);
}
});
@@ -132,13 +129,12 @@ $app->get('/favorite', function() use($app) {
if(array_key_exists('url', $params))
$url = $params['url'];
- $html = render('new-favorite', array(
+ render('new-favorite', array(
'title' => 'New Favorite',
'url' => $url,
'token' => generate_login_token(),
'authorizing' => false
));
- $app->response()->body($html);
}
});
@@ -146,11 +142,10 @@ $app->get('/event', function() use($app) {
if($user=require_login($app)) {
$params = $app->request()->params();
- $html = render('event', array(
+ render('event', array(
'title' => 'Event',
'authorizing' => false
));
- $app->response()->body($html);
}
});
@@ -158,11 +153,10 @@ $app->get('/itinerary', function() use($app) {
if($user=require_login($app)) {
$params = $app->request()->params();
- $html = render('new-itinerary', array(
+ render('new-itinerary', array(
'title' => 'Itinerary',
'authorizing' => false
));
- $app->response()->body($html);
}
});
@@ -170,12 +164,11 @@ $app->get('/photo', function() use($app) {
if($user=require_login($app)) {
$params = $app->request()->params();
- $html = render('photo', array(
+ render('photo', array(
'title' => 'New Photo',
'note_content' => '',
'authorizing' => false
));
- $app->response()->body($html);
}
});
@@ -183,11 +176,10 @@ $app->get('/review', function() use($app) {
if($user=require_login($app)) {
$params = $app->request()->params();
- $html = render('review', array(
+ render('review', array(
'title' => 'Review',
'authorizing' => false
));
- $app->response()->body($html);
}
});
@@ -200,13 +192,12 @@ $app->get('/repost', function() use($app) {
if(array_key_exists('url', $params))
$url = $params['url'];
- $html = render('new-repost', array(
+ render('new-repost', array(
'title' => 'New Repost',
'url' => $url,
'token' => generate_login_token(),
'authorizing' => false
));
- $app->response()->body($html);
}
});
@@ -258,8 +249,7 @@ $app->get('/add-to-home', function() use($app) {
$app->redirect('/add-to-home?token='.$token, 301);
} else {
unset($_SESSION['add-to-home-started']);
- $html = render('add-to-home', array('title' => 'Quill'));
- $app->response()->body($html);
+ render('add-to-home', array('title' => 'Quill'));
}
}
}
@@ -285,24 +275,40 @@ $app->get('/email', function() use($app) {
$user->save();
}
- $html = render('email', array(
+ render('email', array(
'title' => 'Post-by-Email',
'micropub_endpoint' => $user->micropub_endpoint,
'test_response' => $test_response,
'user' => $user
));
- $app->response()->body($html);
}
});
$app->get('/settings', function() use($app) {
if($user=require_login($app)) {
- $html = render('settings', [
+ render('settings', [
'title' => 'Settings',
'user' => $user,
'authorizing' => false
]);
- $app->response()->body($html);
+ }
+});
+
+$app->post('/settings/save', function() use($app) {
+ if($user=require_login($app)) {
+ $params = $app->request()->params();
+
+ if(array_key_exists('html_content', $params))
+ $user->micropub_optin_html_content = $params['html_content'] ? 1 : 0;
+
+ if(array_key_exists('slug_field', $params) && $params['slug_field'])
+ $user->micropub_slug_field = $params['slug_field'];
+
+ $user->save();
+ $app->response()['Content-type'] = 'application/json';
+ $app->response()->body(json_encode(array(
+ 'result' => 'ok'
+ )));
}
});
diff --git a/controllers/editor.php b/controllers/editor.php
index 3818328..0f4380b 100644
--- a/controllers/editor.php
+++ b/controllers/editor.php
@@ -25,6 +25,17 @@ $app->post('/editor/publish', function() use($app) {
'content' => $content
);
+ if(array_key_exists('category', $params) && $params['category'])
+ $micropub_request['category'] = $params['category'];
+
+ if(array_key_exists('slug', $params) && $params['slug'])
+ $micropub_request[$user->micropub_slug_field] = $params['slug'];
+
+ if(array_key_exists('status', $params) && $params['status']) {
+ if($params['status'] == 'draft')
+ $micropub_request['post-status'] = $params['status'];
+ }
+
$r = micropub_post_for_user($user, $micropub_request);
$app->response()['Content-type'] = 'application/json';
diff --git a/controllers/static.php b/controllers/static.php
index bf9740d..c53fa14 100644
--- a/controllers/static.php
+++ b/controllers/static.php
@@ -7,14 +7,11 @@ $app->get('/', function($format='html') use($app) {
$app->redirect('/auth/start?'.http_build_query($params), 302);
}
- ob_start();
render('index', array(
'title' => 'Quill',
'meta' => '',
'authorizing' => false
));
- $html = ob_get_clean();
- $res->body($html);
});
$app->get('/creating-a-token-endpoint', function() use($app) {
@@ -22,16 +19,18 @@ $app->get('/creating-a-token-endpoint', function() use($app) {
});
$app->get('/creating-a-micropub-endpoint', function() use($app) {
- $html = render('creating-a-micropub-endpoint', array('title' => 'Creating a Micropub Endpoint', 'authorizing' => false));
- $app->response()->body($html);
+ render('creating-a-micropub-endpoint', array('title' => 'Creating a Micropub Endpoint', 'authorizing' => false));
});
$app->get('/docs', function() use($app) {
- $html = render('docs', array('title' => 'Documentation', 'authorizing' => false));
- $app->response()->body($html);
+ render('docs', array('title' => 'Documentation', 'authorizing' => false));
+});
+
+$app->get('/docs/post-status', function() use($app) {
+ render('docs/post-status', array('title' => 'Post Status Documentation', 'authorizing' => false));
});
$app->get('/privacy', function() use($app) {
- $html = render('privacy', array('title' => 'Quill Privacy Policy', 'authorizing' => false));
- $app->response()->body($html);
-}); \ No newline at end of file
+ render('privacy', array('title' => 'Quill Privacy Policy', 'authorizing' => false));
+});
+