Skip to content

Commit

Permalink
Version 3.1 Build 3102
Browse files Browse the repository at this point in the history
  • Loading branch information
Gal3riel committed Mar 23, 2013
1 parent eb3d746 commit 6642ba7
Show file tree
Hide file tree
Showing 25 changed files with 158 additions and 56 deletions.
Binary file modified Resources/Back_button_item.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Resources/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Resources/Back_button_item_highlighted.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Resources/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Resources/Bar_item.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Resources/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Resources/Bar_item_highlighted.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Resources/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Resources/Navigation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Resources/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Resources/Placeholder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 32 additions & 4 deletions Stage1st.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
/* Begin PBXBuildFile section */
C002D2BB16EC665D00A5414E /* Icon-72.png in Resources */ = {isa = PBXBuildFile; fileRef = C002D2B916EC665D00A5414E /* Icon-72.png */; };
C002D2BC16EC665D00A5414E /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = C002D2BA16EC665D00A5414E /* [email protected] */; };
C01C820816FDB168003E6B91 /* Bar_item_highlighted.png in Resources */ = {isa = PBXBuildFile; fileRef = C01C820416FDB167003E6B91 /* Bar_item_highlighted.png */; };
C01C820916FDB168003E6B91 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = C01C820516FDB167003E6B91 /* [email protected] */; };
C01C820E16FDB223003E6B91 /* Back_button_item_highlighted.png in Resources */ = {isa = PBXBuildFile; fileRef = C01C820C16FDB222003E6B91 /* Back_button_item_highlighted.png */; };
C01C820F16FDB223003E6B91 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = C01C820D16FDB222003E6B91 /* [email protected] */; };
C01C821116FDB5D2003E6B91 /* content_larger_font.css in Resources */ = {isa = PBXBuildFile; fileRef = C01C821016FDB5D2003E6B91 /* content_larger_font.css */; };
C0401DB316EB0F2000E52A9A /* Social.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C083353416E4E7C40035C1AA /* Social.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
C05286C316D3428E000B0DBD /* S1Parser.m in Sources */ = {isa = PBXBuildFile; fileRef = C05286C216D3428E000B0DBD /* S1Parser.m */; };
C05286C616D3B881000B0DBD /* S1HTTPClient.m in Sources */ = {isa = PBXBuildFile; fileRef = C05286C516D3B881000B0DBD /* S1HTTPClient.m */; };
Expand Down Expand Up @@ -98,6 +103,11 @@
/* Begin PBXFileReference section */
C002D2B916EC665D00A5414E /* Icon-72.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-72.png"; path = "Resources/Icon-72.png"; sourceTree = "<group>"; };
C002D2BA16EC665D00A5414E /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "[email protected]"; path = "Resources/[email protected]"; sourceTree = "<group>"; };
C01C820416FDB167003E6B91 /* Bar_item_highlighted.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Bar_item_highlighted.png; path = Resources/Bar_item_highlighted.png; sourceTree = "<group>"; };
C01C820516FDB167003E6B91 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "[email protected]"; path = "Resources/[email protected]"; sourceTree = "<group>"; };
C01C820C16FDB222003E6B91 /* Back_button_item_highlighted.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Back_button_item_highlighted.png; path = Resources/Back_button_item_highlighted.png; sourceTree = "<group>"; };
C01C820D16FDB222003E6B91 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "[email protected]"; path = "Resources/[email protected]"; sourceTree = "<group>"; };
C01C821016FDB5D2003E6B91 /* content_larger_font.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; path = content_larger_font.css; sourceTree = "<group>"; };
C05286C116D3428E000B0DBD /* S1Parser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = S1Parser.h; path = Stage1st/S1Parser.h; sourceTree = "<group>"; };
C05286C216D3428E000B0DBD /* S1Parser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = S1Parser.m; path = Stage1st/S1Parser.m; sourceTree = "<group>"; };
C05286C416D3B881000B0DBD /* S1HTTPClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = S1HTTPClient.h; path = Stage1st/S1HTTPClient.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -312,10 +322,7 @@
C08DB46216DE2E52002B4A92 /* Cells */ = {
isa = PBXGroup;
children = (
C05286C716D3CE49000B0DBD /* AsyncCell.h */,
C05286C816D3CE49000B0DBD /* AsyncCell.m */,
C05286CA16D3DE7D000B0DBD /* S1TopicCell.h */,
C05286CB16D3DE7D000B0DBD /* S1TopicCell.m */,
C0AEAE8816F73C9800CB0E71 /* Deprecated */,
C08DB46716DE3152002B4A92 /* S1TopicListCell.h */,
C08DB46816DE3152002B4A92 /* S1TopicListCell.m */,
);
Expand Down Expand Up @@ -372,6 +379,7 @@
isa = PBXGroup;
children = (
C08DB46A16DE3794002B4A92 /* content.css */,
C01C821016FDB5D2003E6B91 /* content_larger_font.css */,
C0B1919616F0A80F0053E0C5 /* content_ipad.css */,
C095873F16CA8A36007E0119 /* Stage1st-Info.plist */,
C095874016CA8A36007E0119 /* InfoPlist.strings */,
Expand Down Expand Up @@ -403,6 +411,10 @@
C095875516CA8A43007E0119 /* Resources */ = {
isa = PBXGroup;
children = (
C01C820C16FDB222003E6B91 /* Back_button_item_highlighted.png */,
C01C820D16FDB222003E6B91 /* [email protected] */,
C01C820416FDB167003E6B91 /* Bar_item_highlighted.png */,
C01C820516FDB167003E6B91 /* [email protected] */,
C0AEAE8216F60D7900CB0E71 /* Placeholder.png */,
C08B602116E1B5CE00591827 /* Logo.png */,
C08B602216E1B5CE00591827 /* [email protected] */,
Expand Down Expand Up @@ -568,6 +580,17 @@
path = Vendors/MTStatusBarOverlay;
sourceTree = "<group>";
};
C0AEAE8816F73C9800CB0E71 /* Deprecated */ = {
isa = PBXGroup;
children = (
C05286C716D3CE49000B0DBD /* AsyncCell.h */,
C05286C816D3CE49000B0DBD /* AsyncCell.m */,
C05286CA16D3DE7D000B0DBD /* S1TopicCell.h */,
C05286CB16D3DE7D000B0DBD /* S1TopicCell.m */,
);
name = Deprecated;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -661,6 +684,11 @@
C002D2BC16EC665D00A5414E /* [email protected] in Resources */,
C0B1919716F0A80F0053E0C5 /* content_ipad.css in Resources */,
C0AEAE8316F60D7900CB0E71 /* Placeholder.png in Resources */,
C01C820816FDB168003E6B91 /* Bar_item_highlighted.png in Resources */,
C01C820916FDB168003E6B91 /* [email protected] in Resources */,
C01C820E16FDB223003E6B91 /* Back_button_item_highlighted.png in Resources */,
C01C820F16FDB223003E6B91 /* [email protected] in Resources */,
C01C821116FDB5D2003E6B91 /* content_larger_font.css in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
12 changes: 9 additions & 3 deletions Stage1st/S1AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"Display"];
}
if (![[NSUserDefaults standardUserDefaults] valueForKey:@"BaseURL"]) {
[[NSUserDefaults standardUserDefaults] setValue:@"http://220.196.42.172" forKey:@"BaseURL"];
[[NSUserDefaults standardUserDefaults] setValue:@"http://220.196.42.167" forKey:@"BaseURL"];
}
if (![[NSUserDefaults standardUserDefaults] valueForKey:@"FontSize"]) {
[[NSUserDefaults standardUserDefaults] setValue:@"15px" forKey:@"FontSize"];
}


//URL Cache
S1URLCache *URLCache = [[S1URLCache alloc] initWithMemoryCapacity:4 * 1024 * 1024
Expand All @@ -42,9 +46,11 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
[[UIToolbar appearance] setBackgroundImage:[UIImage imageNamed:@"Toolbar_background.png"] forToolbarPosition:UIToolbarPositionBottom barMetrics:UIBarMetricsDefault];
[[UIToolbar appearance] setBackgroundImage:[UIImage imageNamed:@"Navigation.png"] forToolbarPosition:UIToolbarPositionTop barMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"Navigation.png"] forBarMetrics:UIBarMetricsDefault];
[[UIBarButtonItem appearance] setBackgroundImage:[UIImage imageNamed:@"Bar_item.png"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setBackgroundImage:[[UIImage imageNamed:@"Navigation.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 5, 0, 5)] forBarMetrics:UIBarMetricsDefault];
[[UIBarButtonItem appearance] setBackgroundImage:[[UIImage imageNamed:@"Bar_item.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 5, 0, 5)] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:[[UIImage imageNamed:@"Back_button_item.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 14, 0, 7)] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
[[UIBarButtonItem appearance] setBackgroundImage:[[UIImage imageNamed:@"Bar_item_highlighted.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 5, 0, 5)] forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:[[UIImage imageNamed:@"Back_button_item_highlighted.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 14, 0, 7)] forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault];
}

if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
Expand Down
47 changes: 28 additions & 19 deletions Stage1st/S1ContentViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#import "REComposeViewController.h"
#import "SVModalWebViewController.h"
#import "MTStatusBarOverlay.h"
#import "AFNetworking.h"


#define _REPLY_PER_PAGE 50
Expand Down Expand Up @@ -154,7 +155,7 @@ - (void)viewDidAppear:(BOOL)animated
- (void)viewWillDisappear:(BOOL)animated
{
NSString *path = [NSString stringWithFormat:@"simple/?t%@.html", self.topic.topicID];
[[S1HTTPClient sharedClient] cancelAllHTTPOperationsWithMethod:@"GET" path:path];
[self.HTTPClient cancelAllHTTPOperationsWithMethod:@"GET" path:path];

[self.topic setLastViewedPage:[NSString stringWithFormat:@"%d", _currentPage]];
[self.tracer hasViewed:self.topic];
Expand Down Expand Up @@ -241,7 +242,7 @@ - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger
//Reply
if (0 == buttonIndex) {
if (![[NSUserDefaults standardUserDefaults] valueForKey:@"UserID"]) {
[[[UIAlertView alloc] initWithTitle:@"请先获取登录状态" message:nil delegate:nil cancelButtonTitle:@"完成" otherButtonTitles:nil] show];
[[[UIAlertView alloc] initWithTitle:nil message:@"请先获取登录状态" delegate:nil cancelButtonTitle:@"完成" otherButtonTitles:nil] show];
return;
}
[self rootViewController].modalPresentationStyle = UIModalPresentationCurrentContext;
Expand Down Expand Up @@ -270,12 +271,12 @@ - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger
//Weibo
if (1 == buttonIndex) {
if (!NSClassFromString(@"SLComposeViewController")) {
[[[UIAlertView alloc] initWithTitle:@"需要6.0以上的系统才能使用" message:nil delegate:nil cancelButtonTitle:@"完成" otherButtonTitles:nil] show];
[[[UIAlertView alloc] initWithTitle:nil message:@"需要6.0以上的系统才能使用" delegate:nil cancelButtonTitle:@"完成" otherButtonTitles:nil] show];
return;
}
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeSinaWeibo];
[controller setInitialText:[NSString stringWithFormat:@"%@ #Stage1st Reader#", self.topic.title]];
[controller addURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://bbs.saraba1st.com/2b/read-htm-tid-%@.html", self.topic.topicID]]];
[controller addURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/2b/read-htm-tid-%@.html", [[NSUserDefaults standardUserDefaults] valueForKey:@"BaseURL"], self.topic.topicID]]];
[controller addImage:[self screenShot]];

__weak SLComposeViewController *weakController = controller;
Expand Down Expand Up @@ -344,25 +345,32 @@ - (void)fetchContent
[self fetchContent];
}];
NSString *path = [NSString stringWithFormat:@"simple/?t%@_%d.html", self.topic.topicID, _currentPage];
[[S1HTTPClient sharedClient] getPath:path
parameters:nil
success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSMutableString *HTMLString = [[NSMutableString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
if (HTMLString) {
NSString *string = [S1Parser contentsFromHTMLString:HTMLString withOffset:_currentPage];
[self.webView loadHTMLString:string baseURL:nil];
}
[HUD hideWithDelay:0.5];
}
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"%@", error);
[HUD showRefreshButton];
}];
[self.HTTPClient getPath:path
parameters:nil
success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"%@", operation.request.allHTTPHeaderFields);
NSMutableString *HTMLString = [[NSMutableString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
if (HTMLString) {
NSString *string = [S1Parser contentsFromHTMLString:HTMLString withOffset:_currentPage];
[self.webView loadHTMLString:string baseURL:nil];
}
[HUD hideWithDelay:0.5];
}
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"%@", error);
[HUD showRefreshButton];
}];
}

- (void)replyWithText:(NSString *)text
{

}


- (void)replyWithReplyText:(NSString *)text
{
NSString *suffix = @"\n\n——— 来自Stage1st Reader Evolution";
NSString *suffix = @"\n\n——— 来自[url=http://itunes.apple.com/us/app/stage1st-reader/id509916119?mt=8]Stage1st Reader Evolution[/url]";
NSString *replyWithSuffix = [text stringByAppendingString:suffix];
NSString *timestamp = [[NSString stringWithFormat:@"%ld", (long)[[NSDate date] timeIntervalSince1970]] substringToIndex:10];
NSString *path = [NSString stringWithFormat:@"m/post.php?action=reply&tid=%@&tmp=%@", self.topic.topicID, timestamp];
Expand Down Expand Up @@ -393,6 +401,7 @@ - (void)replyWithReplyText:(NSString *)text
}];
}


#pragma mark - Helpers

- (void)scrollToButtomAnimated:(BOOL)animated
Expand Down
2 changes: 0 additions & 2 deletions Stage1st/S1HTTPClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

@interface S1HTTPClient : AFHTTPClient

+ (S1HTTPClient *)sharedClient;

- (id)initWithBaseURL:(NSURL *)url;

@end
2 changes: 1 addition & 1 deletion Stage1st/S1HTTPClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#import "S1HTTPClient.h"
#import "AFNetworking.h"

static NSString * const baseURLString = @"http://220.196.42.172/2b/";
static NSString * const baseURLString = @"http://bbs.saraba1st.com/2b/";

@implementation S1HTTPClient

Expand Down
36 changes: 31 additions & 5 deletions Stage1st/S1LoginViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,6 @@ - (void)viewDidLoad
}];
}

- (void)viewWillDisappear:(BOOL)animated
{

}

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
Expand All @@ -116,6 +111,7 @@ - (S1HTTPClient *)HTTPClient
return _HTTPClient;
}

//Login from the standard web
- (void)login
{
NSDictionary *param = @{
Expand Down Expand Up @@ -158,6 +154,36 @@ - (void)login
}];
}

// Login from the mobile web
- (void)alternativelogin
{
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
[[self HTTPClient] postPath:@"m/login.php"
parameters:@{ @"pwuser":self.userIDField.text, @"pwpwd":self.userPasswordField.text, @"lgt":@"0" }
success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSString *result = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
NSLog(@"%@", result);
NSLog(@"%@", [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]);
if (result) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"登录" message:@"获取登录状态成功" delegate:nil cancelButtonTitle:@"完成" otherButtonTitles:nil];
[alertView show];
NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
[userDefault setValue:self.userIDField.text forKey:@"UserID"];
[userDefault setValue:self.userPasswordField.text forKey:@"UserPassword"];
} else {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"登录" message:@"获取登录状态未成功" delegate:nil cancelButtonTitle:@"完成" otherButtonTitles:nil];
[alertView show];
}
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
}
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"%@", error);
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"登录" message:@"获取登录状态未成功" delegate:nil cancelButtonTitle:@"完成" otherButtonTitles:nil];
[alertView show];
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
}];
}

#pragma mark - UITextField Delegate

- (BOOL)textFieldShouldReturn:(UITextField *)textField
Expand Down
7 changes: 6 additions & 1 deletion Stage1st/S1Parser.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@ + (NSString *)contentsFromHTMLString:(NSMutableString *)HTMLString withOffset:(N
if (rangeToReplace.location != NSNotFound) {
NSString *path = nil;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
path = [[NSBundle mainBundle] pathForResource:@"content" ofType:@"css"];
NSString *fontSizeKey = [[NSUserDefaults standardUserDefaults] valueForKey:@"FontSize"];
if ([fontSizeKey isEqualToString:@"15px"]) {
path = [[NSBundle mainBundle] pathForResource:@"content" ofType:@"css"];
} else {
path = [[NSBundle mainBundle] pathForResource:@"content_larger_font" ofType:@"css"];
}
} else {
path = [[NSBundle mainBundle] pathForResource:@"content_ipad" ofType:@"css"];
}
Expand Down
1 change: 1 addition & 0 deletions Stage1st/S1RootViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ - (void)viewDidLoad
// Do any additional setup after loading the view.
}


- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
Expand Down
Loading

0 comments on commit 6642ba7

Please sign in to comment.