summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Parecki <aaron@parecki.com>2015-09-08 22:55:56 -0700
committerAaron Parecki <aaron@parecki.com>2015-09-08 22:55:56 -0700
commit2bb18a66be585384acd5a4068a4311a976e28c57 (patch)
tree1f2dc711454a24d76f8004836419ed035f4e22f8
parent881550cac72bfcc2e7551fe13288ea8a1d27ca34 (diff)
add banner to opt in to html content change
-rw-r--r--controllers/controllers.php18
-rw-r--r--controllers/editor.php10
-rw-r--r--public/editor/editor.js12
-rw-r--r--public/editor/style.css26
-rw-r--r--views/editor.php8
5 files changed, 72 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);
diff --git a/public/editor/editor.js b/public/editor/editor.js
index 526a444..f0e9519 100644
--- a/public/editor/editor.js
+++ b/public/editor/editor.js
@@ -89,6 +89,18 @@ $(function() {
});
});
+ $("#micropub-html-btn").click(function(){
+ $.post('/settings/html-content', {
+ html: 1
+ }, function(data){
+ });
+ });
+
+ $.getJSON('/settings/html-content', function(data){
+ if(data.html == '0') {
+ $('.micropub-html-warning').show();
+ }
+ });
});
function reset_page() {
diff --git a/public/editor/style.css b/public/editor/style.css
index 8ae753a..6d02615 100644
--- a/public/editor/style.css
+++ b/public/editor/style.css
@@ -22,6 +22,32 @@ h1, h2, h3, h4, h5, h6, th, td, caption { font-weight:normal; }
img { border: 0; }
+.micropub-html-warning {
+ max-width: 600px;
+ margin-left: auto;
+ margin-right: auto;
+ margin-top: 68px;
+ margin-bottom: -80px;
+ font-size: 12px;
+ font-family: sans-serif;
+ line-height: 16px;
+ background: #fcf8e3;
+ border: 1px #faebcc solid;
+}
+.micropub-html-warning div {
+ padding: 10px 20px;
+}
+.micropub-html-warning button {
+ display: block;
+}
+#micropub-html-btn {
+ border-radius: 6px;
+ padding: 0 12px;
+ height: 28px;
+ background: #e4f8fa;
+ float: right;
+}
+
/* ************************************** */
/* Toolbar */
diff --git a/views/editor.php b/views/editor.php
index f5fd5f6..ac0f429 100644
--- a/views/editor.php
+++ b/views/editor.php
@@ -53,6 +53,14 @@
<div class="clear"></div>
</div>
+<div class="micropub-html-warning hidden"><div>
+ <button class="btn btn-default" id="micropub-html-btn">Upgrade me!</button>
+ <b>Upcoming change!</b>
+ The Micropub spec now requires HTML content be sent as a nested object, <code>content[html]=&lt;b&gt;example&lt;/b&gt;</code>.
+ You can <a href="http://indiewebcamp.com/Micropub-brainstorming#HTML_Escaping">read more about the change here</a>.
+ When you are ready to receive the content as an object, click the button to switch.
+</div></div>
+
<div class="publish-dropdown hidden">
<div class="arrow"></div>
<div class="dropdown-content action-publish">