mastodon-post wip
This commit is contained in:
parent
dee9d7c9fe
commit
28dbc2dd7d
13 changed files with 224 additions and 27 deletions
|
|
@ -16,6 +16,8 @@ $ mkdir mnt config
|
|||
$ docker run -t xrforge docker.io/coderofsalvation/xrforge:latest -v ./mnt:/mnt -v ./config:/config
|
||||
```
|
||||
|
||||
> To scan all (mounted) libraries run this once: `$ docker exec xrforge /manyfold/cli/manyfold.sh scan_libraries`
|
||||
|
||||
# Build & Run the container-image
|
||||
|
||||
> **NOTE**: [nix](https://nixos.org) is used to promote reproducability-over-repeatability
|
||||
|
|
|
|||
|
|
@ -210,8 +210,7 @@ start_syslog(){
|
|||
scan_libraries(){
|
||||
cd /usr/src/app
|
||||
echocolor "scanning libraries"
|
||||
test -f ${db}.startupscan || bin/manyfold libraries scan
|
||||
touch ${db}.startupscan # only do once
|
||||
bin/manyfold libraries scan
|
||||
}
|
||||
|
||||
scan_experience(){
|
||||
|
|
@ -248,6 +247,7 @@ get_xrfragment_assets(){
|
|||
}
|
||||
|
||||
init_database(){
|
||||
test -f ${db}.xrforgeinit && exit 0 # already inited
|
||||
sleep 3
|
||||
test -z "$THEME" || set_global theme "'$THEME'"
|
||||
set_admin
|
||||
|
|
@ -256,12 +256,11 @@ init_database(){
|
|||
set_global model_tags_auto_tag_new "replace('--- \"\"\\n','\\n',char(10))"
|
||||
set_global model_path_template "replace('--- \"{creator}/{modelId} \"\\n','\\n',char(10))"
|
||||
#set_global about "$ABOUT"
|
||||
mount_rclone
|
||||
set_upload_path &
|
||||
force_public &
|
||||
get_xrfragment_assets
|
||||
mount_dir
|
||||
scan_libraries &
|
||||
touch ${db}.xrforgeinit
|
||||
}
|
||||
|
||||
# The new entrypoint of the docker
|
||||
|
|
@ -272,6 +271,8 @@ boot(){
|
|||
rename_app
|
||||
set_homepage
|
||||
start_hook_daemon
|
||||
mount_rclone
|
||||
force_public &
|
||||
|
||||
# enable development mode (disables template caching etc)
|
||||
test -n "$DEV" && {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,6 @@ cd "$dir"
|
|||
echo "[v] scan (new) files of model"
|
||||
id="$(basename "$dir" | sed 's/\#//g')"
|
||||
# TODO: better ratelimiting
|
||||
test -f /tmp/.scan && test $id = "$(cat /tmp/.scan)" && exit
|
||||
#test -f /tmp/.scan && test $id = "$(cat /tmp/.scan)" && exit
|
||||
/manyfold/cli/manyfold.sh scan_experience $id
|
||||
echo $id > /tmp/.scan
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ begin
|
|||
XRForge.log("✅ generating gltf", logfile)
|
||||
gltf_path = ".xrforge/scene.gltf"
|
||||
system("assimp export #{filename} #{gltf_path}")
|
||||
system("assimp extract #{filename} | sed 's|/.*/||g'")
|
||||
|
||||
# tag it!
|
||||
if ! data['keywords'].include?('gltf')
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ cd "$dir"
|
|||
echo "[package_godot_zip.sh] zipping godot.zip"
|
||||
|
||||
# overwrite empty godot template project-zip with given URL
|
||||
test -n "$GODOT_TEMPLATE_ZIP" && timeout 50 wget "$GODOT_TEMPLATE_ZIP" -O ~/template_godot.zip
|
||||
test -n "$GODOT_TEMPLATE_ZIP" && timeout 50 wget "$GODOT_TEMPLATE_ZIP" -O ~/templates/template_godot.zip
|
||||
|
||||
cp ~/template_godot.zip .xrforge/godot.zip
|
||||
cp ~/templates/template_godot.zip .xrforge/godot.zip
|
||||
zip .xrforge/godot.zip *.glb *.usdz *.obj
|
||||
|
|
|
|||
|
|
@ -21,7 +21,8 @@ end
|
|||
|
||||
begin
|
||||
# Change the directory
|
||||
Dir.chdir( File.dirname(filename) )
|
||||
dir = File.dirname(filename)
|
||||
Dir.chdir( dir )
|
||||
# Read and parse the JSON file
|
||||
data = JSON.parse( File.read( "datapackage.json" ) )
|
||||
|
||||
|
|
@ -67,16 +68,25 @@ begin
|
|||
if img and img[1] and img[1].match(/(png|jpg)/)
|
||||
imgurl = img[1]
|
||||
end
|
||||
|
||||
cmd = "cp -r /root/assets/template/mastodon-post .xrforge/. && rm .xrforge/mastodon-post/mastodon-post.png && "
|
||||
|
||||
text = "\n\"#{description}\"\n\n~ #{feed.channel.title}\n#{feed.channel.link}"
|
||||
textFile = ".xrforge/mastodon-post.txt"
|
||||
text = "\n\"#{description}\""
|
||||
textFile = ".xrforge/mastodon-post/mastodon-post.txt"
|
||||
File.open(textFile,'w') do |file|
|
||||
file.puts text
|
||||
end
|
||||
|
||||
cmd = "magick -size 800x800 -background white -pointsize 48 -interline-spacing 10 -fill \\#555 -gravity center -font /usr/local/lib/ruby/3.4.0/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf caption:@#{textFile} mastodon-post.png"
|
||||
puts cmd
|
||||
system(cmd)
|
||||
cmd = cmd + "magick -size 800x800 -background white -pointsize 48 -interline-spacing 10 -fill \\#555 -gravity center -font /usr/local/lib/ruby/3.4.0/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf caption:@#{textFile}"
|
||||
cmd = cmd + " -pointsize 18 -fill \\#FFFFFF -gravity NorthWest -annotate +152+100 #{APHandle} "
|
||||
cmd = cmd + " -fill \\#9c9cc9 -gravity NorthWest -annotate +152+130 #{feed.channel.title} "
|
||||
cmd = cmd + " -fill \\#9c9cc9 -gravity NorthWest -annotate +40+470 #{feed.channel.link} "
|
||||
cmd = cmd + " PNG8:.xrforge/mastodon-post/mastodon-post.png &&"
|
||||
cmd = cmd + "cd .xrforge/mastodon-post && assimp export mastodon-post.gltf mastodon-post.glb && mv mastodon-post.glb ../../."
|
||||
ret = system(cmd)
|
||||
if ret != 0
|
||||
XRForge.log("❌ something went wrong :(", logfile)
|
||||
end
|
||||
|
||||
XRForge.log(" ", logfile)
|
||||
|
||||
BIN
manyfold/root/templates/mastodon-post/mastodon-post-bg.png
Normal file
BIN
manyfold/root/templates/mastodon-post/mastodon-post-bg.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 51 KiB |
BIN
manyfold/root/templates/mastodon-post/mastodon-post.bin
Normal file
BIN
manyfold/root/templates/mastodon-post/mastodon-post.bin
Normal file
Binary file not shown.
154
manyfold/root/templates/mastodon-post/mastodon-post.gltf
Normal file
154
manyfold/root/templates/mastodon-post/mastodon-post.gltf
Normal file
|
|
@ -0,0 +1,154 @@
|
|||
{
|
||||
"asset":{
|
||||
"generator":"Khronos glTF Blender I/O v4.4.56",
|
||||
"version":"2.0"
|
||||
},
|
||||
"extensionsUsed":[
|
||||
"KHR_materials_unlit"
|
||||
],
|
||||
"scene":0,
|
||||
"scenes":[
|
||||
{
|
||||
"name":"Scene",
|
||||
"nodes":[
|
||||
0
|
||||
]
|
||||
}
|
||||
],
|
||||
"nodes":[
|
||||
{
|
||||
"mesh":0,
|
||||
"name":"mastodon-post",
|
||||
"rotation":[
|
||||
0.70710688829422,
|
||||
0,
|
||||
0,
|
||||
0.7071066498756409
|
||||
],
|
||||
"scale":[
|
||||
2.471118211746216,
|
||||
2.471118450164795,
|
||||
2.471118450164795
|
||||
]
|
||||
}
|
||||
],
|
||||
"materials":[
|
||||
{
|
||||
"doubleSided":true,
|
||||
"extensions":{
|
||||
"KHR_materials_unlit":{}
|
||||
},
|
||||
"name":"unlit.001",
|
||||
"pbrMetallicRoughness":{
|
||||
"baseColorTexture":{
|
||||
"index":0
|
||||
},
|
||||
"metallicFactor":0,
|
||||
"roughnessFactor":0.9
|
||||
}
|
||||
}
|
||||
],
|
||||
"meshes":[
|
||||
{
|
||||
"name":"Plane",
|
||||
"primitives":[
|
||||
{
|
||||
"attributes":{
|
||||
"POSITION":0,
|
||||
"NORMAL":1,
|
||||
"TEXCOORD_0":2
|
||||
},
|
||||
"indices":3,
|
||||
"material":0
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"textures":[
|
||||
{
|
||||
"sampler":0,
|
||||
"source":0
|
||||
}
|
||||
],
|
||||
"images":[
|
||||
{
|
||||
"mimeType":"image/png",
|
||||
"name":"mastodon-post",
|
||||
"uri":"mastodon-post.png"
|
||||
}
|
||||
],
|
||||
"accessors":[
|
||||
{
|
||||
"bufferView":0,
|
||||
"componentType":5126,
|
||||
"count":20,
|
||||
"max":[
|
||||
1,
|
||||
0,
|
||||
1
|
||||
],
|
||||
"min":[
|
||||
-1,
|
||||
0,
|
||||
-1
|
||||
],
|
||||
"type":"VEC3"
|
||||
},
|
||||
{
|
||||
"bufferView":1,
|
||||
"componentType":5126,
|
||||
"count":20,
|
||||
"type":"VEC3"
|
||||
},
|
||||
{
|
||||
"bufferView":2,
|
||||
"componentType":5126,
|
||||
"count":20,
|
||||
"type":"VEC2"
|
||||
},
|
||||
{
|
||||
"bufferView":3,
|
||||
"componentType":5123,
|
||||
"count":54,
|
||||
"type":"SCALAR"
|
||||
}
|
||||
],
|
||||
"bufferViews":[
|
||||
{
|
||||
"buffer":0,
|
||||
"byteLength":240,
|
||||
"byteOffset":0,
|
||||
"target":34962
|
||||
},
|
||||
{
|
||||
"buffer":0,
|
||||
"byteLength":240,
|
||||
"byteOffset":240,
|
||||
"target":34962
|
||||
},
|
||||
{
|
||||
"buffer":0,
|
||||
"byteLength":160,
|
||||
"byteOffset":480,
|
||||
"target":34962
|
||||
},
|
||||
{
|
||||
"buffer":0,
|
||||
"byteLength":108,
|
||||
"byteOffset":640,
|
||||
"target":34963
|
||||
}
|
||||
],
|
||||
"samplers":[
|
||||
{
|
||||
"magFilter":9729,
|
||||
"minFilter":9987
|
||||
}
|
||||
],
|
||||
"buffers":[
|
||||
{
|
||||
"byteLength":748,
|
||||
"uri":"mastodon-post.bin"
|
||||
}
|
||||
]
|
||||
}
|
||||
BIN
manyfold/root/templates/mastodon-post/mastodon-post.png
Normal file
BIN
manyfold/root/templates/mastodon-post/mastodon-post.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 176 B |
30
manyfold/root/templates/mastodon-post/mastodon-post.sh
Executable file
30
manyfold/root/templates/mastodon-post/mastodon-post.sh
Executable file
|
|
@ -0,0 +1,30 @@
|
|||
#!/bin/sh
|
||||
test -n "$6" || { echo "usage: ./mastodon-post.sh <text> <title> <link> <handle> <ttf-file> </abs/path/to/out.glb>"; exit 0; }
|
||||
|
||||
out="$6"
|
||||
tmpdir=/tmp/.mastodon-post
|
||||
mydir="$(dirname $(readlink -f $0))"
|
||||
cd $mydir
|
||||
|
||||
# create tmp workspace
|
||||
test -d $tmpdir && rm -rf $tmpdir
|
||||
mkdir $tmpdir
|
||||
cp * $tmpdir/.
|
||||
rm $tmpdir/mastodon-post.png # IMPORTANT: prevent newer/older imagemagick -clobber (non)existence
|
||||
|
||||
set -x
|
||||
magick $tmpdir/mastodon-post-bg.png \
|
||||
\( -background none -pointsize 48 -interline-spacing 10 -fill \#FFF -font "$5" "caption:$1" \) \
|
||||
-gravity center -composite \
|
||||
-pointsize 18 \
|
||||
-fill \#FFFFFF -gravity NorthWest -annotate +152+100 "$4" \
|
||||
-fill \#9c9cc9 -gravity NorthWest -annotate +152+130 "$2" \
|
||||
-fill \#9c9cc9 -gravity NorthWest -annotate +40+470 "$3" \
|
||||
PNG8:$tmpdir/mastodon-post.png
|
||||
|
||||
# -define png:compression-level=9 \
|
||||
# -define png:compression-filter=5 \
|
||||
# -define png:compression-strategy=1 \
|
||||
|
||||
cd $tmpdir
|
||||
assimp export mastodon-post.gltf $out
|
||||
|
|
@ -38,18 +38,18 @@ let
|
|||
finalImageTag = "latest";
|
||||
};
|
||||
|
||||
# generate the reproducable blob below via:
|
||||
# $ nix-shell -p nix-prefetch-github --command 'nix-prefetch-github assimp assimp --rev e778c84cd62bc8b38d8e491ad3d2c27cb8ed37d5'
|
||||
assimpSrc = pkgs.fetchFromGitHub {
|
||||
"owner" = "assimp";
|
||||
"repo" = "assimp";
|
||||
"rev" = "e778c84cd62bc8b38d8e491ad3d2c27cb8ed37d5";
|
||||
"hash" = "sha256-ja5pFwpnzLT2MDIR8ISwC6+eA5UXyqRZW2CMCCrF1Q0=";
|
||||
};
|
||||
myAssimp = pkgs.pkgsStatic.assimp.overrideAttrs (oldAttrs: {
|
||||
inherit assimpSrc; # Set the source to the fetched commit
|
||||
src = assimpSrc;
|
||||
});
|
||||
# # generate the reproducable blob below via:
|
||||
# # $ nix-shell -p nix-prefetch-github --command 'nix-prefetch-github assimp assimp --rev e778c84cd62bc8b38d8e491ad3d2c27cb8ed37d5'
|
||||
# assimpSrc = pkgs.fetchFromGitHub {
|
||||
# "owner" = "assimp";
|
||||
# "repo" = "assimp";
|
||||
# "rev" = "e778c84cd62bc8b38d8e491ad3d2c27cb8ed37d5";
|
||||
# "hash" = "sha256-ja5pFwpnzLT2MDIR8ISwC6+eA5UXyqRZW2CMCCrF1Q0=";
|
||||
# };
|
||||
# myAssimp = pkgs.pkgsStatic.assimp.overrideAttrs (oldAttrs: {
|
||||
# inherit assimpSrc; # Set the source to the fetched commit
|
||||
# src = assimpSrc;
|
||||
# });
|
||||
|
||||
|
||||
in
|
||||
|
|
@ -76,7 +76,8 @@ rec
|
|||
pkgs.pkgsStatic.inotify-tools # inotifywait e.g.
|
||||
pkgs.pkgsStatic.zip # inotifywait e.g.
|
||||
pkgs.pkgsStatic.ts # job management
|
||||
myAssimp # cli 3D editing/conversion
|
||||
pkgs.pkgsStatic.assimp # job management
|
||||
# myAssimp # cli 3D editing/conversion
|
||||
./..
|
||||
];
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue