From d8a13d6e8d00347650244ab86958b4b2a4cdb944 Mon Sep 17 00:00:00 2001 From: Zach Prezkuta Date: Mon, 6 Aug 2012 09:59:57 -0600 Subject: [PATCH] allow themes to change the size of embedded videos --- boot.php | 12 +++++++++++- include/bbcode.php | 8 ++++---- include/oembed.php | 10 ++++++---- view/theme/frost-mobile/profile_photo.tpl | 19 +++++++++++++++++++ view/theme/frost-mobile/theme.php | 4 +++- view/theme/frost-mobile/wallwall_item.tpl | 4 ++-- 6 files changed, 45 insertions(+), 12 deletions(-) create mode 100644 view/theme/frost-mobile/profile_photo.tpl diff --git a/boot.php b/boot.php index 6a350c5f4d..9702b71a83 100644 --- a/boot.php +++ b/boot.php @@ -349,12 +349,22 @@ if(! class_exists('App')) { public $plugins; public $apps = array(); public $identities; - public $sourcename = ''; public $nav_sel; public $category; + // Allow themes to control internal parameters + // by changing App values in theme.php + // + // Possibly should make these part of the plugin + // system, but it seems like overkill to invoke + // all the plugin machinery just to change a couple + // of values + public $sourcename = ''; + public $videowidth = 425; + public $videoheight = 350; + private $scheme; private $hostname; private $baseurl; diff --git a/include/bbcode.php b/include/bbcode.php index d83cd35814..85c0059ccd 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -325,7 +325,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { // Try to Oembed if ($tryoembed) { - $Text = preg_replace("/\[video\](.*?\.(ogg|ogv|oga|ogm|webm|mp4))\[\/video\]/ism", '', $Text); + $Text = preg_replace("/\[video\](.*?\.(ogg|ogv|oga|ogm|webm|mp4))\[\/video\]/ism", '', $Text); $Text = preg_replace("/\[audio\](.*?\.(ogg|ogv|oga|ogm|webm|mp4|mp3))\[\/audio\]/ism", '', $Text); $Text = preg_replace_callback("/\[video\](.*?)\[\/video\]/ism", 'tryoembed', $Text); @@ -339,7 +339,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { if ($tryoembed) - $Text = preg_replace("/\[iframe\](.*?)\[\/iframe\]/ism", '', $Text); + $Text = preg_replace("/\[iframe\](.*?)\[\/iframe\]/ism", '', $Text); else $Text = preg_replace("/\[iframe\](.*?)\[\/iframe\]/ism", '$1', $Text); @@ -355,7 +355,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { $Text = preg_replace("/\[youtube\]https?:\/\/youtu.be\/(.*?)\[\/youtube\]/ism",'[youtube]$1[/youtube]',$Text); if ($tryoembed) - $Text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", '', $Text); + $Text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", '', $Text); else $Text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", "http://www.youtube.com/watch?v=$1", $Text); @@ -369,7 +369,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { $Text = preg_replace("/\[vimeo\]https?:\/\/vimeo.com\/([0-9]+)(.*?)\[\/vimeo\]/ism",'[vimeo]$1[/vimeo]',$Text); if ($tryoembed) - $Text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", '', $Text); + $Text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", '', $Text); else $Text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", "http://vimeo.com/$1", $Text); diff --git a/include/oembed.php b/include/oembed.php index a4452586ee..6fc4c53717 100755 --- a/include/oembed.php +++ b/include/oembed.php @@ -12,7 +12,9 @@ function oembed_replacecb($matches){ function oembed_fetch_url($embedurl){ - $txt = Cache::get($embedurl); + $a = get_app(); + + $txt = Cache::get($a->videowidth . $embedurl); // These media files should now be caught in bbcode.php // left here as a fallback in case this is called from another source @@ -38,7 +40,7 @@ function oembed_fetch_url($embedurl){ $entries = $xpath->query("//link[@type='application/json+oembed']"); foreach($entries as $e){ $href = $e->getAttributeNode("href")->nodeValue; - $txt = fetch_url($href . '&maxwidth=425'); + $txt = fetch_url($href . '&maxwidth=' . $a->videowidth); break; } } @@ -47,7 +49,7 @@ function oembed_fetch_url($embedurl){ if ($txt==false || $txt==""){ // try oohembed service - $ourl = "http://oohembed.com/oohembed/?url=".urlencode($embedurl).'&maxwidth=425'; + $ourl = "http://oohembed.com/oohembed/?url=".urlencode($embedurl).'&maxwidth=' . $a->videowidth; $txt = fetch_url($ourl); } @@ -55,7 +57,7 @@ function oembed_fetch_url($embedurl){ if ($txt[0]!="{") $txt='{"type":"error"}'; //save in cache - Cache::set($embedurl,$txt); + Cache::set($a->videowidth . $embedurl,$txt); } diff --git a/view/theme/frost-mobile/profile_photo.tpl b/view/theme/frost-mobile/profile_photo.tpl new file mode 100644 index 0000000000..42fc139f8f --- /dev/null +++ b/view/theme/frost-mobile/profile_photo.tpl @@ -0,0 +1,19 @@ +

$title

+ +
+ + +
+ + +
+ +
+ +
+ +
+ + diff --git a/view/theme/frost-mobile/theme.php b/view/theme/frost-mobile/theme.php index 314361b9c9..96d40958ef 100644 --- a/view/theme/frost-mobile/theme.php +++ b/view/theme/frost-mobile/theme.php @@ -4,7 +4,7 @@ * Name: Frost--mobile version * Description: Like frosted glass * Credits: Navigation icons taken from http://iconza.com. Other icons taken from http://thenounproject.com, including: Like, Dislike, Black Lock, Unlock, Pencil, Tag, Camera, Paperclip (Marie Coons), Folder (Sergio Calcara), Chain-link (Andrew Fortnum), Speaker (Harold Kim), Quotes (Henry Ryder), Video Camera (Anas Ramadan), and Left Arrow, Right Arrow, and Delete X (all three P.J. Onori). All under Attribution (CC BY 3.0). Others from The Noun Project are public domain or No Rights Reserved (CC0). - * Version: Version 0.2.3 + * Version: Version 0.2.4 * Author: Zach P * Maintainer: Zach P */ @@ -24,5 +24,7 @@ function frost_mobile_init(&$a) { $a->sourcename = 'Friendica mobile web'; + $a->videowidth = 250; + $a->videoheight = 200; } diff --git a/view/theme/frost-mobile/wallwall_item.tpl b/view/theme/frost-mobile/wallwall_item.tpl index 113987246c..e4d6b60bb4 100644 --- a/view/theme/frost-mobile/wallwall_item.tpl +++ b/view/theme/frost-mobile/wallwall_item.tpl @@ -18,12 +18,12 @@
    $item.item_photo_menu
- + -->
- {{ if $item.lock }}
$item.lock
+ {{ if $item.lock }}$item.lock {{ else }}
{{ endif }}
$item.location