Prototype statuses as files initialized

This commit is contained in:
localhost_frssoft 2022-08-05 14:49:48 +03:00
parent e4640ba6e1
commit 952e26444e
7 changed files with 43 additions and 0 deletions

View File

@ -3,6 +3,8 @@
instance=$(jj -i config.json instance)
alias default_auth_browser=links
export main_basedir=$(dirname $0)
proxy_init()
{
main_proxy=$(jj -i config.json main_proxy)
@ -437,6 +439,8 @@ statuses_render()
if [ "$reversed_statuses" = 'true' ]; then
ids_massive=$(echo "$ids_massive" | tr ' ' '\n' | tac | tr '\n' ' ')
fi
echo "$jsonmassive" | ./utils/statuses2files.sh
./utils/extract_text_content.sh
for i in $ids_massive; do
status=$(echo "$jsonmassive" | jj "#[id=$i]")
reblog=$(echo "$status" | jj reblog.id)

3
utils/delq Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
sed 's/"//g'

3
utils/delqse Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
sed 's/^"//g; s/"$//g'

12
utils/extract_text_content.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
# Extract some content from statuses
for i in "$main_basedir"/statuses/*/*.json; do
content=$(jj -i $i content | "$main_basedir"/utils/html_to_txt_render)
status_id=$(jj -i $i 'id')
status_date=$(jj -i $i 'created_at')
touch -d "$status_date" "$main_basedir"/statuses/$status_id
jj -i $i content | "$main_basedir"/utils/html_to_txt_render > "$main_basedir"/statuses/$status_id/content
chmod 600 "$main_basedir"/statuses/$status_id/content
done

4
utils/find_pgp_message Executable file
View File

@ -0,0 +1,4 @@
#!/bin/sh
awk '/-----BEGIN PGP MESSAGE-----/,/-----END PGP MESSAGE----/'

3
utils/html_to_txt_render Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
sed -e "s/<br[^>]*>/\n/g ; s/<p[^>]*>/\n/g ; s/<[^>]*>//g ; s/&gt;*/>/g ; s/&lt;*/</g ; s/&quot;/\"/g ; s/&#39;/'/g"

14
utils/statuses2files.sh Executable file
View File

@ -0,0 +1,14 @@
#!/bin/sh
# convert statuses as files and dirs
json="$(cat)"
ids=$(echo "$json" | jj -l '#.id' | sed 's/"//g')
for i in $ids; do
if [ -f "$main_basedir"/statuses/$i.json ]; then
continue
fi
mkdir -m 711 -p "$main_basedir"/statuses/$i
echo "$json" | jj -p "#[id=$i]" > "$main_basedir"/statuses/$i/$i.json
chmod 600 "$main_basedir"/statuses/$i/$i.json
done
"$main_basedir"/utils/extract_text_content.sh