Initial version that only shows a "Reply with Quill" button
[tt-rss-micropub.git] / init.php
1 <?php
2 /**
3  * Simple Micropub client to post reponses
4  *
5  * PHP version 5
6  *
7  * @author  Christian Weiske <cweiske@cweiske.de>
8  * @license AGPLv3 or later
9  * @link    https://www.w3.org/TR/micropub/
10  */
11 class Micropub extends Plugin
12 {
13     public function about()
14     {
15         return array(
16             0.1,
17             'Micropub',
18             'cweiske',
19             false
20         );
21     }
22     
23     public function init($host)
24     {
25         $host->add_hook($host::HOOK_RENDER_ARTICLE, $this);
26     }
27
28     function get_css()
29     {
30         return file_get_contents(__DIR__ . '/init.css');
31     }
32
33     /**
34      * @param array $article Article data. Keys:
35      *                       - id 
36      *                       - title 
37      *                       - link 
38      *                       - content 
39      *                       - feed_id 
40      *                       - comments 
41      *                       - int_id 
42      *                       - lang 
43      *                       - updated 
44      *                       - site_url 
45      *                       - feed_title 
46      *                       - hide_images 
47      *                       - always_display_enclosures 
48      *                       - num_comments 
49      *                       - author 
50      *                       - guid 
51      *                       - orig_feed_id 
52      *                       - note 
53      *                       - tags 
54      */
55     public function hook_render_article($article)
56     {
57         $quillUrl = 'https://quill.p3k.io/new'
58             . '?reply=' . urlencode($article['link']);
59         $hQuillUrl = htmlspecialchars($quillUrl);
60         // did I tell you I hate dojo/dijit?
61         $article['content'] .= '<div class="reply">'
62             . '<a href="' . $hQuillUrl . '" class="mpbutton">'
63             . 'Reply with Quill'
64             . '</a>'
65             . '</div>';
66         return $article;
67     }
68
69     public function api_version()
70     {
71         return 2;
72     }
73 }
74 ?>