mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
adding in logic for showing friends vs public
This commit is contained in:
parent
77db3063e0
commit
5061e5c861
5 changed files with 134 additions and 60 deletions
|
@ -108,7 +108,7 @@
|
|||
}
|
||||
|
||||
- (void)viewDidAppear:(BOOL)animated {
|
||||
[self.storyTitlesTable deselectRowAtIndexPath:[storyTitlesTable indexPathForSelectedRow] animated:YES];
|
||||
//[self.storyTitlesTable deselectRowAtIndexPath:[storyTitlesTable indexPathForSelectedRow] animated:YES];
|
||||
|
||||
UIBarButtonItem *refreshButton = [[UIBarButtonItem alloc]
|
||||
initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
|
||||
|
|
|
@ -44,14 +44,16 @@
|
|||
- (void)showOriginalSubview:(id)sender;
|
||||
- (IBAction)doNextUnreadStory;
|
||||
- (IBAction)doPreviousStory;
|
||||
- (IBAction)toggleFontSize:(id)sender;
|
||||
|
||||
- (void)markedAsRead;
|
||||
- (void)setActiveStory;
|
||||
- (IBAction)toggleFontSize:(id)sender;
|
||||
- (void)setFontStyle:(NSString *)fontStyle;
|
||||
- (void)setFontSize:(float)fontSize;
|
||||
- (NSString *)getComments;
|
||||
- (NSString *)getReplies:(NSArray *)replies;
|
||||
- (NSString *)getAvatars:(BOOL)areFriends;
|
||||
- (NSDictionary *)getUser:(int)user_id;
|
||||
- (void)setFontStyle:(NSString *)fontStyle;
|
||||
- (IBAction)doShareButton:(id)sender;
|
||||
|
||||
@end
|
||||
|
|
|
@ -122,53 +122,108 @@
|
|||
#pragma mark -
|
||||
#pragma mark Story layout
|
||||
|
||||
- (NSString *)getComments {
|
||||
NSString *comments = @"";
|
||||
- (NSString *)getAvatars:(BOOL)areFriends {
|
||||
NSString *avatarString = @"";
|
||||
NSArray *share_user_ids;
|
||||
if (areFriends) {
|
||||
NSMutableArray *friends = [appDelegate.activeStory objectForKey:@"share_user_ids"];
|
||||
NSArray *all_share_user_ids = [appDelegate.activeStory objectForKey:@"share_user_ids"];
|
||||
NSArray *all_shared_by_public = [appDelegate.activeStory objectForKey:@"shared_by_public"];
|
||||
|
||||
if ([appDelegate.activeStory objectForKey:@"comments"]) {
|
||||
NSArray *comments_array = [appDelegate.activeStory objectForKey:@"comments"];
|
||||
if ([comments_array count] > 0) {
|
||||
|
||||
comments = [comments stringByAppendingString:[NSString stringWithFormat:@
|
||||
"<div class=\"NB-story-comments-shares-teaser-wrapper\">"
|
||||
"<div class=\"NB-story-comments-shares-teaser\">"
|
||||
"<div class=\"NB-right\">Shared by <b>%@</b> people</div>"
|
||||
"<div class=\"NB-story-share-label\">Shared by: </div>"
|
||||
"<div class=\"NB-story-share-profiles NB-story-share-profiles-friends\">"
|
||||
"<div class=\"NB-story-share-profile\"><div class=\"NB-user-avatar\" original-title=\"popular\"><img src=\"http://f.cl.ly/items/0L3E37240r1O1V140k2q/popular.jpg\"></div></div>"
|
||||
"<div class=\"NB-story-share-profile\"><div class=\"NB-user-avatar\" original-title=\"roy\"><img src=\"http://a0.twimg.com/profile_images/1220963194/32457_608147485418_1702670_35737586_6975021_n_normal.jpg\"></div></div>"
|
||||
"<div class=\"NB-story-share-profile\"><div class=\"NB-user-avatar\" original-title=\"samuel\"><img src=\"http://a0.twimg.com/profile_images/1382021023/Campeche_Steps_normal.jpg\"></div></div>"
|
||||
"</div></div></div>",
|
||||
[appDelegate.activeStory objectForKey:@"comment_count"]
|
||||
]];
|
||||
|
||||
for (int i = 0; i < comments_array.count; i++) {
|
||||
NSDictionary *comment_dict = [comments_array objectAtIndex:i];
|
||||
NSDictionary *user = [self getUser:[[comment_dict objectForKey:@"user_id"] intValue]];
|
||||
NSString *comment = [NSString stringWithFormat:@
|
||||
"<div class=\"NB-story-comment\"><div>"
|
||||
|
||||
"<div class=\"NB-user-avatar\"><img src=\"%@\" /></div>"
|
||||
|
||||
"<div class=\"NB-story-comment-author-container\">"
|
||||
"<div class=\"NB-story-comment-username\">%@</div>"
|
||||
"<div class=\"NB-story-comment-date\">%@</div>"
|
||||
"<div class=\"NB-story-comment-reply-button\"><div class=\"NB-story-comment-reply-button-wrapper\">"
|
||||
"<a href=\"nb-share://share-link\">reply</a>"
|
||||
"</div></div>"
|
||||
"</div>"
|
||||
|
||||
"<div class=\"NB-story-comment-content\">%@</div>"
|
||||
"%@"
|
||||
"</div></div>",
|
||||
[user objectForKey:@"photo_url"],
|
||||
[user objectForKey:@"username"],
|
||||
[comment_dict objectForKey:@"shared_date"],
|
||||
[comment_dict objectForKey:@"comments"],
|
||||
[self getReplies:[comment_dict objectForKey:@"replies"]]];
|
||||
comments = [comments stringByAppendingString:comment];
|
||||
for (int i = 0; i < all_share_user_ids.count; i++) {
|
||||
for (int j = 0; j < all_shared_by_public.count; j++) {
|
||||
if ([[all_share_user_ids objectAtIndex:i] intValue] == [[all_shared_by_public objectAtIndex:j] intValue]) {
|
||||
[friends removeObject:[all_share_user_ids objectAtIndex:i]];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
share_user_ids = [NSArray arrayWithArray:friends];
|
||||
|
||||
// only if your friends are sharing to do you see the shared label
|
||||
if ([share_user_ids count]) {
|
||||
avatarString = [avatarString stringByAppendingString:@
|
||||
"<div class=\"NB-story-share-label\">Shared by: </div>"
|
||||
"<div class=\"NB-story-share-profiles NB-story-share-profiles-friends\">"];
|
||||
}
|
||||
} else {
|
||||
share_user_ids = [appDelegate.activeStory objectForKey:@"shared_by_public"];
|
||||
}
|
||||
|
||||
for (int i = 0; i < share_user_ids.count; i++) {
|
||||
NSDictionary *user = [self getUser:[[share_user_ids objectAtIndex:i] intValue]];
|
||||
NSString *avatar = [NSString stringWithFormat:@
|
||||
"<div class=\"NB-story-share-profile\"><div class=\"NB-user-avatar\">"
|
||||
"<img src=\"%@\">"
|
||||
"</div></div>",
|
||||
[user objectForKey:@"photo_url"]];
|
||||
avatarString = [avatarString stringByAppendingString:avatar];
|
||||
}
|
||||
|
||||
if (areFriends && [share_user_ids count]) {
|
||||
avatarString = [avatarString stringByAppendingString:@"</div"];
|
||||
}
|
||||
|
||||
return avatarString;
|
||||
}
|
||||
|
||||
- (NSString *)getComments {
|
||||
NSString *comments = @"";
|
||||
int share_count = [[appDelegate.activeStory objectForKey:@"share_count"] intValue];
|
||||
|
||||
if (share_count) {
|
||||
NSArray *comments_array = [appDelegate.activeStory objectForKey:@"comments"];
|
||||
comments = [comments stringByAppendingString:[NSString stringWithFormat:@
|
||||
"<div class=\"NB-feed-story-comments\">"
|
||||
"<div class=\"NB-story-comments-shares-teaser-wrapper\">"
|
||||
"<div class=\"NB-story-comments-shares-teaser\">"
|
||||
|
||||
"<div class=\"NB-right\">Shared by <b>%@</div>"
|
||||
|
||||
"<div class=\"NB-story-share-profiles NB-story-share-profiles-public\">"
|
||||
"%@"
|
||||
"</div>"
|
||||
|
||||
|
||||
"%@"
|
||||
|
||||
"</div></div>",
|
||||
[[appDelegate.activeStory objectForKey:@"share_count"] intValue] == 1
|
||||
? [NSString stringWithFormat:@"1 person"] :
|
||||
[NSString stringWithFormat:@"%@ people", [appDelegate.activeStory objectForKey:@"share_count"]],
|
||||
[self getAvatars:NO],
|
||||
[self getAvatars:YES]
|
||||
]];
|
||||
|
||||
for (int i = 0; i < comments_array.count; i++) {
|
||||
NSDictionary *comment_dict = [comments_array objectAtIndex:i];
|
||||
NSDictionary *user = [self getUser:[[comment_dict objectForKey:@"user_id"] intValue]];
|
||||
NSString *comment = [NSString stringWithFormat:@
|
||||
"<div class=\"NB-story-comment\"><div>"
|
||||
|
||||
"<div class=\"NB-user-avatar\"><img src=\"%@\" /></div>"
|
||||
|
||||
"<div class=\"NB-story-comment-author-container\">"
|
||||
"<div class=\"NB-story-comment-username\">%@</div>"
|
||||
"<div class=\"NB-story-comment-date\">%@</div>"
|
||||
"<div class=\"NB-story-comment-reply-button\"><div class=\"NB-story-comment-reply-button-wrapper\">"
|
||||
"<a href=\"nb-share://share-link\">reply</a>"
|
||||
"</div></div>"
|
||||
"</div>"
|
||||
|
||||
"<div class=\"NB-story-comment-content\">%@</div>"
|
||||
"%@"
|
||||
"</div></div>",
|
||||
[user objectForKey:@"photo_url"],
|
||||
[user objectForKey:@"username"],
|
||||
[comment_dict objectForKey:@"shared_date"],
|
||||
[comment_dict objectForKey:@"comments"],
|
||||
[self getReplies:[comment_dict objectForKey:@"replies"]]];
|
||||
comments = [comments stringByAppendingString:comment];
|
||||
}
|
||||
comments = [comments stringByAppendingString:[NSString stringWithFormat:@"</div>"]];
|
||||
|
||||
}
|
||||
return comments;
|
||||
}
|
||||
|
@ -281,7 +336,7 @@
|
|||
"<html><head>%@ %@</head>"
|
||||
"<body id=\"story_pane\">%@"
|
||||
"<div class=\"NB-story\">%@ </div>"
|
||||
"<div class=\"NB-feed-story-comments\">%@</div>" // comments
|
||||
"%@" // comments
|
||||
"%@" // share
|
||||
"</body></html>",
|
||||
universalImgCssString,
|
||||
|
@ -292,7 +347,7 @@
|
|||
sharingHtmlString
|
||||
];
|
||||
|
||||
NSLog(@"\n\n\n\nstory content\n\n\n%@<div class=\"NB-story\">%@</div>\n\n\n", storyHeader, [appDelegate.activeStory objectForKey:@"story_content"]);
|
||||
// NSLog(@"\n\n\n\nstory content\n\n\n%@<div class=\"NB-story\">%@</div>\n\n\n", storyHeader, [appDelegate.activeStory objectForKey:@"story_content"]);
|
||||
NSString *path = [[NSBundle mainBundle] bundlePath];
|
||||
NSURL *baseURL = [NSURL fileURLWithPath:path];
|
||||
|
||||
|
|
|
@ -1272,7 +1272,7 @@
|
|||
29B97313FDCFA39411CA2CEA /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 0420;
|
||||
LastUpgradeCheck = 0430;
|
||||
ORGANIZATIONNAME = NewsBlur;
|
||||
};
|
||||
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "NewsBlur" */;
|
||||
|
@ -1543,6 +1543,7 @@
|
|||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = NewsBlur_Prefix.pch;
|
||||
GCC_THUMB_SUPPORT = NO;
|
||||
GCC_VERSION = "";
|
||||
HEADER_SEARCH_PATHS = "";
|
||||
INFOPLIST_FILE = "NewsBlur-iPhone-Info.plist";
|
||||
|
@ -1576,6 +1577,7 @@
|
|||
COPY_PHASE_STRIP = YES;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = NewsBlur_Prefix.pch;
|
||||
GCC_THUMB_SUPPORT = NO;
|
||||
GCC_VERSION = "";
|
||||
HEADER_SEARCH_PATHS = "";
|
||||
INFOPLIST_FILE = "NewsBlur-iPhone-Info.plist";
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
/* Disable certain interactions on touch devices */
|
||||
body { -webkit-touch-callout: none; -webkit-text-size-adjust: none; -webkit-user-select: none; -webkit-highlight: none; -webkit-tap-highlight-color: rgba(0,0,0,0); }
|
||||
|
||||
body {
|
||||
line-height: 1.6;
|
||||
font-size: 17px;
|
||||
|
@ -16,8 +13,6 @@ h1, h2, h3, h4, h5, h6, div, table, span, pre, code {
|
|||
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: #308ab8;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
blockquote {
|
||||
|
@ -69,29 +64,31 @@ small {
|
|||
}
|
||||
|
||||
.NB-story img {
|
||||
max-width: 574px !important;
|
||||
max-width: 572px !important;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.NB-story img.NB-large-image {
|
||||
max-width: 574px !important;
|
||||
margin: 0 auto 20px !important;
|
||||
padding: 5px;
|
||||
display: block !important;
|
||||
width: auto !important;
|
||||
height: auto !important;
|
||||
background: #fff;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.NB-story img.NB-small-image {
|
||||
background: #fff;
|
||||
max-width: 574px !important;
|
||||
max-width: 572px !important;
|
||||
margin: 0 20px 10px 0 !important;
|
||||
padding: 5px;
|
||||
display: block !important;
|
||||
width: auto;
|
||||
height: auto;
|
||||
float: left;
|
||||
display: inline-block;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.NB-feed-story-comments {
|
||||
|
@ -152,6 +149,16 @@ del {
|
|||
|
||||
/* Comments */
|
||||
|
||||
/* Disable certain interactions on touch devices */
|
||||
#story_pane .NB-story-comment {
|
||||
-webkit-touch-callout: none;
|
||||
-webkit-text-size-adjust: none;
|
||||
-webkit-user-select: none;
|
||||
-webkit-highlight: none;
|
||||
-webkit-tap-highlight-color: rgba(0,0,0,0);
|
||||
}
|
||||
|
||||
|
||||
#story_pane .NB-story-comment .NB-story-comment-content {
|
||||
float: none;
|
||||
}
|
||||
|
@ -162,6 +169,14 @@ del {
|
|||
|
||||
/* Sharing */
|
||||
|
||||
.NB-share-wrapper {
|
||||
-webkit-touch-callout: none;
|
||||
-webkit-text-size-adjust: none;
|
||||
-webkit-user-select: none;
|
||||
-webkit-highlight: none;
|
||||
-webkit-tap-highlight-color: rgba(0,0,0,0);
|
||||
}
|
||||
|
||||
.NB-share-button,
|
||||
.NB-save-button {
|
||||
padding: 20px 0 50px;
|
||||
|
|
Loading…
Add table
Reference in a new issue