Ver Fonte

Ticket #559 - embed.ly integration.

AntonLV há 9 anos atrás
pai
commit
28f565819c

+ 9 - 1
inc/classes/BxDolTemplate.php

@@ -343,15 +343,17 @@ class BxDolTemplate extends BxDolFactory implements iBxDolSingleton
             'spin.min.js',
             'jquery.easing.js',
             'jquery.cookie.min.js',
+            'jquery.embedly.min.js',
             'moment-with-locales.min.js',
             'functions.js',
             'jquery.webForms.js',
             'jquery.dolPopup.js',
+        	'jquery.dolEmbedly.js',
             'marka/marka.min.js',
             'headroom.min.js',
         ));
 
-        //--- Load default JS ---//
+        //--- Load translations in JS ---//
         bx_import('BxDolLanguages');
         $this->addJsTranslation(array(
             '_are you sure?',
@@ -359,6 +361,12 @@ class BxDolTemplate extends BxDolFactory implements iBxDolSingleton
             '_sys_loading',
         ));
 
+        //--- Load options in JS ---//
+        $this->addJsOption(array(
+        	'sys_embedly_api_key',
+        	'sys_embedly_api_pattern',
+        ));
+
         //--- Load injection's cache ---//
         if (getParam('sys_db_cache_enable')) {
             $oDb = BxDolDb::getInstance();

+ 7 - 0
inc/js/functions.js

@@ -723,4 +723,11 @@ function bx_get_style(sUrl)
 	$("head").append($("<link rel='stylesheet' href='" + sUrl + "' type='text/css' />"));
 }
 
+function bx_get_param(s) {
+    if (!window.aDolOptions || !aDolOptions[s])
+        return false;
+
+    return aDolOptions[s];
+}
+
 /** @} */

+ 23 - 0
inc/js/jquery.dolEmbedly.js

@@ -0,0 +1,23 @@
+(function( $ ){
+	$.fn.dolEmbedly = function(options) {
+        var o = $.extend({}, {'max-width':900}, options);
+		var sEmbedlyKey = bx_get_param('sys_embedly_api_key');
+		var sEmbedlyPattern = bx_get_param('sys_embedly_api_pattern');
+		if(!sEmbedlyKey || !sEmbedlyPattern)
+			return this;
+
+        var eBox = $(this).parents('.bx-db-content, .bx-def-box');
+        var iMaxWidth = eBox.size() ? eBox.innerWidth() : $(window).width() - 70;
+
+        if (iMaxWidth > o['max-width']) iMaxWidth = o['max-width'];
+        
+		return this.each(function() {
+			$(this).embedly({
+                key: sEmbedlyKey,
+                query: {maxwidth: iMaxWidth},
+                // only videos/sound/images are supported, to generate own list goto http://embed.ly/tools/generator
+                urlRe: sEmbedlyPattern
+            });
+		});
+	};
+})( jQuery );

Diff do ficheiro suprimidas por serem muito extensas
+ 0 - 0
install/sql/system.sql


+ 2 - 0
modules/boonex/english/data/langs/system/en.xml

@@ -1233,6 +1233,8 @@
 	<string name="_adm_stg_cpt_option_sys_install_time"><![CDATA[Installation date]]></string>
 	<string name="_adm_stg_cpt_option_sys_live_updates_interval"><![CDATA[Live updates interval (in milliseconds)]]></string>
 	<string name="_adm_stg_cpt_option_sys_maps_api_key"><![CDATA[Google Maps API key]]></string>
+	<string name="_adm_stg_cpt_option_sys_embedly_api_key"><![CDATA[Embed.ly API key]]></string>
+	<string name="_adm_stg_cpt_option_sys_embedly_api_pattern"><![CDATA[Embed.ly API pattern]]></string>
 	<string name="_adm_stg_cpt_option_sys_oauth_key"><![CDATA[UNA account key]]></string>
 	<string name="_adm_stg_cpt_option_sys_oauth_secret"><![CDATA[UNA account secret]]></string>
 	<string name="_adm_stg_cpt_option_sys_page_cache_enable"><![CDATA[Enable Page cache]]></string>

+ 3 - 0
modules/boonex/ocean/data/template/system/_header.html

@@ -76,6 +76,9 @@
                     bx_menu_slide_close_all_opened();
                 }
             }).init();
+
+            // init Embed.ly support
+            $('a.bx-link-embed').dolEmbedly();
         });
 
         (function(w) {

+ 3 - 0
modules/boonex/protean/data/template/system/_header.html

@@ -73,6 +73,9 @@
                     bx_menu_slide_close_all_opened();
                 }
             }).init();
+
+            // init Embed.ly support
+            $('a.bx-link-embed').dolEmbedly();
         });
 
         (function(w) {

+ 2 - 0
modules/boonex/russian/data/langs/system/ru.xml

@@ -1231,6 +1231,8 @@
 	<string name="_adm_stg_cpt_option_sys_install_time"><![CDATA[Дата установки]]></string>
     <string name="_adm_stg_cpt_option_sys_live_updates_interval"><![CDATA[Интервал обновлений (в миллисекундах)]]></string>
     <string name="_adm_stg_cpt_option_sys_maps_api_key"><![CDATA[Ключ Google Maps API]]></string>
+    <string name="_adm_stg_cpt_option_sys_embedly_api_key"><![CDATA[Ключ Embed.ly API]]></string>
+    <string name="_adm_stg_cpt_option_sys_embedly_api_pattern"><![CDATA[Шаблон Embed.ly API]]></string>
 	<string name="_adm_stg_cpt_option_sys_oauth_key"><![CDATA[UNA-аккаунт - Key (ключ)]]></string>
 	<string name="_adm_stg_cpt_option_sys_oauth_secret"><![CDATA[UNA-аккаунт - Secret (секретное слово)]]></string>
 	<string name="_adm_stg_cpt_option_sys_page_cache_enable"><![CDATA[Задействовать кэш для Страниц]]></string>

Diff do ficheiro suprimidas por serem muito extensas
+ 5 - 0
plugins_public/jquery.embedly.min.js


+ 3 - 0
template/_header.html

@@ -73,6 +73,9 @@
                     bx_menu_slide_close_all_opened();
                 }
             }).init();
+
+            // init Embed.ly support
+            $('a.bx-link-embed').dolEmbedly();
         });
 
         (function(w) {

Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff