Style adjustments.

This commit is contained in:
Samuel Clay 2019-08-27 20:28:11 -07:00
parent 7ce3b92e56
commit b5925d0228
4 changed files with 118 additions and 13 deletions

View file

@ -10,5 +10,6 @@ urlpatterns = patterns('',
url(r'^add_site/?$', views.add_site_authed, name='api-add-site-authed'),
url(r'^check_share_on_site/(?P<token>\w+)', views.check_share_on_site, name='api-check-share-on-site'),
url(r'^share_story/(?P<token>\w+)', views.share_story, name='api-share-story'),
url(r'^save_story/(?P<token>\w+)', views.save_story, name='api-save-story'),
url(r'^share_story/?$', views.share_story),
)

View file

@ -306,7 +306,6 @@ def share_story(request, token=None):
message = "Not authenticated, couldn't find user by token."
else:
message = "Not authenticated, no token supplied and not authenticated."
if not profile:
return HttpResponse(json.encode({
@ -397,3 +396,104 @@ def share_story(request, token=None):
response['Access-Control-Allow-Methods'] = 'POST'
return response
@required_params('story_url', 'title')
def save_story(request, token=None):
code = 0
story_url = request.POST['story_url']
user_tags = request.POST.getlist('user_tags') or request.REQUEST.getlist('user_tags[]') or []
add_user_tag = request.POST.get('add_user_tag', None)
title = request.POST['title']
content = request.POST.get('content', None)
rss_url = request.POST.get('rss_url', None)
feed_id = request.POST.get('feed_id', None) or 0
feed = None
message = None
profile = None
if request.user.is_authenticated():
profile = request.user.profile
else:
try:
profile = Profile.objects.get(secret_token=token)
except Profile.DoesNotExist:
code = -1
if token:
message = "Not authenticated, couldn't find user by token."
else:
message = "Not authenticated, no token supplied and not authenticated."
if not profile:
return HttpResponse(json.encode({
'code': code,
'message': message,
'story': None,
}), mimetype='text/plain')
if feed_id:
feed = Feed.get_by_id(feed_id)
else:
if rss_url:
logging.user(request.user, "~FBFinding feed (save_story): %s" % rss_url)
feed = Feed.get_feed_from_url(rss_url, create=True, fetch=True)
if not feed:
logging.user(request.user, "~FBFinding feed (save_story): %s" % story_url)
feed = Feed.get_feed_from_url(story_url, create=True, fetch=True)
if feed:
feed_id = feed.pk
if content:
content = lxml.html.fromstring(content)
content.make_links_absolute(story_url)
content = lxml.html.tostring(content)
else:
importer = TextImporter(story=None, story_url=story_url, request=request, debug=settings.DEBUG)
document = importer.fetch(skip_save=True, return_document=True)
content = document['content']
if not title:
title = document['title']
starred_story = MStarredStory.objects.filter(user_id=profile.user.pk,
story_feed_id=feed_id,
story_guid=story_url).limit(1).first()
if not starred_story:
story_db = {
"story_guid": story_url,
"story_permalink": story_url,
"story_title": title,
"story_feed_id": feed_id,
"story_content": content,
"story_date": datetime.datetime.now(),
"user_id": profile.user.pk,
"has_comments": bool(comments),
}
shared_story = MSharedStory.objects.create(**story_db)
socialsubs = MSocialSubscription.objects.filter(subscription_user_id=profile.user.pk)
for socialsub in socialsubs:
socialsub.needs_unread_recalc = True
socialsub.save()
logging.user(profile.user, "~BM~FYSharing story from site: ~SB%s: %s" % (story_url, comments))
message = "Sharing story from site: %s: %s" % (story_url, comments)
else:
shared_story.story_content = content
shared_story.story_title = title
shared_story.comments = comments
shared_story.story_permalink = story_url
shared_story.story_guid = story_url
shared_story.has_comments = bool(comments)
shared_story.story_feed_id = feed_id
shared_story.save()
logging.user(profile.user, "~BM~FY~SBUpdating~SN shared story from site: ~SB%s: %s" % (story_url, comments))
message = "Updating shared story from site: %s: %s" % (story_url, comments)
shared_story.publish_update_to_subscribers()
response = HttpResponse(json.encode({
'code': code,
'message': message,
'story': shared_story,
}), mimetype='text/plain')
response['Access-Control-Allow-Origin'] = '*'
response['Access-Control-Allow-Methods'] = 'POST'
return response

View file

@ -106,7 +106,7 @@
width: 514px;
overflow: hidden;
float: right;
border-left: 6px solid #38457E;
border-left: 2px solid #F0F0F0;
margin: 24px 0 0;
}
.NB-bookmarklet .NB-bookmarklet-side {
@ -187,7 +187,7 @@
width: 8px;
}
.NB-bookmarklet .NB-folders {
width: 160px;
width: 190px;
}
.NB-bookmarklet .NB-modal-submit {
margin: 12px 0 8px;
@ -199,7 +199,6 @@
clear: both;
padding: 0 16px;
line-height: 24px;
width: 176px;
text-align: center;
text-shadow: none;
font-weight: normal;
@ -219,6 +218,9 @@
float: left;
vertical-align: top;
}
.NB-bookmarklet .NB-bookmarklet-button-subscribe {
width: 210px;
}
.NB-bookmarklet .NB-bookmarklet-error {
margin: 0;
padding: 0 12px 0 24px;
@ -300,19 +302,21 @@
font-family: "Lucida Sans", "Lucida Grande", Verdana, Arial, Helvetica, sans-serif !important;
color: #404040;
font-size: 13px;
height: 82px;
height: 98px;
background-color: white;
display: block;
}
.NB-bookmarklet .NB-bookmarklet-comment-submit,
.NB-bookmarklet .NB-bookmarklet-save {
.NB-bookmarklet .NB-bookmarklet-save-button {
clear: both;
width: 220px;
margin: 4px 0 4px 12px;
margin: 4px 0 4px 73px;
padding: 8px 0;
line-height: 16px;
}
.NB-bookmarklet .NB-bookmarklet-save {
.NB-bookmarklet .NB-bookmarklet-comment-submit {
width: 160px;
}
.NB-bookmarklet .NB-bookmarklet-save-button {
margin-left: 0;
width: 220px;
}
@ -335,13 +339,13 @@
.NB-bookmarklet .NB-bookmarklet-comment-separator {
float: left;
width: 1px;
height: 48px;
background-color: rgba(0,0,0,0.25);
height: 100%;
background-color: #e0e0e0;
margin: 0 12px 0 0;
}
.NB-bookmarklet .NB-bookmarklet-user-tags select {
width: 220px;
height: 56px;
height: 72px;
margin: 0 12px 0 0;
}

View file

@ -86,7 +86,7 @@
'Signed in as ',
$.make('b', { style: 'color: #505050' }, this.username)
]),
$.make('div', { className: 'NB-modal-title' }, 'Share this story on NewsBlur'),
$.make('div', { className: 'NB-modal-title' }, 'Send this story to NewsBlur'),
$.make('div', { className: 'NB-bookmarklet-main'}, [
$.make('div', { className: 'NB-bookmarklet-page' }, [
$.make('div', { className: 'NB-bookmarklet-page-title', contenteditable: true }),