Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 11-26-2012, 07:49 AM   #1
ousire
Junior Member
ousire began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Nov 2012
Device: Nook Color
help making a plugboard for sorting series?

I've been using calibre for a while now, and i've been using this plugboard i found online to keep my series under control:

{series}{series_index:0>2s| #| - }{title}

this mostly does what i want, making all the books in my library show up in nice ordered series. It was good at the start, but now that i have a lot of different books on my nook, i've noticed a new problem: i like making a separate shelf for each series, and whenever i go to add books to it, around half of the series i have are all stuck under T because they have "the" in the beginning of their name.

so my list looks something like this:
The Black company # -
The Chronicles of Narnia # -
The Earthsea Cycle # -
etc.

However, my own preference for making shelves is having the "The" at the end of the name, so its easier to find the books. so my question is: is it possible to make a plugboard that reads something like this:

Black Company, The # -
Chronicles of Narnia, The # -
Earthsea Cycle, the # -

I'm sure its possible, but i have no idea how to write plugboards, and i didn't find anything about it by searching around google or the forum. I know i could just delete the "the" from the beginning of the series, but i prefer to have accurate names so i leave them in most of the time, but it makes sorting a pain.
ousire is offline   Reply With Quote
Old 11-26-2012, 08:01 AM   #2
DoctorOhh
US Navy, Retired
DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.
 
DoctorOhh's Avatar
 
Posts: 8,908
Karma: 12755553
Join Date: Feb 2009
Location: North Carolina
Device: Nexus 7
Quote:
Originally Posted by ousire View Post
However, my own preference for making shelves is having the "The" at the end of the name, so its easier to find the books. so my question is: is it possible to make a plugboard that reads something like this:

Black Company, The # -
Chronicles of Narnia, The # -
Earthsea Cycle, the # -

I'm sure its possible, but i have no idea how to write plugboards, and i didn't find anything about it by searching around google or the forum. I know i could just delete the "the" from the beginning of the series, but i prefer to have accurate names so i leave them in most of the time, but it makes sorting a pain.
This should be the default. Go to Preferences - Tweaks - Control formatting of title and series when used in templates and make sure the tweak is set to library_order.

Last edited by DoctorOhh; 11-26-2012 at 08:04 AM.
DoctorOhh is offline   Reply With Quote
Old 11-26-2012, 08:04 AM   #3
ousire
Junior Member
ousire began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Nov 2012
Device: Nook Color
Quote:
Originally Posted by DoctorOhh View Post
Go to Preferences - Tweaks - Control formatting of title and series when used in templates and make sure the tweak is set to library_order.
i just checked, and it IS set to library order, but the book still all show up under "the" on my nook
ousire is offline   Reply With Quote
Old 11-26-2012, 08:21 AM   #4
chaley
"chaley", not "charley"
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 5,898
Karma: 1216548
Join Date: Jan 2010
Location: France
Device: Many android devices
Instead of the template segment
Code:
{series}
use the following segment in template program mode
Code:
{:'series_sort()'}
This template segment calls the template function series_sort() that (ta da!) returns the series sort value.

@DoctorOhh: plugboards, like composite custom columns, don't use that tweak. The only templates that respect the tweak are send & save.
chaley is offline   Reply With Quote
Old 11-26-2012, 08:25 AM   #5
DoctorOhh
US Navy, Retired
DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.
 
DoctorOhh's Avatar
 
Posts: 8,908
Karma: 12755553
Join Date: Feb 2009
Location: North Carolina
Device: Nexus 7
Quote:
Originally Posted by chaley View Post
@DoctorOhh: plugboards, like composite custom columns, don't use that tweak. The only templates that respect the tweak are send & save.
Template != Plugboard, seems simple enough to remember. One day it might sink in.
DoctorOhh is offline   Reply With Quote
Old 11-26-2012, 08:37 AM   #6
ousire
Junior Member
ousire began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Nov 2012
Device: Nook Color
Quote:
Originally Posted by chaley View Post
Instead of the template segment
Code:
{series}
use the following segment in template program mode
Code:
{:'series_sort()'}
This template segment calls the template function series_sort() that (ta da!) returns the series sort value.
.

i'm afraid i have no idea what any of that means

am i just supposed to replace the {series} with {:'series_sort()'} ? i tried that and got an error:
calibre, version 0.9.7
ERROR: Invalid template: <p>The template {:'series_sort()'}{series_index:0>2s| #| - }{title} is invalid:<br>'NoneType' object has no attribute 'series'

i really dont know anything at all about coding or templates, and the template language link made no sense to me
ousire is offline   Reply With Quote
Old 11-26-2012, 09:32 AM   #7
chaley
"chaley", not "charley"
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 5,898
Karma: 1216548
Join Date: Jan 2010
Location: France
Device: Many android devices
Quote:
Originally Posted by ousire View Post
i'm afraid i have no idea what any of that means

am i just supposed to replace the {series} with {:'series_sort()'} ? i tried that and got an error:
calibre, version 0.9.7
ERROR: Invalid template: <p>The template {:'series_sort()'}{series_index:0>2s| #| - }{title} is invalid:<br>'NoneType' object has no attribute 'series'

i really dont know anything at all about coding or templates, and the template program mode link made no sense to me
Sorry. In the end, templates are a program language.

Your assumption was correct. The exception is a bug. I have fixed that problem for the next calibre release. In the meantime, you can use the following template (in general program mode) that does the same thing but doesn't toss that error.
Code:
program: strcat(series_sort(), template('{series_index:0>2s| #| -  }{title}'))
chaley is offline   Reply With Quote
Old 11-26-2012, 09:54 AM   #8
ousire
Junior Member
ousire began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Nov 2012
Device: Nook Color
Quote:
Originally Posted by chaley View Post
Code:
program: strcat(series_sort(), template('{series_index:0>2s| #| -  }{title}'))
ah fantastic! this looks like it does exactly what i need! i still dont most of the code that makes it work, but i wont complain if it gets the job done :P

my only complaint is that it's removed the space from between the series name and the #, why is that? its minor, but i couldnt help but notice after resorting all my books that needed to be fixed
ousire is offline   Reply With Quote
Old 11-26-2012, 10:03 AM   #9
chaley
"chaley", not "charley"
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 5,898
Karma: 1216548
Join Date: Jan 2010
Location: France
Device: Many android devices
Quote:
Originally Posted by ousire View Post
my only complaint is that it's removed the space from between the series name and the #, why is that? its minor, but i couldnt help but notice after resorting all my books that needed to be fixed
It is an artifact of the way the "template" function works. That space ends up at the beginning of the function's result so it is stripped off.

You can add it back in easily. Use
Code:
program: strcat(series_sort(), ' ', template('{series_index:0>2s| #| -  }{title}'))
The change is adding ' ', (quote space quote comma space) just before the template function. If there isn't a series then this extra space will be at the beginning of the result and thus will be stripped away.
chaley is offline   Reply With Quote
Old 11-26-2012, 10:20 AM   #10
ousire
Junior Member
ousire began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Nov 2012
Device: Nook Color
Quote:
Originally Posted by chaley View Post
It is an artifact of the way the "template" function works. That space ends up at the beginning of the function's result so it is stripped off.

You can add it back in easily. Use
Code:
program: strcat(series_sort(), ' ', template('{series_index:0>2s| #| -  }{title}'))
The change is adding ' ', (quote space quote comma space) just before the template function. If there isn't a series then this extra space will be at the beginning of the result and thus will be stripped away.
aaha, that did the trick nicely! and thanks to all this, i'm understanding this coding stuff a lot better then trying to force my way through the manual. if i'm understanding right, the commas mark the space as something to be inserted, and without them, the code just assumed the space was extra filler to ignore?

either way, my problem has been nicely solved, and my library management has been simplified tenfold. thank you for all the help!
ousire is offline   Reply With Quote
Old 11-26-2012, 10:40 AM   #11
chaley
"chaley", not "charley"
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 5,898
Karma: 1216548
Join Date: Jan 2010
Location: France
Device: Many android devices
Quote:
Originally Posted by ousire View Post
aaha, that did the trick nicely! and thanks to all this, i'm understanding this coding stuff a lot better then trying to force my way through the manual. if i'm understanding right, the commas mark the space as something to be inserted, and without them, the code just assumed the space was extra filler to ignore?
Sort of ...

That template returns the value generated by the strcat function, where "strcat" is programmer-shorthand for "string concatenate". A "string" is a possibly-empty sequence of characters.

A function like strcat takes "arguments", which are "things" that it is supposed to use when it does its job. The "things" are found between the open and close parentheses. A "thing" can be the result of another function, or a constant. Constant strings are characters surrounded by quotes. "Things" must be separated by a comma.

Applying both of these definitions, we see that in the template that works, strcat is to create a single string (its result) from 3 "things": the result from the series_sort() function, the constant ' ' (a single space in quotes), and the result of the template() function (the rest of what you want). The resulting string has all leading and trailing spaces removed, then is passed back to the "user", in this case the plugboard.

So, if there is no series (series_sort() returns nothing), strcat creates a string from the second argument (the constant string) and the third argument (template()). The extra leading space (the second argument) is then removed. If series_sort() returns something then that constant space is in the middle of the result (between the series name and the result of template()), and is not stripped away.

My guess is that this is more information than you wanted. That said, the ex-professor in me is happy to try to satisfy someone's curiosity about how this stuff really works.
Quote:
either way, my problem has been nicely solved, and my library management has been simplified tenfold. thank you for all the help!
You are quite welcome.
chaley is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Plugboard "Metadata: Show series [series index] - title as title (Kindle)" Deep Cover Library Management 6 11-30-2012 06:17 PM
Series sorting in plugboard ac4lt Devices 6 01-13-2012 01:53 PM
Plugboard: Series Contains Star Wars formatting uli Library Management 2 10-22-2011 02:03 PM
@chaley – Sony PRS505 vs PRS650 - Book sorting & Metadata Plugboard jackie_w Calibre 32 12-26-2010 12:45 PM
Metadata Plugboard - First Char of each word in Series MikeP1212 Calibre 2 10-14-2010 07:14 PM


All times are GMT -4. The time now is 02:21 PM.


MobileRead.com is a privately owned, operated and funded community.