🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.readers
7 messages
7 total messages Started by ernobe Tue, 27 Aug 2013 22:21
[slrn] Solution to the age-old question
#255434
Author: ernobe
Date: Tue, 27 Aug 2013 22:21
193 lines
6725 bytes
I gave up on a previous attempt to solve what is a pretty simple problem 
because it required a complex set of macros which placed too much burden on 
slrn and still didn't solve the problem completely.  

The problem is how to place a mark on only the latest never before seen 
messages within a thread.  

The other attempt had to reconstruct the whole thread on entry to the group, 
and all the other messages within it appeared marked as read.  So here is the 
real deal.  It only takes a pretty simple Icon program, running slrnpull in 
rebuild mode, scoring the articles by age, a simple macro within slrn to tag 
the newest articles, and setting sorting method to custom for better 
appearance of the results.  

The Icon program changes the date of each article to yesterday with the --date 
option of date in Unix ( date --date=yesterday ).  Before running slrnpull 
you have to run it with the --rebuild option so as to rebuild the overview 
files.  By scoring the articles that are younger than one day, like this

[*]
Score: 1
Age: 1

then all the newer articles received from the server are the only ones to 
receive a high score and are distinguished with a mark within slrn.  If the 
last time you downloaded was more than one day ago you will have to change the 
behaviour of the date command and the score accordingly.

The score file scores the articles by age so that the ones older than a day 
are also marked.  The youngest ones are tagged, those at least two days old 
are not marked at all, to avoid clutter and to make the newest ones more 
visible, and those three and five days old are also marked.

[*]
Score: -2
Age: 4

[*]
Score: -3
Age: 3

[*]
Score: -4
Age: 2

[*]
Score: -5
Age: 1

Then in .slrnrc put the following and remember to run slrnpull with the 
--kill-score option to -16 or else it will kill all the articles.

set max_low_score -16
set min_high_score -5 

Here is the macro within slrn to tag the articles.  

    define tag_high_score ()
    {
        call ("header_bob");
        do
        {  
            if ( (-14) == get_header_score ())  
            {
		set_header_flags (HEADER_TAGGED);
            }
            if ( (0) == get_header_score ())  
            {
		set_header_flags (12);
            }
        }
        while (header_down (1));
    }
    
    () = register_hook ("article_mode_hook", "tag_high_score" );

I need to look up slangs' case function for better coding.  Anyway, you need 
to put this in a file and call it from .slrnrc like this:

interpret yourfile.sl

Also put these two for navigating to the tagged articles.  They move to the 
tagged article and open it for viewing.  I've only been able to open it for 
viewing with the article_line_down function.

    define prevheader ()
    {
	if (1 == prev_tagged_header ())
	{
	    if (0 == get_body_status ())
	    	article_line_down (1);
	    if (0 == has_parent ())
		collapse_threads ();
	}
    }

    define nextheader ()
    {
	if (1 == next_tagged_header ())
	{
	    if (0 == get_body_status ())
		article_line_down (1);
	    if (0 == has_parent ())
		collapse_threads ();
	}
    }
    definekey ("nextheader", "7", "article" );
    definekey ("prevheader", "6", "article" );

And here is the sorting method in .slrnrc:

set sorting_method 12
set custom_sort_order "body,score,Date|date" 
set custom_sort_by_threads 1

This shows the newest threads and articles at the top by their scores and 
dates.  Within the threads though it shows the oldest articles first.

Finally for those who want to take a look at it, here is the Icon code.  In 
adition to changing the date to yesterday, it adds a new header ( X-URL: ) so 
that it is marked as not needing to be re-dated.  Thereafter only the 
immediately previous downloaded articles dates are changed.

Note that this works on Linux.  It requires tweaking for other operating 
systems.

procedure main( x )
d := []
s0 := read( open( "date --date=yesterday \"+%a, %d %b %Y %T %z\"", "p" ) )
s4 := open( "/home/roy/News/spool/slrnpull.conf" ) | stop( "no slrnpull conf file" )
while s1 := read( s4 ) do {
    if s1[ 1 ] == "#" then next
    s1 ? {
	s2 := tab( upto( ' ' ) | 0 )
	if s2 == ( "default" | "" ) then next
	    else put( d, s2 )
	} 
    }
every man( m1( !d ), s0 )
end

procedure m1( s5 )
f := "/home/roy/News/spool/news/"
s5 ? { while s1 := tab( upto( '.' ) ) do 
    { f ||:= s1 || "/" 
	move( 1 ) 
	}
    f ||:= tab( 0 ) || "/"
    }
return f
end

procedure man( s, s0 )
no := "no"
n := open( "ls " || s, "p" ) | stop( "unable to list ", s )
while p := read( n ) do {
    numeric( p ) | next
    a := open( s2 := s || p, "rw" ) | stop( "unable to open a:", s2 )
    g := read( a )
    if g == "X-URL: " then 
	{ close( a )
	next
	} 
	else { t := open( s3 := s2 || "new", "crw" ) | stop( "unable to open t:", s3 )
	write( t, "X-URL: \n", g )
	}
    while b := read( a ) do {
	if b[1:6] == "Date:" then 
	    { write( t, "Date: ", s0 )
	    no := "yes" 
	    } 
	    else write( t, b ) 
	}
    if no == "yes" then no := "no"
	else { seek( t, 1 )
	    seek( a, 1 )
	write( t, "X-URL: \nDate: ", s0 )
	while write( t, read( a ) ) 
	}
    system( "mv " || s3 || " " || s2 )
    close( a )
    close( t )
    }
close( n )
write( "finished ", s )
return
end

		    
-- 
"The world of existence is an emanation of the merciful attribute of God."
Abdu'l-Baha
http://www.costarricense.cr/pagina/ernobe
Re: [slrn] Solution to the age-old question
#255459
Author: ernobe
Date: Fri, 06 Sep 2013 16:50
176 lines
7886 bytes
> I gave up on a previous attempt to solve what is a pretty simple problem 
> because it required a complex set of macros which placed too much burden on 
> slrn and still didn't solve the problem completely.  
>
> The problem is how to place a mark on only the latest never before seen 
> messages within a thread.  
>
> The other attempt had to reconstruct the whole thread on entry to the group, 
> and all the other messages within it appeared marked as read.  So here is the 
> real deal.  It only takes a pretty simple Icon program, running slrnpull in 
> rebuild mode, scoring the articles by age, a simple macro within slrn to tag 
> the newest articles, and setting sorting method to custom for better 
> appearance of the results.  
>
> The Icon program changes the date of each article to yesterday with the --date 
> option of date in Unix ( date --date=yesterday ).  Before running slrnpull 
> you have to run it with the --rebuild option so as to rebuild the overview 
> files.  By scoring the articles that are younger than one day, like this
>
> [*]
> Score: 1
> Age: 1
>
> then all the newer articles received from the server are the only ones to 
> receive a high score and are distinguished with a mark within slrn.  If the 
> last time you downloaded was more than one day ago you will have to change the 
> behaviour of the date command and the score accordingly.
>

I think I've spotted a bug in slrn.  If I change the score file in .slrnrc it 
will continue to read the default score file of slrnpull.

I've resolved the above problem of having to download within the fixed time 
specified in the code.  Instead of changing the date, it is possible to add a 
number to the date line and use it to score the article ( it still reads the 
date OK ), and to obtain its message id and place it in the stickytags file.  
That way the tag is permanent ( until the next download ) and the number 
placed in the date line makes it possible to organize the results by score 
in the article pane.

When a new group is added, I only put a limit on the age of articles ( not 
their number ) like this:

[*]
Score: -1
~Age: 7

so that articles over 7 days old are not downloaded.  Then run my program on 
it like this:

$~/slnews comp/lang/icon

replacing the dots with slashes.  This will initialize the group(s).  It only 
adds a new header to each article.  Without arguments, the program looks for 
new articles ( those which don't have the header ) in groups specified in its 
configuration file.  It does three things to them:

1) obtain the message-id and place it in the .slrn-stickytags file.
2) add a number to the date line, ( I use the Linux command 'date +%s' which 
is the number of seconds since 1970, it is a unique number for every time 
the program is run ).  The date line then looks like this:

Date: Fri, 6 Sep 2013 01:47:19 +0000 (UTC) 1378439505

The last number is the one added.
3) add a new header ( 'X-URL: ' ) to mark it as done for the next time.

It also creates a file which is included in the score file with the include 
command:

include scoring

The 'scoring' file only contains the number above:

[*]
Score: 1
Date: 1378439505

The sorting method set in .slrnrc is the same as in the previous program.  The 
min_high_score setting is different.  It is set to 2, and max_low_score is 
left at the default setting.

set min_high_score 2

When you do catchup, all articles except the tagged ones ( the newest ones ) 
are deleted.  Then after downloading the next time, run the program without 
any arguments, having placed the path to the groups, ending with a slash, in 
the configuration file.  If you've configured .slrnrc as mentioned, at the top 
you will have articles and threads that you've read ( if you've read all the 
articles that were new the previous time ) but which no one has replied to.  
Next will be articles and threads that are new ( not part of threads you have 
read the previous time ).  These are all tagged.  Finally there will be 
threads containing articles you've read and newer, tagged ones.  What I do 
is re-read those articles at the top, which no one has replied to ( asking 
myself why no one has replied to them ).  Then simply use the tag navigating 
functions mentioned in the original post to navigate to the newer tagged 
articles, reply to them if there is something worth replying to, then catchup 
the group and repeat.

Here is the modified Icon program:

global q, u
procedure main( x )
d := []
u := " " || read( open( "date +%s", "p" ) )
if \x[ 1 ] then every mani( !x )
else
    { q := open( "/home/roy/.slrn-stickytags", "crw" ) | stop( "unable to create slrn-stickytags" )
    s4 := open( "/home/roy/News/spool/newupd.conf" ) | stop( "no slrnpull conf file" )
    s5 := open( "/home/roy/News/spool/scoring", "crw" ) | stop( "unable to create scoring" )
    write( s5, "[*]\nScore: 1\nDate:", u )
    while a := read( s4 ) do
	{ if a[ 1 ] == "#" then next 
	put( d, a )
	} 
    every man( !d )
    }
end

procedure man( s )
n := open( "ls " || s, "p" ) | stop( "unable to list ", s )
while p := read( n ) do 
    { numeric( p ) | next
    a := open( s2 := s || p, "rw" ) | stop( "unable to open a:", s2 )
    g := read( a )
    if g == "X-URL: " then
	{ close( a )
	next
	} 
    else 
	{ t := open( s3 := s2 || "new", "crw" ) | stop( "unable to open t:", s3 )
	write( t, "X-URL: \n", g )
	while b := read( a ) do
	    { case b[1:7] of {
		"Messag" : write( q, b[13:0] )
		"Date: " : { write( t, b, u ) 
		    next 
		    }
		}
	    write( t, b )
	    }
	}
    close( a )
    close( t )
    system( "mv " || s3 || " " || s2 )
    }
close( n )
write( "finished ", s )
return
end

procedure mani( si )
ti := "/home/roy/News/spool/news/" || si || "/"
n := open( "ls " || ti, "p" ) | stop( "unable to list ", s )
write( "initializing ", ti, "..." )
while p := read( n ) do 
    { numeric( p ) | next
    a := open( s2 := ti || p, "rw" ) | stop( "unable to open a:", s2 )
    t := open( s3 := s2 || "new", "crw" ) | stop( "unable to open t:", s3 )
    write( t, "X-URL: " )
    while b := read( a ) do write( t, b )
    close( a )
    close( t )
    system( "mv " || s3 || " " || s2 )
    }
close( n )
write( "done" )
return
end
		    

-- 
"The world of existence is an emanation of the merciful attribute of God."
Abdu'l-Baha
http://www.costarricense.cr/pagina/ernobe
Re: [slrn] Solution to the age-old question
#255480
Author: ernobe
Date: Thu, 12 Sep 2013 20:57
84 lines
4315 bytes
>
> I've resolved the above problem of having to download within the fixed time 
> specified in the code.  Instead of changing the date, it is possible to add a 
> number to the date line and use it to score the article ( it still reads the 
> date OK ), and to obtain its message id and place it in the stickytags file.  
> That way the tag is permanent ( until the next download ) and the number 
> placed in the date line makes it possible to organize the results by score 
> in the article pane.
>

Ok, I've had a look at what's going on in the news directories of the spool, 
and figured out how to spot the newest articles there.  With the -t option of 
the list command in Linux, it is possible to list the articles by the time 
they are added to the directories.  By saving the name of the latest article 
in the Icon programs' configuration file it is possible to obtain the 
message-ids from all the newer ones, which appear following it.  Then the 
message-ids are added to the .slrn-stickytags file and to a score file.  So 
now the Icon program does the same as the previous one but has been greatly 
simplified and runs much faster.  The articles are not modified in any way and 
it is not necessary to run slrnpull in rebuild mode.  To initialize new groups 
simply add them to the configuration file after the first download.

procedure main()
q := open( "/home/roy/.slrn-stickytags", "crw" ) | stop( "unable to create slrn-stickytags" )
g := open( "/home/roy/News/spool/newupd.conf" ) | stop( "no slrnpull conf file" )
m := open( "/home/roy/News/spool/newupdi.conf", "crw" ) | stop( "unable to create newupdi.conf" )
u := open( "/home/roy/News/spool/scoring", "crw" ) | stop( "unable to create scoring" )
write( u, "[*]\nScore:: 1" )
while a := read( g ) do
    { a ? 
	{ y := tab( upto( ' ' ) | 0 ) 
        move( 1 )
        i := tab( 0 )
        }
    if *trim( y ) = 0 then break
    ( z := numeric( i ) ) | write( "initializing ", y, "..." )
    n := open( "ls -t " || y, "p" ) | stop( "unable to list ", y )
    while p := read( n ) do 
	{ ( o := numeric( p ) ) | break 
	if /z then 
	    next 
	else 
	    if o = z then 
		while p := read( n ) do 
		    { ( o := numeric( p ) ) | break
    		    j := open( y || p ) | stop( "unable to open ", y, p )
		    while b := read( j ) do
			{ if b[1:7] == "Messag" then 
			    { write( q, b[13:0] )
			    write( u, b ) 
			    break
			    }
			}
		    close( j )
		    }
	}
    close( n )
    \o | { write( "you must run slrnpull with ", y, " in slrnpull.conf" )
	write( m, y )
	next
	}
    write( m, y, " ", o )
    write( "finished     ", y )
    o := &null
    }
close( m )
close( g )
system( "mv /home/roy/News/spool/newupdi.conf /home/roy/News/spool/newupd.conf" )
end
		    
Sample configuration file:

/home/roy/News/spool/news/sci/logic/ 109183
/home/roy/News/spool/news/news/software/readers/ 24772
/home/roy/News/spool/news/alt/philosophy/zen/ 113729
/home/roy/News/spool/news/alt/philosophy/ 325656
/home/roy/News/spool/news/alt/atheism/ 1615025


-- 
"The world of existence is an emanation of the merciful attribute of God."
Abdu'l-Baha
http://www.costarricense.cr/pagina/ernobe
Re: [slrn] Solution to the age-old question
#255479
Author: ernobe
Date: Thu, 12 Sep 2013 21:34
11 lines
1682 bytes
I just realized that the -t option of the Linux list command arranges the 
articles by newest first.  Will have to modify the program of my latest post 
accordingly, though it works as advertized if you remove the -t option from 
the source code ( and your server provides the articles in numerical order ).


-- 
"The world of existence is an emanation of the merciful attribute of God."
Abdu'l-Baha
http://www.costarricense.cr/pagina/ernobe
Re: [slrn] Solution to the age-old question
#255492
Author: ernobe
Date: Sat, 14 Sep 2013 14:29
86 lines
4326 bytes
>
> I just realized that the -t option of the Linux list command arranges the 
> articles by newest first.  Will have to modify the program of my latest post 
> accordingly, though it works as advertized if you remove the -t option from 
> the source code ( and your server provides the articles in numerical order ).
>
>

The -t option to the Linux ls command lists the articles by newest first, as 
in 'ls -lt'.  But if they have been placed in the directory quicker than about 
a second apart, they are listed by name.  So the following program examines 
the date by day, hour, and minute.  The articles names are irrelevant ( they 
only must be numerical ), and the configuration file keeps a record of the 
time the last article was downloaded.  When the program reaches an article 
with that date, it stops processing that newsgroup.  If for some reason you 
only want to update some of the groups, do nothing to the configuration file, 
just don't use slrnpull to download any new articles from that group.  To 
initialize a new group, add its full path ending with a slash to the 
configuration file ( after downloading articles from it ).

I think it would be a good idea to have it report if it didn't find a 
message-id in an article.  Just to keep tabs on the servers' behaviour.  
Anyway, I'll leave it on the wishlist for now.

procedure main()
no := po := 0
q := open( "/home/roy/.slrn-stickytags", "crw" ) | stop( "unable to create slrn-stickytags" )
g := open( "/home/roy/News/spool/newupd.conf" ) | stop( "no slrnpull conf file" )
m := open( "/home/roy/News/spool/newupdi.conf", "crw" ) | stop( "unable to create newupdi.conf" )
u := open( "/home/roy/News/spool/scoring", "crw" ) | stop( "unable to create scoring" )
write( u, "[*]\nScore:: 1" )
while a := read( g ) do
    { a ? 
	{ y := tab( upto( ' ' ) | 0 ) 
        move( 1 )
        i := tab( 0 )
        }
    if *trim( y ) = 0 then break
    ( z := numeric( i )) | write( "initializing ", y, "..." )
    n := open( "ls -lt --time-style=+:%j%H%M " || y, "p" ) | stop( "unable to list ", y )
    while p := read( n ) do 
	{ p ? 
	    { &pos := (( upto( ':' ) + 1 ) | next )
		kk := move( 7 )
		move( 1 )
		k := ( numeric( tab( 0 )) | next )
	    }
	no +:= 1
	if no = 1 then nn := kk      
	if /z | ( kk = z ) then  
	    break 
	else 
	    { j := open( y || k ) | stop( "unable to open ", y || k )
	    while b := read( j ) do
		{ if b[1:7] == "Messag" then 
		    { write( q, b[13:0] )
		    write( u, b ) 
		    break
		    }
		}
	    close( j )
	    }
	}
    close( n )
    ( no > 0 ) | { write( "you must run slrnpull with ", y, " in slrnpull.conf" )
	write( m, y )
	next
	}
    write( m, y, " ", nn )
    write( "finished     ", y )
    po +:= no - 1
    no := 0
    }
close( m )
close( g )
system( "mv /home/roy/News/spool/newupdi.conf /home/roy/News/spool/newupd.conf" )
write( "added ", po, " new posts" )
end


		    
-- 
"The world of existence is an emanation of the merciful attribute of God."
Abdu'l-Baha
http://www.costarricense.cr/pagina/ernobe
Re: [slrn] Solution to the age-old question
#255498
Author: ernobe
Date: Sun, 15 Sep 2013 22:43
38 lines
3086 bytes
>
>>
>> I just realized that the -t option of the Linux list command arranges the 
>> articles by newest first.  Will have to modify the program of my latest post 
>> accordingly, though it works as advertized if you remove the -t option from 
>> the source code ( and your server provides the articles in numerical order ).
>>
>>
>
> The -t option to the Linux ls command lists the articles by newest first, as 
> in 'ls -lt'.  But if they have been placed in the directory quicker than about 
> a second apart, they are listed by name.  So the following program examines 
> the date by day, hour, and minute.  The articles names are irrelevant ( they 
> only must be numerical ), and the configuration file keeps a record of the 
> time the last article was downloaded.  When the program reaches an article 
> with that date, it stops processing that newsgroup.  If for some reason you 
> only want to update some of the groups, do nothing to the configuration file, 
> just don't use slrnpull to download any new articles from that group.  


I've found out the hard way this does not work as expected.  It unsubscribes 
the group and when you subscribe again all read articles are marked unread.  
One way around this is to make a copy of your .slrn-stickytags file, then 
enter the group and tag all the articles.  Then delete the groups entry from 
slrnpull.conf and download the other groups as usual.  After subscribing to it 
next time, enter the group and do a catch-up "c", exit slrn, re-instate your 
original .slrn-stickytags file and you're done.  That's one real use for 
stickytags.  But in my opinion, if slrn had a "go to previous high scoring 
article" keystroke and scored articles the way it tags them, stickytags would 
be useless.



-- 
"The world of existence is an emanation of the merciful attribute of God."
Abdu'l-Baha
http://www.costarricense.cr/pagina/ernobe
Re: [slrn] Solution to the age-old question
#255518
Author: ernobe
Date: Tue, 24 Sep 2013 19:06
103 lines
4971 bytes
>
>>
>> I just realized that the -t option of the Linux list command arranges the 
>> articles by newest first.  Will have to modify the program of my latest post 
>> accordingly, though it works as advertized if you remove the -t option from 
>> the source code ( and your server provides the articles in numerical order ).
>>
>>
>
> The -t option to the Linux ls command lists the articles by newest first, as 
> in 'ls -lt'.  But if they have been placed in the directory quicker than about 
> a second apart, they are listed by name.  So the following program examines 
> the date by day, hour, and minute.  The articles names are irrelevant ( they 
> only must be numerical ), and the configuration file keeps a record of the 
> time the last article was downloaded.  When the program reaches an article 
> with that date, it stops processing that newsgroup.  If for some reason you 
> only want to update some of the groups, do nothing to the configuration file, 
> just don't use slrnpull to download any new articles from that group.  To 
> initialize a new group, add its full path ending with a slash to the 
> configuration file ( after downloading articles from it ).
>
> I think it would be a good idea to have it report if it didn't find a 
> message-id in an article.  Just to keep tabs on the servers' behaviour.  
> Anyway, I'll leave it on the wishlist for now.
>
> procedure main()
> no := po := 0
> q := open( "/home/roy/.slrn-stickytags", "crw" ) | stop( "unable to create slrn-stickytags" )
> g := open( "/home/roy/News/spool/newupd.conf" ) | stop( "no slrnpull conf file" )
> m := open( "/home/roy/News/spool/newupdi.conf", "crw" ) | stop( "unable to create newupdi.conf" )
> u := open( "/home/roy/News/spool/scoring", "crw" ) | stop( "unable to create scoring" )
> write( u, "[*]\nScore:: 1" )
> while a := read( g ) do
>     { a ? 
> 	{ y := tab( upto( ' ' ) | 0 ) 
>         move( 1 )
>         i := tab( 0 )
>         }

The following code terminates program in case of empty string at the end of 
the configuration file:

>     if *trim( y ) = 0 then break

This checks if there is empty string instead of date number following the 
groups' path in the configuration file ( in which case initialization of it 
begins ):

>     ( z := numeric( i )) | write( "initializing ", y, "..." )
>     n := open( "ls -lt --time-style=+:%j%H%M " || y, "p" ) | stop( "unable to list ", y )
>     while p := read( n ) do 
> 	{ p ? 
> 	    { &pos := (( upto( ':' ) + 1 ) | next )
> 		kk := move( 7 )
> 		move( 1 )
> 		k := ( numeric( tab( 0 )) | next )
> 	    }
> 	no +:= 1
> 	if no = 1 then nn := kk      
> 	if /z | ( kk = z ) then  
> 	    break 
> 	else 
> 	    { j := open( y || k ) | stop( "unable to open ", y || k )
> 	    while b := read( j ) do
> 		{ if b[1:7] == "Messag" then 
> 		    { write( q, b[13:0] )
> 		    write( u, b ) 
> 		    break
> 		    }
> 		}
> 	    close( j )
> 	    }
> 	}
>     close( n )
>     ( no > 0 ) | { write( "you must run slrnpull with ", y, " in slrnpull.conf" )
> 	write( m, y )
> 	next
> 	}
>     write( m, y, " ", nn )
>     write( "finished     ", y )
>     po +:= no - 1
>     no := 0
      z := &null
>     }
> close( m )
> close( g )
> system( "mv /home/roy/News/spool/newupdi.conf /home/roy/News/spool/newupd.conf" )
> write( "added ", po, " new posts" )
> end
>
>
> 		    

The above addition to the code is necessary to have it properly identify  
when a new group is added to be initialized ( in the configuration file ).



-- 
"The world of existence is an emanation of the merciful attribute of God."
Abdu'l-Baha
http://www.costarricense.cr/pagina/ernobe
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads