Skip to content

Commit

Permalink
WIP: quick integration
Browse files Browse the repository at this point in the history
  • Loading branch information
ross-spencer committed Jun 17, 2024
1 parent b1fbf38 commit 2babff0
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 90 deletions.
2 changes: 1 addition & 1 deletion demystify-lite.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ async def file_select():

results = document.getElementById("sf-results");

content = results.innerHTML;
content = results.value;
content = content.strip()

console.log(content.startswith("---"))
Expand Down
28 changes: 28 additions & 0 deletions demystify.css
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,31 @@ hr {
margin-top: 20px;
margin-bottom: 15px;
}

li.sf-select {
padding-top: 5px;
}

div.ready {
visibility: hidden;
height: 0px;
}

.loader {
visibility: hidden;
height: 0px;
margin-top:20px;
margin-left: 115px;
width: 50px;
aspect-ratio: 1;
border-radius: 50%;
background:
radial-gradient(farthest-side,#0b95be 94%,#0000) top/8px 8px no-repeat,
conic-gradient(#0000 30%,#0d39b4);
-webkit-mask: radial-gradient(farthest-side,#0000 calc(100% - 8px),#000 0);
animation: l13 1s infinite linear;
}
@keyframes l13{
100%{transform: rotate(1turn)
}
}
67 changes: 46 additions & 21 deletions index.htm
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<meta name="keywords" content="Digital Preservation, Pyscript, Demystify, File-Formats"/>
<meta name="rating" content="Utilities"/>
<link rel="stylesheet" href="https://pyscript.net/releases/2024.3.1/core.css"/>
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<script type="module" src="https://pyscript.net/releases/2024.3.1/core.js">
// do not delete...
</script>
Expand All @@ -38,16 +39,16 @@
<script src="sf/test.js" defer></script>
<script src="sf/wasm_exec.js"></script>
<script>
const go = new window.Go();
const go = new window.Go();

WebAssembly.instantiateStreaming(
fetch("sf/sf.wasm"),
go.importObject
).then(
(obj) => {
go.run(obj.instance);
}
);
WebAssembly.instantiateStreaming(
fetch("sf/sf.wasm"),
go.importObject
).then(
(obj) => {
go.run(obj.instance);
}
);
</script>
<!-- Siegfried Integration -->
</head>
Expand Down Expand Up @@ -107,16 +108,42 @@ <h2 class="subtitle">An analysis tool for file-format reports for digital preser
</p>
</div>
</section>

<p>
<select name="format" id="format" hidden>
<option value="yaml">YAML</option>
</select>
<ul>
<li class="sf-select">
Hash (hash):
<select name="hash" id="hash">
<option value="md5">md5</option>
<option value="sha1">sha1</option>
<option value="sha256">sha256</option>
<option value="sha512">sha512</option>
<option value="crc">crc</option>
<option value="none">none</option>
</select>
</li>
<li class="sf-select">
Scan within archive files:<input type="radio" name="z" value="true"> true <input type="radio" name="z" value="false" checked> false
</li>
</ul>
</p>
<p>
</p>
<button id="butOpen" type="button">
Siegfried: Open file
Siegfried: Open file
</button>

<button id="butDirectory" type="button">
Siegfried: Identify directory
</button>
<div class="loader" id="loader"></div>
<div class="w3-panel w3-pale-blue w3-border ready" id="ready">
<h4>Ready!</h4>
<p>Siegfried has finished scanning, 'run Demystify' to show the results.</p>
</div>
<div id="sf-results" hidden>

</div>


<section class="noprint">
<hr/>
<div>
Expand All @@ -130,22 +157,20 @@ <h2 class="subtitle">An analysis tool for file-format reports for digital preser
<section class="noprint" id="denylistTextBox" style="display: none;">
<textarea class="denylist" id="denylist" cols="500" rows="10"></textarea>
</section>

<!-- SF integration -->
<!-- SF integration -->
<!-- SF integration -->
<section class="noprint">
<div class="drag" id="drop_zone">
<label class="custom-file-upload">
<input type="button" id="my_button" />
### RUN DEMYSTIFY ###
</label>
<label class="custom-file-upload">
<input type="button" id="my_button" />
### run Demystify ###
</label>
</div>
</section>
<!-- SF integration-->
<!-- SF integration-->
<!-- SF integration-->

<section class="noprint">
<div class="noprint">
<br />
Expand Down
Binary file modified sf/sf.wasm
Binary file not shown.
65 changes: 41 additions & 24 deletions sf/test.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,53 @@
function getArgs() {
const args = [];
var e = document.getElementById("format");
var val = e.options[e.selectedIndex].value;
args.push(val);
e = document.getElementById("hash");
val = e.options[e.selectedIndex].value;
if (val != "none") {
args.push(val);
}
val = document.querySelector('input[name="z"]:checked').value;
if (val == "true") {
args.push("z")
}
console.log(args);
return args;
}

window.onload = () => {
document.getElementById('butOpen').addEventListener('click', () => {

window.showOpenFilePicker().then(handles => {
for (const idx in handles) {
handles[idx].getFile().then(file => {
file.arrayBuffer().then(buff => {
let data = new Uint8Array(buff);
let res = identify(file.name, data);
results = document.getElementById("sf-results");
results.innerHTML = res;
console.log("sf complete");
//console.log(res)
});
});
}
const args = getArgs();
args.unshift(handles[idx]);
identify.apply(null, args).then(result => {
document.getElementById('sf-results').value = result;
})
};
}
);
});

/*
const butDir = document.getElementById('butDirectory');
butDir.addEventListener('click', async () => {
const dirHandle = await window.showDirectoryPicker();
for await (const entry of dirHandle.values()) {
console.log(entry.kind, entry.name);
if (entry.kind == "directory") {
for await (const [key, value] of dirHandle.entries()) {
console.log({ key, value });
}
}
document.getElementById('butDirectory').addEventListener('click', () => {
window.showDirectoryPicker().then(handle => {
const args = getArgs();
args.unshift(handle);
document.getElementById('ready').style.visibility = "hidden";
document.getElementById('ready').style.height = "0px";
document.getElementById('loader').style.visibility = "visible";
document.getElementById('loader').style.height = "auto";
identify.apply(null, args).then(result => {
document.getElementById('sf-results').value = result;
document.getElementById('loader').style.visibility = "hidden";
document.getElementById('loader').style.height = "0px";
document.getElementById('ready').style.visibility = "visible";
document.getElementById('ready').style.height = "auto";
})
}
);
});
*/
}


Expand Down
44 changes: 0 additions & 44 deletions sf/wasm.go

This file was deleted.

0 comments on commit 2babff0

Please sign in to comment.