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) {
backgroundColor = self.selected || self.highlighted ?
[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 {
backgroundColor = self.selected || self.highlighted ?
[UIColor colorWithRed:0.15 green:0.55 blue:0.95 alpha:1.0] :

View file

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

View file

@ -96,9 +96,10 @@
// 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];
self.feedTitlesTable.separatorColor = bgColor;
self.feedTitlesTable.backgroundColor = bgColor;
self.feedTitlesTable.separatorColor = [UIColor clearColor];
// reset all feed detail specific data
appDelegate.activeFeed = nil;
appDelegate.isSocialView = NO;

View file

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

View file

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

View file

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

View file

@ -12,7 +12,7 @@
green:((float)((rgbValue & 0xFF00) >> 8))/255.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 NEWSBLUR_URL [NSString stringWithFormat:@"nb.local.host"]

View file

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