[personal profile] learnedax
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 [livejournal.com profile] 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.

Date: 2005-04-04 05:42 pm (UTC)
From: [identity profile] hfcougar.livejournal.com
You do realize you may be the hero of LJ now?

Date: 2005-04-04 05:50 pm (UTC)
From: [identity profile] metahacker.livejournal.com
Ha! See here. Way to get my back!

Now, can you explain it so the rest of us understand?

Date: 2005-04-04 06:19 pm (UTC)
From: [identity profile] learnedax.livejournal.com
Sure. The actual code modification was changing
$content = $e.text;
to
if ($e.text->length() > 1000) {
  $content = $e.text->substr(0, 1000) +
    "<p><strong>[POST HAS BEEN CUT FOR LENGTH. SEE FULL POST AT <a href=\""
    + $e.permalink_url + "\">THIS LINK</a>.]</strong>";
} else { $content = $e.text; }
inside the print_entry function.

$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.

Date: 2005-04-04 06:36 pm (UTC)
From: [identity profile] metahacker.livejournal.com
Where does this code go? What style FAQ should I be reading?

Date: 2005-04-04 06:58 pm (UTC)
From: [identity profile] learnedax.livejournal.com
The Advanced Customization page (http://www.livejournal.com/customize/advanced/), which they have cleverly not linked to under any of the Edit My Style pages, even though I'm set to use S2. The docs are reasonably good.

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.

Date: 2005-04-04 05:51 pm (UTC)
tpau: (Default)
From: [personal profile] tpau
wow. doe sthis only work for S2?

Date: 2005-04-04 05:57 pm (UTC)
From: [identity profile] learnedax.livejournal.com
Yes. I can't think of a way to overlay it on S1, although you don't need to code your own style for this, so you can switch to S2 relatively easily and keep pretty much everything as it was in S1.

Date: 2005-04-04 06:00 pm (UTC)
tpau: (Default)
From: [personal profile] tpau
hmm, ok. well iam using s2 for here, and s1 on greatestjournal, so i cna certanly do it here

Date: 2005-04-04 06:14 pm (UTC)
siderea: (Default)
From: [personal profile] siderea
Hrm. I went to your page, and your Mar 13 entry had "[POST HAS BEEN CUT FOR LENGTH. SEE FULL POST AT THIS LINK.]" at the bottom. When I clicked the link (taking me to the page for that entry alone) I saw.... exactly the same text, with the same "[POST HAS BEEN CUT FOR LENGTH. SEE FULL POST AT THIS LINK.]" link at the bottom, and no more text than appeared on your page. Same with others, including March 9, where the cut falls in the midst of someone's screen name, so the link doesn't take you to your page, it takes you to their user info.

Date: 2005-04-04 06:15 pm (UTC)
siderea: (Default)
From: [personal profile] siderea
Having checked you Mar 9 entry under my style, I see there is more text which isn't appearing on the entry's page under your style.

Date: 2005-04-04 06:29 pm (UTC)
From: [identity profile] learnedax.livejournal.com
You are correct. I hadn't yet added in the special case to deal with different views, so it didn't have the desired behavior for my own entries. The permalink_url provided by LJ's Entry object will point to the page in its native style, so it only had that quirk when the style was mine. I've set it to only cut in friends view now.

Date: 2005-04-04 07:17 pm (UTC)
From: [identity profile] dglenn.livejournal.com
There are reasons (which I consider very good reasons, obviously) why I cut-tag when I do and don't when I don't, even for length. What you've done here hands partial control (they can't make something I've cut appear on their friendslist as though I hadn't, right?) to the reader, so that if they have an even better reason for wanting things cut than I have for wanting them uncut, they control their own reading experience without my having to accomodate them in a way that affects all my other readers as well. In a way this is sort of an extension of the "the web is not for control-freaks" design philosophy that says the user should be able to override colours and font sizes and such on web pages to adjust their reading environment for their own comfort and efficiency. This is pretty darned cool at a level beyond simple "I wish so-and-so would use cuts" grumbling.

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.)

Date: 2005-04-04 07:53 pm (UTC)
From: [identity profile] learnedax.livejournal.com
On the topic tags: I was very disappointed that LJ just picked more-pretty-styles to work on, rather than tagging. I hope that since tags were #2 in the poll they will at least get around to them sooner.

(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.

Date: 2005-04-04 08:49 pm (UTC)
From: [identity profile] dglenn.livejournal.com
Well ... that so many users who answered the poll picked "more pretty styles", anyhow ...

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.)

Date: 2005-04-04 08:54 pm (UTC)
From: [identity profile] dglenn.livejournal.com
FYI: Small glitchitude if the cutoff happens in the middle of an HTML tag (at least within an HREF). Take a look at houw my most recent entry appears on your friends page -- the auto-cut message is missing.

Date: 2005-04-04 09:01 pm (UTC)
From: [identity profile] learnedax.livejournal.com
Yeah, I haven't found a useful way around that. Without parsing for context, the message will appear in whatever html context it interrupts, which could be confusing.

Date: 2005-04-05 05:24 am (UTC)
From: [identity profile] patrissimo.livejournal.com
would you mind giving a step-by-step sort of tutorial on how to set this? I've never even glanced at any LJ customization options...is it easy to add this feature without changing my friends list style?

Profile

learnedax

November 2011

S M T W T F S
  12345
6789101112
13141516171819
20 212223242526
27282930   

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Sep. 18th, 2025 11:54 am
Powered by Dreamwidth Studios