mirror of
https://github.com/samsonjs/samhuri.net-ios.git
synced 2026-04-27 15:07:44 +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 *)requestUnpublishPost:(Post *)post;
|
||||||
- (PMKPromise *)requestDeletePost:(Post *)post;
|
- (PMKPromise *)requestDeletePost:(Post *)post;
|
||||||
|
|
||||||
|
- (PMKPromise *)requestSync;
|
||||||
- (PMKPromise *)requestPublishToStagingEnvironment;
|
- (PMKPromise *)requestPublishToStagingEnvironment;
|
||||||
- (PMKPromise *)requestPublishToProductionEnvironment;
|
- (PMKPromise *)requestPublishToProductionEnvironment;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -127,6 +127,10 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (PMKPromise *)requestSync {
|
||||||
|
return [_service requestSync];
|
||||||
|
}
|
||||||
|
|
||||||
- (PMKPromise *)requestPublishToStagingEnvironment {
|
- (PMKPromise *)requestPublishToStagingEnvironment {
|
||||||
return [_service requestPublishEnvironment:@"staging"];
|
return [_service requestPublishEnvironment:@"staging"];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ typedef NS_ENUM(NSUInteger, BlogServiceErrorCode) {
|
||||||
|
|
||||||
- (PMKPromise *)requestBlogStatus;
|
- (PMKPromise *)requestBlogStatus;
|
||||||
- (PMKPromise *)requestPublishEnvironment:(NSString *)environment;
|
- (PMKPromise *)requestPublishEnvironment:(NSString *)environment;
|
||||||
|
- (PMKPromise *)requestSync;
|
||||||
|
|
||||||
- (PMKPromise *)requestDrafts;
|
- (PMKPromise *)requestDrafts;
|
||||||
- (PMKPromise *)requestPublishedPosts;
|
- (PMKPromise *)requestPublishedPosts;
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,10 @@ NSString *const BlogServiceErrorDomain = @"BlogServiceErrorDomain";
|
||||||
return [self.client postJSON:[self urlFor:@"/publish"] headers:nil fields:fields];
|
return [self.client postJSON:[self urlFor:@"/publish"] headers:nil fields:fields];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (PMKPromise *)requestSync {
|
||||||
|
return [self.client post:[self urlFor:@"/sync"] headers:nil];
|
||||||
|
}
|
||||||
|
|
||||||
- (PMKPromise *)requestDrafts {
|
- (PMKPromise *)requestDrafts {
|
||||||
return [self.client get:[self urlFor:@"/posts/drafts"] headers:nil].then([self decodePostsBlock]);
|
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];
|
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;
|
__typeof__(self) self = welf;
|
||||||
[self dismissViewControllerAnimated:YES completion:nil];
|
[self dismissViewControllerAnimated:YES completion:nil];
|
||||||
publish([self.blogController requestPublishToProductionEnvironment]);
|
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;
|
__typeof__(self) self = welf;
|
||||||
[self dismissViewControllerAnimated:YES completion:nil];
|
[self dismissViewControllerAnimated:YES completion:nil];
|
||||||
publish([self.blogController requestPublishToStagingEnvironment]);
|
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) {
|
[alertController addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
|
||||||
__typeof__(self) self = welf;
|
__typeof__(self) self = welf;
|
||||||
[self dismissViewControllerAnimated:YES completion:nil];
|
[self dismissViewControllerAnimated:YES completion:nil];
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue