diff options
| author | Maria Lisina <sekoohaka.sarisan@gmail.com> | 2025-08-31 13:06:21 +0500 |
|---|---|---|
| committer | Maria Lisina <sekoohaka.sarisan@gmail.com> | 2025-08-31 13:06:21 +0500 |
| commit | 1d537b9c0b71b15ab58482968192351b43fe49d0 (patch) | |
| tree | fabf553dbc0719c85c5233c284a0afc53d7d748b | |
| parent | a08c3d4e1a43df88232ca0408cf9f26c16a2d696 (diff) | |
submodules/command_hash: Add preview
Signed-off-by: Maria Lisina <sekoohaka.sarisan@gmail.com>
| -rw-r--r-- | submodules/command_hash.zsh | 12 | ||||
| -rw-r--r-- | units/ib_hash.zsh | 13 |
2 files changed, 24 insertions, 1 deletions
diff --git a/submodules/command_hash.zsh b/submodules/command_hash.zsh index 8b51b85..292b0c0 100644 --- a/submodules/command_hash.zsh +++ b/submodules/command_hash.zsh @@ -17,7 +17,8 @@ then return 0 fi -ib_post_id="${cache}/${update_id}_${ib_post_md5}.txt" +ib_post_id="${cache}/${update_id}_${ib_post_md5}_id.txt" +ib_sample="${cache}/${update_id}_${ib_post_md5}_sample.txt" for ib_board in {a..z} do @@ -57,6 +58,15 @@ do keyboard_offset=$((keyboard_offset + 0.5)) done +if [[ -f "${ib_sample}" ]] +then + link_preview_options="$( + jq --null-input --compact-output \ + --arg url "$(< "${ib_sample}")" \ + '{"url": $url, "prefer_small_media": true, "show_above_text": true}' + )" +fi + if [[ -n "${ids_text}" ]] then output_text="${ids_text}" diff --git a/units/ib_hash.zsh b/units/ib_hash.zsh index 5b47326..7760e2d 100644 --- a/units/ib_hash.zsh +++ b/units/ib_hash.zsh @@ -20,5 +20,18 @@ ib_hash="$(sha1sum <<< "${user_id}${ib_board}${ib_query}" | cut -d ' ' -f 1)" if [[ -z "${output_text}" ]] then ib_id="$(jq -r ".${ib_iarray}[0].${ib_iid}" "${ib_file}")" + + if ! [[ -f "${ib_sample}" ]] + then + ib_file_size="$(jq -r ".${ib_iarray}[0].${ib_isize}" "${ib_file}")" + ib_file_url="$(jq -r ".${ib_iarray}[0].${ib_ifile}" "${ib_file}")" + ib_sample_url="$(jq -r ".${ib_iarray}[0].${ib_isample}" "${ib_file}")" + ib_preview_url="$(jq -r ".${ib_iarray}[0].${ib_ipreview}" "${ib_file}")" + + . "${units}/ib_meta.zsh" + + printf "%s\n" "${ib_sample_url}" > "${ib_sample}" + fi + printf "%s\n" "${ib_id}" > "${ib_post_id}" fi |
