Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
37d12ec
Create abstraction interface for NoteArchiveDocument
bdewey Dec 30, 2019
f953dcd
Swiftformat + comments
bdewey Dec 30, 2019
cd85317
Switch to Combine from custom "observers" protocol
bdewey Dec 30, 2019
f18aa3a
swiftformat
bdewey Dec 30, 2019
6ef6d6f
Make the async version of studySession a protocol extension
bdewey Dec 30, 2019
ec59811
Use an explicitly-typed PageIdentifier in NoteStorage
bdewey Dec 30, 2019
1c94140
Move PageIdentifier down a level
bdewey Dec 30, 2019
21f4a2d
Change where I do substring conversion
bdewey Dec 30, 2019
d6a18ea
Refactor: PageIdentifier -> NoteIdentifier
bdewey Dec 30, 2019
215a6e2
Refactor: pageIdentifier -> noteIdentifier
bdewey Dec 30, 2019
3e198d0
Refactor: pageProperties -> noteProperties
bdewey Dec 30, 2019
04d8c6f
Refactor: notePropertiesDidChange is now a Void passthrough
bdewey Dec 30, 2019
b0694d6
Cosmetic reorganization.
bdewey Dec 31, 2019
8e762df
More lifting of code from NoteDocumentStorage to NoteStorage
bdewey Dec 31, 2019
b3e9948
Can set properties along with content at the NoteArchive level
bdewey Dec 31, 2019
9b44a54
Refactor step towards single Note type
bdewey Dec 31, 2019
3b52f5e
Introduce NoteStorage API v2
bdewey Jan 1, 2020
299af8a
Use APIv2 for manipulating text
bdewey Jan 1, 2020
c2bbc45
Remove dead code
bdewey Jan 1, 2020
e504716
Make study session logic use APIv2
bdewey Jan 1, 2020
cebca03
Use APIv2 inside the VocabularyViewController
bdewey Jan 2, 2020
2bc18e5
Get rid of `noteProperties` from NoteStorage
bdewey Jan 2, 2020
c2e20ee
Get rid of file import code
bdewey Jan 2, 2020
c72d715
More refactoring / cleanup in protocol
bdewey Jan 2, 2020
35c9d8b
Update changelog.
bdewey Jan 2, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Uncomitted

### Changed

- Internally, storage now goes through a `NoteStorage` protocol instance. This is the abstraction layer that will let me experiment with a sqlite file format.

## [0.13.0] - 2019-09-28

### Changed
Expand Down
42 changes: 25 additions & 17 deletions CommonplaceBookApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
637F8B0C22AE186100698868 /* MiniMarkdown in Frameworks */ = {isa = PBXBuildFile; productRef = 637F8B0B22AE186100698868 /* MiniMarkdown */; };
BE050A647575E8F075868DF1 /* Pods_CommonplaceBookApp.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A8D2C034B73F8605B9C553FE /* Pods_CommonplaceBookApp.framework */; };
D30B0243229E513C00F3B459 /* StudyLog.swift in Sources */ = {isa = PBXBuildFile; fileRef = D30B0242229E513C00F3B459 /* StudyLog.swift */; };
D30B0245229EB88900F3B459 /* NoteArchiveDocument+TextEditViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D30B0244229EB88900F3B459 /* NoteArchiveDocument+TextEditViewController.swift */; };
D30B0245229EB88900F3B459 /* SavingTextEditViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D30B0244229EB88900F3B459 /* SavingTextEditViewController.swift */; };
D30BD4F822A0B13B007E1F31 /* ParsingRules+CommonplaceBook.swift in Sources */ = {isa = PBXBuildFile; fileRef = D30BD4F722A0B13B007E1F31 /* ParsingRules+CommonplaceBook.swift */; };
D30BD4FC22A0B8C2007E1F31 /* Optional+Collection.swift in Sources */ = {isa = PBXBuildFile; fileRef = D30BD4FB22A0B8C2007E1F31 /* Optional+Collection.swift */; };
D30D261823193F9A0031AA20 /* VocabularyViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D30D261723193F9A0031AA20 /* VocabularyViewController.swift */; };
Expand Down Expand Up @@ -73,8 +73,10 @@
D375D33C20ED9BEC00EAB4F0 /* DocumentListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D375D33B20ED9BEC00EAB4F0 /* DocumentListViewController.swift */; };
D375D33E20EDA08F00EAB4F0 /* DocumentTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D375D33D20EDA08F00EAB4F0 /* DocumentTableViewCell.swift */; };
D37E6D34228D7AC6006CD0FA /* Observable.swift in Sources */ = {isa = PBXBuildFile; fileRef = D37E6D33228D7AC6006CD0FA /* Observable.swift */; };
D37E6D36228D9DD8006CD0FA /* PageProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = D37E6D35228D9DD8006CD0FA /* PageProperties.swift */; };
D37E6D36228D9DD8006CD0FA /* NoteProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = D37E6D35228D9DD8006CD0FA /* NoteProperties.swift */; };
D37E6D38228DBC88006CD0FA /* CommonCrypto+Swift.swift in Sources */ = {isa = PBXBuildFile; fileRef = D37E6D37228DBC88006CD0FA /* CommonCrypto+Swift.swift */; };
D38862B423BB94FA00A44F1C /* Note.swift in Sources */ = {isa = PBXBuildFile; fileRef = D38862B323BB94FA00A44F1C /* Note.swift */; };
D38862B623BE404300A44F1C /* Note+Markdown.swift in Sources */ = {isa = PBXBuildFile; fileRef = D38862B523BE404300A44F1C /* Note+Markdown.swift */; };
D39015C2229025EA0097B182 /* NoteArchiveDocumentTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D39015C1229025EA0097B182 /* NoteArchiveDocumentTests.swift */; };
D3A6EFAD20EE500D00AC428D /* FileMetadata.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3A6EFAC20EE500D00AC428D /* FileMetadata.swift */; };
D3A99ED422EDDCA7000D6DE2 /* DocumentTableController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3A99ED322EDDCA7000D6DE2 /* DocumentTableController.swift */; };
Expand All @@ -86,8 +88,8 @@
D3C5C7DE232E871F00A8BEDF /* QuestionAndAnswerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3C5C7DD232E871F00A8BEDF /* QuestionAndAnswerTests.swift */; };
D3C5C7E0232E891200A8BEDF /* QuestionAndAnswer.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3C5C7DF232E891200A8BEDF /* QuestionAndAnswer.swift */; };
D3C5D26A214B1A7A0055F6B5 /* KeyboardInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3C5D269214B1A7A0055F6B5 /* KeyboardInfo.swift */; };
D3D3688E229C579200E4D062 /* NoteArchiveDocument.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3D3688D229C579200E4D062 /* NoteArchiveDocument.swift */; };
D3D36890229C61F500E4D062 /* NoteArchiveDocument+Importing.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3D3688F229C61F500E4D062 /* NoteArchiveDocument+Importing.swift */; };
D3CC03CA23BA734C003393DC /* NoteStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3CC03C923BA734C003393DC /* NoteStorage.swift */; };
D3D3688E229C579200E4D062 /* NoteDocumentStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3D3688D229C579200E4D062 /* NoteDocumentStorage.swift */; };
D3D36892229C9A8000E4D062 /* Date+CloseEnough.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3D36891229C9A8000E4D062 /* Date+CloseEnough.swift */; };
D3D50A2D231AC8EB007440F1 /* VocabularyChallengeTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3D50A2C231AC8EB007440F1 /* VocabularyChallengeTemplate.swift */; };
D3DC5EC320EC9B0100F0B74B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3DC5EC220EC9B0100F0B74B /* AppDelegate.swift */; };
Expand Down Expand Up @@ -145,7 +147,7 @@
C2519F393D974710775AF26A /* Pods_CommonplaceBookAppTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_CommonplaceBookAppTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
C69D2589A8BFE5C01679833D /* Pods-CommonplaceBookApp.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CommonplaceBookApp.release.xcconfig"; path = "Pods/Target Support Files/Pods-CommonplaceBookApp/Pods-CommonplaceBookApp.release.xcconfig"; sourceTree = "<group>"; };
D30B0242229E513C00F3B459 /* StudyLog.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StudyLog.swift; sourceTree = "<group>"; };
D30B0244229EB88900F3B459 /* NoteArchiveDocument+TextEditViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NoteArchiveDocument+TextEditViewController.swift"; sourceTree = "<group>"; };
D30B0244229EB88900F3B459 /* SavingTextEditViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SavingTextEditViewController.swift; sourceTree = "<group>"; };
D30BD4F722A0B13B007E1F31 /* ParsingRules+CommonplaceBook.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ParsingRules+CommonplaceBook.swift"; sourceTree = "<group>"; };
D30BD4FB22A0B8C2007E1F31 /* Optional+Collection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Optional+Collection.swift"; sourceTree = "<group>"; };
D30D261723193F9A0031AA20 /* VocabularyViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VocabularyViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -210,8 +212,10 @@
D375D33D20EDA08F00EAB4F0 /* DocumentTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DocumentTableViewCell.swift; sourceTree = "<group>"; };
D375D33F20EDCE1700EAB4F0 /* CommonplaceBookApp.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = CommonplaceBookApp.entitlements; sourceTree = "<group>"; };
D37E6D33228D7AC6006CD0FA /* Observable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Observable.swift; sourceTree = "<group>"; };
D37E6D35228D9DD8006CD0FA /* PageProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PageProperties.swift; sourceTree = "<group>"; };
D37E6D35228D9DD8006CD0FA /* NoteProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoteProperties.swift; sourceTree = "<group>"; };
D37E6D37228DBC88006CD0FA /* CommonCrypto+Swift.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CommonCrypto+Swift.swift"; sourceTree = "<group>"; };
D38862B323BB94FA00A44F1C /* Note.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Note.swift; sourceTree = "<group>"; };
D38862B523BE404300A44F1C /* Note+Markdown.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Note+Markdown.swift"; sourceTree = "<group>"; };
D39015C1229025EA0097B182 /* NoteArchiveDocumentTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoteArchiveDocumentTests.swift; sourceTree = "<group>"; };
D3A6EFAC20EE500D00AC428D /* FileMetadata.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileMetadata.swift; sourceTree = "<group>"; };
D3A99ED322EDDCA7000D6DE2 /* DocumentTableController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DocumentTableController.swift; sourceTree = "<group>"; };
Expand All @@ -223,8 +227,8 @@
D3C5C7DD232E871F00A8BEDF /* QuestionAndAnswerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuestionAndAnswerTests.swift; sourceTree = "<group>"; };
D3C5C7DF232E891200A8BEDF /* QuestionAndAnswer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuestionAndAnswer.swift; sourceTree = "<group>"; };
D3C5D269214B1A7A0055F6B5 /* KeyboardInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyboardInfo.swift; sourceTree = "<group>"; };
D3D3688D229C579200E4D062 /* NoteArchiveDocument.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoteArchiveDocument.swift; sourceTree = "<group>"; };
D3D3688F229C61F500E4D062 /* NoteArchiveDocument+Importing.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NoteArchiveDocument+Importing.swift"; sourceTree = "<group>"; };
D3CC03C923BA734C003393DC /* NoteStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoteStorage.swift; sourceTree = "<group>"; };
D3D3688D229C579200E4D062 /* NoteDocumentStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoteDocumentStorage.swift; sourceTree = "<group>"; };
D3D36891229C9A8000E4D062 /* Date+CloseEnough.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Date+CloseEnough.swift"; sourceTree = "<group>"; };
D3D50A2C231AC8EB007440F1 /* VocabularyChallengeTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VocabularyChallengeTemplate.swift; sourceTree = "<group>"; };
D3DC5EBF20EC9B0100F0B74B /* CommonplaceBookApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CommonplaceBookApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -370,25 +374,28 @@
D3DC5ED020EC9B0200F0B74B /* Info.plist */,
D3C5D269214B1A7A0055F6B5 /* KeyboardInfo.swift */,
D3DC5ECD20EC9B0200F0B74B /* LaunchScreen.storyboard */,
D36214652334F607008C8FF4 /* LayoutManager.swift */,
D31AFA89229D61E900ED2B76 /* LoadingViewController.swift */,
D3591501231C340100883AC4 /* LocaleAwareTextField.swift */,
D3FD46A52329257C008FDAE4 /* LoggingSpeechSynthesizer.swift */,
D54C311D21E7E3CD007AE62E /* MarkdownEditingTextView.swift */,
D31AFA9B229D61EC00ED2B76 /* MetadataQuery.swift */,
D38862B323BB94FA00A44F1C /* Note.swift */,
D38862B523BE404300A44F1C /* Note+Markdown.swift */,
D33F64742298C70C008C3A92 /* NoteArchive.swift */,
D3D3688D229C579200E4D062 /* NoteArchiveDocument.swift */,
D3D3688F229C61F500E4D062 /* NoteArchiveDocument+Importing.swift */,
D30B0244229EB88900F3B459 /* NoteArchiveDocument+TextEditViewController.swift */,
D3D3688D229C579200E4D062 /* NoteDocumentStorage.swift */,
D37E6D35228D9DD8006CD0FA /* NoteProperties.swift */,
D3CC03C923BA734C003393DC /* NoteStorage.swift */,
D31AFA9F229D61EC00ED2B76 /* NSAttributedString+ChapterAndVerse.swift */,
D37E6D33228D7AC6006CD0FA /* Observable.swift */,
D30BD4FB22A0B8C2007E1F31 /* Optional+Collection.swift */,
D37E6D35228D9DD8006CD0FA /* PageProperties.swift */,
D30BD4F722A0B13B007E1F31 /* ParsingRules+CommonplaceBook.swift */,
D31AFAAA229D61EE00ED2B76 /* PersonalitySpeechSynthesizer.swift */,
D3C5C7DF232E891200A8BEDF /* QuestionAndAnswer.swift */,
D3B3323F232FC55C00F0B710 /* QuestionAndAnswerTemplate.swift */,
D339C6FD21EB928700924178 /* QuoteTemplate.swift */,
D31AFA8D229D61E900ED2B76 /* RenderedMarkdown+Stylesheet.swift */,
D30B0244229EB88900F3B459 /* SavingTextEditViewController.swift */,
D3B8514D22AC0794004F3B95 /* Settings.bundle */,
D33F647822999138008C3A92 /* String+ParsingHelpers.swift */,
D31AFA8F229D61EB00ED2B76 /* String+Typography.swift */,
Expand All @@ -411,7 +418,6 @@
D3591503231C3AC800883AC4 /* View+Locale.swift */,
D3D50A2C231AC8EB007440F1 /* VocabularyChallengeTemplate.swift */,
D30D261723193F9A0031AA20 /* VocabularyViewController.swift */,
D36214652334F607008C8FF4 /* LayoutManager.swift */,
);
path = CommonplaceBookApp;
sourceTree = "<group>";
Expand Down Expand Up @@ -667,9 +673,10 @@
buildActionMask = 2147483647;
files = (
D33F64752298C70C008C3A92 /* NoteArchive.swift in Sources */,
D30B0245229EB88900F3B459 /* NoteArchiveDocument+TextEditViewController.swift in Sources */,
D30B0245229EB88900F3B459 /* SavingTextEditViewController.swift in Sources */,
D374AB6B229655BA00F54561 /* TextSnippetArchive.swift in Sources */,
D3DC5EE520EC9F7500F0B74B /* TextEditViewController.swift in Sources */,
D38862B623BE404300A44F1C /* Note+Markdown.swift in Sources */,
D31AFACB229D61EE00ED2B76 /* ChallengeTemplate.swift in Sources */,
D3E98EFE21D2F784008445DA /* DirectoryMetadataProvider.swift in Sources */,
D3D36892229C9A8000E4D062 /* Date+CloseEnough.swift in Sources */,
Expand All @@ -692,6 +699,7 @@
D31AFAB6229D61EE00ED2B76 /* CardDocumentProperties.swift in Sources */,
D37E6D38228DBC88006CD0FA /* CommonCrypto+Swift.swift in Sources */,
D31AFAB9229D61EE00ED2B76 /* ClosedRange+SwiftFlash.swift in Sources */,
D3CC03CA23BA734C003393DC /* NoteStorage.swift in Sources */,
D31AFACA229D61EE00ED2B76 /* ClozeCard.swift in Sources */,
D3C5D26A214B1A7A0055F6B5 /* KeyboardInfo.swift in Sources */,
D33F646F22981E38008C3A92 /* TextSnippet.swift in Sources */,
Expand All @@ -715,8 +723,9 @@
D33F64772298CE8E008C3A92 /* TextSnippetArchive+ChallengeTemplate.swift in Sources */,
D54C311E21E7E3CD007AE62E /* MarkdownEditingTextView.swift in Sources */,
D31AFAAD229D61EE00ED2B76 /* UIStackView+SetArrangedSubviews.swift in Sources */,
D3D3688E229C579200E4D062 /* NoteArchiveDocument.swift in Sources */,
D37E6D36228D9DD8006CD0FA /* PageProperties.swift in Sources */,
D38862B423BB94FA00A44F1C /* Note.swift in Sources */,
D3D3688E229C579200E4D062 /* NoteDocumentStorage.swift in Sources */,
D37E6D36228D9DD8006CD0FA /* NoteProperties.swift in Sources */,
D35E90C7230C5AD300A46B3F /* UserDefault.swift in Sources */,
D3331C8722F4EF11002B62AF /* StringProtocol+FuzzyMatch.swift in Sources */,
D3A99ED422EDDCA7000D6DE2 /* DocumentTableController.swift in Sources */,
Expand All @@ -737,7 +746,6 @@
D3A6EFAD20EE500D00AC428D /* FileMetadata.swift in Sources */,
D35E90C9230C755D00A46B3F /* UIApplication+Environment.swift in Sources */,
D31AFAD6229D61EE00ED2B76 /* AnswerStatistics.swift in Sources */,
D3D36890229C61F500E4D062 /* NoteArchiveDocument+Importing.swift in Sources */,
D31AFAC5229D61EE00ED2B76 /* IdentifierToStudyMetadata.swift in Sources */,
D30B0243229E513C00F3B459 /* StudyLog.swift in Sources */,
);
Expand Down
18 changes: 9 additions & 9 deletions CommonplaceBookApp/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ final class AppDelegate: UIResponder, UIApplicationDelegate {
return loadingViewController
}()

var noteArchiveDocument: NoteArchiveDocument?
var noteArchiveDocument: NoteStorage?
/// If non-nil, we want to open this page initially upon opening the document.
var initialPageIdentifier: String?
var initialPageIdentifier: Note.Identifier?

@UserDefault("opened_document", defaultValue: nil) var openedDocumentBookmark: Data?
@UserDefault("has_run_0", defaultValue: false) var hasRun: Bool
Expand Down Expand Up @@ -103,7 +103,7 @@ final class AppDelegate: UIResponder, UIApplicationDelegate {
break
}
DDLogInfo("Opening page \(uniqueIdentifier)")
initialPageIdentifier = uniqueIdentifier
initialPageIdentifier = Note.Identifier(rawValue: uniqueIdentifier)
default:
break
}
Expand Down Expand Up @@ -202,7 +202,7 @@ extension AppDelegate: UIDocumentBrowserViewControllerDelegate {
/// - parameter controller: The view controller from which to present the DocumentListViewController
private func openDocument(at url: URL, from controller: UIDocumentBrowserViewController, animated: Bool) {
DDLogInfo("Opening document at \(url)")
let noteArchiveDocument = NoteArchiveDocument(
let noteArchiveDocument = NoteDocumentStorage(
fileURL: url,
parsingRules: ParsingRules.commonplace
)
Expand All @@ -224,9 +224,9 @@ extension AppDelegate: UIDocumentBrowserViewControllerDelegate {
wrappedViewController.modalPresentationStyle = .fullScreen
wrappedViewController.modalTransitionStyle = .crossDissolve
controller.present(wrappedViewController, animated: animated, completion: nil)
let pageIdentifierCopy = initialPageIdentifier
let noteIdentifierCopy = initialPageIdentifier
noteArchiveDocument.open(completionHandler: { success in
pageIdentifierCopy.flatMap { documentListViewController.showPage(with: $0) }
noteIdentifierCopy.flatMap { documentListViewController.showPage(with: $0) }
let properties: [String: String] = [
"Success": success.description,
"documentState": String(describing: noteArchiveDocument.documentState),
Expand All @@ -249,7 +249,7 @@ extension AppDelegate: UIDocumentBrowserViewControllerDelegate {
func documentBrowser(_ controller: UIDocumentBrowserViewController, didRequestDocumentCreationWithHandler importHandler: @escaping (URL?, UIDocumentBrowserViewController.ImportMode) -> Void) {
let directoryURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).last!
let url = directoryURL.appendingPathComponent(UUID().uuidString).appendingPathExtension("notebundle")
let document = NoteArchiveDocument(fileURL: url, parsingRules: ParsingRules.commonplace)
let document = NoteDocumentStorage(fileURL: url, parsingRules: ParsingRules.commonplace)
document.save(to: url, for: .forCreating) { saveSuccess in
guard saveSuccess else {
DDLogError("Could not save document to \(url): \(document.previousError?.localizedDescription ?? "nil")")
Expand Down Expand Up @@ -287,7 +287,7 @@ extension AppDelegate: UISplitViewControllerDelegate {
) -> Bool {
guard
let navigationController = secondaryViewController as? UINavigationController,
let textEditViewController = navigationController.visibleViewController as? TextEditViewController
let textEditViewController = navigationController.visibleViewController as? SavingTextEditViewController
else {
assertionFailure()
return false
Expand All @@ -299,7 +299,7 @@ extension AppDelegate: UISplitViewControllerDelegate {
//
// In our case, if the textEditViewController doesn't represent a real page, we don't
// want to show it.
return textEditViewController.pageIdentifier == nil
return textEditViewController.noteIdentifier == nil
}
}

Expand Down
8 changes: 8 additions & 0 deletions CommonplaceBookApp/Array+Node.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ extension Array where Element == Node {
].joined())
}

func makeChallengeTemplates() -> [ChallengeTemplate] {
var results: [ChallengeTemplate] = []
results.append(contentsOf: ClozeTemplate.extract(from: self))
results.append(contentsOf: QuoteTemplate.extract(from: self))
results.append(contentsOf: QuestionAndAnswerTemplate.extract(from: self))
return results
}

/// Extracts the title from an array of nodes.
///
/// - note: If there is a heading anywhere in the nodes, the contents of the first heading
Expand Down
Loading