-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor SmartDirectories to integrate SmartGroups and enhance direct…
…ory management - Introduced `SmartGroups` and `SmartGroup` classes, replacing `SmartEntities` in `SmartDirectories` and `SmartDirectory` for improved group handling. - Added `DirectoryGroupAdapter` and `SourceDirectoryGroupsAdapter` to manage directory group creation and structure. - Updated `package.json` to reflect changes in main entry point and dependencies. - Removed obsolete components related to directory rendering, streamlining the codebase. - Added a test script to create a directory structure for integration testing of SmartDirectories. These changes enhance the modularity and functionality of the SmartDirectories system, facilitating better directory management and integration with smart groups.
- Loading branch information
Brian Joseph Petro
committed
Dec 20, 2024
1 parent
17d1068
commit ff1ea05
Showing
17 changed files
with
479 additions
and
274 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { GroupAdapter } from '../../smart-groups/adapters/_adapter.js'; | ||
|
||
/** | ||
* @class DirectoryGroupAdapter | ||
* @extends GroupAdapter | ||
* @description | ||
* A base class for group-level adapters that build groups from directories. | ||
*/ | ||
export class DirectoryGroupAdapter extends GroupAdapter { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* @file SourceDirectoryGroupsAdapter.js | ||
* @description Adapts directory groups by scanning SmartSources to build directory items. | ||
*/ | ||
|
||
import { GroupCollectionAdapter, GroupItemAdapter } from '../../smart-groups/adapters/_adapter.js'; | ||
|
||
export class SourceDirectoryGroupsAdapter extends GroupCollectionAdapter { | ||
/** | ||
* Build groups by scanning the `smart_sources` collection. | ||
* For each source, derive its directory path and ensure a SmartDirectory group item exists. | ||
*/ | ||
async build_groups() { | ||
const source_paths = Object.keys(this.collection.env.smart_sources.items); | ||
const created_dirs = new Set(); | ||
|
||
for (const path of source_paths) { | ||
const dir_path = path.split('/').slice(0, -1).join('/') + '/'; | ||
await this.ensure_parent_directories(dir_path, created_dirs); | ||
} | ||
} | ||
|
||
async ensure_parent_directories(dir_path, created_dirs) { | ||
const parts = dir_path.split('/').filter(p => p); | ||
let current_path = ''; | ||
|
||
for (const part of parts) { | ||
current_path += part + '/'; | ||
if (!created_dirs.has(current_path)) { | ||
const existing = this.collection.get(current_path); | ||
if (!existing) { | ||
const item = this.collection.create_or_update({ path: current_path }); | ||
// item.init() if needed | ||
} | ||
created_dirs.add(current_path); | ||
} | ||
} | ||
} | ||
} | ||
|
||
export class SourceDirectoryGroupAdapter extends GroupItemAdapter { | ||
} | ||
|
||
export default { | ||
collection: SourceDirectoryGroupsAdapter, | ||
item: SourceDirectoryGroupAdapter | ||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
import { SmartDirectory } from "./smart_directory.js"; | ||
import { SmartDirectories } from "./smart_directories.js"; | ||
import source_directory_group_adapter from "./adapters/sources.js"; | ||
|
||
export { | ||
SmartDirectory, | ||
SmartDirectories, | ||
source_directory_group_adapter | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.