mirror of
https://github.com/qdrant/landing_page.git
synced 2026-09-25 14:08:30 +02:00
Feat/mila/blog social preview (#481)
* pictures script * wip preview image processing * universal image processign script * bash for generating preview images * add CI script * do not force the push --------- Co-authored-by: generall <andrey@vasnetsov.com>
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
name: update-blog-preview-images
|
||||
on:
|
||||
# Allows you to run this workflow manually from the Actions tab
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
sync:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Run a script
|
||||
run: |
|
||||
ADD_TO_GIT=true bash -x automation/gen-all-blogs-previews.sh
|
||||
if [[ `git status --porcelain` ]]; then
|
||||
# Changes
|
||||
echo "Changes detected"
|
||||
else
|
||||
# No changes
|
||||
echo "No changes detected"
|
||||
exit 0
|
||||
fi
|
||||
git config --global user.name 'qdrant'
|
||||
git config --global user.email 'qdrant@users.noreply.github.com'
|
||||
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
|
||||
git checkout $GITHUB_HEAD_REF
|
||||
git commit -am "update blog preview images" && git push || true
|
||||
@@ -0,0 +1,69 @@
|
||||
#!/bin/bash
|
||||
|
||||
# directory of the current script
|
||||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
|
||||
|
||||
PATH_TO_BLOGS="$DIR/../qdrant-landing/content/blog"
|
||||
|
||||
STATIC_FOLDER=$(realpath "$DIR/../qdrant-landing/static")
|
||||
|
||||
|
||||
function get_value_from_md() {
|
||||
local key=$1
|
||||
local file=$2
|
||||
local value=$(grep -m 1 "^$key:" "$file" | sed "s/^$key: //")
|
||||
echo "$value"
|
||||
}
|
||||
|
||||
|
||||
function process_blog() {
|
||||
echo "-----"
|
||||
|
||||
echo "Processing $1 file..."
|
||||
|
||||
# Check if draft
|
||||
DRAFT=$(get_value_from_md "draft" "$1")
|
||||
|
||||
if [ "$DRAFT" == "true" ]; then
|
||||
echo "Draft. Skipping"
|
||||
return
|
||||
fi
|
||||
|
||||
SLUG=$(get_value_from_md "slug" "$1")
|
||||
|
||||
if [ -z "$SLUG" ]; then
|
||||
SLUG=$(basename "$1" | sed 's/\.md$//')
|
||||
fi
|
||||
|
||||
echo "Slug: $SLUG"
|
||||
|
||||
IMAGE_KEY="preview_image" # ToDo: change to generic image key
|
||||
|
||||
SOURCE_IMAGE_PATH=$(get_value_from_md "${IMAGE_KEY}" "$1")
|
||||
|
||||
if [ -z "$SOURCE_IMAGE_PATH" ]; then
|
||||
echo "No preview image for $1"
|
||||
return
|
||||
fi
|
||||
|
||||
FULL_IMAGE_PATH="${STATIC_FOLDER}/${SOURCE_IMAGE_PATH}"
|
||||
|
||||
echo "Source image path: $FULL_IMAGE_PATH"
|
||||
|
||||
PATH_TO_IMAGE="${FULL_IMAGE_PATH}" \
|
||||
bash ${DIR}/process-blog-img.sh "$FULL_IMAGE_PATH" "$SLUG"
|
||||
}
|
||||
|
||||
|
||||
|
||||
for f in $PATH_TO_BLOGS/*.md; do
|
||||
# Absolute path to the file
|
||||
|
||||
abs_path=$(realpath "$f")
|
||||
|
||||
|
||||
process_blog "$abs_path"
|
||||
done
|
||||
|
||||
@@ -17,13 +17,14 @@ if [ ! -f "$1" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
IMG_DESTINATION="./qdrant-landing/static/articles_data/${2}/preview"
|
||||
mkdir -p $IMG_DESTINATION
|
||||
# Get the directory of the script
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
|
||||
convert "$1" -resize 1200x630^ -gravity center -extent 1200x630 "${IMG_DESTINATION}/social_preview.jpg";
|
||||
|
||||
convert "$1" -resize 898x300^ -gravity center -extent 898x300 "${IMG_DESTINATION}/title.jpg";
|
||||
convert "${IMG_DESTINATION}/title.jpg" -resize 530x145^ -gravity center -extent 530x145 "${IMG_DESTINATION}/preview.jpg";
|
||||
|
||||
cwebp -q 95 "${IMG_DESTINATION}/title.jpg" -o "${IMG_DESTINATION}/title.webp";
|
||||
cwebp -q 95 "${IMG_DESTINATION}/preview.jpg" -o "${IMG_DESTINATION}/preview.webp";
|
||||
PATH_TO_IMAGE=$1 \
|
||||
STATIC_DIRECTORY_NAME="./qdrant-landing/static/articles_data/${2}" \
|
||||
SOCIAL_PREVIEW_RESOLUTION="1200x630" \
|
||||
TITLE_RESOLUTION="898x300" \
|
||||
PREVIEW_RESOLUTION="530x145" \
|
||||
bash -x ${DIR}/process-img.sh
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "Please provide a path to the image"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$2" ]; then
|
||||
echo "Please provide an blog slug"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f "$1" ]; then
|
||||
echo "File $1 does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get the directory of the script
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
|
||||
|
||||
|
||||
PATH_TO_IMAGE=$1 \
|
||||
STATIC_DIRECTORY_NAME="./qdrant-landing/static/blog_data/${2}" \
|
||||
SOCIAL_PREVIEW_RESOLUTION="1200x630" \
|
||||
TITLE_RESOLUTION="916x515" \
|
||||
PREVIEW_RESOLUTION="350x201" \
|
||||
bash -x ${DIR}/process-img.sh
|
||||
@@ -0,0 +1,79 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This script is used to process images for content suitable for social networks
|
||||
|
||||
set -e
|
||||
|
||||
|
||||
# Example usage
|
||||
#
|
||||
#
|
||||
# PATH_TO_IMAGE="./qdrant-landing/static/blog_data/qdrant-v-1-7/preview.png"
|
||||
# STATIC_DIRECTORY_NAME="./qdrant-landing/static/blog_data/qdrant-v-1-7"
|
||||
|
||||
|
||||
PATH_TO_IMAGE=${PATH_TO_IMAGE:-""}
|
||||
STATIC_DIRECTORY_NAME=${STATIC_DIRECTORY_NAME:-""}
|
||||
|
||||
|
||||
SOCIAL_PREVIEW_RESOLUTION=${SOCIAL_PREVIEW_RESOLUTION:-"1200x630"}
|
||||
TITLE_RESOLUTION=${TITLE_RESOLUTION:-"898x300"}
|
||||
PREVIEW_RESOLUTION=${PREVIEW_RESOLUTION:-"530x145"}
|
||||
|
||||
ALLOW_OVERWRITE=${ALLOW_OVERWRITE:-"false"}
|
||||
|
||||
|
||||
if [ -z "$PATH_TO_IMAGE" ]; then
|
||||
echo "Please provide a path to the image"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$STATIC_DIRECTORY_NAME" ]; then
|
||||
echo "Please provide an directory name to store images"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check that PATH_TO_IMAGE exists and have a valid extension (png, jpg, jpeg)
|
||||
if [ ! -f "$PATH_TO_IMAGE" ]; then
|
||||
echo "File $PATH_TO_IMAGE does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! "$PATH_TO_IMAGE" =~ \.(png|jpg|jpeg)$ ]]; then
|
||||
echo "File $PATH_TO_IMAGE has invalid extension. Only png, jpg, jpeg are allowed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
IMG_DESTINATION="${STATIC_DIRECTORY_NAME}/preview"
|
||||
mkdir -p $IMG_DESTINATION
|
||||
|
||||
function check_file_exists() {
|
||||
local file=$1
|
||||
if [ -f "${file}" ] && [ "$ALLOW_OVERWRITE" != "true" ]; then
|
||||
echo "$file exists. Please remove it or set ALLOW_OVERWRITE=true"
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
|
||||
check_file_exists "${IMG_DESTINATION}/social_preview.jpg"
|
||||
check_file_exists "${IMG_DESTINATION}/title.jpg"
|
||||
check_file_exists "${IMG_DESTINATION}/preview.jpg"
|
||||
check_file_exists "${IMG_DESTINATION}/title.webp"
|
||||
check_file_exists "${IMG_DESTINATION}/preview.webp"
|
||||
|
||||
|
||||
convert "${PATH_TO_IMAGE}" -resize "${SOCIAL_PREVIEW_RESOLUTION}^" -gravity center -extent $SOCIAL_PREVIEW_RESOLUTION "${IMG_DESTINATION}/social_preview.jpg";
|
||||
convert "${PATH_TO_IMAGE}" -resize "${TITLE_RESOLUTION}^" -gravity center -extent "${TITLE_RESOLUTION}" "${IMG_DESTINATION}/title.jpg";
|
||||
convert "${IMG_DESTINATION}/title.jpg" -resize "${PREVIEW_RESOLUTION}^" -gravity center -extent "${PREVIEW_RESOLUTION}" "${IMG_DESTINATION}/preview.jpg";
|
||||
|
||||
cwebp -q 95 "${IMG_DESTINATION}/title.jpg" -o "${IMG_DESTINATION}/title.webp";
|
||||
cwebp -q 95 "${IMG_DESTINATION}/preview.jpg" -o "${IMG_DESTINATION}/preview.webp";
|
||||
|
||||
ADD_TO_GIT=${ADD_TO_GIT:-"false"}
|
||||
|
||||
if [ "$ADD_TO_GIT" == "true" ]; then
|
||||
git add "${IMG_DESTINATION}"
|
||||
fi
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
draft: false
|
||||
draft: true
|
||||
title: New 0.7.0 update of the Qdrant engine went live
|
||||
slug: qdrant-0-7-0-released
|
||||
short_description: Qdrant v0.7.0 engine has been released
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
---
|
||||
draft: true
|
||||
title: Qdrant v0.6.0 engine with gRPC interface has been released
|
||||
short_description: We’ve released a new engine, version 0.6.0.
|
||||
description: We’ve released a new engine, version 0.6.0. The main feature of the release in the gRPC interface.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
draft: false
|
||||
draft: true
|
||||
title: v0.8.0 update of the Qdrant engine was released
|
||||
slug: qdrant-0-8-0-released
|
||||
short_description: "The new version of our engine - v0.8.0, went live. "
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
draft: false
|
||||
draft: true
|
||||
title: v0.9.0 update of the Qdrant engine went live
|
||||
slug: qdrant-v090-release
|
||||
short_description: We've released the new version of Qdrant engine - v.0.9.0.
|
||||
|
||||
Reference in New Issue
Block a user