pict-section-filebrowser 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/README.md +107 -0
  2. package/docs/.nojekyll +0 -0
  3. package/docs/README.md +110 -0
  4. package/docs/_sidebar.md +15 -0
  5. package/docs/_topbar.md +7 -0
  6. package/docs/cover.md +11 -0
  7. package/docs/css/docuserve.css +73 -0
  8. package/docs/index.html +39 -0
  9. package/docs/retold-catalog.json +100 -0
  10. package/docs/retold-keyword-index.json +19 -0
  11. package/package.json +58 -0
  12. package/source/Pict-Section-FileBrowser-DefaultConfiguration.js +400 -0
  13. package/source/Pict-Section-FileBrowser.js +27 -0
  14. package/source/bin/browse.js +166 -0
  15. package/source/providers/Pict-Provider-FileBrowserBrowse.js +211 -0
  16. package/source/providers/Pict-Provider-FileBrowserIcons.js +480 -0
  17. package/source/providers/Pict-Provider-FileBrowserLayout.js +254 -0
  18. package/source/providers/Pict-Provider-FileBrowserList.js +310 -0
  19. package/source/providers/Pict-Provider-FileBrowserView.js +176 -0
  20. package/source/services/Pict-Service-FileBrowser.js +597 -0
  21. package/source/views/Pict-View-FileBrowser-BrowseSearch.js +189 -0
  22. package/source/views/Pict-View-FileBrowser-BrowseTree.js +266 -0
  23. package/source/views/Pict-View-FileBrowser-ListDetail.js +299 -0
  24. package/source/views/Pict-View-FileBrowser-ListIcons.js +251 -0
  25. package/source/views/Pict-View-FileBrowser-ViewFileInfo.js +122 -0
  26. package/source/views/Pict-View-FileBrowser-ViewImage.js +114 -0
  27. package/source/views/Pict-View-FileBrowser.js +151 -0
  28. package/source/www/icon-styles.html +570 -0
  29. package/source/www/index.html +920 -0
  30. package/test/Pict-Section-FileBrowser_tests.js +1681 -0
@@ -0,0 +1,176 @@
1
+ const libPictProvider = require('pict-provider');
2
+
3
+ const _DefaultProviderConfiguration =
4
+ {
5
+ "ProviderIdentifier": "Pict-FileBrowser-View",
6
+ "AutoInitialize": true,
7
+ "AutoInitializeOrdinal": 0,
8
+ "AutoSolveWithApp": true,
9
+ "AutoSolveOrdinal": 0
10
+ };
11
+
12
+ /**
13
+ * Base provider for viewing-type views (file info, image preview).
14
+ *
15
+ * Handles retrieval of the currently selected file's metadata and
16
+ * provides helpers for type detection and display formatting.
17
+ * Subclass to add custom viewing logic (e.g. code preview, video player).
18
+ */
19
+ class PictFileBrowserViewProvider extends libPictProvider
20
+ {
21
+ constructor(pFable, pOptions, pServiceHash)
22
+ {
23
+ super(pFable, pOptions, pServiceHash);
24
+ }
25
+
26
+ /**
27
+ * Get the currently selected file entry from AppData.
28
+ *
29
+ * @returns {Object|null} The current file entry or null
30
+ */
31
+ getCurrentFile()
32
+ {
33
+ let tmpStateAddresses = this.getFileBrowserOption('StateAddresses', {});
34
+ let tmpFileAddress = tmpStateAddresses.CurrentFile || 'AppData.PictFileBrowser.CurrentFile';
35
+
36
+ return this.pict.manifest.getValueByHash(
37
+ { AppData: this.pict.AppData, Pict: this.pict },
38
+ tmpFileAddress) || null;
39
+ }
40
+
41
+ /**
42
+ * Check if the current file is an image.
43
+ *
44
+ * @param {Object} [pFileEntry] - Optional file entry (defaults to getCurrentFile())
45
+ * @returns {boolean} True if the file is an image type
46
+ */
47
+ isImage(pFileEntry)
48
+ {
49
+ let tmpEntry = pFileEntry || this.getCurrentFile();
50
+ if (!tmpEntry)
51
+ {
52
+ return false;
53
+ }
54
+
55
+ // Check MimeType first
56
+ if (tmpEntry.MimeType && tmpEntry.MimeType.indexOf('image/') === 0)
57
+ {
58
+ return true;
59
+ }
60
+
61
+ // Fall back to extension
62
+ let tmpExt = (tmpEntry.Extension || '').toLowerCase();
63
+ let tmpImageExtensions = ['.jpg', '.jpeg', '.png', '.gif', '.svg', '.webp', '.bmp', '.ico', '.tiff', '.tif'];
64
+ return tmpImageExtensions.indexOf(tmpExt) >= 0;
65
+ }
66
+
67
+ /**
68
+ * Get the URL for an image file (for display in an <img> tag).
69
+ *
70
+ * If the entry has a ThumbnailURL or URL property, return that.
71
+ * Otherwise return null — the consuming application must provide URLs.
72
+ *
73
+ * @param {Object} [pFileEntry] - Optional file entry
74
+ * @returns {string|null} The image URL or null
75
+ */
76
+ getImageURL(pFileEntry)
77
+ {
78
+ let tmpEntry = pFileEntry || this.getCurrentFile();
79
+ if (!tmpEntry)
80
+ {
81
+ return null;
82
+ }
83
+
84
+ return tmpEntry.URL || tmpEntry.ThumbnailURL || null;
85
+ }
86
+
87
+ /**
88
+ * Get the file type description based on extension.
89
+ *
90
+ * @param {Object} [pFileEntry] - Optional file entry
91
+ * @returns {string} Human-readable file type
92
+ */
93
+ getFileTypeDescription(pFileEntry)
94
+ {
95
+ let tmpEntry = pFileEntry || this.getCurrentFile();
96
+ if (!tmpEntry)
97
+ {
98
+ return 'Unknown';
99
+ }
100
+
101
+ if (tmpEntry.Type === 'folder')
102
+ {
103
+ return 'Folder';
104
+ }
105
+
106
+ let tmpExt = (tmpEntry.Extension || '').toLowerCase();
107
+ switch (tmpExt)
108
+ {
109
+ case '.jpg': case '.jpeg': return 'JPEG Image';
110
+ case '.png': return 'PNG Image';
111
+ case '.gif': return 'GIF Image';
112
+ case '.svg': return 'SVG Image';
113
+ case '.webp': return 'WebP Image';
114
+ case '.bmp': return 'Bitmap Image';
115
+ case '.pdf': return 'PDF Document';
116
+ case '.doc': case '.docx': return 'Word Document';
117
+ case '.xls': case '.xlsx': return 'Excel Spreadsheet';
118
+ case '.csv': return 'CSV File';
119
+ case '.txt': return 'Text File';
120
+ case '.md': return 'Markdown File';
121
+ case '.html': return 'HTML File';
122
+ case '.css': return 'CSS Stylesheet';
123
+ case '.js': return 'JavaScript File';
124
+ case '.ts': return 'TypeScript File';
125
+ case '.json': return 'JSON File';
126
+ case '.xml': return 'XML File';
127
+ case '.yaml': case '.yml': return 'YAML File';
128
+ case '.py': return 'Python Script';
129
+ case '.rb': return 'Ruby Script';
130
+ case '.java': return 'Java File';
131
+ case '.c': return 'C Source File';
132
+ case '.cpp': return 'C++ Source File';
133
+ case '.go': return 'Go Source File';
134
+ case '.rs': return 'Rust Source File';
135
+ case '.zip': return 'ZIP Archive';
136
+ case '.tar': return 'TAR Archive';
137
+ case '.gz': return 'GZip Archive';
138
+ case '.rar': return 'RAR Archive';
139
+ case '.mp3': return 'MP3 Audio';
140
+ case '.wav': return 'WAV Audio';
141
+ case '.mp4': return 'MP4 Video';
142
+ case '.avi': return 'AVI Video';
143
+ case '.mov': return 'QuickTime Video';
144
+ default:
145
+ if (tmpExt)
146
+ {
147
+ return tmpExt.substring(1).toUpperCase() + ' File';
148
+ }
149
+ return 'File';
150
+ }
151
+ }
152
+
153
+ /**
154
+ * Get a filebrowser option from the main filebrowser view configuration.
155
+ *
156
+ * @param {string} pKey - The option key
157
+ * @param {*} pDefault - Default value
158
+ * @returns {*} The option value
159
+ */
160
+ getFileBrowserOption(pKey, pDefault)
161
+ {
162
+ if (this.pict.views && this.pict.views['Pict-FileBrowser'])
163
+ {
164
+ let tmpOptions = this.pict.views['Pict-FileBrowser'].options;
165
+ if (tmpOptions && (pKey in tmpOptions))
166
+ {
167
+ return tmpOptions[pKey];
168
+ }
169
+ }
170
+ return pDefault;
171
+ }
172
+ }
173
+
174
+ module.exports = PictFileBrowserViewProvider;
175
+
176
+ module.exports.default_configuration = _DefaultProviderConfiguration;