mirror of
https://github.com/samsonjs/samhuri.net-ios.git
synced 2026-03-25 09:25:47 +00:00
implement sync (git push)
This commit is contained in:
parent
3b597a5c86
commit
a02874d82d
5 changed files with 17 additions and 2 deletions
|
|
@ -33,6 +33,7 @@
|
|||
- (PMKPromise *)requestUnpublishPost:(Post *)post;
|
||||
- (PMKPromise *)requestDeletePost:(Post *)post;
|
||||
|
||||
- (PMKPromise *)requestSync;
|
||||
- (PMKPromise *)requestPublishToStagingEnvironment;
|
||||
- (PMKPromise *)requestPublishToProductionEnvironment;
|
||||
|
||||
|
|
|
|||
|
|
@ -127,6 +127,10 @@
|
|||
});
|
||||
}
|
||||
|
||||
- (PMKPromise *)requestSync {
|
||||
return [_service requestSync];
|
||||
}
|
||||
|
||||
- (PMKPromise *)requestPublishToStagingEnvironment {
|
||||
return [_service requestPublishEnvironment:@"staging"];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ typedef NS_ENUM(NSUInteger, BlogServiceErrorCode) {
|
|||
|
||||
- (PMKPromise *)requestBlogStatus;
|
||||
- (PMKPromise *)requestPublishEnvironment:(NSString *)environment;
|
||||
- (PMKPromise *)requestSync;
|
||||
|
||||
- (PMKPromise *)requestDrafts;
|
||||
- (PMKPromise *)requestPublishedPosts;
|
||||
|
|
|
|||
|
|
@ -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]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
|
|
|
|||
Loading…
Reference in a new issue