LT Sort Author Works

DiscussãoHacking LibraryThing

Aderi ao LibraryThing para poder publicar.

LT Sort Author Works

Este tópico está presentemente marcado como "adormecido"—a última mensagem tem mais de 90 dias. Pode acordar o tópico publicando uma resposta.

1brightcopy
Editado: Fev 3, 2013, 12:54am

http://userscripts.org/scripts/show/158254

Adds "sort by copies" and "sort by title" links to the works headers on author pages. These let you resort the works on the fly.

Note that if you're on an author page where some works are hidden behind a "show all" link, it will only sort the visible works. Click on the "show all" link and then sort.



2benuathanasia
Fev 2, 2013, 11:49pm

...how does it work?
What are the steps?

I clicked the install button, but it just showed me your script...

3brightcopy
Fev 3, 2013, 12:09am

Here's a good starting point:
http://www.librarything.com/wiki/index.php/Hacking_LibraryThing#Hacking_LibraryT...

Let me know if it still leaves some questions unanswered.

4benuathanasia
Fev 3, 2013, 12:42am

Ok, I installed Greasemonkey, installed the script, and went to an author's page. Greasemonkey shows a little "check" next to the LibraryThing script, but I don't see anything that allows me to sort works by popularity or title. Where should I be looking for it?

5brightcopy
Fev 3, 2013, 12:55am

I added a couple of screenshots to the initial post.

6Collectorator
Fev 3, 2013, 3:52am

brightcopy, you are a genius. Thank you very, very much.

7Collectorator
Editado: Fev 3, 2013, 5:16am

It only worked for me one time, though. Now it doesn't appear even though I closed FF and reopened. I will reboot.
...
Nope, that didn't do it.

8henkl
Fev 3, 2013, 8:22am

Brightcopy, thank you. Works perfectly.

9benuathanasia
Fev 3, 2013, 1:58pm

Doesn't look like that on mine. It still looks like it used to look. Greasemonkey says the script is running.

10brightcopy
Fev 3, 2013, 6:19pm

For those having problems - give me an example author url. Also, try
http://www.librarything.com/author/kingstephen
and
http://www.librarything.com/author/kingstephen&all=1
and tell me if it works on one, both or neither.

11eromsted
Fev 3, 2013, 6:34pm

It works for me on some author pages but not others. I do not see the sorting links on either of the Stephen King pages. I do see them on the William Shakespeare pages:
http://www.librarything.com/author/shakespearewilliam
http://www.librarything.com/author/shakespearewilliam&all=1

I can find other examples of working and not working if that would be useful.

12benuathanasia
Editado: Fev 3, 2013, 7:01pm

Works on both King pages, neither Shakespeare pages. Edit: It showed up on the Shakespeare pages if I let the page sit a minute or so.
Other pages I tried it on and saw it didn't work:
http://www.librarything.com/author/dumasalexandre-1
http://www.librarything.com/author/twainmark

Pages I tried where it does work:
http://www.librarything.com/author/dickenscharles
http://www.librarything.com/author/austenjane
http://www.librarything.com/author/brontecharlotte
http://www.librarything.com/author/lowrylois
http://www.librarything.com/author/lewiscs
http://www.librarything.com/author/remarqueerichmaria
http://www.librarything.com/author/leeharper
http://www.librarything.com/author/steinbeckjohn
http://www.librarything.com/author/bradburyray
http://www.librarything.com/author/hugovictor
http://www.librarything.com/author/rowlingjk

Edit: Something I noticed...all the author pages work fine if I go to them from my library (I look in my library and select their name from there). They do NOT work if I do a "search site" of the author's name and look at it from there.

13brightcopy
Fev 4, 2013, 1:59am

I think I see some of the problems. Thanks, everyone, I''ll upload a fix when I get a chance.

14brightcopy
Fev 6, 2013, 10:28pm

Okay, I think that does the trick. The main problem was between authors that are in your catalog versus those you have no works from.

Update your script and test it out and let me know how it goes. For those new to the whole thing, you can just go to the script page at the very top and click the green Install button.

(But not the stupid green "Download" button.)

15Collectorator
Fev 7, 2013, 4:30pm

Perfect. Thank you so much for this long-desired solution! :D

16.Monkey.
Fev 7, 2013, 4:45pm

I do so love you and your scripts. hahaha. I never even bother trying to look at stuff on author pages because it's ridiculous, you can't find anything with prolific authors! This is awesome.

17brightcopy
Editado: Fev 8, 2013, 9:15am

Glad to help! For whatever reason, this one piqued my interest.

One oddity is that it'll promote weird "No title" works to the top. Like this one (please don't "fix" it, though - I'm going to file a bug report):
http://www.librarything.com/author/shakespearewilliam&all=1

Sort by title and the first one is "No title". This is a side effect of the title being blank even though the link text is "No title". I sort by the link's title.

The odd part is that it should have a title. That book is this one:
http://www.librarything.com/work/9595012/book/72244836

Weird, huh? Like I said, time for a bug report. I posted about a similar one when fixing an entry like this on Stephen King (see the All Hail King Stephen thread in Talk About LibraryThing).

18.Monkey.
Editado: Fev 8, 2013, 9:44am

Aww, I just discovered for some reason the script doesn't work on my laptop, boooo. :( lol.

(also I have no idea what's up with that title. I tried looking for others that have only copies of the work title in Greek text, but they seem to be fine, so I'm out of ideas lol)

19brightcopy
Fev 8, 2013, 10:02am

Is your laptop running the same browser and the same version? And which would that be?

20.Monkey.
Fev 8, 2013, 12:05pm

No, it's old, lol. I'm on a super outdated Ubuntu, running Fx 3.6.11 haha. But all your other scripts work fine! heh

21brightcopy
Fev 8, 2013, 3:11pm

Ah, that'd be .outerHTML()s doing, I'm afraid. I could code around it if you need to, but it was the easiest way and only requires FF 11. Can't you update? Lots of security holes there, I'm sure.

22.Monkey.
Fev 9, 2013, 6:43am

Not really, due to the super outdated Ubuntu, lol. That's okay though, it works on my desktop, and eventually I'll update/upgrade the laptop to a new (and current lol) flavor of Linux. :P

23Collectorator
Mar 14, 2013, 4:30pm

I don't want to appear to be complaining, because this is one of the best improvements to LT in a very long time. It is such a huge help.

However, I would request some tweaking to the alphabetization rules that the script encompasses. It doesn't alphabetize like the rest of LT does; for instance titles that begin with "A ....." or "The ....." are lumped together. It also separates capitalized titles from non-capitalized titles, which is kind of helpful in a way, but probably not optimal. (how it even does that is far, far beyond me)
My example today is http://www.librarything.com/author/digestreaders&all=1

So, many thanks once again, brightcopy.

24jjmcgaffey
Mar 14, 2013, 5:20pm

It's actually harder to mix capitalized and non-capitalized - in straight ASCII and most codes based on/related to it, all the capitals come first and then all the non-capitals, so an ASCII-order sort (which is the simplest one) will do that separation.

Don't know if it would be possible to do an LT-style sort - there's a lot of code in there for ignoring A and The and the like.

25lorax
Mar 14, 2013, 9:20pm

24>

Well, adding the -i flag or using tolower() isn't exactly hard. But yeah, it's not as though omitting it is at all mystifying.

Just excluding leading "The, A, An" would be easy enough to do - that's a one-line regexp. LT's proper sorting is harder.

26brightcopy
Mar 14, 2013, 9:40pm

It would be fairly easy to do a case-insensitive search. All I'd have to do is do a lowercase() of the two values when I compare them. It doesn't affect the value, just the comparison basis.

I thought about doing some more fancy, and yeah the A/An/The would be low-hanging fruit. I also found that there's a locale-sensitive lowercase that might be nice for people using other languages. But of course it won't do any good if you have some books from several languages.

27brightcopy
Abr 8, 2013, 11:05pm

Finally got a chance to look at this again now that my cover nav script is finished. I think I got all the requests and more:

Sort by title will use a locale-sensitive sort (meaning it takes the language of your computer into account - though not necessarily the language of the individual books).

Sorting will also attempt to intelligently sort numbers so "Abc 99 Def" comes before "Abc 1000 Def".

By default, the sort will ignore the first word if it is "a", "an" or "the". You can edit this list of words by choosing "Leading title words to ignore" from the script menu.

Just use your browser's built in updating if it has it (in google there is a "check for userscript updates" option, in Firefox you have to find the script under Tools->Addons->User scripts, right-click on it and choose "Find updates"). If it doesn't or that doesn't work, just go to the script page at the top of message #1 and click the green Install button at the top right of the page (beware of advertisements that have "download" or "install" buttons that aren't at the top right).

28jjwilson61
Abr 9, 2013, 11:13am

By default, the sort will ignore the first word if it is "a", "an" or "the". You can edit this list of words by choosing "Leading title words to ignore" from the script menu.

This will cause A is for Alibi to sort to the wrong location and there may be some mixed language libraries for which this won't work well. But you probably knew that already.

29brightcopy
Abr 9, 2013, 11:16am

#28 by jjwilson61> Yep. Until we get some sort of real artificial intelligence, you can't have it both ways.

30r.orrison
Abr 9, 2013, 11:27am

LibraryThing uses || to indicate the sort point in a title, e.g. "||A is for Alibi" should sort with the As. Whether that shows up in the data you're looking at I don't know. I also don't know how well known it is, or how often it's used. I'm not sure what I do know, sometimes.

31LolaWalser
Abr 9, 2013, 11:30am

brightcopy, this is GREAT. How many times did I wish for this while doing some of my 22K combinations!

Thanks!

32brightcopy
Editado: Abr 9, 2013, 11:36am

#30 by r.orrison> Nope. :) What you see is what I get.

#31 by LolaWalser> You're quite welcome!

I have more scripts up my sleeve. Hopefully now that I'm done with the giant cover navigation one I can get a few more smaller ones banged out.