diff --git a/Blog/BlogController.h b/Blog/BlogController.h index 3635aef..ebe9588 100644 --- a/Blog/BlogController.h +++ b/Blog/BlogController.h @@ -33,6 +33,7 @@ - (PMKPromise *)requestUnpublishPost:(Post *)post; - (PMKPromise *)requestDeletePost:(Post *)post; +- (PMKPromise *)requestSync; - (PMKPromise *)requestPublishToStagingEnvironment; - (PMKPromise *)requestPublishToProductionEnvironment; diff --git a/Blog/BlogController.m b/Blog/BlogController.m index 835e9db..ef2bff6 100644 --- a/Blog/BlogController.m +++ b/Blog/BlogController.m @@ -127,6 +127,10 @@ }); } +- (PMKPromise *)requestSync { + return [_service requestSync]; +} + - (PMKPromise *)requestPublishToStagingEnvironment { return [_service requestPublishEnvironment:@"staging"]; } diff --git a/Blog/BlogService.h b/Blog/BlogService.h index ccf865d..3d1ebb5 100644 --- a/Blog/BlogService.h +++ b/Blog/BlogService.h @@ -26,6 +26,7 @@ typedef NS_ENUM(NSUInteger, BlogServiceErrorCode) { - (PMKPromise *)requestBlogStatus; - (PMKPromise *)requestPublishEnvironment:(NSString *)environment; +- (PMKPromise *)requestSync; - (PMKPromise *)requestDrafts; - (PMKPromise *)requestPublishedPosts; diff --git a/Blog/BlogService.m b/Blog/BlogService.m index 80dab82..18786ce 100644 --- a/Blog/BlogService.m +++ b/Blog/BlogService.m @@ -77,6 +77,10 @@ NSString *const BlogServiceErrorDomain = @"BlogServiceErrorDomain"; return [self.client postJSON:[self urlFor:@"/publish"] headers:nil fields:fields]; } +- (PMKPromise *)requestSync { + return [self.client post:[self urlFor:@"/sync"] headers:nil]; +} + - (PMKPromise *)requestDrafts { return [self.client get:[self urlFor:@"/posts/drafts"] headers:nil].then([self decodePostsBlock]); } diff --git a/Blog/PostsViewController.m b/Blog/PostsViewController.m index 3354e99..b5e6c9c 100644 --- a/Blog/PostsViewController.m +++ b/Blog/PostsViewController.m @@ -273,16 +273,21 @@ static const NSUInteger SectionPublished = 1; }); }; UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Publish" message:nil preferredStyle:UIAlertControllerStyleActionSheet]; - [alertController addAction:[UIAlertAction actionWithTitle:@"Production" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) { + [alertController addAction:[UIAlertAction actionWithTitle:@"samhuri.net" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) { __typeof__(self) self = welf; [self dismissViewControllerAnimated:YES completion:nil]; publish([self.blogController requestPublishToProductionEnvironment]); }]]; - [alertController addAction:[UIAlertAction actionWithTitle:@"Staging" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { + [alertController addAction:[UIAlertAction actionWithTitle:@"beta.samhuri.net" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { __typeof__(self) self = welf; [self dismissViewControllerAnimated:YES completion:nil]; publish([self.blogController requestPublishToStagingEnvironment]); }]]; + [alertController addAction:[UIAlertAction actionWithTitle:@"Push to GitHub" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { + __typeof__(self) self = welf; + [self dismissViewControllerAnimated:YES completion:nil]; + publish([self.blogController requestSync]); + }]]; [alertController addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { __typeof__(self) self = welf; [self dismissViewControllerAnimated:YES completion:nil];