-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinit.php
89 lines (68 loc) · 2.13 KB
/
init.php
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
// Modifyed based on andyt's version (https://tt-rss.org/oldforum/viewtopic.php?f=22&t=1401)
class Instapaper extends Plugin{
private $host;
public function about()
{
return array(
1.0,
'Share via Instapaper',
'andyt',
);
}//end about()
public function init($host)
{
$this->host = $host;
$host->add_hook($host::HOOK_ARTICLE_BUTTON, $this);
$host->add_hook($host::HOOK_HOTKEY_MAP, $this);
}//end init()
public function get_js()
{
return file_get_contents(__DIR__.'/instapaper.js');
}//end get_js()
function get_css() {
return file_get_contents(__DIR__ . "/instapaper.css");
}
function hook_hotkey_map($hotkeys) {
// Trigger App.hotkey_actions
$hotkeys['i'] = "instapaper";
// VIM style scrolling
$hotkeys["j"] = "article_scroll_down";
$hotkeys["k"] = "article_scroll_up";
return $hotkeys;
}
public function hook_article_button($line)
{
return "<i class='icon-instapaper' onclick='shareArticleToInstapaper({$line["id"]})' style='cursor : pointer' title=\"".__('Read it Later')."\">Instapaper</i>
";
}//end hook_article_button()
public function getInfo()
{
$id = $_REQUEST['id'];
$st = $this->pdo->prepare(
'
SELECT title, link FROM ttrss_entries, ttrss_user_entries
WHERE id=? and ref_id=id AND owner_uid=?
'
);
$st->execute([$id, $_SESSION['uid']]);
if ($result = $st->fetch()) {
$title = truncate_string(strip_tags($result['title']), 100, '...');
$link = $result['link'];
print json_encode(
array(
'title' => $title,
'link' => $link,
'id' => $id,
'uid' => $_SESSION['uid'],
)
);
} else {
print json_encode(false);
}
}//end getInfo()
public function api_version()
{
return 2;
}//end api_version()
}//end class