]> git.wh0rd.org - tt-rss.git/commitdiff
Merge branch 'tribut-enclosure-size'
authorAndrew Dolgov <noreply@fakecake.org>
Wed, 16 Jul 2014 07:49:37 +0000 (11:49 +0400)
committerAndrew Dolgov <noreply@fakecake.org>
Wed, 16 Jul 2014 07:49:37 +0000 (11:49 +0400)
classes/feedenclosure.php
classes/feeditem/atom.php
classes/feeditem/rss.php
include/functions.php
include/functions2.php
include/rssfuncs.php
schema/ttrss_schema_mysql.sql
schema/ttrss_schema_pgsql.sql
schema/versions/mysql/126.sql [new file with mode: 0644]
schema/versions/pgsql/126.sql [new file with mode: 0644]

index b57100b0600bb35448694ac892f8e477ea25a541..64f1a0616aa89df2ececa1fb8dbe8c485a1d8aa2 100644 (file)
@@ -4,5 +4,7 @@ class FeedEnclosure {
        public $type;
        public $length;
        public $title;
+       public $height;
+       public $width;
 }
 ?>
index 48e3aa567173e7067f89d88002a7d429a3e37034..dfac7149f6cb4981cd6d768dd36e3600b80dd438 100644 (file)
@@ -145,6 +145,8 @@ class FeedItem_Atom extends FeedItem_Common {
                        $enc->type = $enclosure->getAttribute("type");
                        $enc->link = $enclosure->getAttribute("url");
                        $enc->length = $enclosure->getAttribute("length");
+                       $enc->height = $enclosure->getAttribute("height");
+                       $enc->width = $enclosure->getAttribute("width");
 
                        $desc = $this->xpath->query("media:description", $enclosure)->item(0);
                        if ($desc) $enc->title = strip_tags($desc->nodeValue);
@@ -164,6 +166,8 @@ class FeedItem_Atom extends FeedItem_Common {
                                $enc->type = $content->getAttribute("type");
                                $enc->link = $content->getAttribute("url");
                                $enc->length = $content->getAttribute("length");
+                               $enc->height = $content->getAttribute("height");
+                               $enc->width = $content->getAttribute("width");
 
                                $desc = $this->xpath->query("media:description", $content)->item(0);
                                if ($desc) {
@@ -184,6 +188,8 @@ class FeedItem_Atom extends FeedItem_Common {
 
                        $enc->type = "image/generic";
                        $enc->link = $enclosure->getAttribute("url");
+                       $enc->height = $enclosure->getAttribute("height");
+                       $enc->width = $enclosure->getAttribute("width");
 
                        array_push($encs, $enc);
                }
index bf08a1dfefe747a47c1192613d45cbd22eae0998..c9a7467cda6581b6d00ec788c08a64d5c7d6345e 100644 (file)
@@ -113,6 +113,8 @@ class FeedItem_RSS extends FeedItem_Common {
                        $enc->type = $enclosure->getAttribute("type");
                        $enc->link = $enclosure->getAttribute("url");
                        $enc->length = $enclosure->getAttribute("length");
+                       $enc->height = $enclosure->getAttribute("height");
+                       $enc->width = $enclosure->getAttribute("width");
 
                        array_push($encs, $enc);
                }
@@ -125,6 +127,8 @@ class FeedItem_RSS extends FeedItem_Common {
                        $enc->type = $enclosure->getAttribute("type");
                        $enc->link = $enclosure->getAttribute("url");
                        $enc->length = $enclosure->getAttribute("length");
+                       $enc->height = $enclosure->getAttribute("height");
+                       $enc->width = $enclosure->getAttribute("width");
 
                        $desc = $this->xpath->query("media:description", $enclosure)->item(0);
                        if ($desc) $enc->title = strip_tags($desc->nodeValue);
@@ -144,6 +148,8 @@ class FeedItem_RSS extends FeedItem_Common {
                                $enc->type = $content->getAttribute("type");
                                $enc->link = $content->getAttribute("url");
                                $enc->length = $content->getAttribute("length");
+                               $enc->height = $content->getAttribute("height");
+                               $enc->width = $content->getAttribute("width");
 
                                $desc = $this->xpath->query("media:description", $content)->item(0);
                                if ($desc) {
@@ -164,6 +170,8 @@ class FeedItem_RSS extends FeedItem_Common {
 
                        $enc->type = "image/generic";
                        $enc->link = $enclosure->getAttribute("url");
+                       $enc->height = $enclosure->getAttribute("height");
+                       $enc->width = $enclosure->getAttribute("width");
 
                        array_push($encs, $enc);
                }
index b5d52ccb2d25e444ae286dc53c911bccbc6faa96..cb91b637e1bfcb534ef8f8421afa6c2c0a8cdc73 100644 (file)
@@ -1,6 +1,6 @@
 <?php
        define('EXPECTED_CONFIG_VERSION', 26);
-       define('SCHEMA_VERSION', 125);
+       define('SCHEMA_VERSION', 126);
 
        define('LABEL_BASE_INDEX', -1024);
        define('PLUGIN_FEED_BASE_INDEX', -128);
index d6a399ffcdd9a1fd4db9a5c7740abfe9ceb4d00d..07024d38fadf00cfaf924f73b36bdd73b25d7679 100644 (file)
                                $url = $line["content_url"];
                                $ctype = $line["content_type"];
                                $title = $line["title"];
+                               $width = $line["width"];
+                               $height = $line["height"];
 
                                if (!$ctype) $ctype = __("unknown type");
 
                                $entry["filename"] = $filename;
                                $entry["url"] = $url;
                                $entry["title"] = $title;
+                               $entry["width"] = $width;
+                               $entry["height"] = $height;
 
                                array_push($entries, $entry);
                        }
                                                                preg_match("/\.(jpg|png|gif|bmp)/i", $entry["filename"])) {
 
                                                                if (!$hide_images) {
+                                                                       $encsize = '';
+                                                                       if ($entry['height'] > 0)
+                                                                               $encsize .= ' height="' . intval($entry['width']) . '"';
+                                                                       if ($entry['width'] > 0)
+                                                                               $encsize .= ' width="' . intval($entry['height']) . '"';
                                                                        $rv .= "<p><img
                                                                        alt=\"".htmlspecialchars($entry["filename"])."\"
-                                                                       src=\"" .htmlspecialchars($entry["url"]) . "\"/></p>";
+                                                                       src=\"" .htmlspecialchars($entry["url"]) . "\"
+                                                                       " . $encsize . " /></p>";
                                                                } else {
                                                                        $rv .= "<p><a target=\"_blank\"
                                                                        href=\"".htmlspecialchars($entry["url"])."\"
                curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0 Firefox/5.0');
                curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
                curl_setopt($curl, CURLOPT_HEADER, true);
+               curl_setopt($curl, CURLOPT_NOBODY, true);
                curl_setopt($curl, CURLOPT_REFERER, $url);
                curl_setopt($curl, CURLOPT_ENCODING, 'gzip,deflate');
                curl_setopt($curl, CURLOPT_AUTOREFERER, true);
index 60cb3b2d24a007cbbee15612736f1f54a5dcdf82..cdc490cb09d9f0440455884c29252d5bf7d14d08 100644 (file)
                                if (is_array($encs)) {
                                        foreach ($encs as $e) {
                                                $e_item = array(
-                                                       $e->link, $e->type, $e->length, $e->title);
+                                                       $e->link, $e->type, $e->length, $e->title, $e->width, $e->height);
                                                array_push($enclosures, $e_item);
                                        }
                                }
                                        $enc_type = db_escape_string($enc[1]);
                                        $enc_dur = db_escape_string($enc[2]);
                                        $enc_title = db_escape_string($enc[3]);
+                                       $enc_width = intval($enc[4]);
+                                       $enc_height = intval($enc[5]);
 
                                        $result = db_query("SELECT id FROM ttrss_enclosures
                                                WHERE content_url = '$enc_url' AND post_id = '$entry_ref_id'");
 
                                        if (db_num_rows($result) == 0) {
                                                db_query("INSERT INTO ttrss_enclosures
-                                                       (content_url, content_type, title, duration, post_id) VALUES
-                                                       ('$enc_url', '$enc_type', '$enc_title', '$enc_dur', '$entry_ref_id')");
+                                                       (content_url, content_type, title, duration, post_id, width, height) VALUES
+                                                       ('$enc_url', '$enc_type', '$enc_title', '$enc_dur', '$entry_ref_id', $enc_width, $enc_height)");
                                        }
                                }
 
index f8ff944c014f22b2ebcdf3671c411116f2f336ed..a9a35822031a6fce7ee1a57f1ea27a7ba6a07902 100644 (file)
@@ -301,7 +301,7 @@ create table ttrss_tags (id integer primary key auto_increment,
 
 create table ttrss_version (schema_version int not null) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
 
-insert into ttrss_version values (125);
+insert into ttrss_version values (126);
 
 create table ttrss_enclosures (id integer primary key auto_increment,
        content_url text not null,
@@ -309,6 +309,8 @@ create table ttrss_enclosures (id integer primary key auto_increment,
        post_id integer not null,
        title text not null,
        duration text not null,
+       width integer not null default 0,
+       height integer not null default 0,
        index (post_id),
        foreign key (post_id) references ttrss_entries(id) ON DELETE cascade) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
 
index 3aa65e8b227846766e9f8000eff8474463964d77..c09f044fb870fde4bd5e7aad88dd75f8b2ba8ad8 100644 (file)
@@ -261,13 +261,15 @@ create index ttrss_tags_post_int_id_idx on ttrss_tags(post_int_id);
 
 create table ttrss_version (schema_version int not null);
 
-insert into ttrss_version values (125);
+insert into ttrss_version values (126);
 
 create table ttrss_enclosures (id serial not null primary key,
        content_url text not null,
        content_type varchar(250) not null,
        title text not null,
        duration text not null,
+       width integer not null default 0,
+       height integer not null default 0,
        post_id integer references ttrss_entries(id) ON DELETE cascade NOT NULL);
 
 create index ttrss_enclosures_post_id_idx on ttrss_enclosures(post_id);
diff --git a/schema/versions/mysql/126.sql b/schema/versions/mysql/126.sql
new file mode 100644 (file)
index 0000000..6ff661e
--- /dev/null
@@ -0,0 +1,8 @@
+begin;
+
+alter table ttrss_enclosures add column width integer not null default 0;
+alter table ttrss_enclosures add column height integer not null default 0;
+
+update ttrss_version set schema_version = 126;
+
+commit;
diff --git a/schema/versions/pgsql/126.sql b/schema/versions/pgsql/126.sql
new file mode 100644 (file)
index 0000000..46f391a
--- /dev/null
@@ -0,0 +1,8 @@
+begin;
+
+alter table ttrss_enclosures add column height integer not null default 0;
+alter table ttrss_enclosures add column width integer not null default 0;
+
+update ttrss_version set schema_version = 126;
+
+commit;