-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
url live preview not working #25
Comments
plugins are not working sir |
Hello, looks like yahoo yql stop html database on july, so now it doesn´t work, but i made some changes at the plugin and now it´s working, first on line
for:
on line 229 change:
for:
on line 238:
for:
on line 246:
for:
on line 260:
for:
I hope it helps. |
Hi sir,
Thanks for your response..
…On 8 July 2017 at 20:13, comunicantevisual ***@***.***> wrote:
Hello, looks like yahoo yql stop html database on july, so now it doesn´t
work, but i made some changes at the plugin and now it´s working, first on
line 173 i change:
`var query = 'select * from html where url="' + url + '" and compat="html5" and xpath="'+xpath+'"';`
for:
`var query = 'select * from htmlstring where url="' + url + '"';`
on line 229 change:
```
$(data, '').find('title').each(function()
{
title = $(this).text();
});
for:
```
result_text=$(data).find('result').text();
result_text2=$.parseXML(result_text);
$xml = $(result_text2);
//Checar modificación aquí para el título
//modificación porque Yahoo's yql dejo de dar servicio con la base de datos html
$xml.find('head').find('title').each( function()
//$(data, '<head>').find('title').each(function()
{
title = $(this).text();
});
on line 238:
$(data, '<head>').find('meta').each(function()
{
core.setMetaData($(this));
});
for:
$xml.find('head').find('meta').each( function()
//$(data, '<head>').find('meta').each(function()
{
core.setMetaData($(this));
});
on line 246:
[$(data, '<body>').find('p').each(function()
{
var text = $.trim($(this).text());
if(text.length > 3) {
preview.description = text;
return false;
}
});](url)
for:
$xml.find('body').find('p').each( function()
//$(data, '<body>').find('p').each(function()
{
var text = $.trim($(this).text());
if(text.length > 3) {
preview.description = text;
return false;
}
});
on line 260:
var images = $(data, '<body>').find('img');
if (o.findLogo ) {
images.each(function()
{
var self = $(this);
if (self.attr('src') && self.attr('src').search(o.logoWord, 'i') != -1 ||
self.attr('id' ) && self.attr('id' ).search(o.logoWord, 'i') != -1 ||
this.className && this.className.search(o.logoWord, 'i') != -1
) {
preview.image = $(this).attr('src');
return false;
}
});
}
for:
```
var images = $xml.find('img');
if (o.findLogo ) {
images.each(function()
{
var self = $(this);
if (self.attr('src') && self.attr('src').search(o.logoWord, 'i') != -1 ||
self.attr('id' ) && self.attr('id' ).search(o.logoWord, 'i') != -1 ||
this.className && this.className.search(o.logoWord, 'i') != -1
) {
preview.image = $(this).attr('src');
return false;
}
});
}
I hope it helps.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#25 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ATqGwFKkOhtZ4z5Xr02pdM5iCykHAzVXks5sL5WagaJpZM4N5o3->
.
|
Hi sir,
i have did same above changes as you sent in mail but also it's didn't
worked at all. i am not understanding why its not coming,
please give me any response . i am waiting for your response.
…On 10 July 2017 at 10:37, raj javale ***@***.***> wrote:
Hi sir,
Thanks for your response..
On 8 July 2017 at 20:13, comunicantevisual ***@***.***>
wrote:
> Hello, looks like yahoo yql stop html database on july, so now it doesn´t
> work, but i made some changes at the plugin and now it´s working, first on
> line 173 i change:
>
> `var query = 'select * from html where url="' + url + '" and compat="html5" and xpath="'+xpath+'"';`
>
> for:
>
> `var query = 'select * from htmlstring where url="' + url + '"';`
>
> on line 229 change:
>
> ```
>
> $(data, '').find('title').each(function()
> {
> title = $(this).text();
> });
>
>
> for:
> ```
> result_text=$(data).find('result').text();
> result_text2=$.parseXML(result_text);
> $xml = $(result_text2);
> //Checar modificación aquí para el título
> //modificación porque Yahoo's yql dejo de dar servicio con la base de datos html
> $xml.find('head').find('title').each( function()
> //$(data, '<head>').find('title').each(function()
> {
> title = $(this).text();
> });
>
> on line 238:
>
> $(data, '<head>').find('meta').each(function()
> {
> core.setMetaData($(this));
>
> });
>
> for:
>
> $xml.find('head').find('meta').each( function()
> //$(data, '<head>').find('meta').each(function()
> {
> core.setMetaData($(this));
>
> });
>
> on line 246:
>
> [$(data, '<body>').find('p').each(function()
> {
> var text = $.trim($(this).text());
> if(text.length > 3) {
> preview.description = text;
> return false;
> }
>
> });](url)
>
> for:
>
> $xml.find('body').find('p').each( function()
> //$(data, '<body>').find('p').each(function()
> {
> var text = $.trim($(this).text());
> if(text.length > 3) {
> preview.description = text;
> return false;
> }
>
> });
>
> on line 260:
>
> var images = $(data, '<body>').find('img');
>
> if (o.findLogo ) {
> images.each(function()
> {
> var self = $(this);
>
> if (self.attr('src') && self.attr('src').search(o.logoWord, 'i') != -1 ||
> self.attr('id' ) && self.attr('id' ).search(o.logoWord, 'i') != -1 ||
> this.className && this.className.search(o.logoWord, 'i') != -1
> ) {
> preview.image = $(this).attr('src');
> return false;
> }
>
> });
> }
>
> for:
>
> ```
>
> var images = $xml.find('img');
>
> if (o.findLogo ) {
>
> images.each(function()
> {
> var self = $(this);
>
> if (self.attr('src') && self.attr('src').search(o.logoWord, 'i') != -1 ||
> self.attr('id' ) && self.attr('id' ).search(o.logoWord, 'i') != -1 ||
> this.className && this.className.search(o.logoWord, 'i') != -1
> ) {
> preview.image = $(this).attr('src');
> return false;
> }
>
> });
>
> }
>
>
> I hope it helps.
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <#25 (comment)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ATqGwFKkOhtZ4z5Xr02pdM5iCykHAzVXks5sL5WagaJpZM4N5o3->
> .
>
|
Hello, i'll share you my file zipped, please check if it works for you Sorry for the delay to answer I hope it works |
Hi sir,
Thanks for your response
…On 19 July 2017 at 02:00, comunicantevisual ***@***.***> wrote:
Hello, i'll paste my liveurl.js modified, you can check if it works for you
`/*
- jQuery LiveUrl
-
- MIT License - You are free to use this commercial projects as long
as the copyright header is left intact.
- @author <https://github.com/author> Stephan Fischer
- @copyright <https://github.com/copyright> (c) 2012 Stephan Fischer (
www.ainetworks.de)
- @Version <https://github.com/version> 1.2.2
-
- UriParser is a function from my addon "Superswitch" for Mozilla
FireFox.
*/
(function( $ )
{
$.fn.extend(
{
liveUrl : function( options)
{
var defaults =
{
meta: [
['description','name', 'description'],
['description','property', 'og:description'],
['description','property', 'pinterestapp:about'],
['image','property', 'og:image'],
['image','itemprop', 'image'],
['title','property', 'og:title'],
['video','property', 'og:video'],
['video_type','property', 'og:video:type'],
['video_width','property', 'og:video:width'],
['video_height','property', 'og:video:height']
],
findLogo : false,
findDescription : true,
matchNoData : true,
multipleImages : true,
defaultProtocol : 'https://',
minWidth : 100,
minHeight : 32,
logoWord : 'logo',
success : function() {},
loadStart : function() {},
loadEnd : function() {},
imgLoadStart : function() {},
imgLoadEnd : function() {},
addImage : function() {}
}
var options = $.extend(defaults, options);
this.each(function()
{
var o = options,
core = {already : []},
url = {},
preview = {};
core.init = function ()
{
core.preview = false;
core.processedImg = 0;
preview = {
url : '',
images: [],
image : '',
title: '' ,
description: ''
};
};
core.textUpdate = function(self)
{
// read all links
var links = $.urlHelper.getLinks($(self).val());
core.cleanDuplicates(links);
if (links != null) {
if (!core.preview) {
core.current = $(self);
core.process(links);
}
}
};
core.process = function(urlArray)
{
for (var index in urlArray) {
var strUrl = urlArray[index] ;
if (typeof strUrl == 'string') {
var pLink = new $.urlHelper.UriParser(strUrl);
if (pLink.subdomain && pLink.subdomain.length > 0 ||
pLink.protocol && pLink.protocol.length > 0 ) {
if (pLink.protocol.length == 0) {
strUrl = o.defaultProtocol + strUrl;
}
if (!core.isDuplicate(strUrl, core.already)) {
if ($.urlHelper.isImage(strUrl)) {
preview.image = strUrl;
core.getPreview({}, strUrl);
} else {
core.getData(strUrl);
}
return true;
}
}
}
}
};
core.cleanDuplicates = function(urlArray)
{
var links = core.createLinks(urlArray);
for(var index in core.already) {
var strUrl = core.already[index];
if (!core.isDuplicate(strUrl, links)){
var index = $.inArray(strUrl, core.already);
core.already.splice(index, 1);
}
}
};
core.createLinks = function(urlArray)
{
var links = [];
for(var index in urlArray) {
var strUrl = urlArray[index];
if (typeof strUrl == 'string') {
var pLink = new $.urlHelper.UriParser(strUrl);
if (pLink.subdomain && pLink.subdomain.length > 0 ||
pLink.protocol && pLink.protocol.length > 0 ) {
if (pLink.protocol.length == 0) {
strUrl = o.defaultProtocol + strUrl;
}
links.push(strUrl);
}
}
}
return links;
}
core.isDuplicate = function(url, array)
{
var duplicate = false;
$.each(array, function(key, val)
{
if (val == url) {
duplicate = true;
}
});
return duplicate;
};
core.getData = function (url)
{
var xpath = '//head|//body';
//var query = 'select * from html where url="' + url + '" and compat="html5" and xpath="'+xpath+'"';
//modificación porque Yahoo's yql dejo de dar servicio con la base de datos html
var query = 'select * from htmlstring where url="' + url + '"';
core.addLoader();
$.yql(query, function()
{
var data = {
query : {results: null}
}
core.ajaxSuccess(data, url);
core.removeLoader();
return false;
},
function(data)
{
core.ajaxSuccess(data, url)
}
)
}; //getData
core.ajaxSuccess = function(data, url)
{
// URL already loaded, or preview is already shown.
if (core.isDuplicate(url, core.already) || core.preview) {
core.removeLoader();
return false;
}
if ($(data).find("results").text().length == 0) {
if (o.matchNoData) {
core.getPreview(data, url);
} else {
core.already.push(url);
core.removeLoader();
}
} else {
core.getPreview(data, url);
}
}
core.hasValue = function(section){
return (preview[section].length == 0) ? false : true;
};
core.getPreview = function(data, uri)
{
core.preview = true;
core.already.push(uri);
var title = "" ;
//modificación porque Yahoo's yql dejo de dar servicio con la base de datos html
result_text=$(data).find('result').text();
result_text2=$.parseXML(result_text);
$xml = $(result_text2);
//Checar modificación aquí para el título
//modificación porque Yahoo's yql dejo de dar servicio con la base de datos html
$xml.find('head').find('title').each( function()
//$(data, '<head>').find('title').each(function()
{
title = $(this).text();
});
preview.title = ( title || uri);
preview.url = uri;
//Checar modificación aquí para el título
//modificación porque Yahoo's yql dejo de dar servicio con la base de datos html
$xml.find('head').find('meta').each( function()
//$(data, '<head>').find('meta').each(function()
{
core.setMetaData($(this));
});
if(o.findDescription && !core.hasValue('description')) {
//Checar modificación aquí para la descripción
//modificación porque Yahoo's yql dejo de dar servicio con la base de datos html
$xml.find('body').find('p').each( function()
//$(data, '<body>').find('p').each(function()
{
var text = $.trim($(this).text());
if(text.length > 3) {
preview.description = text;
return false;
}
});
}
if (!core.hasValue('image')) {
// meta tag has no images:
//var images = $(data, '<body>').find('img');
//modificación porque Yahoo's yql dejo de dar servicio con la base de datos html
var images = $xml.find('img');
if (o.findLogo ) {
images.each(function()
{
var self = $(this);
if (self.attr('src') && self.attr('src').search(o.logoWord, 'i') != -1 ||
self.attr('id' ) && self.attr('id' ).search(o.logoWord, 'i') != -1 ||
this.className && this.className.search(o.logoWord, 'i') != -1
) {
preview.image = $(this).attr('src');
return false;
}
});
}
if (!core.hasValue('image') && images.length > 0 ) {
images.each(function()
{
preview.images.push($(this).attr('src'));
});
}
}
core.removeLoader();
// prepare output
var not = 'undefined';
var data = {
title : preview.title,
description : preview.description,
url : preview.url,
video : (typeof preview.video != not && preview.video.length > 0) ? {} : null
};
if (data.video != null) {
data.video = {
file : preview.video,
type : (typeof preview.video_type != not) ? preview.video_type : '',
width : (typeof preview.video_width != not) ? preview.video_width : '',
height: (typeof preview.video_height != not) ? preview.video_height :''
}
}
o.success(data);
if (core.hasValue('image')){
preview.images.push(preview.image);
preview.image = '';
}
core.addImages();
core.current.one('clear', function()
{
core.init();
});
};
core.addLoader = function()
{
o.loadStart();
};
core.removeLoader = function()
{
o.loadEnd();
};
core.setMetaData = function(val)
{
for (index in o.meta) {
var meta = o.meta[index];
preview[meta[0]] = (core.getValue(val,meta[1],meta[2])|| preview[meta[0]] );
}
};
core.getValue = function (val,key, tag) {
if (val.attr(key)) {
if (val.attr(key).toLowerCase() == tag.toLowerCase()) {
if (val.attr('content') && val.attr('content').length > 0) {
return val.attr('content');
}
}
}
};
core.addImages = function()
{
var images = [];
for (var index in preview.images) {
var image = preview.images[index];
if (!$.urlHelper.isAbsolute(image)) {
var pLink = new $.urlHelper.UriParser(preview.url);
var host = pLink.url + pLink.subdomain + pLink.domain;
if ($.urlHelper.isPathAbsolute(image))
image = host + image;
else image = host + $.urlHelper.stripFile(pLink.path) + '/' + image;
}
core.getImage(image, function(img)
{
if (img.width >= o.minWidth &&
img.height >= o.minHeight && core.preview) {
o.addImage(img);
if(!o.multipleImages) {
return;
}
}
});
}
};
core.getImage = function(src, callback)
{
var concat = $.urlHelper.hasParam(src) ? "&" : "?";
src += concat + 'random=' + (new Date()).getTime();
$('<img />').attr({'src': src}).load(function()
{
var img = this;
var tmrLoaded = window.setInterval(function()
{
core.processedImg++;
if (img.width) {
window.clearInterval(tmrLoaded);
callback(img);
}
if(core.processedImg == preview.images.length){
o.imgLoadEnd();
}
}, 100);
});
};
core.init();
var that = this;
var self = $(this);
self.on('keyup', function(e)
{
var links = $.urlHelper.getLinks($(self).val());
core.cleanDuplicates(links);
window.clearInterval(core.textTimer);
var code = (e.keyCode ? e.keyCode : e.which);
if(code == 13 || code == 32) { //Enter keycode
core.textUpdate(that);
} else {
core.textTimer = window.setInterval(function()
{
core.textUpdate(that);
window.clearInterval(core.textTimer);
}, 1000);
}
}).on('paste', function() {core.textUpdate(that)});
});
}
});
//https://query.yahooapis.com/v1/public/yql?q=select%20*%
20from%20yql.tables%20where%20name%20like%20%22%25yahoo%
25%22&diagnostics=true
//path: 'https://query.yahooapis.com/v1/public/yql?q=' PAST
//NEW https://query.yahooapis.com/v1/public/yql?q=select%20*%
20from%20htmlstring%20where%20url%3D'https%3A%2F%2Fwww.
entrepreneur.com%2Ftopic%2Femprendedores'%20and%
20xpath%3D'%2F%2Fa'&format=json&diagnostics=true&env=
store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=
jQuery.yql = function yql(query, error, success)
{
var yql = {
path: 'https://query.yahooapis.com/v1/public/yql?q=',
query: encodeURIComponent(query),
path2:'&format=xml&diagnostics=true&env=store%3A%2F%2Fdatatables.org%
2Falltableswithkeys&callback='
};
var isIE = /msie/.test(navigator.userAgent.toLowerCase());
if (isIE && window.XDomainRequest) {
var xdr = new XDomainRequest();
xdr.open("get", yql['path'] + yql['query']+yql['path2']);
xdr.onload = function()
{
success(xdr.responseText);
};
xdr.send();
} else {
$.ajax({
crossDomain : true,
cache : false,
type : 'GET',
url : yql['path'] + yql['query']+yql['path2'],
timeout : 8000,
dataType : 'xml',
error : error,
success : success
});
}
};
jQuery.urlHelper =
{
UriParser : function (uri)
{
this._regExp = /^((\w+):\/\/\/?)?((\w+):?(\w+)?@)?([^\/\?:]+)?(:\d+)?(.*)?/;
this._regExpHost = /^(.+\.)?(.+\..+)$/;
this._getVal = function(r, i)
{
if(!r) return null;
return (typeof(r[i]) == 'undefined' ? "" : r[i]);
};
this.parse = function(uri)
{
var r = this._regExp.exec(uri);
this.results = r;
this.url = this._getVal(r,1);
this.protocol = this._getVal(r,2);
this.username = this._getVal(r,4);
this.password = this._getVal(r,5);
this.domain = this._getVal(r,6);
this.port = this._getVal(r,7);
this.path = this._getVal(r,8);
var rH = this._regExpHost.exec( this.domain );
this.subdomain = this._getVal(rH,1);
this.domain = this._getVal(rH,2);
return r;
}
if(uri) this.parse(uri);
},
getLinks : function(text)
{
var expression = /((https?:\/\/)?[\w-]+(\.[\w-]+)+\.?(:\d+)?(\/\S*)?)/gi;
return (text.match(expression));
},
isImage : function(img, allowed)
{
//Match jpg, gif or png image
if (allowed == null) allowed = 'jpg|gif|png|jpeg';
var expression = /([^\s]+(?=\.(jpg|gif|png|jpeg))\.\2)/gm;
return (img.match(expression));
},
isAbsolute : function(path)
{
var expression = /^(https?:)?\/\//i;
var value = (path.match(expression) != null) ? true: false;
return value;
},
isPathAbsolute : function(path)
{
if (path.substr(0,1) == '/') return true;
},
hasParam : function(path)
{
return (path.lastIndexOf('?') == -1 ) ? false : true;
},
stripFile : function(path) {
return path.substr(0, path.lastIndexOf('/') + 1);
}
}
})( jQuery );`
I hope it works
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#25 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ATqGwHZeBm5UgG5Gl_wgpQ3x3DnTCdnCks5sPRXbgaJpZM4N5o3->
.
|
hello sir, Failed to load resource: the server responded with a status of 400 (OK) |
url live preview not working now,before its giving video preview and all other url preview .now its not working .same code i am using which i have used first.
The text was updated successfully, but these errors were encountered: