mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Moving linkify and changing a bit of logging.
This commit is contained in:
parent
9093061bbe
commit
8b4c801995
3 changed files with 3 additions and 194 deletions
|
@ -77,7 +77,7 @@ class Feed(models.Model):
|
|||
if not self.feed_title:
|
||||
self.feed_title = "[Untitled]"
|
||||
self.save()
|
||||
return self.feed_title
|
||||
return "%s (%s)" % (self.feed_title, self.pk)
|
||||
|
||||
def canonical(self, full=False, include_favicon=True):
|
||||
feed = {
|
||||
|
@ -158,6 +158,7 @@ class Feed(models.Model):
|
|||
|
||||
@property
|
||||
def favicon_fetching(self):
|
||||
print "%s: %s %s" % (self, self.favicon_not_found, self.favicon_color)
|
||||
return bool(not (self.favicon_not_found or self.favicon_color))
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -1,192 +0,0 @@
|
|||
/* encoding: utf-8
|
||||
|
||||
**** linkify plugin for jQuery - automatically finds and changes URLs in text content into proper hyperlinks ****
|
||||
|
||||
Version: 1.0
|
||||
|
||||
Copyright (c) 2009
|
||||
Már Örlygsson (http://mar.anomy.net/) &
|
||||
Hugsmiðjan ehf. (http://www.hugsmidjan.is)
|
||||
|
||||
Dual licensed under a MIT licence (http://en.wikipedia.org/wiki/MIT_License)
|
||||
and GPL 2.0 or above (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html).
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Demo and Qunit-tests:
|
||||
* <./jquery.linkify-1.0-demo.html>
|
||||
* <./jquery.linkify-1.0-test.html>
|
||||
|
||||
Documentation:
|
||||
* ...
|
||||
|
||||
Get updates from:
|
||||
* <http://github.com/maranomynet/linkify/>
|
||||
* <git://github.com/maranomynet/linkify.git>
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Requires:
|
||||
* jQuery (1.2.6 or later)
|
||||
|
||||
Usage:
|
||||
|
||||
jQuery('.articlebody').linkify();
|
||||
|
||||
// adding plugins:
|
||||
jQuery.extend( jQuery.fn.linkify.plugins, {
|
||||
name1: {
|
||||
re: RegExp
|
||||
tmpl: String/Function
|
||||
},
|
||||
name2: function(html){ return html; }
|
||||
});
|
||||
|
||||
// Uses all plugins by default:
|
||||
jQuery('.articlebody').linkify();
|
||||
|
||||
// Use only certain plugins:
|
||||
jQuery('.articlebody').linkify( 'name1,name2' );
|
||||
jQuery('.articlebody').linkify({ use: 'name1,name2' });
|
||||
jQuery('.articlebody').linkify({ use: ['name1','name2'] });
|
||||
|
||||
// Explicitly use all plugins:
|
||||
jQuery('.articlebody').linkify('*');
|
||||
jQuery('.articlebody').linkify({ use: '*' });
|
||||
jQuery('.articlebody').linkify({ use: ['*'] });
|
||||
|
||||
// Use no plugins:
|
||||
jQuery('.articlebody').linkify('');
|
||||
jQuery('.articlebody').linkify({ use: '' });
|
||||
jQuery('.articlebody').linkify({ use: [] });
|
||||
jQuery('.articlebody').linkify({ use: [''] });
|
||||
|
||||
// Perfmorm actions on all newly created links:
|
||||
jQuery('.articlebody').linkify( function (links){ links.addClass('linkified'); } );
|
||||
jQuery('.articlebody').linkify({ handleLinks: function (links){ links.addClass('linkified'); } });
|
||||
|
||||
*/
|
||||
|
||||
(function($){
|
||||
|
||||
var noProtocolUrl = /(^|["'(\s]|<)(www\..+?\..+?)((?:[:?]|\.+)?(?:\s|$)|>|[)"',])/g,
|
||||
httpOrMailtoUrl = /(^|["'(\s]|<)((?:(?:https?|ftp):\/\/|mailto:).+?)((?:[:?]|\.+)?(?:\s|$)|>|[)"',])/g,
|
||||
linkifier = function ( html ) {
|
||||
return html
|
||||
.replace( noProtocolUrl, '$1<a href="<``>://$2">$2</a>$3' ) // NOTE: we escape `"http` as `"<``>` to make sure `httpOrMailtoUrl` below doesn't find it as a false-positive
|
||||
.replace( httpOrMailtoUrl, '$1<a href="$2">$2</a>$3' )
|
||||
.replace( /"<``>/g, '"http' ); // reinsert `"http`
|
||||
},
|
||||
|
||||
|
||||
linkify = $.fn.linkify = function ( cfg ) {
|
||||
if ( !$.isPlainObject( cfg ) )
|
||||
{
|
||||
cfg = {
|
||||
use: (typeof cfg == 'string') ? cfg : undefined,
|
||||
handleLinks: $.isFunction(cfg) ? cfg : arguments[1]
|
||||
};
|
||||
}
|
||||
var use = cfg.use,
|
||||
allPlugins = linkify.plugins || {},
|
||||
plugins = [linkifier],
|
||||
tmpCont,
|
||||
newLinks = [],
|
||||
callback = cfg.handleLinks;
|
||||
if ( use == undefined || use == '*' ) // use === undefined || use === null
|
||||
{
|
||||
for ( var name in allPlugins )
|
||||
{
|
||||
plugins.push( allPlugins[name] );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
use = $.isArray( use ) ? use : $.trim(use).split( / *, */ );
|
||||
var plugin,
|
||||
name;
|
||||
for ( var i=0, l=use.length; i<l; i++ )
|
||||
{
|
||||
name = use[i];
|
||||
plugin = allPlugins[name];
|
||||
if ( plugin )
|
||||
{
|
||||
plugins.push( plugin );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.each(function () {
|
||||
var childNodes = this.childNodes,
|
||||
i = childNodes.length;
|
||||
while ( i-- )
|
||||
{
|
||||
var n = childNodes[i];
|
||||
if ( n.nodeType == 3 )
|
||||
{
|
||||
var html = n.nodeValue;
|
||||
if ( html.length>1 && /\S/.test(html) )
|
||||
{
|
||||
var htmlChanged,
|
||||
preHtml;
|
||||
tmpCont = tmpCont || $('<div/>')[0];
|
||||
tmpCont.innerHTML = '';
|
||||
tmpCont.appendChild( n.cloneNode(false) );
|
||||
var tmpContNodes = tmpCont.childNodes;
|
||||
|
||||
for (var j=0, plugin; (plugin = plugins[j]); j++)
|
||||
{
|
||||
var k = tmpContNodes.length,
|
||||
tmpNode;
|
||||
while ( k-- )
|
||||
{
|
||||
tmpNode = tmpContNodes[k];
|
||||
if ( tmpNode.nodeType == 3 )
|
||||
{
|
||||
html = tmpNode.nodeValue;
|
||||
if ( html.length>1 && /\S/.test(html) )
|
||||
{
|
||||
preHtml = html;
|
||||
html = html
|
||||
.replace( /&/g, '&' )
|
||||
.replace( /</g, '<' )
|
||||
.replace( />/g, '>' );
|
||||
html = $.isFunction( plugin ) ?
|
||||
plugin( html ):
|
||||
html.replace( plugin.re, plugin.tmpl );
|
||||
htmlChanged = htmlChanged || preHtml!=html;
|
||||
preHtml!=html && $(tmpNode).after(html).remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
html = tmpCont.innerHTML;
|
||||
if ( callback )
|
||||
{
|
||||
html = $('<div/>').html(html);
|
||||
//newLinks.push.apply( newLinks, html.find('a').toArray() );
|
||||
newLinks = newLinks.concat( html.find('a').toArray().reverse() );
|
||||
html = html.contents();
|
||||
}
|
||||
htmlChanged && $(n).after(html).remove();
|
||||
}
|
||||
}
|
||||
else if ( n.nodeType == 1 && !/^(a|button|textarea|code|pre)$/i.test(n.tagName) )
|
||||
{
|
||||
arguments.callee.call( n );
|
||||
}
|
||||
};
|
||||
});
|
||||
callback && callback( $(newLinks.reverse()) );
|
||||
return this;
|
||||
};
|
||||
|
||||
linkify.plugins = {
|
||||
// default mailto: plugin
|
||||
mailto: {
|
||||
re: /(^|["'(\s]|<)([^"'(\s&]+?@.+\.[a-z]{2,7})(([:?]|\.+)?(\s|$)|>|[)"',])/gi,
|
||||
tmpl: '$1<a href="mailto:$2">$2</a>$3'
|
||||
}
|
||||
};
|
||||
|
||||
})(jQuery);
|
|
@ -594,7 +594,7 @@ NEWSBLUR.AssetModel.Reader.prototype = {
|
|||
for (var k in feed) {
|
||||
if (this.feeds[f][k] != feed[k]) {
|
||||
// NEWSBLUR.log(['New Feed', this.feeds[f][k], feed[k], f, k]);
|
||||
NEWSBLUR.log(['Different', k, this.feeds[f][k], feed[k]]);
|
||||
NEWSBLUR.log(['Different', k, this.feeds[f].feed_title, this.feeds[f][k], feed[k]]);
|
||||
this.feeds[f][k] = feed[k];
|
||||
updated = true;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue