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 addSubview:spinner];
|
||||
[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;
|
||||
}
|
||||
|
||||
|
|
|
@ -266,32 +266,32 @@
|
|||
setUsername:(NSString *)username
|
||||
setCommentIndex:(NSString *)commentIndex {
|
||||
self.isShowingShare = YES;
|
||||
|
||||
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
|
||||
// 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.view.frame = CGRectMake(0,
|
||||
self.storyDetailViewController.view.frame.size.height,
|
||||
self.storyDetailViewController.view.frame.size.width,
|
||||
self.storyDetailContainerViewController.view.frame.size.height,
|
||||
self.storyDetailContainerViewController.view.frame.size.width,
|
||||
0);
|
||||
|
||||
int newShareYCoordinate = self.storyDetailViewController.view.frame.size.height - SHARE_MODAL_HEIGHT;
|
||||
int newStoryHeight = self.storyDetailViewController.view.frame.size.height - SHARE_MODAL_HEIGHT;
|
||||
int newShareYCoordinate = self.storyDetailContainerViewController.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,
|
||||
newShareYCoordinate,
|
||||
self.storyDetailViewController.view.frame.size.width,
|
||||
self.storyDetailContainerViewController.view.frame.size.width,
|
||||
SHARE_MODAL_HEIGHT);
|
||||
self.storyDetailViewController.view.frame = CGRectMake(0,
|
||||
0,
|
||||
self.storyDetailContainerViewController.view.frame.size.width,
|
||||
newStoryHeight);
|
||||
} completion:^(BOOL finished) {
|
||||
self.storyDetailViewController.webView.frame = CGRectMake(0,
|
||||
0,
|
||||
self.storyDetailViewController.view.frame.size.width,
|
||||
newStoryHeight);
|
||||
[self.shareViewController.commentField becomeFirstResponder];
|
||||
[self.storyDetailViewController scrolltoBottom];
|
||||
}];
|
||||
} else {
|
||||
[self.navigationController presentModalViewController:self.shareViewController animated:YES];
|
||||
|
@ -323,17 +323,16 @@
|
|||
|
||||
self.isShowingShare = NO;
|
||||
|
||||
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
|
||||
storyDetailViewController.webView.frame = CGRectMake(0,
|
||||
0,
|
||||
storyDetailViewController.view.frame.size.width,
|
||||
storyDetailViewController.view.frame.size.height - 44);
|
||||
|
||||
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
|
||||
[UIView animateWithDuration:0.35 animations:^{
|
||||
shareViewController.view.frame = CGRectMake(0,
|
||||
storyDetailViewController.view.frame.size.height,
|
||||
storyDetailViewController.view.frame.size.width,
|
||||
storyDetailContainerViewController.view.frame.size.height,
|
||||
storyDetailContainerViewController.view.frame.size.width,
|
||||
0);
|
||||
storyDetailViewController.view.frame = CGRectMake(0,
|
||||
0,
|
||||
storyDetailContainerViewController.view.frame.size.width,
|
||||
storyDetailContainerViewController.view.frame.size.height);
|
||||
} completion:^(BOOL finished) {
|
||||
[shareViewController.view removeFromSuperview];
|
||||
}];
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
- (IBAction)doReplyToComment:(id)sender;
|
||||
- (void)finishAddComment:(ASIHTTPRequest *)request;
|
||||
- (void)finishAddReply:(ASIHTTPRequest *)request;
|
||||
- (void)replaceStory:(NSDictionary *)newStory;
|
||||
- (void)requestFailed:(ASIHTTPRequest *)request;- (void)replaceStory:(NSDictionary *)newStory;
|
||||
- (NSString *) stringByStrippingHTML:(NSString *)s;
|
||||
|
||||
@end
|
||||
|
|
|
@ -111,6 +111,7 @@
|
|||
|
||||
- (void)setSiteInfo:(NSString *)type setUserId:(NSString *)userId setUsername:(NSString *)username setCommentIndex:(NSString *)commentIndex {
|
||||
|
||||
|
||||
if ([type isEqualToString: @"edit-reply"]) {
|
||||
[submitButton setTitle:@"Save"];
|
||||
facebookButton.hidden = YES;
|
||||
|
@ -122,7 +123,7 @@
|
|||
// get old comment
|
||||
NSArray *replies = [appDelegate.activeComment objectForKey:@"replies"];
|
||||
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"]) {
|
||||
self.activeCommentIndex = -1;
|
||||
[submitButton setTitle:@"Reply"];
|
||||
|
@ -136,7 +137,7 @@
|
|||
twitterButton.hidden = NO;
|
||||
|
||||
// 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) {
|
||||
[toolbarTitle setTitle:@"Edit Your Comment"];
|
||||
|
@ -211,7 +212,7 @@
|
|||
|
||||
if (self.activeCommentIndex != -1) {
|
||||
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];
|
||||
|
@ -226,7 +227,6 @@
|
|||
NSString *responseString = [request responseString];
|
||||
NSDictionary *results = [[NSDictionary alloc]
|
||||
initWithDictionary:[responseString JSONValue]];
|
||||
|
||||
// add the comment into the activeStory dictionary
|
||||
NSDictionary *comment = [results objectForKey:@"comment"];
|
||||
NSArray *userProfiles = [results objectForKey:@"user_profiles"];
|
||||
|
@ -285,6 +285,12 @@
|
|||
[self replaceStory:[results objectForKey:@"story"]];
|
||||
}
|
||||
|
||||
- (void)requestFailed:(ASIHTTPRequest *)request
|
||||
{
|
||||
NSError *error = [request error];
|
||||
NSLog(@"Error: %@", error);
|
||||
}
|
||||
|
||||
- (void)replaceStory:(NSDictionary *)newStory {
|
||||
[commentField resignFirstResponder];
|
||||
[appDelegate hideShareView:YES];
|
||||
|
@ -310,12 +316,6 @@
|
|||
|
||||
self.commentField.text = nil;
|
||||
[appDelegate refreshComments];
|
||||
|
||||
}
|
||||
|
||||
- (void)requestFailed:(ASIHTTPRequest *)request {
|
||||
NSError *error = [request error];
|
||||
NSLog(@"Error: %@", error);
|
||||
}
|
||||
|
||||
-(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
|
||||
|
|
|
@ -276,6 +276,8 @@
|
|||
"</div>",
|
||||
[sourceUser objectForKey:@"photo_url"]];
|
||||
}
|
||||
|
||||
NSString *commentContent = [self textToHtml:[commentDict objectForKey:@"comments"]];
|
||||
|
||||
NSString *comment = [NSString stringWithFormat:@
|
||||
"<div class=\"NB-story-comment\" id=\"NB-user-comment-%@\">"
|
||||
|
@ -306,7 +308,7 @@
|
|||
[user objectForKey:@"username"],
|
||||
userEditButton,
|
||||
userLikeButton,
|
||||
[commentDict objectForKey:@"comments"],
|
||||
commentContent,
|
||||
[self getReplies:[commentDict objectForKey:@"replies"] forUserId:[commentDict objectForKey:@"user_id"]]];
|
||||
|
||||
return comment;
|
||||
|
@ -336,6 +338,8 @@
|
|||
i // comment number in array
|
||||
];
|
||||
}
|
||||
|
||||
NSString *replyContent = [self textToHtml:[replyDict objectForKey:@"comments"]];
|
||||
|
||||
NSString *reply = [NSString stringWithFormat:@
|
||||
"<div class=\"NB-story-comment-reply\">"
|
||||
|
@ -352,7 +356,7 @@
|
|||
[user objectForKey:@"username"],
|
||||
[replyDict objectForKey:@"publish_date"],
|
||||
userEditButton,
|
||||
[replyDict objectForKey:@"comments"]];
|
||||
replyContent];
|
||||
repliesString = [repliesString stringByAppendingString:reply];
|
||||
}
|
||||
repliesString = [repliesString stringByAppendingString:@"</div>"];
|
||||
|
@ -566,7 +570,11 @@ shouldStartLoadWithRequest:(NSURLRequest *)request
|
|||
navigationType:(UIWebViewNavigationType)navigationType {
|
||||
NSURL *url = [request URL];
|
||||
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.
|
||||
// the pathComponents do not work correctly unless it is a correctly formed url
|
||||
// Is there a better way? Someone show me the light
|
||||
|
@ -757,6 +765,7 @@ shouldStartLoadWithRequest:(NSURLRequest *)request
|
|||
NSString *jsString = [[NSString alloc] initWithFormat:@
|
||||
"document.getElementById('NB-comments-wrapper').innerHTML = '%@';",
|
||||
commentString];
|
||||
NSLog(@"JSSTRING IS %@\n\n\n", jsString);
|
||||
[self.webView stringByEvaluatingJavaScriptFromString:jsString];
|
||||
}
|
||||
|
||||
|
@ -950,4 +959,9 @@ shouldStartLoadWithRequest:(NSURLRequest *)request
|
|||
[appDelegate showOriginalStory:url];
|
||||
}
|
||||
|
||||
- (NSString *)textToHtml:(NSString*)htmlString {
|
||||
htmlString = [htmlString stringByReplacingOccurrencesOfString:@"'" withString:@"'"];
|
||||
return htmlString;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Add table
Reference in a new issue