|
|
#841 |
|
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,374
Karma: 79699999
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Code:
program: subjects = $#subjects; admintags = $#admintags; existing_colls = $#kobocoll; new_colls = strcat( if $#booktype=='Fanfiction' then 'Fanfiction,' fi, if '^Cozy Mystery$' inlist subjects then 'Cozy Mysteries,' fi, if '^Horses$' inlist subjects then 'Horses,' fi, if '(Juvenile|Young Adult)' inlist subjects then 'Juvenile & Young Adults,' fi, if '^(Fantasy|Paranormal|Science Fiction)$' inlist subjects && !'Star Trek' inlist subjects then 'Fantasy & Sci-Fi,' fi, if '^Star Trek$' inlist subjects then 'Star Trek,' fi, if 'Omnibus' in admintags then 'Omnibuses' fi, ); Last edited by ownedbycats; 06-03-2025 at 07:46 PM. |
|
|
|
|
|
#842 | |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,526
Karma: 8065948
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Code:
check_inlist_field(field, values required, values_not_allowed) You should use "inlist_field '#subjects'" instead of "inlist subjects". I also suggest you use parentheses on line 12 to avoid any possibility of operator precidence being what you don't want. Example: Code:
if ('^(Fantasy|Paranormal|Science Fiction)$' inlist_field '#subjects') && (!('Star Trek' inlist_field '#subjects')) then 'Fantasy & Sci-Fi,' fi,
Last edited by chaley; 06-04-2025 at 07:16 AM. |
|
|
|
|
| Advert | |
|
|
|
|
#843 |
|
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,374
Karma: 79699999
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
I have this to display icons for formats, and an unknown icon if none are present:
Code:
program: formats = approximate_formats(); strcat ( if "azw3" inlist formats then 'formats_azw3.png:' fi, if "cbz" inlist formats then 'formats_cbz.png:' fi, if "epub" inlist formats then 'formats_epub.png:' fi, if "html" inlist formats then 'formats_html.png:' fi, if "mobi" inlist formats then 'formats_mobi.png:' fi, if "paperbook" inlist formats then 'formats_paperbook.png:' fi, if "pdf" inlist formats then 'formats_pdf.png:' fi, if "txt" inlist formats then 'formats_txt.png:' fi, if "(overdrive|paperloan)" inlist formats then 'formats_overdrive.png:' fi, if list_difference(formats, 'azw3, cbz, epub, html, mobi, paperbook, pdf, txt, overdrive, paperloan', ',') then 'formats_unknown.png' fi ) |
|
|
|
|
|
#844 |
|
null operator (he/him)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 22,036
Karma: 30277960
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
Maybe there's a way to use the png's in the ???\resources\images\mimetypes folder, where the image names are the format file types - e.g. epub.png, pdf.png etc.
BR |
|
|
|
|
|
#845 |
|
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,374
Karma: 79699999
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Yeah, I copied most icons from there (except paperbook and overdrive).
|
|
|
|
| Advert | |
|
|
|
|
#846 |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,526
Karma: 8065948
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
This isn't as repetitive, but is a bit harder to understand.
Code:
program:
def add_icon_name(res, fmt):
return res & 'formats_' & fmt & '.png:'
fed;
result = '';
formats = approximate_formats();
formats_for_book = list_intersection('azw3, cbz, epub, html, mobi, paperbook, pdf, txt', formats, ',');
for format in formats_for_book:
result = add_icon_name(result, format)
rof;
if "(overdrive|paperloan)" inlist formats then result = add_icon_name(result, 'overdrive') fi;
if list_difference(formats, formats_for_book & ',overdrive,paperloan', ',') then
result = add_icon_name(result, 'unknown')
fi;
re(result, ':$', '')
|
|
|
|
|
|
#847 |
|
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,374
Karma: 79699999
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Code:
{title_sort:'contains(t=uppercase(re($, '^\W*(\w).*$','\1')), '\d', '0-9', t)'}
EDIT: Got it (not sure if transliterate should come before or after uppercase). Code:
{title_sort:'contains(t=uppercase(transliterate(re($, '^\W*(\w).*$','\1'))), '\d', '0-9', t)'}
Last edited by ownedbycats; 06-23-2025 at 11:02 AM. |
|
|
|
|
|
#848 |
|
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 141
Karma: 33086
Join Date: Jan 2021
Device: Likebook Mars
|
I'm not sure if questions about Cover generator templates are appropriate here, but here is my question:
I'd like add an extra line in the footer showing the publish date (pubdate) in a smaller font. The current footer template is this (it shows up to two authors): Code:
program:
# Show at most two authors, on separate lines.
authors = field('authors');
num = count(authors, ' & ');
authors = sublist(authors, 0, 2, ' & ');
authors = list_re(authors, ' & ', '(.+)', '<b>\1');
authors = re(authors, ' & ', '<br>');
re(authors, '&&', '&')
|
|
|
|
|
|
#849 | |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,526
Karma: 8065948
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Code:
program: # Show at most two authors on separate lines. followed by the pubdate authors = sublist($authors, 0, 2, ' & '); authors = re(authors, ' & ', '<br>'); strcat(authors, '<br><small>', $pubdate, '</small>') |
|
|
|
|
|
|
#850 |
|
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 141
Karma: 33086
Join Date: Jan 2021
Device: Likebook Mars
|
Thank you! It doesn't make the font smaller, but it looks fine, so no biggie.
|
|
|
|
|
|
#851 | |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,526
Karma: 8065948
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
|
|
|
|
|
|
|
#852 |
|
Enthusiast
![]() Posts: 31
Karma: 10
Join Date: Jul 2025
Device: paperwhite
|
I'm attempting to display word_count with "K" and "M" suffixes for thousands and millions, respectively. However, I'm encountering an issue saying "TEMPLATE ERROR could not convert string to float". How can I fix the template to work as intended?
Code:
program:
switch(
field('#word_count') >= 1000000, format_number(field('#word_count') / 1000000, '{:.1f}') + ' M',
field('#word_count') >= 1000, format_number(field('#word_count') / 1000, '{:.1f}') + ' K',
field('#word_count')
)
|
|
|
|
|
|
#853 | ||
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,526
Karma: 8065948
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
I suggest you read the template language manual. Example: Code:
program:
first_matching_cmp($#word_count,
1000, $#word_count,
1000000, format_number($#word_count / 1000, '{:.1f}') & ' K',
format_number($#word_count / 1000000, '{:.1f}') & ' M'
)
Quote:
|
||
|
|
|
|
|
#854 |
|
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,374
Karma: 79699999
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Copy to Clipboard action to string together several columns and produce a preformatted string to paste into FanFicFare's personal.ini:
Code:
program:
authortitle = strcat('## ', $author, ' - ', $title);
storyid = strcat('(', $id, ')');
storyUrl = switch_if(
$publisher=='Archive of Our Own', strcat('https://archiveofourown.org/works/', select($identifier, 'ao3')),
$publisher=='FanFiction.net', strcat('https://www.fanfiction.net/s/', select($identifier, 'ffnet'), '/1/'),
''
);
settings = $$#fanficsettings;
copySection = strcat(authortitle, ' ', storyid, character('newline'), '[', storyUrl, ']',character('newline'),settings)
|
|
|
|
|
|
#855 | |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,526
Karma: 8065948
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
|
|
|
|
|
![]() |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Library Management: various questions not worth their own thread | ownedbycats | Library Management | 253 | 10-21-2025 09:15 AM |
| [Metadata Source Plugin] Questions regarding parse select, docs and ref templates | Boilerplate4U | Development | 13 | 07-07-2020 03:35 AM |
| Questions on Kobo [Interfered with another thread topic] | spdavies | Kobo Reader | 8 | 10-12-2014 12:37 PM |
| [OLD Thread] Some questions before buying the fire. | darthreader13 | Amazon Fire | 7 | 05-10-2013 10:19 PM |
| Thread management questions | meme | Feedback | 6 | 01-31-2011 06:07 PM |