Auto cut-tagging achieved
Apr. 4th, 2005 01:16 pm![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Well, that was easy. I've been fiddling a bit with making my friends view block quizlets, which involves a bunch of string parsing that the LJ style language does not already include, and
laurion commented that it would be handy to chop entries over a certain length. I realized that I could do that by adding two lines to the basic layout, so now my friends page auto-cuts after 1000 characters. (That number is actually rather smaller than I want for regular use, but works well for demonstration purposes.)
Take that, overlong uncut entries.
![[livejournal.com profile]](https://www.dreamwidth.org/img/external/lj-userinfo.gif)
Take that, overlong uncut entries.
no subject
Date: 2005-04-04 05:42 pm (UTC)no subject
Date: 2005-04-04 05:50 pm (UTC)Now, can you explain it so the rest of us understand?
no subject
Date: 2005-04-04 06:19 pm (UTC)$e is the Entry object, which contains all the metadata as well as the raw text. $content will later be passed to another function for pretty formatting, and normally would just be a straight dump of the user's input, $e.text, but I'm intercepting it. If the text is longer than my cutoff, I take just that much and append a link to the full entry; otherwise, it gets passed along normally.
Pretty basic change, and there's a lot I could do to make it cleaner (starting with abstracting out the magic number). But, hey, that stuff takes longer than 30 seconds.
no subject
Date: 2005-04-04 06:36 pm (UTC)no subject
Date: 2005-04-04 06:58 pm (UTC)In S2 you have the option to create a pile of different 'layers', but the basic one you want is a top-level layout layer. I copied and pasted the code of mine from the stock Tabular Indent layer, and then tweaked here and there, because I didn't have sweeping changes to enact. It is in this layer that I have added the new code.
no subject
Date: 2005-04-04 05:51 pm (UTC)no subject
Date: 2005-04-04 05:57 pm (UTC)no subject
Date: 2005-04-04 06:00 pm (UTC)no subject
Date: 2005-04-04 06:14 pm (UTC)no subject
Date: 2005-04-04 06:15 pm (UTC)no subject
Date: 2005-04-04 06:29 pm (UTC)no subject
Date: 2005-04-04 07:17 pm (UTC)Now we just need reader-filterable topic tags ...
(Despite my own attitudes toward cut tags (there are things I'd rather see cut, but cutting for length usually just means a bunch of extra mouseclicks and waits-for-download for me), I could see using your code myself if I ever get brave enough to look at friendsfriends again. (With as long a friends list as mine, friendsfriends finds an awful lot of entries at a time.) It could also be useful if I could design an "I only have time to skim" style to use in conjunction with my similar friends-filter, without affecting my ordinary view.)
no subject
Date: 2005-04-04 07:53 pm (UTC)(Uncutting cut sections can't trivially be done, because the display view receives the entries after preprocessing, so the cut text simply isn't there.)
I'm definitely in favor of user-side content filtering when possible, for the reasons you describe. In this case, while I have pointed out to new users that the cut tag exists on occasion, in general I don't want to complain about the way people choose to present their own content. Now we each get our control.
The most straightforward condition to attach for the case you describe seems to be 'if ($p->view_title() == "Friends (Whatever)"', which I have tested and it seems to work fine, so you could stick that on and have a catch-up filter with ultra-brief entries.
no subject
Date: 2005-04-04 08:49 pm (UTC)Thanks for the tip and code fragment. Until today I hadn't had enough incentive to go read the S2 docs yet.
(And I agree that it's reasonable to point out the option of using cut tags when a fairly new user seems unaware of them -- I've done that myself. I'm not completely anti-cut-tag; they do have their uses.)
no subject
Date: 2005-04-04 08:54 pm (UTC)no subject
Date: 2005-04-04 09:01 pm (UTC)no subject
Date: 2005-04-05 05:24 am (UTC)