Skip to content

Commit 06db1ef

Browse files
committed
restore deleted files from origin/develop (undo accidental deletions)
1 parent d5afc73 commit 06db1ef

27 files changed

Lines changed: 12628 additions & 0 deletions
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import os, yaml, subprocess, shutil
2+
from checksumdir import dirhash
3+
4+
5+
def _check_metadata_extension(source_dir):
6+
"""Check if the previewer metadata file has the correct extension"""
7+
8+
# List all the files in the previewers directory
9+
files = os.listdir(".")
10+
11+
if "previewer-meta.yaml" in files:
12+
return "previewer-meta.yaml"
13+
elif "previewer-meta.yml" in files:
14+
return "previewer-meta.yml"
15+
else:
16+
raise FileNotFoundError(
17+
f"No previewer metadata file found for source directory {source_dir}"
18+
)
19+
20+
21+
def build_react_app(source_dir, TARGET_DIR):
22+
"""Builds the react app and copies the files to the target directory
23+
24+
Args:
25+
source_dir (str): Source directory of the react app.
26+
TARGET_DIR (str): Target directory to copy the files to.
27+
REPO_DIR (str): Directory of the repository.
28+
"""
29+
30+
# Move to the source directory to read metadata and instructions
31+
os.chdir(source_dir)
32+
33+
# Check if a previewer metadata file exists
34+
metadata_file = _check_metadata_extension(source_dir)
35+
36+
# Read the previewers metadata
37+
metadata = yaml.safe_load(open(metadata_file))
38+
39+
# Create path map to deploy the necessary files
40+
extension_paths = {
41+
"js": os.path.join(TARGET_DIR, "js"),
42+
"css": os.path.join(TARGET_DIR, "css"),
43+
"html": TARGET_DIR,
44+
}
45+
46+
# Get the hash of the source directory
47+
source_hash = dirhash(metadata["checkdir"], "sha256")
48+
49+
if metadata.get("checksum") == source_hash:
50+
print(f"No changes detected for {metadata['name']}")
51+
return
52+
53+
print(f"Changes detected for {metadata['name']} - Building previewer")
54+
55+
for command in metadata["build"]:
56+
# Run the build commands
57+
subprocess.call(command, shell=True)
58+
59+
for file in metadata["files"]:
60+
# Copy the files to the target directory
61+
fname = os.path.basename(file)
62+
extension = fname.split(".")[-1]
63+
shutil.copy(file, os.path.join(extension_paths[extension], fname))
64+
65+
# Update checksum in metadata file
66+
metadata["checksum"] = source_hash
67+
yaml.safe_dump(metadata, open(metadata_file, "w"), sort_keys=False)
68+
69+
print("Successfully built previewer - Checksum updated")
70+
71+
72+
if __name__ == "__main__":
73+
# Build the react previewers
74+
BASE_DIR = "./previewers/react-source/"
75+
REPO_DIR = os.getcwd()
76+
TARGET_DIR = os.path.join(REPO_DIR, "previewers", "betatest")
77+
78+
# Get all the react previewers
79+
react_previewers = [
80+
os.path.join(BASE_DIR, path)
81+
for path in os.listdir(BASE_DIR)
82+
if not path.startswith(".") and path != "README.md"
83+
]
84+
85+
for source_dir in react_previewers:
86+
# Build the react app
87+
build_react_app(source_dir, TARGET_DIR)
88+
89+
# Return to the repository directory
90+
os.chdir(REPO_DIR)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Build React previewers
2+
3+
on: [push]
4+
5+
jobs:
6+
build_react_previewers:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout
10+
uses: actions/checkout@v2
11+
- name: Set up Python 3.10
12+
uses: actions/setup-python@v2
13+
with:
14+
python-version: "3.10"
15+
- name: Install dependencies
16+
run: python3 -m pip install pyyaml checksumdir
17+
- name: Set up npm
18+
uses: actions/setup-node@v3
19+
- name: Run script and build apps
20+
run: python3 ./.github/scripts/build_previewers.py
21+
- name: Push built previewers
22+
run: |
23+
if [[ `git status --porcelain` ]]; then
24+
git add --all
25+
git config --global user.name 'Previewer Builder'
26+
git config --global user.email 'builder@bot.com'
27+
git commit -am "Previewer update"
28+
git push
29+
else
30+
echo "Nothing changed!"
31+
fi
32+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1" />
6+
7+
<title>H5Web</title>
8+
9+
<meta name="description" content="Web-based HDF5 file viewer." />
10+
<script type="module" crossorigin src="./js/hdf5.js"></script>
11+
<link rel="stylesheet" href="./css/hdf5.css">
12+
</head>
13+
<body>
14+
<noscript>You need to enable JavaScript to run this app.</noscript>
15+
<div id="root"></div>
16+
17+
</body>
18+
</html>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<html>
2+
<head>
3+
<meta charset="utf-8">
4+
<title class="mapPreviewText">Map Preview</title>
5+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
6+
<script type="text/javascript" src="js/xss.js"></script>
7+
<script src="lib/jquery.i18n.js"></script>
8+
<script src="lib/jquery.i18n.messagestore.js"></script>
9+
<script src="lib/jquery.i18n.language.js"></script>
10+
<script type="text/javascript" src="js/retriever.js"></script>
11+
<!-- Latest compiled and minified CSS -->
12+
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"
13+
integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
14+
<!-- Optional theme -->
15+
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap-theme.min.css"
16+
integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous">
17+
<!-- Leaflet -->
18+
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css"
19+
integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A==" crossorigin="anonymous"/>
20+
<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"
21+
integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA==" crossorigin="anonymous"></script>
22+
<link type="text/css" rel="stylesheet" href="css/preview.css" />
23+
<!--drawing raster-->
24+
<script src="https://unpkg.com/georaster@1.6.0/dist/georaster.browser.bundle.min.js"
25+
integrity="sha512-SkPYBKB00LoLZf/I0yaoIwp88e7E+X5iFliB4n84vmzhjdEdEla/vouiA0Nr6aLHoRCB54DK8CCynKNd0DfCSg==" crossorigin="anonymous"></script>
26+
<script src="https://unpkg.com/georaster-layer-for-leaflet@3.10.0/dist/v3/webpack/bundle/georaster-layer-for-leaflet.min.js"
27+
integrity="sha512-bNJ+bvpXepatbIMeaida52kR2AT5lr6a9dTfb/OB0c/3O2KzUrdUi3Gtri0zvJUbfKgmG+wN3GKTkBi/6OkVVA==" crossorigin="anonymous"></script>
28+
<!-- spinner-->
29+
<script src="https://cdnjs.cloudflare.com/ajax/libs/spin.js/2.3.2/spin.js"
30+
integrity="sha512-C7tgVIfPE0ivBKcs2WstAh5y7Njir2odGBjnuIa64SmVzZIoTb8kRrNursRzEv4bNcesPywtVAXqH1GmqRBmpg==" crossorigin="anonymous"></script>
31+
</head>
32+
33+
<body class="container">
34+
<main>
35+
<img id='logo' alt='Site Logo'>
36+
<h1 class="page-title mapPreviewText">Map Preview</h1>
37+
<div class="alert alert-warning" id="file_error" hidden>
38+
<span class="glyphicon glyphicon-warning-sign"></span>&nbsp;<strong>Drawing Error</strong>
39+
</div>
40+
<div class='preview-container'>
41+
<div class='preview-header'></div>
42+
<div class='preview'>
43+
<div id="map" style="width: 800px; height: 500px;"></div>
44+
</div>
45+
</div>
46+
</main>
47+
<script type="text/javascript" src="js/mapraster.js"></script>
48+
</body>
49+
</html>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<html>
2+
<head>
3+
<meta charset="utf-8">
4+
<title class="mapPreviewText">Map Preview</title>
5+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
6+
<script type="text/javascript" src="js/xss.js"></script>
7+
<script src="lib/jquery.i18n.js"></script>
8+
<script src="lib/jquery.i18n.messagestore.js"></script>
9+
<script src="lib/jquery.i18n.language.js"></script>
10+
<script type="text/javascript" src="js/retriever.js"></script>
11+
<!-- Latest compiled and minified CSS -->
12+
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"
13+
integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
14+
<!-- Optional theme -->
15+
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap-theme.min.css"
16+
integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous">
17+
<!-- Leaflet -->
18+
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css"
19+
integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A==" crossorigin="anonymous"/>
20+
<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"
21+
integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA==" crossorigin="anonymous"></script>
22+
<link type="text/css" rel="stylesheet" href="css/preview.css" />
23+
<!-- ShapeJS-->
24+
<script src="https://cdn.rawgit.com/calvinmetcalf/shapefile-js/gh-pages/dist/shp.js"
25+
integrity="sha512-RT1pg7PTZ3R8amXsuOV3aJAVjBxenRKgmLg68ZMN6RMeRQWTrbxnPszM9+6/UVkmuRYaM0cg6R5lqwQJfJhVUw==" crossorigin="anonymous"></script>
26+
<script src="https://cdn.rawgit.com/calvinmetcalf/leaflet.shapefile/gh-pages/leaflet.shpfile.js"
27+
integrity="sha512-pZ4bO+wYEIa3xGxktY7N3CDNF4QfBlzmps/cqfOY2SZA7v1kH/y7rxQaqvk1W31NqjVTcyZkV0fPaOBGcCTOgg==" crossorigin="anonymous"></script>
28+
<!-- spinner-->
29+
<script src="https://cdnjs.cloudflare.com/ajax/libs/spin.js/2.3.2/spin.js"
30+
integrity="sha512-C7tgVIfPE0ivBKcs2WstAh5y7Njir2odGBjnuIa64SmVzZIoTb8kRrNursRzEv4bNcesPywtVAXqH1GmqRBmpg==" crossorigin="anonymous"></script>
31+
32+
</head>
33+
34+
<body class="container">
35+
<main>
36+
<img id='logo' alt='Site Logo'>
37+
<h1 class="page-title mapPreviewText">Map Preview</h1>
38+
<div class="alert alert-warning" id="file_error" hidden>
39+
<span class="glyphicon glyphicon-warning-sign"></span>&nbsp;<strong>Drawing Error</strong>
40+
</div>
41+
<div class='preview-container'>
42+
<div class='preview-header'></div>
43+
<div class='preview'>
44+
<div id="map" style="width: 800px; height: 500px;"></div>
45+
</div>
46+
</div>
47+
</main>
48+
<script type="text/javascript" src="js/mapshp.js"></script>
49+
</body>
50+
</html>

previewers/betatest/css/hdf5.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)