summaryrefslogtreecommitdiff
path: root/plugins/af_redditimgur
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2016-08-01 21:03:36 +0300
committerAndrew Dolgov <[email protected]>2016-08-01 21:03:36 +0300
commit8788698b0531573548dceb1c0db0d3fb2f4c2a0b (patch)
tree5307c4b67b55ae8933d136ab0b1a91218504ea09 /plugins/af_redditimgur
parent90e45935bb5573a94afa369a789f45e923f7bc9f (diff)
basic tweet embedding using oembed
Diffstat (limited to 'plugins/af_redditimgur')
-rwxr-xr-xplugins/af_redditimgur/init.php32
1 files changed, 30 insertions, 2 deletions
diff --git a/plugins/af_redditimgur/init.php b/plugins/af_redditimgur/init.php
index 7414656d5..e283b8cec 100755
--- a/plugins/af_redditimgur/init.php
+++ b/plugins/af_redditimgur/init.php
@@ -29,7 +29,7 @@ class Af_RedditImgur extends Plugin {
$enable_content_dupcheck = $this->host->get($this, "enable_content_dupcheck");
$enable_content_dupcheck_checked = $enable_content_dupcheck ? "checked" : "";
-
+
print "<form dojoType=\"dijit.form.Form\">";
print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">
@@ -59,7 +59,7 @@ class Af_RedditImgur extends Plugin {
print "<label for=\"enable_readability\">" . __("Extract missing content using Readability") . "</label>";
print "<br/>";
-
+
print "<input dojoType=\"dijit.form.CheckBox\" id=\"enable_content_dupcheck\"
$enable_content_dupcheck_checked name=\"enable_content_dupcheck\">&nbsp;";
@@ -95,6 +95,34 @@ class Af_RedditImgur extends Plugin {
$matches = array();
+
+ if (preg_match("/^https?:\/\/twitter.com\/(.*?)\/status\/(.*)/", $entry->getAttribute("href"), $matches)) {
+ _debug("handling as twitter: " . $matches[1] . " " . $matches[2], $debug);
+
+ $oembed_result = fetch_file_contents("https://publish.twitter.com/oembed?url=" . urlencode($entry->getAttribute("href")));
+
+ if ($oembed_result) {
+ $oembed_result = json_decode($oembed_result, true);
+
+ if ($oembed_result && isset($oembed_result["html"])) {
+
+ $tmp = new DOMDocument();
+ if ($tmp->loadHTML($oembed_result["html"])) {
+ $p = $doc->createElement("p");
+
+ $p->appendChild($doc->importNode(
+ $tmp->getElementsByTagName("blockquote")->item(0), TRUE));
+
+ $br = $doc->createElement('br');
+ $entry->parentNode->insertBefore($p, $entry);
+ $entry->parentNode->insertBefore($br, $entry);
+
+ $found = 1;
+ }
+ }
+ }
+ }
+
if (preg_match("/\.gfycat.com\/([a-z]+)?(\.[a-z]+)$/i", $entry->getAttribute("href"), $matches)) {
$entry->setAttribute("href", "http://www.gfycat.com/".$matches[1]);
}