Hocchan Archive / Drives
https://hocchan.netlify.app/archive/drive/g
Take a snapshot of folders/files and turn it into a navigatable HTML file list.
This project is provided as-is. It's primarily built for my workflow, thus Windows only, there are no plans to support other operating systems.
The 📄snap-script.js files are awful please don't look at them :p.
Do not rename
📄snap.py when using to avoid having snap.py listed in your file list output.
📄snap.pyrequires Python to run. Local scans need no dependencies (tqdmwill be used if it's installed for progress feedback). Cloud scans (Google Drive) require dependencies fromrequirements.txt. Install them viapip install -r requirements.txt.
Cloud - Google Drive ··· Multi Page - JSON ··· Multi Page - DOM ··· Single File - DOM
- Works with all three variants below.
- Accepts Service Account and Desktop app credentials from Google Cloud Console. Web application credentials won't work.
a. Put your Google Cloud credential 📄JSON file inside the .credentials/ folder.
b. Run 📄snap.py. When it finds credentials in .credentials/, it will ask which one to use, or let you scan the local directory instead.
c. If you're using a Desktop app credential, 📄snap.py copies the auth URL to your clipboard on the first run. Paste it in your browser to sign in, and it saves the token inside .credentials/ for next time. It then asks for a Google Drive folder URL/ID directly.
d. If you're using a Service Account credential, 📄snap.py lists folders shared with the service account so you can pick one, or paste a Google Drive folder URL/ID.
e. Once you pick a folder, it scans the Drive folder and generates the appropriate 📄JSON / 📄snap.html, or the single 📄snap_cloud.html file.
- Recommended for public websites, has good performance and maintainability
- Requires the use of a server because CORS policy blocks JSON fetches.
- Requires JavaScript.
- (Optional) Access to IndexedDB or In-Memory Cache.
a. Copy and run 📄snap.py to wherever/whatever you want to create a file list of.
b. It will ask if you want to minify the JSON file, choose whichever you prefer (minified JSON is smaller in size).
c. After running and going through the setup, this will generate your 📄JSON file and 📄snap.html which has HTML snippets.
a. Define JSON file location in the HTML head via a meta element.
If no JSON file location is defined, the page will use a fallback JSON file (in this case 📄directories.json is defined as the fallback in 📄snap-script.js under object CONFIG), so be sure to set a jsonPath.
b. Define the JSON version in the head via a meta element.
The JSON version can be found at the generated 📄snap.html.
c. Replace the entire <div class="header">...</div> block from your page.
This can be found at the generated 📄snap.html.
d. Replace the entire <ul id="files" class="view-tiles" data-path="root">...</ul> block from your page.
Again, this can be found at the generated 📄snap.html.
- Compare the meta
jsonVersionwith the📄JSONfile used. - If the JSON versions are identical, prevent fetching the
📄JSONfile on page load. - If the JSON versions are NOT identical keep fetching the
📄JSONfile on page load. - Loop.
- Keep fetching the
📄JSONfile on page load.
- Once
📄JSONis fetched tries to save JSON data in IndexedDB and uses that for subsequent navigations; - If IndexedDB cannot be accessed use In-Memory Cache for subsequent navigations.
- If In-Memory Cache fails, do fetch requests to the
📄JSONfile for every action/navigation (Very slow).
- Can be used for public websites, a bit easier to setup and maintain with less performance
- If database/file list is big (html file size of a few megabytes), page may load slow or freeze for a bit on page load.
- Requires JavaScript.
- (Optional) Access to In-Memory Cache.
a. Copy and run 📄snap.py to wherever/whatever you want to create a file list of.
b. After running this will generate your 📄snap.html which has HTML snippets.
a. Replace the entire <div class="header">...</div> block from your page.
This can be found at the generated 📄snap.html.
b. Replace the entire <ul id="files" class="view-tiles" data-path="root">...</ul> block from your page.
This can be found at the generated 📄snap.html.
c. Replace the entire <script id="dom-cache" type="application/json">...</script> block from your page.
Again, this can be found at the generated 📄snap.html.
Notice that depending on your text or code editor, this may display several hundred lines, as these blocks contain thousands of characters.
I have provided 📄_empty-script-block.html files which contain empty script blocks for this purpose.
- If In-Memory Cache fails, script reads from
<script id="dom-cache" type="application/json">...</script>for every action/navigation.
- Recommended to be used for offline snapshots/archives of your file list.
- Not recommended to be used for public websites, less performance and close to zero maintainability/customization.
- If database/file list is big (html file size of a few megabytes), page may load slow or freeze for a bit on page load.
- Requires JavaScript.
- Copy and run 📄snap.py to whatever you want to create a file list of.
- If In-Memory Cache fails, script reads from
<script id="dom-cache" type="application/json">...</script>for every action/navigation.
Feel free to edit or mess the CSS/HTML stylings but keep the necessary IDs, classes, and data variables used.
On 📄snap-style.css add a new icon type under the /*hocchan union archive*/ comment;
On 📄snap.py under the ICON_PRESETS dictionary, define a new icon type with the file formats it will use;
'A': ['B'],
'A' is the .icon-A defined in 📄snap-style.css with the .icon- part omitted.
And 'B' is the file format(s) that will use that icon preset.
By default any file format not defined will have no icon or can be set to use the default icon preset. This can be done in the 📄snap.py script by changing the USE_DEFAULT_PRESET variable to true.
If you somehow want to edit the HTML/CSS/JS of Single File - DOM (why). The CSS is minified, just tidy that, and the JS is encoded in Base64, either decode that and then tidy. OR alternatively just use/edit the Multi Page - DOM CSS/JS.












