mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Get bash script to add imageAspectRatio working
This commit is contained in:
parent
95be6eaee6
commit
647e92fe7d
@ -25,4 +25,5 @@ ENV NODE_ENV=production
|
||||
COPY --from=build-and-test /nitro-backend/dist ./dist
|
||||
COPY ./public/img/ ./public/img/
|
||||
COPY ./public/providers.json ./public/providers.json
|
||||
COPY ./public/add_image_aspect_ratio.sh ./public/add_image_aspect_ratio.sh
|
||||
RUN yarn install --production=true --frozen-lockfile --non-interactive --no-cache
|
||||
|
||||
@ -1,33 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
shopt -s nullglob
|
||||
TEMP_FILE=/var/lib/neo4j/import/temp.json
|
||||
for image in public/uploads/*; do
|
||||
[ -e "$image" ] || continue
|
||||
export IMAGE_METADATA=$( identify -format '%w %h' "$image" )
|
||||
JSON_STRING=$( jq -n \
|
||||
--arg imageURL "$image" \
|
||||
--arg imageMetaData "$IMAGE_METADATA" \
|
||||
'{imageURL: $imageURL, imageMetaData: $imageMetaData}' )
|
||||
echo "$JSON_STRING," >> "$TEMP_FILE"
|
||||
done
|
||||
|
||||
ENV_FILE=$(dirname "$0")/.env
|
||||
[[ -f "$ENV_FILE" ]] && source "$ENV_FILE"
|
||||
|
||||
if [ -z "$NEO4J_USERNAME" ] || [ -z "$NEO4J_PASSWORD" ]; then
|
||||
echo "Please set NEO4J_USERNAME and NEO4J_PASSWORD environment variables."
|
||||
echo "Database manipulation is not possible without connecting to the database."
|
||||
echo "E.g. you could \`cp .env.template .env\` unless you run the script in a docker container"
|
||||
fi
|
||||
|
||||
until echo 'RETURN "Connection successful" as info;' | cypher-shell
|
||||
do
|
||||
echo "Connecting to neo4j failed, trying again..."
|
||||
sleep 1
|
||||
done
|
||||
echo "
|
||||
WITH "file:${TEMP_FILE}"
|
||||
AS url
|
||||
CALL apoc.load.json(url) YIELD value as post
|
||||
MATCH (p:Post {image: post.imageURL}) return p;
|
||||
" | cypher-shell
|
||||
30
backend/public/add_image_aspect_ratio.sh
Executable file
30
backend/public/add_image_aspect_ratio.sh
Executable file
@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if [ -z "$NEO4J_USERNAME" ] || [ -z "$NEO4J_PASSWORD" ]; then
|
||||
echo "Please set NEO4J_USERNAME and NEO4J_PASSWORD environment variables."
|
||||
echo "Database manipulation is not possible without connecting to the database."
|
||||
echo "E.g. you could \`cp .env.template .env\` unless you run the script in a docker container"
|
||||
fi
|
||||
|
||||
until echo 'RETURN "Connection successful" as info;' | cypher-shell
|
||||
do
|
||||
echo "Connecting to neo4j failed, trying again..."
|
||||
sleep 1
|
||||
done
|
||||
|
||||
shopt -s nullglob
|
||||
for image in uploads/*; do
|
||||
[ -e "$image" ] || continue
|
||||
IMAGE_WIDTH=$( identify -format '%w' "$image" )
|
||||
IMAGE_HEIGHT=$( identify -format '%h' "$image" )
|
||||
IMAGE_ASPECT_RATIO=$(echo | awk "{ print ${IMAGE_WIDTH}/${IMAGE_HEIGHT}}")
|
||||
|
||||
|
||||
echo "$image"
|
||||
echo "$IMAGE_ASPECT_RATIO"
|
||||
echo "
|
||||
match (post:Post {image: '/"${image}"'})
|
||||
set post.imageAspectRatio = "${IMAGE_ASPECT_RATIO}"
|
||||
return post;
|
||||
" | cypher-shell
|
||||
done
|
||||
@ -1,28 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
echo "images"
|
||||
shopt -s nullglob
|
||||
for image in *; do
|
||||
# [ -e "$image" ] || continue
|
||||
echo "$image"
|
||||
done
|
||||
|
||||
# ENV_FILE=$(dirname "$0")/.env
|
||||
# [[ -f "$ENV_FILE" ]] && source "$ENV_FILE"
|
||||
|
||||
# if [ -z "$NEO4J_USERNAME" ] || [ -z "$NEO4J_PASSWORD" ]; then
|
||||
# echo "Please set NEO4J_USERNAME and NEO4J_PASSWORD environment variables."
|
||||
# echo "Database manipulation is not possible without connecting to the database."
|
||||
# echo "E.g. you could \`cp .env.template .env\` unless you run the script in a docker container"
|
||||
# fi
|
||||
|
||||
# until echo 'RETURN "Connection successful" as info;' | cypher-shell
|
||||
# do
|
||||
# echo "Connecting to neo4j failed, trying again..."
|
||||
# sleep 1
|
||||
# done
|
||||
|
||||
# echo "
|
||||
# MATCH (post:Post) where post.teaserImageHeight is not null return post;
|
||||
# " | cypher-shell
|
||||
Loading…
x
Reference in New Issue
Block a user