afuna_archive: (Default)
[personal profile] afuna_archive
Back in January, I realized that you could probably figure out which individual tags filter you were viewing by using the (newly-added) parameter to each Userlite data_link:

3:09 AM me: hm
3:10 AM me: ma thinking of s2 at the moment
does this entry : http://community.livejournal.com/changelog/4356263.html mean that we can determine what tagspage we're on by checking the data link?
3:13 AM murklins: Looks like, but how do you check the data link?
3:14 AM me: Page has a hash of data links


I meant to play around with it, so I posted about it to remind myself, and then promptly forgot.


Then in May, [livejournal.com profile] murklins(<3) needed to customize certain tags views, and reminded me about my idea:
12:51 AM murklins: Hey, this is how we find out if we're on a tags subset of the recent entries page right?
if ((size $this.data_links_order) > 0) {
  if ($this.data_link{"rss"}) {
    var Link dlink = $this.data_link{"rss"};
    if ($dlink.url->contains("?tag=")) {
      print "A Tags Page";
    }
  }
}

12:55 AM me: hee
I don't know :)
I don't tihnk I've ever seen that before
though the concept seems familiar, but my mind might be playing tricks on me
12:56 AM murklins: Oh, it was your idea! :)


And I remembered that I'd had that idea before, and decided to do something with it some day. (And then promptly forgot about it again.)

Then someone made an entry in [livejournal.com profile] s2flexisquares asking whether it was possible to hide a sticky post when filtered by tags. And I was happy that I'd finally have a chance to play with the idea (almost a year after I first thought of it), so I wrote code and replied with it. Then she asked me whether it would be possible to make it so that you could show the sticky post only for certain tags, and after shaking off some rust I came up with this code.

It could be more flexible -- right now it won't work if you filter by multiple tags, but it's good enough, and I'm not crazy enough to try implementing a join/split function in S2.

(What if I made the tags an array instead of a hash? That would make it easier to input tag names -- ["tag1", "tag2"] instead of {"tag1"=>true, "tag2"=>true}, and it's unlikely that the list of tags this is used on would be long enough to affect performance either way.)

Other possibilities are to change colors or images depending on the tag that you're filtering by, or to change the behavior of entries with certain tags (for example, only show summaries for fic-related tags). And others! If you were motivated enough, you could make subtle changes to your layout for each tag you have. I'm not that motivated. :-)

Date: 2007-11-29 06:23 pm (UTC)
From: [identity profile] camomiletea.livejournal.com
OMG <3. I think this will allow me to implement this.

Date: 2007-11-30 12:37 pm (UTC)
afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
From: [personal profile] afuna
Ooh! Neat idea. Ping me when you have it done? I want to see it in action ;-)

Date: 2007-11-30 03:14 pm (UTC)
From: [identity profile] camomiletea.livejournal.com
I took a function from the Core and modified it to append the tags names to the title. I'm not sure yet if I should work something out to replace + with a space in the case of tags that are phrases:

function Page::title() [notags] : string {
    var string title = $.global_title;
    if ($title == "") {
        $title = $.journal.name;
    }
    if ($.view == "friends") {
        $title = $this->view_title();
    } elseif ($.view == "recent" and $.data_link{"rss"}.url->contains("?tag=")) {

        var int baseurl_length = $.base_url->length() + 14; # "/data/rss?tag=" = 14 chars
        var int feedurl_length = $.data_link{"rss"}.url->length();

        var string tag_name= $.data_link{"rss"}.url->substr($baseurl_length, $feedurl_length - $baseurl_length);

        $title = $title + " (" + $tag_name + ")";

    } else {
        $title = $title + " - " + $this->view_title();
    }
    return $title;
}

Date: 2007-12-01 06:47 pm (UTC)
afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
From: [personal profile] afuna
*grins*

Replacing "+" with " " is a bit more complicated, and would (I think) involve going through the entire string character by character and then replacing the "+" if you see it.

Hmm. Maybe not as complicated as I thought:

var string tag_name = "";
foreach var string c($tag_from_url) { $tag_name = $tag_name + (($c == "+") ? " " : $c);}

Date: 2007-11-29 06:41 pm (UTC)
From: [identity profile] murklins.livejournal.com
Forgot to mention in our last chat, but my code related to this is here: http://murklinstest.livejournal.com/28931.html

Date: 2007-11-30 12:39 pm (UTC)
afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
From: [personal profile] afuna
<3

Love you. Love it! I'm thinking of posting to either [livejournal.com profile] s2styles or [livejournal.com profile] s2flexisquares to share the technique. Is it okay if I link that entry (if ever I do get around to making that post ;))

Date: 2007-11-30 04:55 pm (UTC)
From: [identity profile] murklins.livejournal.com
Sure, go for it. :)

Date: 2007-11-29 07:03 pm (UTC)
aveleh: Close up picture of a vibrantly coloured lime (Default)
From: [personal profile] aveleh
<3

Date: 2007-11-30 02:38 pm (UTC)
afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
From: [personal profile] afuna
This is what I do when I'm not GREASEMONKEYING FOR YOU <3

Date: 2007-11-30 06:25 pm (UTC)
aveleh: Close up picture of a vibrantly coloured lime (Default)
From: [personal profile] aveleh
This is why I tell you STOP GREASEMONKEYING FOR ME.

And then I give you a whole big list. I know, I suck.

<3

(Home for two seconds, later!)

Date: 2007-11-30 02:23 am (UTC)
From: [identity profile] ivles.livejournal.com
Wonderful! Mem-ming this. XDDDD

Profile

afuna_archive: (Default)
afuna_archive

June 2009

S M T W T F S
  1 2 3 4 5 6
7 8 9 10 11 1213
14151617181920
21222324252627
282930    

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 6th, 2025 09:07 pm
Powered by Dreamwidth Studios