Skip to content

Commit

Permalink
don't create HTML files for drafts in the publish folder; fix the cop…
Browse files Browse the repository at this point in the history
…yright dates; don't allow asterisks in URLs
  • Loading branch information
simX committed Jan 4, 2012
1 parent 85387bb commit 22f8a91
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
15 changes: 10 additions & 5 deletions EPEntriesManager.m
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -847,24 +847,29 @@ - (void)resetAndPublishAllEntriesForSelectedWeblog;
NSArray *entryPrototypesArray = [realEntriesController arrangedObjects]; NSArray *entryPrototypesArray = [realEntriesController arrangedObjects];


for (NSObject *currentEntryPrototype in entryPrototypesArray) { 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 *relativeToPath = [[selectedWeblog baseFileDirectoryPath] path];
NSString *absolutePlistFilePath = [relativeToPath stringByAppendingPathComponent:relativePath]; NSString *absolutePlistFilePath = [relativeToPath stringByAppendingPathComponent:relativePath];


[self updateStatusWithString:[NSString stringWithFormat:@"Publishing entry page for path: %@",absolutePlistFilePath]]; [self updateStatusWithString:[NSString stringWithFormat:@"Publishing entry page for path: %@",absolutePlistFilePath]];


EPWeblogEntry *existingEntry = [self weblogEntryForPlistFilePath:absolutePlistFilePath EPWeblogEntry *existingEntry = [self weblogEntryForPlistFilePath:absolutePlistFilePath
forWeblog:selectedWeblog]; forWeblog:selectedWeblog];
NSNumber *publishOrderIndexNum = [[currentEntryPrototype value] objectForKey:@"publishOrderIndex"]; NSString *entryPublishedDateString = [entryPrototypeValue objectForKey:@"entryPublishedDateString"];
NSNumber *publishOrderIndexNum = [entryPrototypeValue objectForKey:@"publishOrderIndex"];
[existingEntry setPublishOrderIndex:publishOrderIndexNum]; [existingEntry setPublishOrderIndex:publishOrderIndexNum];


// we don't want to publish here because if there are entries being held as drafts, // 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 // (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 // 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) // to publish an entry that hasn't been published from the entry window)
[HTMLGeneratorInstance createAndSaveHTMLFileUsingWeblogEntryObject:existingEntry
forWeblog:selectedWeblog if (entryPublishedDateString && publishOrderIndexNum) {
shouldPublish:NO]; [HTMLGeneratorInstance createAndSaveHTMLFileUsingWeblogEntryObject:existingEntry
forWeblog:selectedWeblog
shouldPublish:YES];
}
} }


[self stopStatusUpdateSessionOnMainThreadWithString:@"Reset and publish all completed."]; [self stopStatusUpdateSessionOnMainThreadWithString:@"Reset and publish all completed."];
Expand Down
8 changes: 6 additions & 2 deletions EPHTMLGenerator.m
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ - (void)createAndSaveHTMLFileUsingWeblogEntryObject:(EPWeblogEntry *)theWeblogEn
NSURL *noExtensionURL = [categoryFolderURL URLByAppendingPathComponent:truncatedTitle]; NSURL *noExtensionURL = [categoryFolderURL URLByAppendingPathComponent:truncatedTitle];
NSURL *publishURL = [noExtensionURL URLByAppendingPathExtension:@"html"]; NSURL *publishURL = [noExtensionURL URLByAppendingPathExtension:@"html"];


NSURL *draftCategoryFolderURL = [[targetWeblog baseFileDirectoryPath] URLByAppendingPathComponent:truncatedCategory];
NSURL *draftNoExtensionURL = [draftCategoryFolderURL URLByAppendingPathComponent:truncatedTitle];
NSURL *draftSaveURL = [draftNoExtensionURL URLByAppendingPathExtension:@"html"];

NSError *dirCreateError = nil; NSError *dirCreateError = nil;
NSFileManager *defaultManager = [NSFileManager defaultManager]; NSFileManager *defaultManager = [NSFileManager defaultManager];
BOOL succeeded = [defaultManager createDirectoryAtURL:categoryFolderURL BOOL succeeded = [defaultManager createDirectoryAtURL:categoryFolderURL
Expand Down Expand Up @@ -197,7 +201,7 @@ - (void)createAndSaveHTMLFileUsingWeblogEntryObject:(EPWeblogEntry *)theWeblogEn
usingPageTemplate:nil usingPageTemplate:nil
usingForEachEntryTemplate:[NSString stringWithFormat:@"%@/Entry Page Template.txt",[[targetWeblog templateFilesLocation] path]] usingForEachEntryTemplate:[NSString stringWithFormat:@"%@/Entry Page Template.txt",[[targetWeblog templateFilesLocation] path]]
usingSidebarTemplate:[NSString stringWithFormat:@"%@/Sidebar Template.txt",[[targetWeblog templateFilesLocation] path]] usingSidebarTemplate:[NSString stringWithFormat:@"%@/Sidebar Template.txt",[[targetWeblog templateFilesLocation] path]]
toPath:[publishURL path] toPath:[draftSaveURL path]
validatingXML:YES validatingXML:YES
firstPublish:NO]; firstPublish:NO];
} }
Expand Down Expand Up @@ -507,7 +511,7 @@ - (BOOL)writeFileForArrayOfWeblogEntryObjects:(NSArray *)arrayOfEntryObjects
[mainPageTemplateString replaceOccurrencesOfString:@"{[AUTHORNAME]}" withString:@"Simone Manganelli" options:NSLiteralSearch range:NSMakeRange(0,[mainPageTemplateString length])]; [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:@"{[FEEDLASTBUILDDATE]}" withString:currentDateString options:NSLiteralSearch range:NSMakeRange(0,[mainPageTemplateString length])];
[mainPageTemplateString replaceOccurrencesOfString:@"{[FEEDPUBLISHDATE]}" 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:@"{[CATEGORYSTATS]}" withString:categoryStatsString options:NSLiteralSearch range:NSMakeRange(0,[mainPageTemplateString length])];
[mainPageTemplateString replaceOccurrencesOfString:@"{[ARCHIVEPAGEURL]}" withString:archivePageURLString options:NSLiteralSearch range:NSMakeRange(0,[mainPageTemplateString length])]; [mainPageTemplateString replaceOccurrencesOfString:@"{[ARCHIVEPAGEURL]}" withString:archivePageURLString options:NSLiteralSearch range:NSMakeRange(0,[mainPageTemplateString length])];
Expand Down
1 change: 1 addition & 0 deletions EPStringCategory.m
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -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])];
[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]; NSData *ASCIIStringData = [tempString dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
Expand Down

0 comments on commit 22f8a91

Please sign in to comment.