Skip to content

Create standalone HTML viewer for Bagit data. #1517

Description

@NishaSharma14

Is your feature request related to a problem? Please describe.
In the long-term future, if nmrXiv is taken down for any reason, users would lose the ability to visualize and analyze their archived NMR data. Currently, the Bagit archives generated by nmrXiv require the full application stack to be running in order to view the sample information and perform spectra analysis. This creates a dependency risk for long-term data preservation and accessibility.

Describe the solution you'd like
Create a standalone, self-contained HTML page that can render Bagit data without needing to spin up the whole nmrXiv application. This HTML website should:

  1. Render all sample information - Display all metadata and details about the Sample from the Bagit archive
  2. Enable spectra analysis - Embed the NMRium tool via iframe to allow interactive spectral analysis directly from the HTML file
  3. Be fully portable - Work as a single HTML file (or minimal set of files) that can be distributed with the Bagit archive
  4. Function offline - Not require any server-side infrastructure to operate

This would ensure long-term data accessibility and align with FAIR data principles by making the archived data independently usable.

Additional context
Related code snippets from the current Bagit generation implementation:

File: app/Jobs/ProcessMetadataExtractionBagitGenerationJob.php

* Generate BagIt manifests using whikloj/BagItTools library.
*/
protected function generateBagItManifests(string $bagPath): void
{
try {
// Create bag using BagItTools library
$bag = Bag::create($bagPath);
// Update bag with checksums
$bag->update();
// Package the bag (this generates manifests)
$bag->package($bagPath);
Log::debug('Used BagItTools library for manifest generation');
} catch (\Exception $e) {
Log::warning("BagIt library failed: {$e->getMessage()}. Falling back to manual generation...");
// Fallback: Generate manually
$this->generateBagItManually($bagPath);
}
}
/**
* Manually generate BagIt manifests.
*/
protected function generateBagItManually(string $bagPath): void
{
// Create bagit.txt
$bagitContent = "BagIt-Version: 1.0\nTag-File-Character-Encoding: UTF-8\n";
file_put_contents($bagPath.'/bagit.txt', $bagitContent);
// Create manifest-sha256.txt
$manifestLines = [];
$dataPath = $bagPath.'/data';
if (is_dir($dataPath)) {
$files = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator($dataPath),
\RecursiveIteratorIterator::LEAVES_ONLY
);
foreach ($files as $file) {
if ($file->isFile()) {
$relativePath = str_replace($bagPath.'/', '', $file->getPathname());
$hash = hash_file('sha256', $file->getPathname());
$manifestLines[] = "{$hash} {$relativePath}";
}
}
}
file_put_contents($bagPath.'/manifest-sha256.txt', implode("\n", $manifestLines)."\n");
// Create bag-info.txt
$bagInfoContent = 'Payload-Oxum: '.$this->calculatePayloadOxum($dataPath)."\n";
$bagInfoContent .= 'Bagging-Date: '.date('Y-m-d')."\n";
$bagInfoContent .= "Bag-Software-Agent: Laravel-Queue-ProcessStudySpectraJob/1.0\n";
file_put_contents($bagPath.'/bag-info.txt', $bagInfoContent);
// Create tagmanifest-sha256.txt
$tagManifestLines = [];
foreach (['bagit.txt', 'bag-info.txt', 'manifest-sha256.txt'] as $tagFile) {
$tagFilePath = $bagPath.'/'.$tagFile;
if (file_exists($tagFilePath)) {
$hash = hash_file('sha256', $tagFilePath);
$tagManifestLines[] = "{$hash} {$tagFile}";
}
}
file_put_contents($bagPath.'/tagmanifest-sha256.txt', implode("\n", $tagManifestLines)."\n");
Log::debug('Manual BagIt generation complete');
}
/**
* Calculate Payload-Oxum (total bytes.total files).
*/

This job already handles Bagit generation with manifests and metadata. The new HTML viewer would need to:

  • Parse the Bagit structure (bagit.txt, bag-info.txt, manifest files, and data directory)
  • Extract sample metadata from the .nmrium files
  • Embed NMRium for interactive visualization
  • Work entirely client-side using JavaScript

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

featuresomething which is not there

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions