redesigning story detail comments

This commit is contained in:
Roy Yang 2012-08-07 11:27:00 -07:00
parent 3f1abda763
commit d2b5f70201
9 changed files with 117 additions and 1552 deletions

View file

@ -783,18 +783,11 @@
// changes the story layout in story feed detail
[self.feedDetailViewController changeActiveStoryTitleCellLayout];
// set the current row as read
// NSMutableArray *newActiveFeedStories = [self.activeFeedStories mutableCopy];
// NSMutableDictionary *newActiveStory = [[newActiveFeedStories objectAtIndex:activeLocation] mutableCopy];
// [newActiveStory setValue:[NSNumber numberWithInt:1] forKey:@"read_status"];
// [newActiveFeedStories replaceObjectAtIndex:activeLocation withObject:newActiveStory];
// self.activeFeedStories = newActiveFeedStories;
// self.activeStory = [self.activeFeedStories objectAtIndex:activeLocation];
//
int activeIndex = [[activeFeedStoryLocations objectAtIndex:activeLocation] intValue];
NSDictionary *feed;
NSDictionary *friendFeed;
id feedId;
NSString *feedIdStr;
NSMutableArray *otherFriendFeeds = [[self.activeStory objectForKey:@"shared_by_friends"] mutableCopy];
@ -805,7 +798,7 @@
feed = [self.dictSocialFeeds objectForKey:feedIdStr];
[otherFriendFeeds removeObject:feedId];
// NSLog(@"otherFriendFeeds is %@", otherFriendFeeds);
NSLog(@"otherFriendFeeds is %@", otherFriendFeeds);
} else {
feedId = [self.activeStory objectForKey:@"story_feed_id"];
feedIdStr = [NSString stringWithFormat:@"%@",feedId];
@ -813,24 +806,21 @@
}
NSDictionary *story = [activeFeedStories objectAtIndex:activeIndex];
if (self.activeFeed != feed) {
// NSLog(@"activeFeed; %@, feed: %@", activeFeed, feed);
self.activeFeed = feed;
}
[self.recentlyReadStories addObject:[NSNumber numberWithInt:activeLocation]];
[self markStoryRead:story feed:feed];
// decrement all other friend feeds
// decrement all other friend feeds if they have the same story
if (self.isSocialView) {
for (int i = 0; i < otherFriendFeeds.count; i++) {
feedIdStr = [NSString stringWithFormat:@"social:%@",
[otherFriendFeeds objectAtIndex:i]];
feed = [self.dictSocialFeeds objectForKey:feedIdStr];
[self markStoryRead:story feed:feed];
friendFeed = [self.dictSocialFeeds objectForKey:feedIdStr];
[self markStoryRead:story feed:friendFeed];
}
}
// make sure we set the active feed
self.activeFeed = feed;
[self.recentlyReadStories addObject:[NSNumber numberWithInt:activeLocation]];
[self markStoryRead:story feed:feed];
}
- (NSDictionary *)markVisibleStoriesRead {

View file

@ -32,6 +32,7 @@
- (void)finishAddReply:(ASIHTTPRequest *)request;
- (void)requestFailed:(ASIHTTPRequest *)request;
- (void)replaceStory:(NSDictionary *)newStory withReplyId:(NSString *)replyId;
- (void)adjustCommentField;
- (NSString *)stringByStrippingHTML:(NSString *)s;
@end

View file

@ -78,9 +78,28 @@
return YES;
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
[self adjustCommentField];
}
- (void)viewWillAppear:(BOOL)animated {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
[self.commentField becomeFirstResponder];
[self adjustCommentField];
}
}
- (void)adjustCommentField {
UIInterfaceOrientation orientation = (UIInterfaceOrientation)[[UIApplication sharedApplication] statusBarOrientation];
if (UIInterfaceOrientationIsPortrait(orientation)){
self.commentField.frame = CGRectMake(20, 20, 280, 114);
self.twitterButton.frame = CGRectMake(228, 142, 32, 32);
self.facebookButton.frame = CGRectMake(268, 142, 32, 32);
} else {
self.commentField.frame = CGRectMake(60, 20, 400, 74);
self.twitterButton.frame = CGRectMake(15, 20, 32, 32);
self.facebookButton.frame = CGRectMake(15, 60, 32, 32);
}
}

View file

@ -83,7 +83,8 @@
- (IBAction)toggleFontSize:(id)sender;
- (void)setFontStyle:(NSString *)fontStyle;
- (void)changeFontSize:(NSString *)fontSize;
- (NSString *)getComments:(NSString *)type;
- (NSString *)getShareBar;
- (NSString *)getComments;
- (NSString *)getComment:(NSDictionary *)commentDict;
- (NSString *)getReplies:(NSArray *)replies forUserId:(NSString *)commentUserId;
- (NSString *)getAvatars:(BOOL)areFriends;

View file

@ -155,7 +155,7 @@
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[appDelegate adjustStoryDetailWebView];
[self setActiveStory];
}
@ -279,8 +279,8 @@
return avatarString;
}
- (NSString *)getComments:(NSString *)type {
NSString *comments = @"";
- (NSString *)getComments {
NSString *comments = @"<div class=\"NB-feed-story-comments\">";
if ([appDelegate.activeStory objectForKey:@"share_count"] != [NSNull null] &&
[[appDelegate.activeStory objectForKey:@"share_count"] intValue] > 0) {
@ -288,6 +288,42 @@
NSDictionary *story = appDelegate.activeStory;
NSArray *friendsCommentsArray = [story objectForKey:@"friend_comments"];
NSArray *publicCommentsArray = [story objectForKey:@"public_comments"];
// add friends comments
for (int i = 0; i < friendsCommentsArray.count; i++) {
NSString *comment = [self getComment:[friendsCommentsArray objectAtIndex:i]];
comments = [comments stringByAppendingString:comment];
}
if ([[story objectForKey:@"comment_count_public"] intValue] > 0 ) {
NSString *publicCommentHeader = [NSString stringWithFormat:@
"<div class=\"NB-story-comments-public-header-wrapper\">"
"<div class=\"NB-story-comments-public-header\">%i public comment%@</div>"
"</div>",
[[story objectForKey:@"comment_count_public"] intValue],
[[story objectForKey:@"comment_count_public"] intValue] == 1 ? @"" : @"s"];
comments = [comments stringByAppendingString:publicCommentHeader];
// add friends comments
for (int i = 0; i < publicCommentsArray.count; i++) {
NSString *comment = [self getComment:[publicCommentsArray objectAtIndex:i]];
comments = [comments stringByAppendingString:comment];
}
}
comments = [comments stringByAppendingString:[NSString stringWithFormat:@"</div>"]];
}
return comments;
}
- (NSString *)getShareBar {
NSString *comments = @"";
if ([appDelegate.activeStory objectForKey:@"share_count"] != [NSNull null] &&
[[appDelegate.activeStory objectForKey:@"share_count"] intValue] > 0) {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
comments = [comments stringByAppendingString:[NSString stringWithFormat:@
@ -325,32 +361,8 @@
[self getAvatars:YES]
]];
}
// add friends comments
for (int i = 0; i < friendsCommentsArray.count; i++) {
NSString *comment = [self getComment:[friendsCommentsArray objectAtIndex:i]];
comments = [comments stringByAppendingString:comment];
}
if ([[story objectForKey:@"comment_count_public"] intValue] > 0 ) {
NSString *publicCommentHeader = [NSString stringWithFormat:@
"<div class=\"NB-story-comments-public-header-wrapper\">"
"<div class=\"NB-story-comments-public-header\">%i public comment%@</div>"
"</div>",
[[story objectForKey:@"comment_count_public"] intValue],
[[story objectForKey:@"comment_count_public"] intValue] == 1 ? @"" : @"s"];
comments = [comments stringByAppendingString:publicCommentHeader];
// add friends comments
for (int i = 0; i < publicCommentsArray.count; i++) {
NSString *comment = [self getComment:[publicCommentsArray objectAtIndex:i]];
comments = [comments stringByAppendingString:comment];
}
}
comments = [comments stringByAppendingString:[NSString stringWithFormat:@"</div>"]];
}
@ -584,7 +596,8 @@
[appDelegate hideShareView:YES];
[appDelegate resetShareComments];
NSString *commentString = [self getComments:@"friends"];
NSString *shareBarString = [self getShareBar];
NSString *commentString = [self getComments];
NSString *headerString;
NSString *sharingHtmlString;
NSString *footerString;
@ -673,6 +686,7 @@
"<head>%@</head>" // header string
"<body id=\"story_pane\" class=\"%@\">"
" %@" // storyHeader
" %@" // shareBar
" <div class=\"%@\" id=\"NB-font-style\">"
" <div class=\"%@\" id=\"NB-font-size\">"
" <div class=\"NB-story\">%@</div>"
@ -687,7 +701,8 @@
"</html>",
headerString,
contentWidthClass,
storyHeader,
storyHeader,
shareBarString,
fontStyleClass,
fontSizeClass,
[appDelegate.activeStory objectForKey:@"story_content"],
@ -696,7 +711,7 @@
footerString
];
// NSLog(@"\n\n\n\nhtmlString:\n\n\n%@\n\n\n", htmlString);
NSLog(@"\n\n\n\nhtmlString:\n\n\n%@\n\n\n", htmlString);
NSString *path = [[NSBundle mainBundle] bundlePath];
NSURL *baseURL = [NSURL fileURLWithPath:path];
@ -1184,7 +1199,7 @@ shouldStartLoadWithRequest:(NSURLRequest *)request
}
- (void)refreshComments:(NSString *)replyId {
NSString *commentString = [self getComments:@"friends"];
NSString *commentString = [self getComments];
NSString *jsString = [[NSString alloc] initWithFormat:@
"document.getElementById('NB-comments-wrapper').innerHTML = '%@';",
commentString];
@ -1363,7 +1378,7 @@ shouldStartLoadWithRequest:(NSURLRequest *)request
if (contentWidth > 740) {
contentWidthClass = @"NB-ipad-wide";
} else if (contentWidth > 420) {
} else if (contentWidth > 500) {
contentWidthClass = @"NB-ipad-narrow";
} else {
contentWidthClass = @"NB-iphone";

File diff suppressed because it is too large Load diff

View file

@ -3,15 +3,12 @@
}
#story_pane .NB-feed-story-comments {
margin: -24px 200px 32px 28px;
padding: 1px 0 0;
max-width: 700px;
border-top: 2px solid #353535;
border-bottom: 1px solid #353535;
border-bottom: 1px solid #A6A6A6;
}
#story_pane .NB-story-comment {
border-top: 1px solid #A6A6A6;
background-color: #FCFCFC;
background: -webkit-gradient(linear,0% 0,0% 100%,from(#F5F9FB),to(#ECF0F2));
position: relative;
padding: 0 12px 2px 72px;
line-height: 20px;
@ -165,17 +162,19 @@
background-color: whiteSmoke;
color: #202020;
cursor: default;
text-shadow: 0 1px 0 #FFF;
text-shadow: 0 1px 0 white;
font-weight: bold;
text-transform: uppercase;
font-size: 10px;
padding: 8px 12px 0px;
padding: 8px 12px 0;
overflow: hidden;
height: 27px;
height: 26px;
-webkit-transition: all .12s ease-out;
-moz-transition: all .12s ease-out;
-o-transition: all .12s ease-out;
-ms-transition: all .12s ease-out;
background-image: -webkit-gradient(linear,left bottom,left top,color-stop(0.10,#EBEBEC),color-stop(0.84,whiteSmoke));
background-image: -moz-linear-gradient(center bottom,#EBEBEC 10%,whiteSmoke 84%);
}
#story_pane .NB-story-comments-public-teaser-wrapper:hover .NB-story-comments-public-teaser {

View file

@ -1,7 +1,8 @@
<html><head><link rel="stylesheet" type="text/css" href="reader.css" ><link rel="stylesheet" type="text/css" href="storyDetailView.css" ><meta name="viewport" id="viewport" content="width=320, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/></head><body id="story_pane" class="NB-iphone"> <div class="NB-header"><div class="NB-header-inner"><div class="NB-story-date">25 Jul 2012, 1:00am</div><div class="NB-story-title">Comic for July 25, 2012</div><div class="NB-story-author"></div></div></div> <div class="NB-san-serif" id="NB-font-style"> <div class="NB-small" id="NB-font-size"> <div class="NB-story"><img border="0" src="http://dilbert.com/dyn/str_strip/000000000/00000000/0000000/100000/60000/4000/300/164382/164382.strip.print.gif" />
<p><a href="http://feedads.g.doubleclick.net/~at/FkyrdkvEp5DQaR_IXrNgE1jO7qY/0/da"><img border="0" ismap="true" src="http://feedads.g.doubleclick.net/~at/FkyrdkvEp5DQaR_IXrNgE1jO7qY/0/di" /></a><br />
<a href="http://feedads.g.doubleclick.net/~at/FkyrdkvEp5DQaR_IXrNgE1jO7qY/1/da"><img border="0" ismap="true" src="http://feedads.g.doubleclick.net/~at/FkyrdkvEp5DQaR_IXrNgE1jO7qY/1/di" /></a></p><img height="1" src="http://feeds.feedburner.com/~r/DilbertDailyStrip/~4/2TjSV0_Jlo0" width="1" /></div> </div> </div> <div class='NB-share-header'></div><div class='NB-share-wrapper'><div class='NB-share-inner-wrapper'><div id="NB-share-button-id" class='NB-share-button NB-button'><div><a href="http://ios.newsblur.com/share">Post to Blurblog</a></div></div></div></div> <div id="NB-comments-wrapper"> </div> <script src="zepto.js"></script><script src="storyDetailView.js"></script></body></html>
<html><head><link rel="stylesheet" type="text/css" href="reader.css" ><link rel="stylesheet" type="text/css" href="storyDetailView.css" ><meta name="viewport" id="viewport" content="width=320, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/></head><body id="story_pane" class="NB-iphone"> <div class="NB-header"><div class="NB-header-inner"><div class="NB-story-date">6:43am</div><div class="NB-story-title">Glass Half Empty</div><div class="NB-story-author"></div></div></div> <div class="NB-feed-story-comments"><div class="NB-story-comments-shares-teaser-wrapper"><div class="NB-story-comments-shares-teaser"><div class="NB-story-share-label">Shared by: </div><div class="NB-story-share-profile"><div class="NB-user-avatar"><a id="NB-user-share-bar-33405" class="NB-show-profile" href="http://ios.newsblur.com/show-profile/33405"><img src="http://graph.facebook.com/2231474/picture" /></a></div></div><div class="NB-story-share-profile"><div class="NB-user-avatar"><a id="NB-user-share-bar-32048" class="NB-show-profile" href="http://ios.newsblur.com/show-profile/32048"><img src="http://f.cl.ly/items/0L3E37240r1O1V140k2q/popular.jpg" /></a></div></div><div class="NB-story-share-profile"><div class="NB-user-avatar"><a id="NB-user-share-bar-27551" class="NB-show-profile" href="http://ios.newsblur.com/show-profile/27551"><img src="http://graph.facebook.com/1702670/picture" /></a></div></div><div class="NB-story-share-profile"><div class="NB-user-avatar"><a id="NB-user-share-bar-24425" class="NB-show-profile" href="http://ios.newsblur.com/show-profile/24425"><img src="http://a0.twimg.com/profile_images/689503265/profile_normal.jpg" /></a></div></div><div class="NB-story-share-profile"><div class="NB-user-avatar"><a id="NB-user-share-bar-32768" class="NB-show-profile" href="http://ios.newsblur.com/show-profile/32768"><img src="http://a0.twimg.com/profile_images/481286828/tech2_normal.jpg" /></a></div></div></div></div></div> <div class="NB-san-serif" id="NB-font-style"> <div class="NB-small" id="NB-font-size"> <div class="NB-story"><article class="entry">
<a href="http://what-if.xkcd.com/6/"><h1>Glass Half Empty</h1></a>
<p id="question">What if a glass of water was, all of a sudden, literally half empty?</p>
<p id="attribute">—Vittorio Iacovella</p>
<script>
document.getElementById('NB-comments-wrapper').innerHTML = '<div class="NB-feed-story-comments"><div class="NB-story-comments-shares-teaser-wrapper"><div class="NB-story-comments-shares-teaser"><div class="NB-story-share-label">Shared by: </div><div class="NB-story-share-profile"><div class="NB-user-avatar"><a id="NB-user-share-bar-3" class="NB-show-profile" href="http://ios.newsblur.com/show-profile/3"><img src="http://www.gravatar.com/avatar/8cef1a0df909c0290fdc1d87c6c30a55" /></a></div></div></div></div><div class="NB-story-comments-public-header-wrapper"><div class="NB-story-comments-public-header">1 public comment</div></div><div class="NB-story-comment" id="NB-user-comment-3"><div class="NB-user-avatar"><a class="NB-show-profile" href="http://ios.newsblur.com/show-profile/3"><img src="http://www.gravatar.com/avatar/8cef1a0df909c0290fdc1d87c6c30a55" /></a></div><div class="NB-story-comment-author-container"> <div class="NB-story-comment-username">roy</div> <div class="NB-story-comment-date">just a second ago</div></div><div class="NB-story-comment-content">sdfdsf<div style="clear:both"> <div class="NB-story-comment-reply-button NB-button"> <div class="NB-story-comment-reply-button-wrapper"> <a href="http://ios.newsblur.com/reply/3/roy">Reply</a> </div> </div> <div class="NB-story-comment-edit-button NB-story-comment-share-edit-button NB-button"><div class="NB-story-comment-edit-button-wrapper"><a href="http://ios.newsblur.com/edit-share/3">Edit</a></div></div> </div></div></div></div>';
</script>
</article></div> </div> </div> <div class='NB-share-header'></div><div class='NB-share-wrapper'><div class='NB-share-inner-wrapper'><div id="NB-share-button-id" class='NB-share-button NB-button'><div><a href="http://ios.newsblur.com/share">Post to Blurblog</a></div></div></div></div> <div id="NB-comments-wrapper"> <div class="NB-feed-story-comments"><div class="NB-story-comment" id="NB-user-comment-24425"><div class="NB-user-avatar"><a class="NB-show-profile" href="http://ios.newsblur.com/show-profile/24425"><img src="http://a0.twimg.com/profile_images/689503265/profile_normal.jpg" /></a></div><div class="NB-story-comment-author-container"> <div class="NB-story-comment-username">ConstantineXVI</div> <div class="NB-story-comment-date">4 hours ago</div></div><div class="NB-story-comment-content">"the physicist ducks"<div style="clear:both"> <div class="NB-story-comment-reply-button NB-button"> <div class="NB-story-comment-reply-button-wrapper"> <a href="http://ios.newsblur.com/reply/24425/ConstantineXVI">Reply</a> </div> </div> <div class="NB-story-comment-like-button NB-button"><div class="NB-story-comment-like-button-wrapper"><a href="http://ios.newsblur.com/like-comment/24425">Favorite</a></div></div></div></div></div></div> </div> <script src="zepto.js"></script><script src="storyDetailView.js"></script></body></html>

View file

@ -120,6 +120,10 @@ body {
font-family: Helvetica;
}
body.NB-iphone {
line-height: 110%;
}
.NB-story-author {
color: #969696;
text-transform: uppercase;
@ -193,6 +197,17 @@ body {
line-height: 140%;
}
.NB-iphone .NB-story h1,
.NB-iphone .NB-story h2,
.NB-iphone .NB-story h3,
.NB-iphone .NB-story h4,
.NB-iphone .NB-story h5,
.NB-iphone .NB-story h6 {
line-height: 120%;
font-size: 1.1em;
}
a {
text-decoration: none;
}
@ -228,6 +243,10 @@ div + p {
max-width: none;
}
.NB-iphone .NB-header {
font-size: 14px;
}
.NB-story {
overflow: hidden;
}