Requesting implementation of Shiichan's comma syntax to refer to well-defined sets of certain posts.
Like this: http://www.world4ch.org/read.php/vip/1103880078/47,5,15-10,8-
I was nagging MrVacBob into implementing that. Needless to say, it will be in the next Kareha version too.
I was surprised by the backwards ranges (ie. 15-10 in the link above) being valid and listing the posts in reverse order. Not really a bad thing, just unexpected.
I've been thinking of more extensions to that. The only useful one that I can think of is 'qX', which would display every post with an anchor to X. That would be kind of slow, though.
Call it a joke. That one's MrVacBob's. I've put some of my own in Kareha, but it up to you to figure them out.
That's a pretty good idea, I think. Would be easier if one saved some metadata, but quite possible to do anyway. Hard to correctly parse references to range and such, though. One could maybe even add a link somewhere in each post to that.
Well, as an experiment, I've implemented both the q syntax, and http://wakaba.c3.cx/sup/kareha.pl/1102984488/1 on these two boards. Try it out, and give suggestions for improvement or changes.
It's kinda annoying on the eyes to have that link there for every post, though. Maybe this "Replies" feature would better be fit in some external browser thing like http://wakaba.c3.cx/sup/kareha.pl/1104757670 ?
Yeah, I'm not too fond of the replies link either, but it does make the feature much more accessible. If the reply number wasn't already used for the quoting, I'd use that. Can anyone think up any other more elegant way to do this?
Is the feature even that important? The only thing it adds to something a user could do with CTRL+F is the syntax >>9 shows.
>>12
I was thinking of 2ch browser-like programs. Being able to query for every reply to a certain post is easier on bandwidth and CPU on both sides than HTML scraping.
> I was thinking of 2ch browser-like programs.
zomg me too!
Incidentially, it wouldn't be all that hard to extend the q code to handle replies to the replies, to an arbitary depth. Would that be useful, you think?
Seriously, though: Why not make a firefox extension or a small browser for this? There are a lot of features that could be useful for Kareha, but I doubt it would make sense to cram them all into the actual software itself.
Well, it's quite a bit of work. If anyone wants to do this, I'm open to suggestions and making internal changes to help out.
A secret feature :o
>>r3
How did you implement /q? I'm working on it and I've thought of two ways:
* on every /q request, rescan the entire thread for anchors that would load the q parameter; this is slow even when it isn't being done in PHP.
* keep around a cache of what anchors every post requests; this isn't slow, but adds more data files which might annoy someone, and makes me wish for an actual database. Also, it can get corrupted and has to be updated every time someone posts and such.
I scan the entire thread. I figured it's done seldom enough that speed isn't crucial. It's not THAT slow, either, at least not with my data storage setup (keeping posts on separate single lines of a HTML file).
Here's the relevant code (@page contains the lines of the current thread page, $num is the argument to q, @posts is filled with a list of which posts to display, $replyrange_re is a regexp to match the >> syntax, in_range() checks if a certain post number is contained in a >> reference.
push @posts,$num;
OUTER: foreach my $post (1..$total)
{
next if($post eq $num);
while($page[$post+1]=~/>>($replyrange_re)/g)
{
if(in_range($num,$1)) { push @posts,$post; next OUTER; }
}
}
Here's in_range():
sub in_range($$)
{
my ($num,$ranges)=@_;
foreach my $range (split /(,|,)/,$ranges)
{
if($range=~/^([0-9]*)-([0-9]*)$/)
{
my $start=($1 or 1);
my $end=($2 or 1000000); # arbitary large number
($start,$end)=($end,$start) if($start>$end);
return 1 if($num>=$start and $num<=$end);
}
elsif($range=~/^([0-9]+)$/)
{
return 1 if($num==$1);
}
#elsif($range=~/^l([0-9]+)$/i) {} # l ranges never match
#elsif($range=~/^r([0-9]*)$/i) {} # r ranges never match
#elsif($range=~/^q([0-9]+)$/i) {} # q ranges never match
}
return 0;
}
Some notes:
The >> posting regex being used right now matches every comma in an anchor, even if it's at the end and doesn't mean anything. This screws up some sentences a little:
"What this all really means, though, is that you, >>1, should just stick with today's special."
I can't get one to work; it seems to need at least extended regexp syntax, and I don't know enough of that to do something useful.
Well, that's ugly, but at least it doesn't break things entirely, since the link to 1, does work... But let's look at the regexp. I'm using this right now:
/(?:[0-9\-,lrq]|,)+/
One quick but slightly clumsy solution would be something like this:
/(?:[0-9\-,lrq]|,)*[0-9\-lrq]/
That would require the last character to not be a ,.
Shamelessly bumping this to promote further improvement of navigation/linking & sucking up to 0ch! n, next100/previous100, etc. (n´✪ω✪n)
See also: http://wakaba.c3.cx/sup/kareha.pl/1099328662/21-22