Permalink
Browse files

don't create HTML files for drafts in the publish folder; fix the cop…

…yright dates; don't allow asterisks in URLs
  • Loading branch information...
1 parent 85387bb commit 22f8a9199b5b10ce6111695c4d41187894ab9bf3 @simX committed Jan 4, 2012
Showing with 17 additions and 7 deletions.
  1. +10 −5 EPEntriesManager.m
  2. +6 −2 EPHTMLGenerator.m
  3. +1 −0 EPStringCategory.m
View
@@ -847,24 +847,29 @@ - (void)resetAndPublishAllEntriesForSelectedWeblog;
NSArray *entryPrototypesArray = [realEntriesController arrangedObjects];
for (NSObject *currentEntryPrototype in entryPrototypesArray) {
- NSString *relativePath = [[currentEntryPrototype value] objectForKey:@"entryPlistFilePath"];
+ NSDictionary *entryPrototypeValue = (NSDictionary *)[currentEntryPrototype value];
+ NSString *relativePath = [entryPrototypeValue objectForKey:@"entryPlistFilePath"];
NSString *relativeToPath = [[selectedWeblog baseFileDirectoryPath] path];
NSString *absolutePlistFilePath = [relativeToPath stringByAppendingPathComponent:relativePath];
[self updateStatusWithString:[NSString stringWithFormat:@"Publishing entry page for path: %@",absolutePlistFilePath]];
EPWeblogEntry *existingEntry = [self weblogEntryForPlistFilePath:absolutePlistFilePath
forWeblog:selectedWeblog];
- NSNumber *publishOrderIndexNum = [[currentEntryPrototype value] objectForKey:@"publishOrderIndex"];
+ NSString *entryPublishedDateString = [entryPrototypeValue objectForKey:@"entryPublishedDateString"];
+ NSNumber *publishOrderIndexNum = [entryPrototypeValue objectForKey:@"publishOrderIndex"];
[existingEntry setPublishOrderIndex:publishOrderIndexNum];
// we don't want to publish here because if there are entries being held as drafts,
// (done by saving but not publishing from the entry window), then publishing them
// would make them non-drafts; (really, it's because something chokes when trying
// to publish an entry that hasn't been published from the entry window)
- [HTMLGeneratorInstance createAndSaveHTMLFileUsingWeblogEntryObject:existingEntry
- forWeblog:selectedWeblog
- shouldPublish:NO];
+
+ if (entryPublishedDateString && publishOrderIndexNum) {
+ [HTMLGeneratorInstance createAndSaveHTMLFileUsingWeblogEntryObject:existingEntry
+ forWeblog:selectedWeblog
+ shouldPublish:YES];
+ }
}
[self stopStatusUpdateSessionOnMainThreadWithString:@"Reset and publish all completed."];
View
@@ -146,6 +146,10 @@ - (void)createAndSaveHTMLFileUsingWeblogEntryObject:(EPWeblogEntry *)theWeblogEn
NSURL *noExtensionURL = [categoryFolderURL URLByAppendingPathComponent:truncatedTitle];
NSURL *publishURL = [noExtensionURL URLByAppendingPathExtension:@"html"];
+ NSURL *draftCategoryFolderURL = [[targetWeblog baseFileDirectoryPath] URLByAppendingPathComponent:truncatedCategory];
+ NSURL *draftNoExtensionURL = [draftCategoryFolderURL URLByAppendingPathComponent:truncatedTitle];
+ NSURL *draftSaveURL = [draftNoExtensionURL URLByAppendingPathExtension:@"html"];
+
NSError *dirCreateError = nil;
NSFileManager *defaultManager = [NSFileManager defaultManager];
BOOL succeeded = [defaultManager createDirectoryAtURL:categoryFolderURL
@@ -197,7 +201,7 @@ - (void)createAndSaveHTMLFileUsingWeblogEntryObject:(EPWeblogEntry *)theWeblogEn
usingPageTemplate:nil
usingForEachEntryTemplate:[NSString stringWithFormat:@"%@/Entry Page Template.txt",[[targetWeblog templateFilesLocation] path]]
usingSidebarTemplate:[NSString stringWithFormat:@"%@/Sidebar Template.txt",[[targetWeblog templateFilesLocation] path]]
- toPath:[publishURL path]
+ toPath:[draftSaveURL path]
validatingXML:YES
firstPublish:NO];
}
@@ -507,7 +511,7 @@ - (BOOL)writeFileForArrayOfWeblogEntryObjects:(NSArray *)arrayOfEntryObjects
[mainPageTemplateString replaceOccurrencesOfString:@"{[AUTHORNAME]}" withString:@"Simone Manganelli" options:NSLiteralSearch range:NSMakeRange(0,[mainPageTemplateString length])];
[mainPageTemplateString replaceOccurrencesOfString:@"{[FEEDLASTBUILDDATE]}" withString:currentDateString options:NSLiteralSearch range:NSMakeRange(0,[mainPageTemplateString length])];
[mainPageTemplateString replaceOccurrencesOfString:@"{[FEEDPUBLISHDATE]}" withString:currentDateString options:NSLiteralSearch range:NSMakeRange(0,[mainPageTemplateString length])];
- [mainPageTemplateString replaceOccurrencesOfString:@"{[COPYRIGHTDATES]}" withString:@"2003-2008" options:NSLiteralSearch range:NSMakeRange(0,[mainPageTemplateString length])];
+ [mainPageTemplateString replaceOccurrencesOfString:@"{[COPYRIGHTDATES]}" withString:@"2001-2012" options:NSLiteralSearch range:NSMakeRange(0,[mainPageTemplateString length])];
//[mainPageTemplateString replaceOccurrencesOfString:@"{[CATEGORYSTATS]}" withString:categoryStatsString options:NSLiteralSearch range:NSMakeRange(0,[mainPageTemplateString length])];
[mainPageTemplateString replaceOccurrencesOfString:@"{[ARCHIVEPAGEURL]}" withString:archivePageURLString options:NSLiteralSearch range:NSMakeRange(0,[mainPageTemplateString length])];
View
@@ -57,6 +57,7 @@ - (NSString *)URLizedStringWithLengthLimit:(int)length forJavaScript:(BOOL)forJa
[tempString replaceOccurrencesOfString:@"?" withString:@"" options:NSLiteralSearch range:NSMakeRange(0,[tempString length])];
[tempString replaceOccurrencesOfString:@"|" withString:@"" options:NSLiteralSearch range:NSMakeRange(0,[tempString length])];
[tempString replaceOccurrencesOfString:@"%" withString:@"" options:NSLiteralSearch range:NSMakeRange(0,[tempString length])];
+ [tempString replaceOccurrencesOfString:@"*" withString:@"" options:NSLiteralSearch range:NSMakeRange(0,[tempString length])];
}
NSData *ASCIIStringData = [tempString dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];

0 comments on commit 22f8a91

Please sign in to comment.