summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2015-07-08 10:35:29 +0300
committerAndrew Dolgov <[email protected]>2015-07-08 10:35:29 +0300
commit25c747f5767a0588d2079b036fa89873067f924f (patch)
tree45ab0124faf0f09c0433c198ed9a66f5db38f678 /plugins
parent831129f6a4c63530674c8bc73550fc83998971f3 (diff)
parent3cea4a4b758768770366d132393a026ee2d8a430 (diff)
Merge branch 'master' of git.fakecake.org:tt-rss
Diffstat (limited to 'plugins')
-rw-r--r--plugins/af_redditimgur/init.php4
-rw-r--r--plugins/cache_starred_images/init.php26
-rw-r--r--plugins/shorten_expanded/init.css2
-rw-r--r--plugins/shorten_expanded/init.js4
4 files changed, 20 insertions, 16 deletions
diff --git a/plugins/af_redditimgur/init.php b/plugins/af_redditimgur/init.php
index ae500c521..7eafec682 100644
--- a/plugins/af_redditimgur/init.php
+++ b/plugins/af_redditimgur/init.php
@@ -114,8 +114,8 @@ class Af_RedditImgur extends Plugin {
}
$matches = array();
- if (preg_match("/\/\/www\.youtube\.com\/v\/([\w-]+)/", $entry->getAttribute("href"), $matches) ||
- preg_match("/\/\/www\.youtube\.com\/watch\?v=([\w-]+)/", $entry->getAttribute("href"), $matches) ||
+ if (preg_match("/\.youtube\.com\/v\/([\w-]+)/", $entry->getAttribute("href"), $matches) ||
+ preg_match("/\.youtube\.com\/watch\?v=([\w-]+)/", $entry->getAttribute("href"), $matches) ||
preg_match("/\/\/youtu.be\/([\w-]+)/", $entry->getAttribute("href"), $matches)) {
$vid_id = $matches[1];
diff --git a/plugins/cache_starred_images/init.php b/plugins/cache_starred_images/init.php
index b851479c0..f1341a350 100644
--- a/plugins/cache_starred_images/init.php
+++ b/plugins/cache_starred_images/init.php
@@ -6,7 +6,7 @@ class Cache_Starred_Images extends Plugin implements IHandler {
function about() {
return array(1.0,
- "Automatically cache images in Starred articles",
+ "Automatically cache Starred articles' images and HTML5 video files",
"fox",
true);
}
@@ -59,7 +59,8 @@ class Cache_Starred_Images extends Plugin implements IHandler {
if ($hash) {
- $filename = $this->cache_dir . "/" . $hash . '.png';
+ $filename = $this->cache_dir . "/" . $hash;
+ $is_video = strpos($filename, ".mp4") !== FALSE;
if (file_exists($filename)) {
/* See if we can use X-Sendfile */
@@ -73,7 +74,7 @@ class Cache_Starred_Images extends Plugin implements IHandler {
header("Content-type: application/octet-stream");
header('Content-Disposition: attachment; filename="' . basename($filename) . '"');
} else {
- header("Content-type: image/png");
+ header("Content-type: " . ($is_video ? "video/mp4" : "image/png"));
$stamp = gmdate("D, d M Y H:i:s", filemtime($filename)). " GMT";
header("Last-Modified: $stamp", true);
readfile($filename);
@@ -86,7 +87,7 @@ class Cache_Starred_Images extends Plugin implements IHandler {
}
function hook_house_keeping() {
- $files = glob($this->cache_dir . "/*.png");
+ $files = glob($this->cache_dir . "/*.{png,mp4}", GLOB_BRACE);
$last_article_id = 0;
$article_exists = 1;
@@ -113,18 +114,19 @@ class Cache_Starred_Images extends Plugin implements IHandler {
$xpath = new DOMXpath($doc);
if ($article_id) {
- $entries = $xpath->query('(//img[@src])');
+ $entries = $xpath->query('(//img[@src])|(//video/source[@src])');
foreach ($entries as $entry) {
if ($entry->hasAttribute('src')) {
$src = rewrite_relative_url($site_url, $entry->getAttribute('src'));
- $local_filename = $this->cache_dir . $article_id . "-" . sha1($src) . ".png";
+ $extension = $entry->tagName == 'source' ? '.mp4' : '.png';
+ $local_filename = $this->cache_dir . $article_id . "-" . sha1($src) . $extension;
if (file_exists($local_filename)) {
$entry->setAttribute("src", get_self_url_prefix() .
"/public.php?op=cache_starred_images_getimage&method=image&hash=" .
- $article_id . "-" . sha1($src));
+ $article_id . "-" . sha1($src) . $extension);
}
}
@@ -140,12 +142,11 @@ class Cache_Starred_Images extends Plugin implements IHandler {
(ttrss_user_entries.feed_id = ttrss_feeds.id)
WHERE ref_id = ttrss_entries.id AND
marked = true AND
- UPPER(content) LIKE '%<IMG%' AND
+ (UPPER(content) LIKE '%<IMG%' OR UPPER(content) LIKE '%<VIDEO%') AND
site_url != '' AND
plugin_data NOT LIKE '%starred_cache_images%'
ORDER BY ".sql_random_function()." LIMIT 100");
-
while ($line = db_fetch_assoc($result)) {
if ($line["site_url"]) {
$success = $this->cache_article_images($line["content"], $line["site_url"], $line["owner_uid"], $line["id"]);
@@ -170,17 +171,20 @@ class Cache_Starred_Images extends Plugin implements IHandler {
$doc->loadHTML($charset_hack . $content);
$xpath = new DOMXPath($doc);
- $entries = $xpath->query('(//img[@src])');
+ $entries = $xpath->query('(//img[@src])|(//video/source[@src])');
$success = false;
$has_images = false;
foreach ($entries as $entry) {
+
if ($entry->hasAttribute('src')) {
$has_images = true;
$src = rewrite_relative_url($site_url, $entry->getAttribute('src'));
- $local_filename = $this->cache_dir . $article_id . "-" . sha1($src) . ".png";
+ $extension = $entry->tagName == 'source' ? '.mp4' : '.png';
+
+ $local_filename = $this->cache_dir . $article_id . "-" . sha1($src) . $extension;
//_debug("cache_images: downloading: $src to $local_filename");
diff --git a/plugins/shorten_expanded/init.css b/plugins/shorten_expanded/init.css
index 5e1bfa8f3..920e38415 100644
--- a/plugins/shorten_expanded/init.css
+++ b/plugins/shorten_expanded/init.css
@@ -1,7 +1,7 @@
div.contentSizeWrapper {
overflow : hidden;
text-overflow: ellipsis;
- height : 700px;
+ height : 800px;
}
button.expandPrompt {
diff --git a/plugins/shorten_expanded/init.js b/plugins/shorten_expanded/init.js
index ba82b643b..4d80f8407 100644
--- a/plugins/shorten_expanded/init.js
+++ b/plugins/shorten_expanded/init.js
@@ -1,4 +1,4 @@
-var _shorten_expanded_threshold = 900; //px, longer than css height so that we would only clip articles significantly longer than limit
+var _shorten_expanded_threshold = 1.5; //window heights
function expandSizeWrapper(id) {
try {
@@ -28,7 +28,7 @@ dojo.addOnLoad(function() {
window.setTimeout(function() {
if (row) {
- if (row.offsetHeight >= _shorten_expanded_threshold) {
+ if (row.offsetHeight >= _shorten_expanded_threshold * window.innerHeight) {
var content = row.select(".cdmContentInner")[0];
if (content) {