mirror of
https://github.com/viq/NewsBlur.git
synced 2025-08-31 22:20:12 +00:00
Merge branch 'master' into tagging
* master: Now forcing image sizing. Upgrading feedparser. Fixing RSS feed for blurblogs by using permalinks instead of guids. Treat 12:00am as occurring at the start of the day Adding monit for work server. Removing starred stories from mongo backups. Logic error. New algorithm for figuring out how long to renew.
This commit is contained in:
commit
f6b7a553be
9 changed files with 576 additions and 727 deletions
|
@ -242,16 +242,21 @@ class Profile(models.Model):
|
|||
payment_provider='stripe')
|
||||
print " ---> Found %s stripe_payments" % len(stripe_payments)
|
||||
|
||||
# Calculate last payment date
|
||||
# Calculate payments in last year, then add together
|
||||
payment_history = PaymentHistory.objects.filter(user=self.user)
|
||||
most_recent_payment_date = None
|
||||
last_year = datetime.datetime.now() - datetime.timedelta(days=364)
|
||||
recent_payments_count = 0
|
||||
oldest_recent_payment_date = None
|
||||
for payment in payment_history:
|
||||
if not most_recent_payment_date or payment.payment_date > most_recent_payment_date:
|
||||
most_recent_payment_date = payment.payment_date
|
||||
if payment.payment_date > last_year:
|
||||
recent_payments_count += 1
|
||||
if not oldest_recent_payment_date or payment.payment_date < oldest_recent_payment_date:
|
||||
oldest_recent_payment_date = payment.payment_date
|
||||
print " ---> %s payments" % len(payment_history)
|
||||
|
||||
if most_recent_payment_date:
|
||||
self.premium_expire = most_recent_payment_date + datetime.timedelta(days=365)
|
||||
if oldest_recent_payment_date:
|
||||
self.premium_expire = (oldest_recent_payment_date +
|
||||
datetime.timedelta(days=365*recent_payments_count))
|
||||
self.save()
|
||||
|
||||
def refund_premium(self, partial=False):
|
||||
|
|
|
@ -1198,6 +1198,22 @@ def remove_like_comment(request):
|
|||
'user_profiles': profiles,
|
||||
})
|
||||
|
||||
def shared_stories_rss_feed_noid(request):
|
||||
index = HttpResponseRedirect('http://%s%s' % (
|
||||
Site.objects.get_current().domain,
|
||||
reverse('index')))
|
||||
if request.subdomain:
|
||||
username = request.subdomain
|
||||
try:
|
||||
if '.' in username:
|
||||
username = username.split('.')[0]
|
||||
user = User.objects.get(username__iexact=username)
|
||||
except User.DoesNotExist:
|
||||
return index
|
||||
return shared_stories_rss_feed(request, user_id=user.pk, username=request.subdomain)
|
||||
|
||||
return index
|
||||
|
||||
def shared_stories_rss_feed(request, user_id, username):
|
||||
try:
|
||||
user = User.objects.get(pk=user_id)
|
||||
|
@ -1248,7 +1264,7 @@ def shared_stories_rss_feed(request, user_id, username):
|
|||
'description': content,
|
||||
'author_name': shared_story.story_author_name,
|
||||
'categories': shared_story.story_tags,
|
||||
'unique_id': shared_story.story_guid,
|
||||
'unique_id': shared_story.story_permalink,
|
||||
'pubdate': shared_story.shared_date,
|
||||
}
|
||||
rss.add_item(**story_data)
|
||||
|
|
12
config/monit_work.conf
Normal file
12
config/monit_work.conf
Normal file
|
@ -0,0 +1,12 @@
|
|||
set daemon 120
|
||||
|
||||
set logfile /var/log/monit.log
|
||||
|
||||
set eventqueue
|
||||
basedir /var/monit # set the base directory where events will be stored
|
||||
slots 100 # optionally limit the queue size
|
||||
|
||||
# If no feeds have been queued in the last minute, something is wrong
|
||||
check file newsblur.log with path /srv/newsblur/logs/newsblur.log
|
||||
if timestamp > 2 minutes then exec "/usr/bin/supervisorctl reload"
|
||||
as uid root and gid root
|
5
fabfile.py
vendored
5
fabfile.py
vendored
|
@ -476,6 +476,11 @@ def config_monit_app():
|
|||
sudo('echo "START=yes" > /etc/default/monit')
|
||||
sudo('/etc/init.d/monit restart')
|
||||
|
||||
def config_monit_work():
|
||||
put('config/monit_work.conf', '/etc/monit/conf.d/work.conf', use_sudo=True)
|
||||
sudo('echo "START=yes" > /etc/default/monit')
|
||||
sudo('/etc/init.d/monit restart')
|
||||
|
||||
def config_monit_redis():
|
||||
sudo('chown root.root /etc/init.d/redis')
|
||||
sudo('chmod a+x /etc/init.d/redis')
|
||||
|
|
|
@ -2117,9 +2117,9 @@ body {
|
|||
max-width: 100%;
|
||||
}
|
||||
.NB-feed-story .NB-feed-story-content img {
|
||||
max-width: 100% !important;
|
||||
width: auto;
|
||||
height: auto !important;
|
||||
max-width: 100% !important;
|
||||
/* width: auto;*/
|
||||
/* height: auto !important;*/
|
||||
}
|
||||
.NB-feed-story {
|
||||
position: relative;
|
||||
|
|
2
urls.py
2
urls.py
|
@ -1,6 +1,7 @@
|
|||
from django.conf.urls import include, url, patterns
|
||||
from django.conf import settings
|
||||
from apps.reader import views as reader_views
|
||||
from apps.social import views as social_views
|
||||
from apps.static import views as static_views
|
||||
|
||||
urlpatterns = patterns('',
|
||||
|
@ -16,6 +17,7 @@ urlpatterns = patterns('',
|
|||
(r'^user/.*?', reader_views.index),
|
||||
(r'^null/.*?', reader_views.index),
|
||||
(r'^story/.*?', reader_views.index),
|
||||
(r'^feed/?', social_views.shared_stories_rss_feed_noid),
|
||||
(r'^rss_feeds/', include('apps.rss_feeds.urls')),
|
||||
(r'^classifier/', include('apps.analyzer.urls')),
|
||||
(r'^profile/', include('apps.profile.urls')),
|
||||
|
|
|
@ -10,7 +10,9 @@ os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
|
|||
import time
|
||||
import s3
|
||||
|
||||
COLLECTIONS = "classifier_tag classifier_author classifier_feed classifier_title userstories starred_stories shared_stories category category_site sent_emails social_profile social_subscription social_services statistics feedback"
|
||||
COLLECTIONS = "classifier_tag classifier_author classifier_feed classifier_title userstories shared_stories category category_site sent_emails social_profile social_subscription social_services statistics feedback"
|
||||
if False:
|
||||
COLLECTIONS += " starred_stories"
|
||||
|
||||
date = time.strftime('%Y-%m-%d-%H-%M')
|
||||
collections = COLLECTIONS.split(' ')
|
||||
|
|
1229
utils/feedparser.py
1229
utils/feedparser.py
File diff suppressed because it is too large
Load diff
|
@ -35,9 +35,9 @@ def format_story_link_date__short(date, now=None):
|
|||
now = datetime.datetime.now()
|
||||
date = date.replace(tzinfo=None)
|
||||
midnight = midnight_today(now)
|
||||
if date > midnight:
|
||||
if date >= midnight:
|
||||
return date.strftime('%I:%M%p').lstrip('0').lower()
|
||||
elif date > midnight_yesterday(midnight):
|
||||
elif date >= midnight_yesterday(midnight):
|
||||
return 'Yesterday, ' + date.strftime('%I:%M%p').lstrip('0').lower()
|
||||
else:
|
||||
return date.strftime('%d %b %Y, ') + date.strftime('%I:%M%p').lstrip('0').lower()
|
||||
|
@ -49,11 +49,11 @@ def format_story_link_date__long(date, now=None):
|
|||
midnight = midnight_today(now)
|
||||
parsed_date = DateFormat(date)
|
||||
|
||||
if date > midnight:
|
||||
if date >= midnight:
|
||||
return 'Today, ' + parsed_date.format('F jS ') + date.strftime('%I:%M%p').lstrip('0').lower()
|
||||
elif date > midnight_yesterday(midnight):
|
||||
elif date >= midnight_yesterday(midnight):
|
||||
return 'Yesterday, ' + parsed_date.format('F jS g:ia').replace('.','')
|
||||
elif date > beginning_of_this_month():
|
||||
elif date >= beginning_of_this_month():
|
||||
return parsed_date.format('l, F jS g:ia').replace('.','')
|
||||
else:
|
||||
return parsed_date.format('l, F jS, Y g:ia').replace('.','')
|
||||
|
|
Loading…
Add table
Reference in a new issue