implement publishing the site (untested)

This commit is contained in:
Sami Samhuri 2015-05-03 16:12:27 -07:00
parent a84bd41d58
commit fc906ef976
3 changed files with 24 additions and 1 deletions

View file

@ -43,4 +43,7 @@ extern NSString *BlogPostDeletedNotification;
- (PMKPromise *)requestUnpublishPostWithPath:(NSString *)path;
- (PMKPromise *)requestDeletePostWithPath:(NSString *)path;
- (PMKPromise *)requestPublishToStagingEnvironment;
- (PMKPromise *)requestPublishToProductionEnvironment;
@end

View file

@ -137,4 +137,12 @@ NSString *BlogPostDeletedNotification = @"BlogPostDeletedNotification";
});
}
- (PMKPromise *)requestPublishToStagingEnvironment {
return [_service requestPublishEnvironment:@"staging"];
}
- (PMKPromise *)requestPublishToProductionEnvironment {
return [_service requestPublishEnvironment:@"production"];
}
@end

View file

@ -194,7 +194,19 @@ static const NSUInteger SectionPublished = 1;
}
- (IBAction)publish:(id)sender {
NSLog(@"publish");
// TODO: activity indicator, maybe show an action sheet to select Staging or Production?
self.publishButton.enabled = NO;
[self.blogController requestPublishToStagingEnvironment].then(^{
[self requestStatusWithoutCaching];
}).catch(^(NSError *error) {
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Error" message:error.localizedDescription preferredStyle:UIAlertControllerStyleAlert];
[alertController addAction:[UIAlertAction actionWithTitle:@"Dismiss" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[self dismissViewControllerAnimated:YES completion:nil];
}]];
[self presentViewController:alertController animated:YES completion:nil];
}).finally(^{
self.publishButton.enabled = YES;
});
}
#pragma mark - Segues