mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-08-31 21:41:33 +00:00
logic for story titles in landscape view and edit reply logic
This commit is contained in:
parent
6801c84f54
commit
52f5c20a72
6 changed files with 66 additions and 40 deletions
|
@ -460,13 +460,13 @@
|
||||||
cell.imageView.image = resizedSpacer;
|
cell.imageView.image = resizedSpacer;
|
||||||
[cell.imageView addSubview:spinner];
|
[cell.imageView addSubview:spinner];
|
||||||
[spinner startAnimating];
|
[spinner startAnimating];
|
||||||
|
|
||||||
UIView *topBorder = [[UIView alloc] init];
|
|
||||||
topBorder.frame = CGRectMake(0, 0, self.view.frame.size.width, 1);
|
|
||||||
topBorder.backgroundColor = [UIColor colorWithRed:.9 green:.9 blue:.9 alpha:1.0];
|
|
||||||
[cell addSubview:topBorder];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UIView *topBorder = [[UIView alloc] init];
|
||||||
|
topBorder.frame = CGRectMake(0, 0, self.view.frame.size.width, 1);
|
||||||
|
topBorder.backgroundColor = [UIColor colorWithRed:.9 green:.9 blue:.9 alpha:1.0];
|
||||||
|
[cell addSubview:topBorder];
|
||||||
|
|
||||||
return cell;
|
return cell;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -266,32 +266,32 @@
|
||||||
setUsername:(NSString *)username
|
setUsername:(NSString *)username
|
||||||
setCommentIndex:(NSString *)commentIndex {
|
setCommentIndex:(NSString *)commentIndex {
|
||||||
self.isShowingShare = YES;
|
self.isShowingShare = YES;
|
||||||
|
|
||||||
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
|
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
|
||||||
// add shareViewController to storyDetail
|
// add shareViewController to storyDetail
|
||||||
[self.storyDetailViewController.view addSubview:self.shareViewController.view];
|
[self.storyDetailContainerViewController.view addSubview:self.shareViewController.view];
|
||||||
[self.shareViewController setSiteInfo:type setUserId:userId setUsername:username setCommentIndex:commentIndex];
|
[self.shareViewController setSiteInfo:type setUserId:userId setUsername:username setCommentIndex:commentIndex];
|
||||||
|
|
||||||
|
|
||||||
self.shareViewController.view.frame = CGRectMake(0,
|
self.shareViewController.view.frame = CGRectMake(0,
|
||||||
self.storyDetailViewController.view.frame.size.height,
|
self.storyDetailContainerViewController.view.frame.size.height,
|
||||||
self.storyDetailViewController.view.frame.size.width,
|
self.storyDetailContainerViewController.view.frame.size.width,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
int newShareYCoordinate = self.storyDetailViewController.view.frame.size.height - SHARE_MODAL_HEIGHT;
|
int newShareYCoordinate = self.storyDetailContainerViewController.view.frame.size.height - SHARE_MODAL_HEIGHT;
|
||||||
int newStoryHeight = self.storyDetailViewController.view.frame.size.height - SHARE_MODAL_HEIGHT;
|
int newStoryHeight = self.storyDetailContainerViewController.view.frame.size.height - SHARE_MODAL_HEIGHT + 44;
|
||||||
|
|
||||||
[UIView animateWithDuration:0.35 animations:^{
|
[UIView animateWithDuration:0.35 animations:^{
|
||||||
self.shareViewController.view.frame = CGRectMake(0,
|
self.shareViewController.view.frame = CGRectMake(0,
|
||||||
newShareYCoordinate,
|
newShareYCoordinate,
|
||||||
self.storyDetailViewController.view.frame.size.width,
|
self.storyDetailContainerViewController.view.frame.size.width,
|
||||||
SHARE_MODAL_HEIGHT);
|
SHARE_MODAL_HEIGHT);
|
||||||
|
self.storyDetailViewController.view.frame = CGRectMake(0,
|
||||||
|
0,
|
||||||
|
self.storyDetailContainerViewController.view.frame.size.width,
|
||||||
|
newStoryHeight);
|
||||||
} completion:^(BOOL finished) {
|
} completion:^(BOOL finished) {
|
||||||
self.storyDetailViewController.webView.frame = CGRectMake(0,
|
|
||||||
0,
|
|
||||||
self.storyDetailViewController.view.frame.size.width,
|
|
||||||
newStoryHeight);
|
|
||||||
[self.shareViewController.commentField becomeFirstResponder];
|
[self.shareViewController.commentField becomeFirstResponder];
|
||||||
[self.storyDetailViewController scrolltoBottom];
|
|
||||||
}];
|
}];
|
||||||
} else {
|
} else {
|
||||||
[self.navigationController presentModalViewController:self.shareViewController animated:YES];
|
[self.navigationController presentModalViewController:self.shareViewController animated:YES];
|
||||||
|
@ -323,17 +323,16 @@
|
||||||
|
|
||||||
self.isShowingShare = NO;
|
self.isShowingShare = NO;
|
||||||
|
|
||||||
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
|
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
|
||||||
storyDetailViewController.webView.frame = CGRectMake(0,
|
|
||||||
0,
|
|
||||||
storyDetailViewController.view.frame.size.width,
|
|
||||||
storyDetailViewController.view.frame.size.height - 44);
|
|
||||||
|
|
||||||
[UIView animateWithDuration:0.35 animations:^{
|
[UIView animateWithDuration:0.35 animations:^{
|
||||||
shareViewController.view.frame = CGRectMake(0,
|
shareViewController.view.frame = CGRectMake(0,
|
||||||
storyDetailViewController.view.frame.size.height,
|
storyDetailContainerViewController.view.frame.size.height,
|
||||||
storyDetailViewController.view.frame.size.width,
|
storyDetailContainerViewController.view.frame.size.width,
|
||||||
0);
|
0);
|
||||||
|
storyDetailViewController.view.frame = CGRectMake(0,
|
||||||
|
0,
|
||||||
|
storyDetailContainerViewController.view.frame.size.width,
|
||||||
|
storyDetailContainerViewController.view.frame.size.height);
|
||||||
} completion:^(BOOL finished) {
|
} completion:^(BOOL finished) {
|
||||||
[shareViewController.view removeFromSuperview];
|
[shareViewController.view removeFromSuperview];
|
||||||
}];
|
}];
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
- (IBAction)doReplyToComment:(id)sender;
|
- (IBAction)doReplyToComment:(id)sender;
|
||||||
- (void)finishAddComment:(ASIHTTPRequest *)request;
|
- (void)finishAddComment:(ASIHTTPRequest *)request;
|
||||||
- (void)finishAddReply:(ASIHTTPRequest *)request;
|
- (void)finishAddReply:(ASIHTTPRequest *)request;
|
||||||
- (void)replaceStory:(NSDictionary *)newStory;
|
- (void)requestFailed:(ASIHTTPRequest *)request;- (void)replaceStory:(NSDictionary *)newStory;
|
||||||
|
- (NSString *) stringByStrippingHTML:(NSString *)s;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -111,6 +111,7 @@
|
||||||
|
|
||||||
- (void)setSiteInfo:(NSString *)type setUserId:(NSString *)userId setUsername:(NSString *)username setCommentIndex:(NSString *)commentIndex {
|
- (void)setSiteInfo:(NSString *)type setUserId:(NSString *)userId setUsername:(NSString *)username setCommentIndex:(NSString *)commentIndex {
|
||||||
|
|
||||||
|
|
||||||
if ([type isEqualToString: @"edit-reply"]) {
|
if ([type isEqualToString: @"edit-reply"]) {
|
||||||
[submitButton setTitle:@"Save"];
|
[submitButton setTitle:@"Save"];
|
||||||
facebookButton.hidden = YES;
|
facebookButton.hidden = YES;
|
||||||
|
@ -122,7 +123,7 @@
|
||||||
// get old comment
|
// get old comment
|
||||||
NSArray *replies = [appDelegate.activeComment objectForKey:@"replies"];
|
NSArray *replies = [appDelegate.activeComment objectForKey:@"replies"];
|
||||||
int commentIdx = [commentIndex intValue];
|
int commentIdx = [commentIndex intValue];
|
||||||
self.commentField.text = [[replies objectAtIndex:commentIdx] objectForKey:@"comments"];
|
self.commentField.text = [self stringByStrippingHTML:[[replies objectAtIndex:commentIdx] objectForKey:@"comments"]];
|
||||||
} else if ([type isEqualToString: @"reply"]) {
|
} else if ([type isEqualToString: @"reply"]) {
|
||||||
self.activeCommentIndex = -1;
|
self.activeCommentIndex = -1;
|
||||||
[submitButton setTitle:@"Reply"];
|
[submitButton setTitle:@"Reply"];
|
||||||
|
@ -136,7 +137,7 @@
|
||||||
twitterButton.hidden = NO;
|
twitterButton.hidden = NO;
|
||||||
|
|
||||||
// get old comment
|
// get old comment
|
||||||
self.commentField.text = [appDelegate.activeComment objectForKey:@"comments"];
|
self.commentField.text = [self stringByStrippingHTML:[appDelegate.activeComment objectForKey:@"comments"]];
|
||||||
|
|
||||||
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
|
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
|
||||||
[toolbarTitle setTitle:@"Edit Your Comment"];
|
[toolbarTitle setTitle:@"Edit Your Comment"];
|
||||||
|
@ -211,7 +212,7 @@
|
||||||
|
|
||||||
if (self.activeCommentIndex != -1) {
|
if (self.activeCommentIndex != -1) {
|
||||||
NSDictionary *activeComment = [[appDelegate.activeComment objectForKey:@"replies"] objectAtIndex:self.activeCommentIndex];
|
NSDictionary *activeComment = [[appDelegate.activeComment objectForKey:@"replies"] objectAtIndex:self.activeCommentIndex];
|
||||||
[request setPostValue:[activeComment objectForKey:@"comments"] forKey:@"original_message"];
|
[request setPostValue:[self stringByStrippingHTML:[activeComment objectForKey:@"comments"]] forKey:@"original_message"];
|
||||||
}
|
}
|
||||||
|
|
||||||
[request setDelegate:self];
|
[request setDelegate:self];
|
||||||
|
@ -226,7 +227,6 @@
|
||||||
NSString *responseString = [request responseString];
|
NSString *responseString = [request responseString];
|
||||||
NSDictionary *results = [[NSDictionary alloc]
|
NSDictionary *results = [[NSDictionary alloc]
|
||||||
initWithDictionary:[responseString JSONValue]];
|
initWithDictionary:[responseString JSONValue]];
|
||||||
|
|
||||||
// add the comment into the activeStory dictionary
|
// add the comment into the activeStory dictionary
|
||||||
NSDictionary *comment = [results objectForKey:@"comment"];
|
NSDictionary *comment = [results objectForKey:@"comment"];
|
||||||
NSArray *userProfiles = [results objectForKey:@"user_profiles"];
|
NSArray *userProfiles = [results objectForKey:@"user_profiles"];
|
||||||
|
@ -285,6 +285,12 @@
|
||||||
[self replaceStory:[results objectForKey:@"story"]];
|
[self replaceStory:[results objectForKey:@"story"]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)requestFailed:(ASIHTTPRequest *)request
|
||||||
|
{
|
||||||
|
NSError *error = [request error];
|
||||||
|
NSLog(@"Error: %@", error);
|
||||||
|
}
|
||||||
|
|
||||||
- (void)replaceStory:(NSDictionary *)newStory {
|
- (void)replaceStory:(NSDictionary *)newStory {
|
||||||
[commentField resignFirstResponder];
|
[commentField resignFirstResponder];
|
||||||
[appDelegate hideShareView:YES];
|
[appDelegate hideShareView:YES];
|
||||||
|
@ -310,12 +316,6 @@
|
||||||
|
|
||||||
self.commentField.text = nil;
|
self.commentField.text = nil;
|
||||||
[appDelegate refreshComments];
|
[appDelegate refreshComments];
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)requestFailed:(ASIHTTPRequest *)request {
|
|
||||||
NSError *error = [request error];
|
|
||||||
NSLog(@"Error: %@", error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)keyboardWillShowOrHide:(NSNotification*)notification {
|
-(void)keyboardWillShowOrHide:(NSNotification*)notification {
|
||||||
|
@ -360,4 +360,12 @@
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-(NSString *)stringByStrippingHTML:(NSString *)s {
|
||||||
|
NSRange r;
|
||||||
|
|
||||||
|
while ((r = [s rangeOfString:@"<[^>]+>" options:NSRegularExpressionSearch]).location != NSNotFound)
|
||||||
|
s = [s stringByReplacingCharactersInRange:r withString:@""];
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -276,6 +276,8 @@
|
||||||
"</div>",
|
"</div>",
|
||||||
[sourceUser objectForKey:@"photo_url"]];
|
[sourceUser objectForKey:@"photo_url"]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NSString *commentContent = [self textToHtml:[commentDict objectForKey:@"comments"]];
|
||||||
|
|
||||||
NSString *comment = [NSString stringWithFormat:@
|
NSString *comment = [NSString stringWithFormat:@
|
||||||
"<div class=\"NB-story-comment\" id=\"NB-user-comment-%@\">"
|
"<div class=\"NB-story-comment\" id=\"NB-user-comment-%@\">"
|
||||||
|
@ -306,7 +308,7 @@
|
||||||
[user objectForKey:@"username"],
|
[user objectForKey:@"username"],
|
||||||
userEditButton,
|
userEditButton,
|
||||||
userLikeButton,
|
userLikeButton,
|
||||||
[commentDict objectForKey:@"comments"],
|
commentContent,
|
||||||
[self getReplies:[commentDict objectForKey:@"replies"] forUserId:[commentDict objectForKey:@"user_id"]]];
|
[self getReplies:[commentDict objectForKey:@"replies"] forUserId:[commentDict objectForKey:@"user_id"]]];
|
||||||
|
|
||||||
return comment;
|
return comment;
|
||||||
|
@ -336,6 +338,8 @@
|
||||||
i // comment number in array
|
i // comment number in array
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NSString *replyContent = [self textToHtml:[replyDict objectForKey:@"comments"]];
|
||||||
|
|
||||||
NSString *reply = [NSString stringWithFormat:@
|
NSString *reply = [NSString stringWithFormat:@
|
||||||
"<div class=\"NB-story-comment-reply\">"
|
"<div class=\"NB-story-comment-reply\">"
|
||||||
|
@ -352,7 +356,7 @@
|
||||||
[user objectForKey:@"username"],
|
[user objectForKey:@"username"],
|
||||||
[replyDict objectForKey:@"publish_date"],
|
[replyDict objectForKey:@"publish_date"],
|
||||||
userEditButton,
|
userEditButton,
|
||||||
[replyDict objectForKey:@"comments"]];
|
replyContent];
|
||||||
repliesString = [repliesString stringByAppendingString:reply];
|
repliesString = [repliesString stringByAppendingString:reply];
|
||||||
}
|
}
|
||||||
repliesString = [repliesString stringByAppendingString:@"</div>"];
|
repliesString = [repliesString stringByAppendingString:@"</div>"];
|
||||||
|
@ -566,7 +570,11 @@ shouldStartLoadWithRequest:(NSURLRequest *)request
|
||||||
navigationType:(UIWebViewNavigationType)navigationType {
|
navigationType:(UIWebViewNavigationType)navigationType {
|
||||||
NSURL *url = [request URL];
|
NSURL *url = [request URL];
|
||||||
NSArray *urlComponents = [url pathComponents];
|
NSArray *urlComponents = [url pathComponents];
|
||||||
NSString *action = [NSString stringWithFormat:@"%@", [urlComponents objectAtIndex:1]];
|
NSString *action = @"";
|
||||||
|
if ([urlComponents count] > 1) {
|
||||||
|
action = [NSString stringWithFormat:@"%@", [urlComponents objectAtIndex:1]];
|
||||||
|
}
|
||||||
|
|
||||||
// HACK: Using ios.newsblur.com to intercept the javascript share, reply, and edit events.
|
// HACK: Using ios.newsblur.com to intercept the javascript share, reply, and edit events.
|
||||||
// the pathComponents do not work correctly unless it is a correctly formed url
|
// the pathComponents do not work correctly unless it is a correctly formed url
|
||||||
// Is there a better way? Someone show me the light
|
// Is there a better way? Someone show me the light
|
||||||
|
@ -757,6 +765,7 @@ shouldStartLoadWithRequest:(NSURLRequest *)request
|
||||||
NSString *jsString = [[NSString alloc] initWithFormat:@
|
NSString *jsString = [[NSString alloc] initWithFormat:@
|
||||||
"document.getElementById('NB-comments-wrapper').innerHTML = '%@';",
|
"document.getElementById('NB-comments-wrapper').innerHTML = '%@';",
|
||||||
commentString];
|
commentString];
|
||||||
|
NSLog(@"JSSTRING IS %@\n\n\n", jsString);
|
||||||
[self.webView stringByEvaluatingJavaScriptFromString:jsString];
|
[self.webView stringByEvaluatingJavaScriptFromString:jsString];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -950,4 +959,9 @@ shouldStartLoadWithRequest:(NSURLRequest *)request
|
||||||
[appDelegate showOriginalStory:url];
|
[appDelegate showOriginalStory:url];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSString *)textToHtml:(NSString*)htmlString {
|
||||||
|
htmlString = [htmlString stringByReplacingOccurrencesOfString:@"'" withString:@"'"];
|
||||||
|
return htmlString;
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Add table
Reference in a new issue