Revision: 28907 http://sourceforge.net/p/bibdesk/svn/28907 Author: hofman Date: 2024-05-15 14:17:32 +0000 (Wed, 15 May 2024) Log Message: ----------- remove template path preference, we never set it and always use application support
Modified Paths: -------------- trunk/bibdesk/BDSKStringConstants.h trunk/bibdesk/BDSKStringConstants.m trunk/bibdesk/BDSKTeXTask.m trunk/bibdesk/BibDocument.m trunk/bibdesk/BibPref_Files.m trunk/bibdesk/Preferences.plist Modified: trunk/bibdesk/BDSKStringConstants.h =================================================================== --- trunk/bibdesk/BDSKStringConstants.h 2024-05-15 09:16:14 UTC (rev 28906) +++ trunk/bibdesk/BDSKStringConstants.h 2024-05-15 14:17:32 UTC (rev 28907) @@ -76,7 +76,6 @@ extern NSString *BDSKCitationFieldsKey; extern NSString *BDSKPersonFieldsKey; extern NSString *BDSKDefaultViewersKey; -extern NSString *BDSKOutputTemplateFileKey; extern NSString *BDSKMainTableViewFontNameKey; extern NSString *BDSKMainTableViewFontSizeKey; extern NSString *BDSKGroupTableViewFontNameKey; Modified: trunk/bibdesk/BDSKStringConstants.m =================================================================== --- trunk/bibdesk/BDSKStringConstants.m 2024-05-15 09:16:14 UTC (rev 28906) +++ trunk/bibdesk/BDSKStringConstants.m 2024-05-15 14:17:32 UTC (rev 28907) @@ -153,7 +153,6 @@ NSString *BDSKCitationFieldsKey = @"Citation fields"; NSString *BDSKPersonFieldsKey = @"Person fields"; NSString *BDSKDefaultViewersKey = @"BDSKDefaultViewersKey"; -NSString *BDSKOutputTemplateFileKey = @"Output Template File"; NSString *BDSKUseLocalUrlAndUrlKey = @"BDSKUseLocalUrlAndUrlKey"; NSString *BDSKAutomaticallyConvertURLFieldsKey = @"BDSKAutomaticallyConvertURLFieldsKey"; Modified: trunk/bibdesk/BDSKTeXTask.m =================================================================== --- trunk/bibdesk/BDSKTeXTask.m 2024-05-15 09:16:14 UTC (rev 28906) +++ trunk/bibdesk/BDSKTeXTask.m 2024-05-15 14:17:32 UTC (rev 28907) @@ -380,21 +380,24 @@ NSStringEncoding encoding = [[NSUserDefaults standardUserDefaults] integerForKey:BDSKTeXPreviewFileEncodingKey]; NSError *error; + NSMutableString *bibTemplate = [[NSMutableString alloc] init]; - // this should likely be the same encoding as our other files; presumably it's here because the user can have a default @preamble or something that's relevant? - NSMutableString *bibTemplate = [[NSMutableString alloc] initWithContentsOfFile: - [[[NSUserDefaults standardUserDefaults] stringForKey:BDSKOutputTemplateFileKey] stringByStandardizingPath] encoding:encoding error:&error]; - - if (nil == bibTemplate) { - NSLog(@"unable to read file %@ in task %@", [[NSUserDefaults standardUserDefaults] stringForKey:BDSKOutputTemplateFileKey], self); - NSLog(@"Foundation reported error %@", error); - bibTemplate = [[NSMutableString alloc] init]; + if ([[NSUserDefaults standardUserDefaults] boolForKey:BDSKShouldShareFilesKey]) { + // this should likely be the same encoding as our other files; presumably it's here because the user can have a default @preamble or something that's relevant? + NSURL *templateURL = [[[NSFileManager defaultManager] applicationSupportDirectoryURL] URLByAppendingPathComponent:@"template.txt"]; + bibTemplate = [[NSMutableString alloc] initWithContentsOfURL:templateURL encoding:encoding error:&error]; + [bibTemplate appendString:@"\n"]; + + if (nil == bibTemplate) { + NSLog(@"unable to read file %@ in task %@", [templateURL path], self); + NSLog(@"Foundation reported error %@", error); + bibTemplate = [[NSMutableString alloc] init]; + } } - [bibTemplate appendString:@"\n"]; [bibTemplate appendString:bibStr]; [bibTemplate appendString:@"\n"]; - + BOOL didWrite; didWrite = [bibTemplate writeToFile:[texPath bibFilePath] atomically:NO encoding:encoding error:&error]; if(NO == didWrite) { Modified: trunk/bibdesk/BibDocument.m =================================================================== --- trunk/bibdesk/BibDocument.m 2024-05-15 09:16:14 UTC (rev 28906) +++ trunk/bibdesk/BibDocument.m 2024-05-15 14:17:32 UTC (rev 28907) @@ -1392,7 +1392,8 @@ NSStringEncoding groupsEncoding = [BDSKBibTeXParser isUnparseableEncoding:encoding] ? encoding : NSUTF8StringEncoding; if([[NSUserDefaults standardUserDefaults] boolForKey:BDSKShouldUseTemplateFileKey]){ - NSMutableString *templateFile = [NSMutableString stringWithContentsOfFile:[[[NSUserDefaults standardUserDefaults] stringForKey:BDSKOutputTemplateFileKey] stringByExpandingTildeInPath] usedEncoding:NULL error:NULL] ?: [NSMutableString string]; + NSURL *templateURL = [[[NSFileManager defaultManager] applicationSupportDirectoryURL] URLByAppendingPathComponent:@"template.txt"]; + NSMutableString *templateFile = [NSMutableString stringWithContentsOfURL:templateURL usedEncoding:NULL error:NULL] ?: [NSMutableString string]; NSString *userName = NSFullUserName(); if ([userName canBeConvertedToEncoding:encoding] == NO) Modified: trunk/bibdesk/BibPref_Files.m =================================================================== --- trunk/bibdesk/BibPref_Files.m 2024-05-15 09:16:14 UTC (rev 28906) +++ trunk/bibdesk/BibPref_Files.m 2024-05-15 14:17:32 UTC (rev 28907) @@ -85,9 +85,10 @@ } - (IBAction)editTemplateFile:(id)sender{ - if(![[NSWorkspace sharedWorkspace] openFile:[[sud stringForKey:BDSKOutputTemplateFileKey] stringByExpandingTildeInPath]]) - if(![[NSWorkspace sharedWorkspace] openFile:[[sud stringForKey:BDSKOutputTemplateFileKey] stringByExpandingTildeInPath] withApplication:@"TextEdit"]) - NSBeep(); + NSURL *templateURL = [[[NSFileManager defaultManager] applicationSupportDirectoryURL] URLByAppendingPathComponent:@"template.txt"]; + if (NO == [[NSWorkspace sharedWorkspace] openURL:templateURL] && + NO == [[NSWorkspace sharedWorkspace] openURLs:@[templateURL] withAppBundleIdentifier:@"com.apple.TextEdit" options:NSWorkspaceLaunchDefault additionalEventParamDescriptor:nil launchIdentifiers:NULL]) + NSBeep(); } - (IBAction)resetTemplateFile:(id)sender{ @@ -97,15 +98,9 @@ [alert addButtonWithTitle:NSLocalizedString(@"OK", @"Button title")]; [alert addButtonWithTitle:NSLocalizedString(@"Cancel", @"Button title")]; [alert beginSheetModalForWindow:[[self view] window] completionHandler:^(NSInteger returnCode){ - if (returnCode == NSAlertFirstButtonReturn) { - NSFileManager *fileManager = [NSFileManager defaultManager]; - NSString *templateFilePath = [[sud stringForKey:BDSKOutputTemplateFileKey] stringByExpandingTildeInPath]; - if([fileManager fileExistsAtPath:templateFilePath]) - [fileManager removeItemAtPath:templateFilePath error:NULL]; + if (returnCode == NSAlertFirstButtonReturn) // copy template.txt file from the bundle - [fileManager copyItemAtPath:[[[NSBundle mainBundle] sharedSupportPath] stringByAppendingPathComponent:@"template.txt"] - toPath:templateFilePath error:NULL]; - } + [[NSFileManager defaultManager] copyFileFromSharedSupportToApplicationSupport :@"template.txt" overwrite:YES]; }]; } Modified: trunk/bibdesk/Preferences.plist =================================================================== --- trunk/bibdesk/Preferences.plist 2024-05-15 09:16:14 UTC (rev 28906) +++ trunk/bibdesk/Preferences.plist 2024-05-15 14:17:32 UTC (rev 28907) @@ -506,8 +506,6 @@ <integer>4</integer> <key>Load files in background</key> <false/> - <key>Output Template File</key> - <string>~/Library/Application Support/BibDesk/template.txt</string> <key>Save Annote and Abstract at End of Item</key> <false/> <key>Save normalized names in BibTeX files</key> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. _______________________________________________ Bibdesk-commit mailing list Bibdesk-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bibdesk-commit