I have a bunch of individual icon rules for use in my Cleanup library; e.g. show a tag icon for missing tags, that sort of thing. Combining them into one advanced rule is proving itself to be a bit difficult though.
First I tried a gpm with a lot of elifs, only to figure out that all the 'fis' were causing processing to stop prematurely. So I thought that a first_non_empty would work better:
Code:
program:
## Some common variables
ids = $identifiers;
## Check for 'Cleanup' VL.
if 'Cleanup' in virtual_libraries() then
## Begin first_non_empty
first_non_empty(
## Missing metadata
if !$languages then 'languages.png' fi;
if !$#pagecount then 'cover_flow.png' fi;
if !$#chaptercount then 'cover_flow.png' fi;
if !$tags then 'tags.png' fi;
## Fanfiction check
if $#fanficcat then
status = $#fanficstatus;
## Identifiers
if select(ids, 'url') then
if
'(Archive of Our Own|Fanfiction.net)' in $publisher
&& '(Completed|Abandoned|Oneshot|Incomplete)' in status
then 'metadata.png'
elif
!select(ids, 'ao3')
&& $publisher == 'Archive of Our Own'
&& status == 'In-Progress'
then 'metadata.png'
elif
!select(ids, 'ffnet')
&& $publisher == 'FanFiction.net'
&& status == 'In-Progress'
then "metadata.png"
fi
fi
## End fanfiction check
fi;
## Marked books
if is_marked() then
m = is_marked();
first_non_empty(
contains(m, "invalid_author_sort|invalid_title_sort", 'auto_author_sort.png', ''),
contains(m, "epub_calibre_bookmarks", 'snippets.png', ''),
if 'fff' in m && check_yes_no('#onkobo', 0, 0, 1) then 'sync.png' fi,
if 'reading_list_send_to_device' in m then 'sync.png' fi,
if 'reading_list_to_be_read' in m then 'list.png' fi,
contains(m, "fff", 'download-metadata.png', ''),
contains(m, "search_results", 'search.png', ''),
if m then 'marked.png' fi
)
fi;
## Fallback to polish.png for undefined issues
'polish.png'
## End first_non_empty
)
# End Cleanup VL check
fi
So I ran this on a book that should've matched one of the metadata.png tests, and instead of the expected 'metadata.png', it returned... polish.png?
Did I make a mistake? I tested this:
Code:
program:
## Some common variables
ids = $identifiers;
## Check for 'Cleanup' VL.
if 'Cleanup' in virtual_libraries() then
## Fanfiction check
if $#fanficcat then
status = $#fanficstatus;
## Identifiers
if select(ids, 'url') then
if
'(Archive of Our Own|Fanfiction.net)' in $publisher
&& '(Completed|Abandoned|Oneshot|Incomplete)' in status
then 'metadata.png'
elif
!select(ids, 'ao3')
&& $publisher == 'Archive of Our Own'
&& status == 'In-Progress'
then 'metadata.png'
elif
!select(ids, 'ffnet')
&& $publisher == 'FanFiction.net'
&& status == 'In-Progress'
then "metadata.png"
fi
fi
## End fanfiction check
fi
# End Cleanup VL check
fi
returns metadata.png.
So I return to the original template and comment out polish.png (removing the semicolon on the is_marked() section). Now it's returning blank.
But if I uncomment polish.png and move the entire 'Fanfiction check' section below it, it returns metadata.png.
Did I accidentally turn my first_non_empty into a last_non_empty?
I also got some strange results on a far simpler test template: