Compare commits

..

No commits in common. "3d168d4f9ef9cdc2262baecf06f66f1f91511cc2" and "72b169826c88541065f68a38d83fa1e39ea48320" have entirely different histories.

3 changed files with 14 additions and 69 deletions

View File

@ -1,5 +1,5 @@
PREFIX = ~/.local
VERSION = 0.4.0
VERSION = 0.3.1
PKG_CONFIG = pkg-config

View File

@ -29,8 +29,6 @@ sub_help() {
echo " fzf show articles using fzf"
echo " use the commands /read (enter), /purge (ctrl-d), /purge-all (ctrl-alt-d),"
echo " /watch-later (ctrl-w) and /queue (ctrl-e)"
echo " you can also run 'fzf feed' for a specific feed."
echo " 'fzf -s' shuffles the feed."
echo
echo "article commands (pass files as arguments):"
echo " read opens link from an article file in either a browser or mpv"
@ -65,19 +63,14 @@ list_purge() {
while read -r ARTICLE; do
if [ -h "$ARTICLE" ]; then
rm "$ARTICLE"
if [ -n "$INDXFILE" ]; then
ENTRY="$(grep "^[0-9]*: $ARTICLE" "$INDXFILE")"
ID="$(printf "%s" "$ENTRY" | grep -o "^[0-9]*")"
sed -i "/^$ID:.*$/d" "$LISTFILE"
fi
fi
done
}
sub_purge() {
if [ -z "$@" ]; then
cd "$MRSS_DIR"/new
find . -type l -or -type f | list_purge
cd "$MRSS_DIR"
rm -r "$MRSS_NEWDIR"/*
else
for art in "$@"; do
printf "%s\n" "$art"
@ -129,7 +122,7 @@ list_read() {
VIDFILES="$art"
fi
else
xdg-open "$LINK" 2> /dev/null &
xdg-open $LINK 2> /dev/null &
sub_purge "$art"
fi
done
@ -158,11 +151,7 @@ sub_preview() {
ARTICLE="$1"
DIRNAME="$(cat "$ARTICLE" | jq -r '.feedname // ""')"
if [ -z "$DIRNAME" ]; then
DIRNAME="$(basename $(dirname "$ARTICLE"))"
fi
DIRNAME="$(basename $(dirname "$ARTICLE"))"
TITLE="$(cat "$ARTICLE" | jq -r '.title')"
DESC_TRUNC="$(cat "$ARTICLE" | jq -r '.description // ""' | w3m -dump -T text/html | head -n 20)"
@ -244,29 +233,7 @@ sub_select() {
)
}
list_fzf_filename() {
# searches entry in index and returns its filename
while read -r ENTRY; do
ID="$(printf "%s" "$ENTRY" | grep -o "^[0-9]*")"
grep "^$ID: " "$INDXFILE" | sed "s/^[0-9]*: //"
done
}
sub_fzf_preview() {
# wrapper over sub_preview() that runs fzf_filename
INDXFILE="$1"
ENTRY="$2"
sub_preview "$(echo "$ENTRY" | list_fzf_filename "$INDXFILE")"
}
sub_fzf() {
while getopts ":s" flag; do
case "$flag" in
s) MRSS_SHUF="yes";;
esac
done
shift `expr $OPTIND - 1`
if [ -z "$1" ]; then
DIR="$MRSS_NEWDIR"
else
@ -274,25 +241,12 @@ sub_fzf() {
fi
cd "$DIR"
LISTFILE=`mktemp --suffix=mrss`
INDXFILE=`mktemp --suffix=mrss`
COUNTER="1"
find . -type l -or -type f \
| ([ -n "$MRSS_SHUF" ] && shuf || cat) \
| nl -ba -d'' -n'rz' -s': ' -w1 \
> "$INDXFILE"
cat "$INDXFILE" | sed "s/^[0-9]*: //" \
| xargs -rd "\n" cat \
| jq -r '[.feedname?, .title] | map(select(. != null)) | join(" - ")' \
| nl -ba -d'' -n'rz' -s': ' -w1 \
> "$LISTFILE"
while true; do
OUTPUT="$(cat "$LISTFILE" |
NEWARTS="$(find . -type l -or -type f)"
OUTPUT="$(printf "%s" "$NEWARTS" |
export SHELL="/bin/sh"
fzf --marker='*' --multi --print-query \
--preview "cd $DIR; mrss fzf_preview '$INDXFILE' {}" \
--preview "cd $DIR; mrss preview {}" \
--bind "ctrl-d:change-query(/purge)+accept" \
--bind "ctrl-alt-d:change-query(/purge-all)+accept" \
--bind "enter:change-query(/read)+accept" \
@ -306,7 +260,7 @@ sub_fzf() {
break
fi
SEL="$(printf "$OUTPUT\n" | tail -n+2 | list_fzf_filename)"
SEL="$(printf "%s" "$OUTPUT" | tail -n+2)"
ACTION="$(printf "%s" "$OUTPUT" | head -n 1 | tail -c+2)"
case "$ACTION" in
@ -337,9 +291,6 @@ sub_fzf() {
esac
done
rm "$LISTFILE"
rm "$INDXFILE"
if [ -n "$QUEUE" ]; then
printf "%s\n" "$QUEUE" | list_read
fi

View File

@ -155,13 +155,10 @@ openFile(const char *folder, char *fileName, char *fileExt)
}
static void
outputHtml(itemStruct *item, FILE *f, const char *folder)
outputHtml(itemStruct *item, FILE *f)
{
if (item->fields[FIELD_TITLE])
fprintf(f, "<h1>%s</h1><br>\n", item->fields[FIELD_TITLE]);
fprintf(f, "From feed <b>%s</b><br>\n", folder);
if (item->fields[FIELD_LINK])
fprintf(f, "<a href=\"%s\">Link</a><br>\n", item->fields[FIELD_LINK]);
if (item->fields[FIELD_ENCLOSURE_URL])
@ -174,13 +171,10 @@ outputHtml(itemStruct *item, FILE *f, const char *folder)
#ifdef JSON
static void
outputJson(itemStruct *item, FILE *f, const char *folder)
outputJson(itemStruct *item, FILE *f)
{
json_object *root = json_object_new_object();
json_object_object_add(root, "feedname",
json_object_new_string(folder));
if (item->fields[FIELD_TITLE])
json_object_object_add(root, "title",
json_object_new_string(item->fields[FIELD_TITLE]));
@ -217,7 +211,7 @@ processItem(itemStruct *item, const char *folder)
int ret = 0;
char fileExt[10];
void (*outputFunction)(itemStruct *, FILE *, const char *);
void (*outputFunction)(itemStruct *, FILE *);
switch (outputFormat) {
case OUTPUT_HTML:
@ -253,7 +247,7 @@ processItem(itemStruct *item, const char *folder)
// Do not overwrite files
if (!ftell(itemFile)) {
outputFunction(item, itemFile, folder);
outputFunction(item, itemFile);
ret = 1;
if (summaryFormat == SUMMARY_FILES)
logMsg(LOG_OUTPUT, "%s%c%s%s\n", folder, fsep(), basename, fileExt);