-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo.json
More file actions
33 lines (33 loc) · 5.66 KB
/
Copy pathdemo.json
File metadata and controls
33 lines (33 loc) · 5.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
{
"$schema": "https://playground.wordpress.net/blueprint-schema.json",
"meta": {
"title": "Send to E-Reader (Demo)",
"description": "Send posts to your e-reader as ePub files, by email or direct download. Works standalone or integrates with the Friends plugin. Pre-loaded with a handful of posts and two configured e-readers, so the row and bulk actions on the Posts screen work right away.",
"author": "Alex Kirk",
"categories": [
"Apps",
"Publishing"
]
},
"landingPage": "/wp-admin/edit.php",
"login": true,
"steps": [
{
"step": "installPlugin",
"pluginData": {
"resource": "git:directory",
"url": "https://github.com/akirk/send-to-e-reader",
"ref": "dist/main",
"refType": "branch"
},
"options": {
"activate": true,
"targetFolderName": "send-to-e-reader"
}
},
{
"step": "runPHP",
"code": "<?php\nrequire_once '/wordpress/wp-load.php';\n\n$posts = array(\n\tarray(\n\t\t'title' => 'Why an ePub beats a browser tab',\n\t\t'content' => \"<p>A reading list that lives in browser tabs is a reading list you will never finish. The tabs are on the wrong device, they reflow badly on a small screen, and every one of them is one notification away from being closed.</p>\\n\\n<p>An ePub is the opposite. It is a single file, it is finished the moment it is built, and the device it lands on has one job. There is no address bar to wander off into.</p>\\n\\n<p>The trick is getting the article out of the browser and onto the device without a cable, a conversion service, or a second account. That is the whole problem this plugin solves.</p>\",\n\t),\n\tarray(\n\t\t'title' => 'What goes into the file',\n\t\t'content' => \"<p>Each post becomes one chapter. The chapter opens with the post title, carries the byline and the permalink, and then the post content itself, converted to XHTML so that the e-reader's renderer accepts it without complaint.</p>\\n\\n<p>Images in the post body are pulled into the file rather than linked, including the ones hosted on the same site. That matters on a device that spends most of its life offline: an article whose illustrations are missing is usually an article that no longer makes sense.</p>\\n\\n<p>Select several posts and they become several chapters in one file, with a title page in front. One file, one transfer, one thing to find on the device.</p>\",\n\t),\n\tarray(\n\t\t'title' => 'Sending to more than one device',\n\t\t'content' => \"<p>Most people end up with more than one place to send things: the e-reader by the bed, a tablet, and a plain download for everything else.</p>\\n\\n<p>Configure each of them once on the E-Readers screen. From then on the Posts screen offers one row action and one bulk action per device, so choosing where an article goes is a single click rather than a trip back through the settings.</p>\\n\\n<p>Delivery goes through WordPress's own mail, so whatever the site already uses to send mail is what carries the file.</p>\",\n\t),\n\tarray(\n\t\t'title' => 'A long one, for testing pagination',\n\t\t'content' => \"<p>Short posts do not tell you much about how a file will read on a device. This one is deliberately longer, so the chapter runs over several screens and you can see how headings, lists and quotes survive the trip.</p>\\n\\n<h2>Headings</h2>\\n\\n<p>A heading should still look like a heading after conversion, and it should not collide with the paragraph underneath it.</p>\\n\\n<h3>A smaller heading</h3>\\n\\n<p>Nested headings are where converters usually start to disagree with each other.</p>\\n\\n<h2>Lists</h2>\\n\\n<ul><li>An unordered list, with a first item that runs on a little longer than the others so that at least one item has to wrap.</li><li>A shorter one.</li><li>And a third.</li></ul>\\n\\n<ol><li>An ordered list.</li><li>Because numbering is its own kind of trouble.</li></ol>\\n\\n<h2>Quotes and code</h2>\\n\\n<blockquote><p>A block quote, indented, and long enough that it wraps onto a second line on a phone-sized screen.</p></blockquote>\\n\\n<p>Inline <code>code</code> should stay monospaced, and a block should keep its line breaks:</p>\\n\\n<pre><code>wp send-to-e-reader --help</code></pre>\\n\\n<h2>The end</h2>\\n\\n<p>If everything above survived, the rest of your posts almost certainly will too.</p>\",\n\t),\n\tarray(\n\t\t'title' => 'One that is already sent',\n\t\t'content' => \"<p>The plugin remembers which posts it has already put on a device, so a second pass over the same list can skip them.</p>\\n\\n<p>This post is marked as already sent, so you can see how that looks before sending anything yourself.</p>\",\n\t),\n);\n\n$post_ids = array();\nforeach ( $posts as $index => $post ) {\n\t$post_ids[] = wp_insert_post(\n\t\tarray(\n\t\t\t'post_title' => $post['title'],\n\t\t\t'post_content' => $post['content'],\n\t\t\t'post_status' => 'publish',\n\t\t\t'post_type' => 'post',\n\t\t\t'post_author' => 1,\n\t\t\t'post_date' => gmdate( 'Y-m-d H:i:s', time() - ( ( count( $posts ) - $index ) * DAY_IN_SECONDS ) ),\n\t\t)\n\t);\n}\n\n// Mark the last one as already sent so the \"already sent\" state is visible.\nupdate_post_meta( end( $post_ids ), 'sent-to-ereader', time() - HOUR_IN_SECONDS );\n\n// Add a second e-reader next to the \"Download ePub\" one the activation hook\n// creates, so that the per-e-reader row and bulk actions are visible.\nif ( class_exists( 'Send_To_E_Reader\\E_Reader_Kindle' ) ) {\n\t$option = 'send-to-e-reader_readers';\n\t$ereaders = get_option( $option, array() );\n\t$kindle = new Send_To_E_Reader\\E_Reader_Kindle( 'My Kindle', 'demo@free.kindle.com' );\n\t$kindle->active = true;\n\t$id = $kindle->get_id();\n\tif ( $id ) {\n\t\t$ereaders[ $id ] = $kindle;\n\t\tupdate_option( $option, $ereaders );\n\t}\n}\n"
}
]
}