update hooks
This commit is contained in:
parent
34f6e052da
commit
5e0bfbf799
3 changed files with 52 additions and 30 deletions
19
manyfold/root/hook.d/inotify_MODIFY/create_yaml.sh
Normal file
19
manyfold/root/hook.d/inotify_MODIFY/create_yaml.sh
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
#!/bin/sh
|
||||||
|
echo "$1" | grep datapackage || exit 0 # nothing to do
|
||||||
|
dir=$(dirname $1)
|
||||||
|
cd "$dir"
|
||||||
|
|
||||||
|
test -f xrforge.yml || exit 0 # nothing to do
|
||||||
|
|
||||||
|
echo '--- # xrforge yaml v0.1
|
||||||
|
scene:
|
||||||
|
version: 1.0
|
||||||
|
xrf:
|
||||||
|
links: yes # add links from datapackage.json#/links [rezstyle fontmap / ruler]
|
||||||
|
sidecar_json: yes # add links from <experience>.json sidecar-file (https://xrfragment.org)
|
||||||
|
|
||||||
|
texture:
|
||||||
|
export: yes # extract textures from uploaded 3D file
|
||||||
|
import: yes # import uploaded texture to 3D file (when name matches)
|
||||||
|
|
||||||
|
' > xrforge.yaml
|
||||||
|
|
@ -1,34 +1,14 @@
|
||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
require 'json'
|
require 'json'
|
||||||
|
require_relative './../../xrforge.rb'
|
||||||
extensions = ['.glb', '.gltf', '.blend', '.usdz', '.obj', '.dae']
|
|
||||||
|
|
||||||
# Check if a filename is provided
|
# Check if a filename is provided
|
||||||
if ARGV.length != 1
|
if ARGV.length != 1
|
||||||
puts "Usage: #{$0} <filename>"
|
puts "Usage: #{$0} <path/to/datapackage.json>"
|
||||||
exit 1
|
exit 1
|
||||||
end
|
end
|
||||||
|
|
||||||
def log_message(message, filename, reset = false)
|
|
||||||
|
|
||||||
# Empty the log file if reset is true
|
|
||||||
if reset
|
|
||||||
File.open(filename, 'w') do |file|
|
|
||||||
timestamp = Time.now.strftime('%Y-%m-%d %H:%M')
|
|
||||||
file.write("#{timestamp}\n\n")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Create the full log entry
|
|
||||||
|
|
||||||
# Append the log entry to the log file
|
|
||||||
File.open(filename, 'a') do |file|
|
|
||||||
file.write("#{message}\n")
|
|
||||||
end
|
|
||||||
puts("#{message}\n")
|
|
||||||
end
|
|
||||||
|
|
||||||
filename = ARGV[0]
|
filename = ARGV[0]
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
|
@ -37,11 +17,11 @@ begin
|
||||||
|
|
||||||
logfile = File.join( File.dirname(filename), "xrfragment.txt" )
|
logfile = File.join( File.dirname(filename), "xrfragment.txt" )
|
||||||
|
|
||||||
log_message("✔ starting XR fragments check", logfile, true)
|
log("✅ starting XR fragments check", logfile, true)
|
||||||
|
|
||||||
# Extract the desired field (assuming the field is named 'model_file')
|
# Extract the desired field (assuming the field is named 'model_file')
|
||||||
thumb_file = data['image']
|
thumb_file = data['image']
|
||||||
log_message("✔ thumbnail sidecar-file '#{thumb_file}' detected", logfile)
|
log("✅ thumbnail sidecar-file '#{thumb_file}' detected", logfile)
|
||||||
|
|
||||||
# Get the base name of the thumbnail file without its extension
|
# Get the base name of the thumbnail file without its extension
|
||||||
base_name = File.basename(thumb_file, File.extname(thumb_file))
|
base_name = File.basename(thumb_file, File.extname(thumb_file))
|
||||||
|
|
@ -49,26 +29,26 @@ begin
|
||||||
model_file = nil # Initialize model_file to nil
|
model_file = nil # Initialize model_file to nil
|
||||||
|
|
||||||
# Loop over the list of extensions
|
# Loop over the list of extensions
|
||||||
extensions.each do |ext|
|
Xrforge.model_extensions.each do |ext|
|
||||||
# Construct the filename with the current extension
|
# Construct the filename with the current extension
|
||||||
filename = "#{base_name}#{ext}"
|
filename = "#{base_name}#{ext}"
|
||||||
|
|
||||||
# Check if the file exists
|
# Check if the file exists
|
||||||
if File.exist?(filename)
|
if File.exist?(filename)
|
||||||
log_message("✔ 3D file '#{filename}' detected", logfile)
|
log("✅ 3D file '#{filename}' detected", logfile)
|
||||||
model_file = filename # Store the found filename
|
model_file = filename # Store the found filename
|
||||||
break # Stop the loop once a file is found
|
break # Stop the loop once a file is found
|
||||||
else
|
else
|
||||||
# Log a message for the file that was not found, but don't stop
|
# Log a message for the file that was not found, but don't stop
|
||||||
log_message("⚠️ 3D file '#{filename}' not detected", logfile)
|
log("⚠️ 3D file '#{filename}' not detected", logfile)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Check if a model file was found after the loop
|
# Check if a model file was found after the loop
|
||||||
if model_file
|
if model_file
|
||||||
log_message("✅ Final model file: '#{model_file}'", logfile)
|
log("✅ Final model file: '#{model_file}'", logfile)
|
||||||
else
|
else
|
||||||
log_message("❌ No suitable 3D file found for XR Fragments-compatible experience", logfile)
|
log("❌ No suitable 3D file found for XR Fragments-compatible experience", logfile)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Construct the output filename
|
# Construct the output filename
|
||||||
|
|
@ -87,4 +67,4 @@ rescue => e
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
log_message("", logfile)
|
log("", logfile)
|
||||||
|
|
|
||||||
23
manyfold/root/xrforge.rb
Normal file
23
manyfold/root/xrforge.rb
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
Module xrforge
|
||||||
|
|
||||||
|
model_extensions = ['.glb', '.gltf', '.blend', '.usdz', '.obj', '.dae']
|
||||||
|
|
||||||
|
def log(message, filename, reset = false)
|
||||||
|
|
||||||
|
# Empty the log file if reset is true
|
||||||
|
if reset
|
||||||
|
File.open(filename, 'w') do |file|
|
||||||
|
timestamp = Time.now.strftime('%Y-%m-%d %H:%M')
|
||||||
|
file.write("#{timestamp}\n\n")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Create the full log entry
|
||||||
|
|
||||||
|
# Append the log entry to the log file
|
||||||
|
File.open(filename, 'a') do |file|
|
||||||
|
file.write("#{message}\n")
|
||||||
|
end
|
||||||
|
puts("#{message}\n")
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Add table
Reference in a new issue