adding in html encoding for comments and other fixes

This commit is contained in:
Roy Yang 2012-07-20 19:55:38 -07:00
parent dbf793db67
commit bb023430ba
8 changed files with 59 additions and 23 deletions

View file

@ -94,7 +94,9 @@ static CGFloat *psColors = nil;
if (self.isSocial) { if (self.isSocial) {
backgroundColor = self.selected || self.highlighted ? backgroundColor = self.selected || self.highlighted ?
[UIColor colorWithRed:0.15 green:0.55 blue:0.95 alpha:1.0] : [UIColor colorWithRed:0.15 green:0.55 blue:0.95 alpha:1.0] :
UIColorFromRGB(0xe9e9ee); //UIColorFromRGB(0xe9e9ee);
[UIColor colorWithRed:0.95 green:0.95 blue:0.95 alpha:1.0];
} else { } else {
backgroundColor = self.selected || self.highlighted ? backgroundColor = self.selected || self.highlighted ?
[UIColor colorWithRed:0.15 green:0.55 blue:0.95 alpha:1.0] : [UIColor colorWithRed:0.15 green:0.55 blue:0.95 alpha:1.0] :

View file

@ -650,7 +650,8 @@
} else { } else {
feedTitle = [activeFeed objectForKey:@"feed_title"]; feedTitle = [activeFeed objectForKey:@"feed_title"];
} }
[self.storyDetailViewController initStory];
self.storyDetailViewController.navigationItem.titleView = nil;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
if ([[self.splitStoryDetailNavigationController viewControllers] containsObject:self.storyDetailViewController]) { if ([[self.splitStoryDetailNavigationController viewControllers] containsObject:self.storyDetailViewController]) {
@ -667,6 +668,11 @@
navController.navigationItem.hidesBackButton = YES; navController.navigationItem.hidesBackButton = YES;
navController.navigationBar.tintColor = [UIColor colorWithRed:0.16f green:0.36f blue:0.46 alpha:0.9]; navController.navigationBar.tintColor = [UIColor colorWithRed:0.16f green:0.36f blue:0.46 alpha:0.9];
} }
[self.storyDetailViewController initStory];
} }
- (void)navigationController:(UINavigationController *)navController - (void)navigationController:(UINavigationController *)navController

View file

@ -96,9 +96,10 @@
// self.feedTitlesTable.separatorStyle = UITableViewCellSeparatorStyleNone; // DO NOT USE. THIS BREAKS SHIT. // self.feedTitlesTable.separatorStyle = UITableViewCellSeparatorStyleNone; // DO NOT USE. THIS BREAKS SHIT.
UIColor *bgColor = [UIColor colorWithRed:0.95 green:0.95 blue:0.95 alpha:1.0]; UIColor *bgColor = [UIColor colorWithRed:0.95 green:0.95 blue:0.95 alpha:1.0];
self.feedTitlesTable.separatorColor = bgColor;
self.feedTitlesTable.backgroundColor = bgColor; self.feedTitlesTable.backgroundColor = bgColor;
self.feedTitlesTable.separatorColor = [UIColor clearColor];
// reset all feed detail specific data // reset all feed detail specific data
appDelegate.activeFeed = nil; appDelegate.activeFeed = nil;
appDelegate.isSocialView = NO; appDelegate.isSocialView = NO;

View file

@ -124,7 +124,7 @@
int commentIdx = [commentIndex intValue]; int commentIdx = [commentIndex intValue];
self.commentField.text = [[replies objectAtIndex:commentIdx] objectForKey:@"comments"]; self.commentField.text = [[replies objectAtIndex:commentIdx] objectForKey:@"comments"];
} else if ([type isEqualToString: @"reply"]) { } else if ([type isEqualToString: @"reply"]) {
self.activeCommentIndex = 0; self.activeCommentIndex = -1;
[submitButton setTitle:@"Reply"]; [submitButton setTitle:@"Reply"];
facebookButton.hidden = YES; facebookButton.hidden = YES;
twitterButton.hidden = YES; twitterButton.hidden = YES;
@ -209,7 +209,7 @@
[request setPostValue:[appDelegate.activeComment objectForKey:@"user_id"] forKey:@"comment_user_id"]; [request setPostValue:[appDelegate.activeComment objectForKey:@"user_id"] forKey:@"comment_user_id"];
[request setPostValue:commentField.text forKey:@"reply_comments"]; [request setPostValue:commentField.text forKey:@"reply_comments"];
if (self.activeCommentIndex) { 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:[activeComment objectForKey:@"comments"] forKey:@"original_message"];
} }

View file

@ -70,4 +70,5 @@
- (NSString *)getAvatars:(BOOL)areFriends; - (NSString *)getAvatars:(BOOL)areFriends;
- (NSDictionary *)getUser:(int)user_id; - (NSDictionary *)getUser:(int)user_id;
- (NSString *)textToHtml:(NSString*)htmlString;
@end @end

View file

@ -19,6 +19,7 @@
#import "Base64.h" #import "Base64.h"
#import "Utilities.h" #import "Utilities.h"
#import "JSON.h" #import "JSON.h"
#import "NSString+HTML.h"
@implementation StoryDetailViewController @implementation StoryDetailViewController
@ -112,6 +113,21 @@
} }
} }
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *theTouch = [touches anyObject];
CGPoint touchLocation = [theTouch locationInView:self.view];
CGFloat y = touchLocation.y;
[appDelegate dragFeedDetailView:y];
}
- (void)viewDidUnload {
[self setButtonNextStory:nil];
[self setInnerView:nil];
[super viewDidUnload];
}
- (void)initStory { - (void)initStory {
id storyId = [appDelegate.activeStory objectForKey:@"id"]; id storyId = [appDelegate.activeStory objectForKey:@"id"];
if (self.activeStoryId != storyId) { if (self.activeStoryId != storyId) {
@ -302,6 +318,8 @@
[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-%@\">"
"<div class=\"%@\"><a class=\"NB-show-profile\" href=\"http://ios.newsblur.com/show-profile/%@\"><img src=\"%@\" /></a></div>" "<div class=\"%@\"><a class=\"NB-show-profile\" href=\"http://ios.newsblur.com/show-profile/%@\"><img src=\"%@\" /></a></div>"
@ -329,7 +347,7 @@
userEditButton, userEditButton,
[commentDict objectForKey:@"user_id"], [commentDict objectForKey:@"user_id"],
[user objectForKey:@"username"], [user objectForKey:@"username"],
[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;
@ -360,6 +378,8 @@
]; ];
} }
NSString *commentContent = [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\">"
" <a class=\"NB-show-profile\" href=\"http://ios.newsblur.com/show-profile/%@\">" " <a class=\"NB-show-profile\" href=\"http://ios.newsblur.com/show-profile/%@\">"
@ -375,7 +395,7 @@
[user objectForKey:@"username"], [user objectForKey:@"username"],
[replyDict objectForKey:@"publish_date"], [replyDict objectForKey:@"publish_date"],
userEditButton, userEditButton,
[replyDict objectForKey:@"comments"]]; commentContent];
repliesString = [repliesString stringByAppendingString:reply]; repliesString = [repliesString stringByAppendingString:reply];
} }
repliesString = [repliesString stringByAppendingString:@"</div>"]; repliesString = [repliesString stringByAppendingString:@"</div>"];
@ -1021,16 +1041,14 @@ shouldStartLoadWithRequest:(NSURLRequest *)request
[appDelegate showOriginalStory:url]; [appDelegate showOriginalStory:url];
} }
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { - (NSString *)textToHtml:(NSString*)htmlString {
UITouch *theTouch = [touches anyObject]; htmlString = [htmlString stringByReplacingOccurrencesOfString:@"&" withString:@"&amp;"];
CGPoint touchLocation = [theTouch locationInView:self.view]; htmlString = [htmlString stringByReplacingOccurrencesOfString:@"<" withString:@"&lt;"];
CGFloat y = touchLocation.y; htmlString = [htmlString stringByReplacingOccurrencesOfString:@">" withString:@"&gt;"];
[appDelegate dragFeedDetailView:y]; htmlString = [htmlString stringByReplacingOccurrencesOfString:@"""" withString:@"&quot;"];
htmlString = [htmlString stringByReplacingOccurrencesOfString:@"'" withString:@"&#039;"];
htmlString = [htmlString stringByReplacingOccurrencesOfString:@"\n" withString:@"<br>"];
return htmlString;
} }
- (void)viewDidUnload {
[self setButtonNextStory:nil];
[self setInnerView:nil];
[super viewDidUnload];
}
@end @end

View file

@ -12,7 +12,7 @@
green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \ green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0] blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
// f#define BACKGROUND_REFRESH_SECONDS -5 // #define BACKGROUND_REFRESH_SECONDS -5
#define BACKGROUND_REFRESH_SECONDS -10*60 #define BACKGROUND_REFRESH_SECONDS -10*60
#define NEWSBLUR_URL [NSString stringWithFormat:@"nb.local.host"] #define NEWSBLUR_URL [NSString stringWithFormat:@"nb.local.host"]

View file

@ -95,6 +95,7 @@
<string key="NSFrame">{{75, 8}, {170, 30}}</string> <string key="NSFrame">{{75, 8}, {170, 30}}</string>
<reference key="NSSuperview" ref="895374018"/> <reference key="NSSuperview" ref="895374018"/>
<reference key="NSWindow"/> <reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<string key="targetRuntimeIdentifier">IBIPadFramework</string> <string key="targetRuntimeIdentifier">IBIPadFramework</string>
<int key="IBSegmentControlStyle">2</int> <int key="IBSegmentControlStyle">2</int>
<int key="IBNumberOfSegments">3</int> <int key="IBNumberOfSegments">3</int>
@ -639,6 +640,7 @@
<string>activitesLabel</string> <string>activitesLabel</string>
<string>activitiesModule</string> <string>activitiesModule</string>
<string>appDelegate</string> <string>appDelegate</string>
<string>header</string>
<string>interactionsLabel</string> <string>interactionsLabel</string>
<string>interactionsModule</string> <string>interactionsModule</string>
</object> </object>
@ -647,6 +649,7 @@
<string>UILabel</string> <string>UILabel</string>
<string>ActivityModule</string> <string>ActivityModule</string>
<string>NewsBlurAppDelegate</string> <string>NewsBlurAppDelegate</string>
<string>UIImageView</string>
<string>UILabel</string> <string>UILabel</string>
<string>InteractionsModule</string> <string>InteractionsModule</string>
</object> </object>
@ -658,6 +661,7 @@
<string>activitesLabel</string> <string>activitesLabel</string>
<string>activitiesModule</string> <string>activitiesModule</string>
<string>appDelegate</string> <string>appDelegate</string>
<string>header</string>
<string>interactionsLabel</string> <string>interactionsLabel</string>
<string>interactionsModule</string> <string>interactionsModule</string>
</object> </object>
@ -675,6 +679,10 @@
<string key="name">appDelegate</string> <string key="name">appDelegate</string>
<string key="candidateClassName">NewsBlurAppDelegate</string> <string key="candidateClassName">NewsBlurAppDelegate</string>
</object> </object>
<object class="IBToOneOutletInfo">
<string key="name">header</string>
<string key="candidateClassName">UIImageView</string>
</object>
<object class="IBToOneOutletInfo"> <object class="IBToOneOutletInfo">
<string key="name">interactionsLabel</string> <string key="name">interactionsLabel</string>
<string key="candidateClassName">UILabel</string> <string key="candidateClassName">UILabel</string>
@ -698,12 +706,12 @@
<object class="NSArray" key="dict.sortedKeys"> <object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
<string>appDelegate</string> <string>appDelegate</string>
<string>toolbar</string> <string>storyLabel</string>
</object> </object>
<object class="NSArray" key="dict.values"> <object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
<string>NewsBlurAppDelegate</string> <string>NewsBlurAppDelegate</string>
<string>UIToolbar</string> <string>UILabel</string>
</object> </object>
</object> </object>
<object class="NSMutableDictionary" key="toOneOutletInfosByName"> <object class="NSMutableDictionary" key="toOneOutletInfosByName">
@ -711,7 +719,7 @@
<object class="NSArray" key="dict.sortedKeys"> <object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
<string>appDelegate</string> <string>appDelegate</string>
<string>toolbar</string> <string>storyLabel</string>
</object> </object>
<object class="NSArray" key="dict.values"> <object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
@ -720,8 +728,8 @@
<string key="candidateClassName">NewsBlurAppDelegate</string> <string key="candidateClassName">NewsBlurAppDelegate</string>
</object> </object>
<object class="IBToOneOutletInfo"> <object class="IBToOneOutletInfo">
<string key="name">toolbar</string> <string key="name">storyLabel</string>
<string key="candidateClassName">UIToolbar</string> <string key="candidateClassName">UILabel</string>
</object> </object>
</object> </object>
</object> </object>