implement sync (git push)

This commit is contained in:
Sami Samhuri 2015-05-08 19:50:01 -07:00
parent 3b597a5c86
commit a02874d82d
5 changed files with 17 additions and 2 deletions

View file

@ -33,6 +33,7 @@
- (PMKPromise *)requestUnpublishPost:(Post *)post;
- (PMKPromise *)requestDeletePost:(Post *)post;
- (PMKPromise *)requestSync;
- (PMKPromise *)requestPublishToStagingEnvironment;
- (PMKPromise *)requestPublishToProductionEnvironment;

View file

@ -127,6 +127,10 @@
});
}
- (PMKPromise *)requestSync {
return [_service requestSync];
}
- (PMKPromise *)requestPublishToStagingEnvironment {
return [_service requestPublishEnvironment:@"staging"];
}

View file

@ -26,6 +26,7 @@ typedef NS_ENUM(NSUInteger, BlogServiceErrorCode) {
- (PMKPromise *)requestBlogStatus;
- (PMKPromise *)requestPublishEnvironment:(NSString *)environment;
- (PMKPromise *)requestSync;
- (PMKPromise *)requestDrafts;
- (PMKPromise *)requestPublishedPosts;

View file

@ -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]);
}

View file

@ -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];