mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
Being far kinder during feed exception handling and showing users error text. Cannot believe this wasn't there.
This commit is contained in:
parent
4260bf6c3a
commit
21bd9a0c3d
5 changed files with 53 additions and 34 deletions
|
@ -176,7 +176,7 @@ def exception_change_feed_address(request):
|
|||
original_feed = feed
|
||||
feed_address = request.POST['feed_address']
|
||||
code = -1
|
||||
|
||||
|
||||
if feed.has_page_exception or feed.has_feed_exception:
|
||||
# Fix broken feed
|
||||
logging.user(request, "~FRFixing feed exception by address: ~SB%s~SN to ~SB%s" % (feed.feed_address, feed_address))
|
||||
|
@ -223,6 +223,10 @@ def exception_change_feed_address(request):
|
|||
feeds = {
|
||||
original_feed.pk: usersub.canonical(full=True, classifiers=classifiers),
|
||||
}
|
||||
|
||||
if feed and feed.has_feed_exception:
|
||||
code = -1
|
||||
|
||||
return {
|
||||
'code': code,
|
||||
'feeds': feeds,
|
||||
|
@ -284,6 +288,9 @@ def exception_change_feed_link(request):
|
|||
feed.update_all_statistics()
|
||||
classifiers = get_classifiers_for_user(usersub.user, usersub.feed.pk)
|
||||
|
||||
if feed and feed.has_feed_exception:
|
||||
code = -1
|
||||
|
||||
feeds = {
|
||||
original_feed.pk: usersub.canonical(full=True, classifiers=classifiers),
|
||||
}
|
||||
|
|
|
@ -5058,6 +5058,9 @@ background: transparent;
|
|||
.NB-modal-exception .NB-modal-loading {
|
||||
margin: 6px 8px 0;
|
||||
}
|
||||
.NB-modal-exception .NB-fieldset-fields .NB-error {
|
||||
padding: 6px 0 6px 4px;
|
||||
}
|
||||
.NB-modal-feed-settings .NB-preference-label {
|
||||
float: left;
|
||||
margin: 6px 0;
|
||||
|
|
|
@ -852,39 +852,35 @@ NEWSBLUR.AssetModel.Reader.prototype = {
|
|||
}, pre_callback, error_callback);
|
||||
},
|
||||
|
||||
save_exception_change_feed_link: function(feed_id, feed_link, callback) {
|
||||
save_exception_change_feed_link: function(feed_id, feed_link, callback, error_callback) {
|
||||
var self = this;
|
||||
|
||||
var pre_callback = function(data) {
|
||||
// NEWSBLUR.log(['save_exception_change_feed_link pre_callback', feed_id, feed_link, data]);
|
||||
self.post_refresh_feeds(data, callback);
|
||||
NEWSBLUR.reader.force_feed_refresh(feed_id, data.new_feed_id);
|
||||
};
|
||||
|
||||
if (NEWSBLUR.Globals.is_authenticated) {
|
||||
this.make_request('/rss_feeds/exception_change_feed_link', {
|
||||
'feed_id': feed_id,
|
||||
'feed_link': feed_link
|
||||
}, pre_callback);
|
||||
}, function(data) {
|
||||
// NEWSBLUR.log(['save_exception_change_feed_link pre_callback', feed_id, feed_link, data]);
|
||||
self.post_refresh_feeds(data, callback);
|
||||
NEWSBLUR.reader.force_feed_refresh(feed_id, data.new_feed_id);
|
||||
}, error_callback);
|
||||
} else {
|
||||
if ($.isFunction(callback)) callback();
|
||||
}
|
||||
},
|
||||
|
||||
save_exception_change_feed_address: function(feed_id, feed_address, callback) {
|
||||
save_exception_change_feed_address: function(feed_id, feed_address, callback, error_callback) {
|
||||
var self = this;
|
||||
|
||||
var pre_callback = function(data) {
|
||||
// NEWSBLUR.log(['save_exception_change_feed_address pre_callback', feed_id, feed_address, data]);
|
||||
self.post_refresh_feeds(data, callback);
|
||||
NEWSBLUR.reader.force_feed_refresh(feed_id, data.new_feed_id);
|
||||
};
|
||||
|
||||
if (NEWSBLUR.Globals.is_authenticated) {
|
||||
this.make_request('/rss_feeds/exception_change_feed_address', {
|
||||
'feed_id': feed_id,
|
||||
'feed_address': feed_address
|
||||
}, pre_callback);
|
||||
}, function(data) {
|
||||
// NEWSBLUR.log(['save_exception_change_feed_address pre_callback', feed_id, feed_address, data]);
|
||||
self.post_refresh_feeds(data, callback);
|
||||
NEWSBLUR.reader.force_feed_refresh(feed_id, data.new_feed_id);
|
||||
}, error_callback);
|
||||
} else {
|
||||
if ($.isFunction(callback)) callback();
|
||||
}
|
||||
|
|
|
@ -250,35 +250,49 @@ _.extend(NEWSBLUR.ReaderFeedException.prototype, {
|
|||
},
|
||||
|
||||
change_feed_address: function() {
|
||||
var $loading = $('.NB-modal-loading', this.$modal);
|
||||
$loading.addClass('NB-active');
|
||||
|
||||
$('.NB-modal-submit-address', this.$modal).addClass('NB-disabled').attr('value', 'Parsing...');
|
||||
|
||||
var feed_id = this.feed_id;
|
||||
var feed_address = $('input[name=feed_address]', this.$modal).val();
|
||||
var $loading = $('.NB-modal-loading', this.$modal);
|
||||
var $feed_address = $('input[name=feed_address]', this.$modal);
|
||||
var $submit = $('.NB-modal-submit-address', this.$modal);
|
||||
var $error = $feed_address.closest('.NB-exception-option').find('.NB-error');
|
||||
var feed_address = $feed_address.val();
|
||||
|
||||
$loading.addClass('NB-active');
|
||||
$submit.addClass('NB-disabled').attr('value', 'Parsing...');
|
||||
$error.hide().html('');
|
||||
|
||||
if (feed_address.length) {
|
||||
this.model.save_exception_change_feed_address(feed_id, feed_address, function(code) {
|
||||
NEWSBLUR.reader.force_feed_refresh(feed_id);
|
||||
$.modal.close();
|
||||
}, function(data) {
|
||||
$error.show().html((data && data.message) || "There was a problem fetching the feed from this URL.");
|
||||
$loading.removeClass('NB-active');
|
||||
$submit.removeClass('NB-disabled').attr('value', 'Parse this RSS/XML Feed');
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
change_feed_link: function() {
|
||||
var $loading = $('.NB-modal-loading', this.$modal);
|
||||
$loading.addClass('NB-active');
|
||||
|
||||
$('.NB-modal-submit-link', this.$modal).addClass('NB-disabled').attr('value', 'Fetching...');
|
||||
|
||||
var feed_id = this.feed_id;
|
||||
var feed_link = $('input[name=feed_link]', this.$modal).val();
|
||||
|
||||
var $feed_link = $('input[name=feed_link]', this.$modal);
|
||||
var $loading = $('.NB-modal-loading', this.$modal);
|
||||
var $submit = $('.NB-modal-submit-link', this.$modal);
|
||||
var $error = $feed_link.closest('.NB-exception-option').find('.NB-error');
|
||||
var feed_link = $feed_link.val();
|
||||
|
||||
$loading.addClass('NB-active');
|
||||
$submit.addClass('NB-disabled').attr('value', 'Fetching...');
|
||||
$error.hide().html('');
|
||||
|
||||
if (feed_link.length) {
|
||||
this.model.save_exception_change_feed_link(feed_id, feed_link, function(code) {
|
||||
NEWSBLUR.reader.force_feed_refresh(feed_id);
|
||||
$.modal.close();
|
||||
}, function(data) {
|
||||
$error.show().html((data && data.message) || "There was a problem fetching the feed from this URL.");
|
||||
$loading.removeClass('NB-active');
|
||||
$submit.removeClass('NB-disabled').attr('value', 'Fetch Feed from Website');
|
||||
});
|
||||
}
|
||||
},
|
||||
|
|
|
@ -129,12 +129,11 @@ def json_view(func):
|
|||
request_repr,
|
||||
)
|
||||
# print message
|
||||
response = {'result': 'error',
|
||||
'text': unicode(e)}
|
||||
code = 500
|
||||
if not settings.DEBUG:
|
||||
mail_admins(subject, message, fail_silently=True)
|
||||
|
||||
response = {'result': 'error',
|
||||
'text': unicode(e)}
|
||||
code = 500
|
||||
else:
|
||||
print '\n'.join(traceback.format_exception(*exc_info))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue