[dw-free] Style Comments Page with Outline Indicators in Place of Indents
[commit: http://hg.dwscoalition.org/dw-free/rev/619352340c84]
http://bugs.dwscoalition.org/show_bug.cgi?id=3286
Add a setting to display explicit comment hierarchy indicators on site
scheme comment pages (such as those that you see when you do ?style=light).
e.g., 1., 2., 2a., 2b., 2b1., 2c., 3... etc. So that those for whom visual
indents don't mean anything can still get an idea of the conversation flow.
Patch by
allen.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=3286
Add a setting to display explicit comment hierarchy indicators on site
scheme comment pages (such as those that you see when you do ?style=light).
e.g., 1., 2., 2a., 2b., 2b1., 2c., 3... etc. So that those for whom visual
indents don't mean anything can still get an idea of the conversation flow.
Patch by
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Files modified:
- bin/upgrading/en.dat
- bin/upgrading/proplists.dat
- cgi-bin/DW/Setting/DisplayEchi.pm
- cgi-bin/LJ/Setting/BoolSetting.pm
- cgi-bin/LJ/Talk.pm
- htdocs/manage/settings/index.bml
- htdocs/talkread.bml
-------------------------------------------------------------------------------- diff -r 61302c5ab73b -r 619352340c84 bin/upgrading/en.dat --- a/bin/upgrading/en.dat Thu Aug 25 12:18:43 2011 +0800 +++ b/bin/upgrading/en.dat Thu Aug 25 16:57:38 2011 +0800 @@ -2563,6 +2563,10 @@ setting.display.viewstyle.site=Site skin +setting.echi_display.des=Display Explicit Comment Hierarchy Indicators (site scheme only) + +setting.echi_display.label=Comment Hierarchy + setting.emailalias.label=Email Alias setting.emailalias.option=Receive email sent to [[user]]@[[domain]] diff -r 61302c5ab73b -r 619352340c84 bin/upgrading/proplists.dat --- a/bin/upgrading/proplists.dat Thu Aug 25 12:18:43 2011 +0800 +++ b/bin/upgrading/proplists.dat Thu Aug 25 16:57:38 2011 +0800 @@ -654,6 +654,14 @@ multihomed: 0 prettyname: Contextual Popup +userproplist.opt_echi_display: + cldversion: 4 + datatype: bool + des: Explicit Hierarchy Comment Indicator (1., 1a, 1b, 2.) display for comments + indexed: 1 + multihomed: 0 + prettyname: Explicit Hierarchy Comment Indicator display + userproplist.opt_embedplaceholders: cldversion: 4 datatype: char diff -r 61302c5ab73b -r 619352340c84 cgi-bin/DW/Setting/DisplayEchi.pm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgi-bin/DW/Setting/DisplayEchi.pm Thu Aug 25 16:57:38 2011 +0800 @@ -0,0 +1,56 @@ +#!/usr/bin/perl +# +# DW::Setting::DisplayEchi +# +# LJ::Setting module which controls whether to display the Explicit +# Comment Hierarchi Indicator (ECHI) for comments +# +# Authors: +# Allen Petersen <allen@suberic.net> +# +# Copyright (c) 2011 by Dreamwidth Studios, LLC. +# +# This program is free software; you may redistribute it and/or modify it under +# the same terms as Perl itself. For a copy of the license, please reference +# 'perldoc perlartistic' or 'perldoc perlgpl'. +# + +package DW::Setting::DisplayEchi; +use base 'LJ::Setting::BoolSetting'; +use strict; +use warnings; + +sub prop_name { + return "opt_echi_display"; +} + +sub checked_value { + return "Y"; +} + +sub unchecked_value { + return ""; +} + +sub should_render { + my ( $class, $u ) = @_; + return $u && $u->is_individual; +} + +sub label { + my $class = shift; + return $class->ml( 'setting.echi_display.label' ); +} + +sub option { + my ( $class, $u, $errs, $args ) = @_; + return $class->as_html( $u, $errs ); +} + +sub des { + my $class = $_[0]; + + return $class->ml( 'setting.echi_display.des' ); +} + +1; diff -r 61302c5ab73b -r 619352340c84 cgi-bin/LJ/Setting/BoolSetting.pm --- a/cgi-bin/LJ/Setting/BoolSetting.pm Thu Aug 25 12:18:43 2011 +0800 +++ b/cgi-bin/LJ/Setting/BoolSetting.pm Thu Aug 25 16:57:38 2011 +0800 @@ -56,10 +56,10 @@ value => 1, id => "${key}check", selected => $class->is_selected($u), - }) . " <label for='${key}check'>" . $class->label . "</label>"; - if (my $des = $class->des) { - $html .= "<br /><span class='helper'>$des</span>"; - } + }) . " <label for='${key}check'>"; + $html .= $class->des || $class->label; + $html .= "</label>"; + return $html; } diff -r 61302c5ab73b -r 619352340c84 cgi-bin/LJ/Talk.pm --- a/cgi-bin/LJ/Talk.pm Thu Aug 25 12:18:43 2011 +0800 +++ b/cgi-bin/LJ/Talk.pm Thu Aug 25 16:57:38 2011 +0800 @@ -940,6 +940,7 @@ # - _loaded => 1 (if fully loaded, subject & body) # unknown items will never be _loaded # - _show => {0|1}, if item is to be ideally shown (0 if deleted or screened) +# - echi (explicit comment hierarchy indicator) sub load_comments { my ($u, $remote, $nodetype, $nodeid, $opts) = @_; @@ -1030,6 +1031,64 @@ $showable_children{$post->{'parenttalkid'}} += $sum; unshift @{$children{$post->{'parenttalkid'}}}, $post->{'talkid'}; } + + } + + # explicit comment hierarchy indicator generation + if ( ( ! $opts->{'flat'} ) && $remote && $remote->prop( "opt_echi_display" ) eq "Y" ) { + + my @alpha = ( "a".."z" ); + + # all echi values are initially stored as numeric values; this + # translates from the number to a..z, a[a..z]..z[a..z], etc. + my $to_alpha = sub { + my $num = shift; + # this is 0-based, while the count is 1-based. + $num--; + my $retval = ""; + + # prepend a third letter only if we have more than 702 + # comments (26^2 = 676, plus the initial 26 which don't + # have a second letter = 702) + if ( $num >= 702 ) { + $retval .= $alpha[ ( $num - 702 ) / 676 ]; + } + if ( $num >= 26 ) { + $retval .= $alpha[ ( ( $num - 26) / 26 ) % 26 ]; + } + $retval .= $alpha[ $num % 26 ]; + return $retval; + }; + + my $top_counter = 1; + + foreach my $post (sort { $a->{'talkid'} <=> $b->{'talkid'} } values %$posts) { + # set the echi for this comment + my $parentid = $post->{'parenttalkid'} || $post->{'parenttalkid_actual'} || 0; + if ( $parentid && $posts->{$parentid} ) { + my $parent = $posts->{$parentid}; + $post->{'echi_count'} = 0; + if ( ! $parent->{'echi_count'} ) { + $parent->{'echi_count'} = 1; + } else { + $parent->{'echi_count'} = $parent->{'echi_count'} + 1; + } + if ( ! $parent->{'echi_type'} ) { + $parent->{'echi_type'} = 'N'; + } + if ( $parent->{'echi_type'} eq 'N' ) { + $post->{'echi_type'} = 'A'; + $post->{echi} = $parent->{echi} . $to_alpha->( $parent->{'echi_count'} ); + } else { + $post->{'echi_type'} = 'N'; + $post->{echi} = $parent->{echi} . $parent->{'echi_count'}; + } + } else { + $post->{echi} = $top_counter++; + $post->{'echi_count'} = 0; + $post->{'echi_type'} = 'N'; + } + } } } @@ -1089,8 +1148,10 @@ ## %expand_children - list of comments, children of which are to expand my %expand_children = map { $_ => 1 } @top_replies; my (@subjects_to_load, @subjects_ignored); + while (@check_for_children) { my $cfc = shift @check_for_children; + next unless defined $children{$cfc}; foreach my $child (@{$children{$cfc}}) { if (@posts_to_load < $page_size || $expand_children{$cfc} || $opts->{expand_all}) { diff -r 61302c5ab73b -r 619352340c84 htdocs/manage/settings/index.bml --- a/htdocs/manage/settings/index.bml Thu Aug 25 12:18:43 2011 +0800 +++ b/htdocs/manage/settings/index.bml Thu Aug 25 16:57:38 2011 +0800 @@ -82,6 +82,7 @@ LJ::Setting::NavStrip LJ::Setting::NCTalkLinks LJ::Setting::StyleMine + DW::Setting::DisplayEchi LJ::Setting::CtxPopup LJ::Setting::AdultContent DW::Setting::AdultContentReason diff -r 61302c5ab73b -r 619352340c84 htdocs/talkread.bml --- a/htdocs/talkread.bml Thu Aug 25 12:18:43 2011 +0800 +++ b/htdocs/talkread.bml Thu Aug 25 16:57:38 2011 +0800 @@ -475,11 +475,16 @@ } - my $cleansubject = LJ::ehtml($post->{'subject'}); + my $cleansubject = LJ::ehtml( $post->{'subject'} ); + + my $echitext = ""; + if ( $post->{echi} ) { + $echitext = qq{<span class="echi">$post->{echi}.</span> }; + } if ( $post->{state} eq 'S' ) { - $ret .= "<span class='commentsubject'>" . BML::ml( '.comment.screened.subject' ) . "<b>$cleansubject</b></span> $icon"; + $ret .= "<span class='commentsubject'>" . BML::ml( '.comment.screened.subject' ) . "$echitext<b>$cleansubject</b></span> $icon"; } else { - $ret .= "<span class='commentsubject'><b>$cleansubject</b></span> $icon"; + $ret .= "<span class='commentsubject'><b>$echitext$cleansubject</b></span> $icon"; } $ret .= "<br />$user\n"; $ret .= " " . BML::ml( '.from_external', {site=>$post->{props}->{imported_from}} ) if $post->{props}->{imported_from}; --------------------------------------------------------------------------------
no subject
no subject