Thread View: news.software.readers
5 messages
5 total messages
Started by ernobe
Fri, 23 Jul 2010 16:56
[slrnpull] Logging of retrieved articles?
Author: ernobe
Date: Fri, 23 Jul 2010 16:56
Date: Fri, 23 Jul 2010 16:56
11 lines
1605 bytes
1605 bytes
I'm thinking of delving into the slrnpull code to see if I can keep a log of retrieved messages. These could be used as part of my clean threads macro ( mentioned in the true offline mode thread ) so that the new messages can be tagged, and threads will then show read, unread, and new messages. Does anyone have any ideas on how to go about this? -- "The world of existence is an emanation of the merciful attribute of God." Abdu'l-Baha http://www.costarricense.cr/pagina/ernobe
Re: [slrnpull] Logging of retrieved articles?
Author: W. Citoan
Date: Sat, 24 Jul 2010 01:04
Date: Sat, 24 Jul 2010 01:04
19 lines
2138 bytes
2138 bytes
ernobe wrote: > I'm thinking of delving into the slrnpull code to see if I can keep a > log of retrieved messages. These could be used as part of my clean > threads macro ( mentioned in the true offline mode thread ) so that > the new messages can be tagged, and threads will then show read, > unread, and new messages. Does anyone have any ideas on how to go > about this? While you could hack slrnpull to do that, it would seem easier to just right an external script / program to parse the spool and use a batch file to run it right after running slrnpull. Saves having to worry about the slrnpull code or merging changes in the future. - W. Citoan -- It is easy to go down into Hell; night and day, the gates of dark Death stand wide; but to climb back up again, to retrace one's steps to the upper air - there's the rub, the task. -- Publius Vergilius Maro (Virgil)
Re: [slrnpull] Logging of retrieved articles?
Author: ernobe
Date: Sat, 24 Jul 2010 21:25
Date: Sat, 24 Jul 2010 21:25
85 lines
4174 bytes
4174 bytes
> I'm thinking of delving into the slrnpull code to see if I can keep a log of
> retrieved messages. These could be used as part of my clean threads macro (
> mentioned in the true offline mode thread ) so that the new messages
> can be tagged, and threads will then show read, unread, and new messages.
> Does anyone have any ideas on how to go about this?
>
I don't know how to do it with S-Lang, but here is Icon code (
http://cs.arizona.edu/icon ) that will do it. If you use Linux/Unix your
distribution probably has custom made packages for it, or else it is easy to
install from the website. This program produces three files in the directory
it is run in: all headers, all bodies, and new bodies. It takes a single
argument, and that is the directory path of the slrnpull spool directory for
the group. To be on the safe side don't end the path with a slash. The names
of the files produced is taken from the directory path, and consists of all
the letters following the slashes. This has been tested on my Debian unstable
installation. It will require some tweaking for a Windows installation
because the details of accessing the files and writing to the directories
varies. In the first run, the yourdirname-allbodies and yourdirname-newbodies
files will be identical since all bodies are new bodies. Then go to slrn,
request some bodies for that group, and re-run the program in the same
directory you ran it the first time (after getting the bodies with slrnpull).
The yourdirname-newbodies file should have the header numbers of the new
messages.
procedure main( s )
f := \s[ 1 ] | stop( "missing directory argument" )
g := ""
k := []
iii := []
yyy := []
f ? { while tab( upto( '/' ) + 1 ) do {
g ||:= move( 1 ) }
}
g1 := g || "-spool"
g2 := g || "-bodies"
g3 := g || "-allbodies"
g4 := g || "-newbodies"
system( "ls " || f || " > " || g1 )
n := open( f || "/.headers", "rw" ) | stop( "unable to open directory" )
i := open( g1, "rw" )
j := open( g2, "crw" )
y := open( g3, "rw" | "crw" )
s := open( g4, "crw" )
nn := read( n )
close( n )
nn ? {
repeat {
nnn := tab( upto( ',' ) | 0 )
if numeric( nnn ) then {
put( k, integer( nnn ) )
move( 1 ) | break
next
}
nnn ? {
kk := integer( tab( upto( '-' ) ) )
move( 1 )
kkk := integer( tab( 0 ) )
put( k, kk )
while kk +:= 1 do {
put( k, kk )
if kk = kkk then break
}
}
move( 1 ) | break }
}
while ii := read( i ) do {
put( iii, integer( ii ) ) }
while yy := read( y ) do {
put( yyy, integer( yy ) ) }
jj := set( iii ) -- set( k )
ss := jj -- set( yyy )
every write( j, !jj )
every write( s, !ss )
close( j )
close( y )
system( "mv " || g2 || " " || g3 )
end
--
"The world of existence is an emanation of the merciful attribute of God."
Abdu'l-Baha
http://www.costarricense.cr/pagina/ernobe
Re: [slrnpull] Logging of retrieved articles?
Author: ernobe
Date: Fri, 06 Aug 2010 00:01
Date: Fri, 06 Aug 2010 00:01
421 lines
15779 bytes
15779 bytes
Here's an expanded version of it, which includes code that will write slrn
macros to tag the retrieved articles. I've been unable to get slrn to
automatically subscribe new groups, even setting unsubscribe_new_groups to 0
and check_new_groups to 1 explicitly in .slrnrc. Consequently, the
group_mode_startup_hook that the program creates does not recognize new groups
that have article bodies downloaded in accordance with the slrnpull score
file. But this is only the first run, you have to subscribe to the new
groups first, then the macro will set the GROUP_NEW_GROUP_FLAG on it ( N ) to
signal that it is one of the groups that has tagged articles. The program
runs slrn with a special group_mode_startup_hook that only enters and quits
the groups that have tagged articles, and then exits, in order to avoid
loosing tagged articles if the groups are not entered before another run of
slrnpull. So as the program stands, it is necessary to manually
subscribe and enter new groups that have tagged articles, before the next run
of slrnpull. Otherwise tagged articles could be lost in the ( somewhat rare
) eventuality that newer bodiless headers were received in the same thread as
the downloaded article bodies, and the threads OP is not present. Since the
program removes the old tags when the new articles are received, there is
nothing stopping the cleanthreads macro ( see below ) from deleting it and the
whole thread. It is necessary to enter the group once so that the tag
will prevent the cleanthreads macro from deleting it along with the rest of
the thread. Then the tag can be removed and it will cause the cleanthreads
macro to rebuild the thread the second time the group is entered. You will
have to edit four lines of the program according to your setup, and these are:
1. The location of your slrnpull conf file
2. The slrnpull command line
3. The location of where this program will keep its files
4. The location of the slrnpull spool directory
Also, for the call to slrn you need a copy of your .slrnrc file in the
directory you run this in, unless you edit that too. It must contain the
three calls to the macros being used ( two of which were created by the
program itself, and if you edited the location of the new .slrnrc file you
have to edit their location as well ):
interpret cleanthreads.sl
interpret mythreads.sl
interpret groups.sl
procedure main()
v := []
d := []
e := []
s := open( "/home/roy/spool/slrnpull.conf" ) | stop( "no slrnpull conf file" )
while s1 := read( s ) do {
if s1[ 1 ] == "#" then next
s1 ? {
s2 := tab( upto( ' ' ) | 0 )
if s2 == ( "default" | "" ) then next
else put( d, s2 )
} }
system( "slrnpull -d /home/roy/spool --fetch-score 1" ) | exit()
every put( v, m1( !d ) )
if *v > 0 then {
m := open( "mythreads.sl", "crw" )
n := open( "groups.sl", "crw" )
write( m, "define my_groups ()\n{ variable mm = current_newsgroup (),dma,hhh,list;" )
every b := !v do {
b1 := get( b )
b2 := get( b )
b3 := get( b )
write( m, "variable " || b[ 2 ] || "_threads = {" )
every u := open( b3 || "/" || !b1, "r" ) do
{
b2 -:= 1
while c := read( u ) do {
( c[ 1:9 ] == "Message-" ) & break
}
writes( m, "\"", c[ 13:0 ], "\"" )
if b2 > 0 then write( m, "," )
close( u )
}
write( m, " };" )
put( e, b )
}
write( m, "switch (mm)" )
every e1 := !e do {
write( m, "{ case \"", e1[ 1 ], "\" : list = ", e1[ 2 ] || "_threads; }" )
}
write( m, "{ list = {}; }\nhhh = length (list);\nwhile (hhh)\n{ hhh--;\n",
"dma = list[hhh];\nif (1 == locate_header_by_msgid (dma,0))\n",
"set_header_flags (12); }\ncollapse_threads ();\nmake_clean_threads (); }\n",
"() = register_hook (\"article_mode_startup_hook\",\"my_groups\");\n",
"define group_mode_startup_hook ()\n{variable dma, hhh, news = {" )
write( n, "define group_mode_startup_hook ()\n{variable dma, hhh, news = {" )
while e2 := get( e ) do {
writes( n, "\"", !e2, "\"" )
writes( m, "\"", !e2, "\"" )
if *e > 0 then { write( n, "," ); write( m, "," ) } }
write( n, " };\nhhh = length (news);\nwhile (hhh)\n{ hhh--;\ndma = news[hhh];\n",
"set_group_order (dma);\ngroup_up_n (1);\nif (dma == current_newsgroup ())\n",
"{select_group ();\ncall(\"quit\");}}\ncall(\"quit\");}" )
write( m, " };\nhhh = length (news);\nwhile (hhh)\n{ hhh--;\ndma = news[hhh];\n",
"set_group_order (dma);\ngroup_up_n (1);\nset_group_flags (2); } }" )
# must uncomment this to view the number of messages for each group ( see below )
# delay( 5000 )
system( "slrn -n -w0 -i groupmoderc --debug slrnfile" )
}
end
procedure m1( s )
s2 := ""
f := "/home/roy/spool/news/"
g := ""
k := []
g1 := "/home/roy/clean/"
g6 := []
g7 := []
s ? { while s1 := tab( upto( '.' ) ) do {
f ||:= s1 || "/"
s2 ||:= s1[ 1:2 ]
move( 1 ) }
s3 := tab( 0 )
f ||:= s3
s2 ||:= s3[ 1:4 ]
every g ||:= ( !s2 ** &letters )
}
n := ( open( f || "/.headers" ) | "" )
n1 := !n
\n1 ? {
repeat {
n2 := tab( upto( ',' ) | 0 )
if numeric( n2 ) then {
put( k, integer( n2 ) )
move( 1 ) | break
next
}
n2 ? {
k1 := integer( tab( upto( '-' ) ) )
move( 1 )
k2 := integer( tab( 0 ) )
put( k, k1 )
while k1 +:= 1 do {
put( k, k1 )
if k1 = k2 then break
}
}
move( 1 ) | break }
}
g2 := g1 || g || "-spool"
system( "ls " || f || " > " || g2 ) | stop( "unable to open directory" )
g3 := open( g2, "rw" )
g4 := g1 || g || "-allbodies"
g5 := open( g4, "rw" | "crw" )
# get existing headers and bodies
while put( g6, integer( read( g3 ) ) )
while put( g7, integer( read( g5 ) ) )
# find new total bodies and newer bodies
g8 := set( g6 ) -- set( k )
g9 := g8 -- set( g7 )
h := *g9
# if uncommented, this prints the number of new bodies for each group ( see above )
# write( s, ": ", h, " new messages" )
if h > 0 then {
g01 := g1 || g || "-bodies"
g02 := open( g01, "crw" )
g03 := open( g1 || g || "-newbodies", "crw" )
every write( g02, !g8 )
every write( g03, !g9 )
close( g02 )
close( g03 )
system( "mv " || g01 || " " || g4 )
return [ g9, h, f, s, g ] }
end
I'm wouldn't be posting this if I wasn't pretty certain it works as
advertized. It has been tested and corrected in every part that could
have errors. The only requirement for regular slrn use is to have
'interpret' lines for two of the macros ( without the groups.sl macro ). Here
is a copy of my current mythreads.sl macro:
define my_groups ()
{ variable mm = current_newsgroup (),dma,hhh,list;
variable apzen_threads = {
"<-c6dnZqA1_jX1GDWnZ2dnUVZ_q2dnZ2d@earthlink.com>" };
switch (mm)
{ case "alt.philosophy.zen" : list = apzen_threads; }
{ list = {}; }
hhh = length (list);
while (hhh)
{ hhh--;
dma = list[hhh];
if (1 == locate_header_by_msgid (dma,0))
set_header_flags (12); }
collapse_threads ();
make_clean_threads (); }
() = register_hook ("article_mode_startup_hook","my_groups");
define group_mode_startup_hook ()
{variable dma, hhh, news = {
"alt.philosophy.zen" };
hhh = length (news);
while (hhh)
{ hhh--;
dma = news[hhh];
set_group_order (dma);
group_up_n (1);
set_group_flags (2); } }
There is only one message-id for one newsgroup, both of which could obviously
be multiple. But this is enough to see what it's doing. Then here is the
groups.sl macro:
define group_mode_startup_hook ()
{variable dma, hhh, news = {
"alt.philosophy.zen" };
hhh = length (news);
while (hhh)
{ hhh--;
dma = news[hhh];
set_group_order (dma);
group_up_n (1);
if (dma == current_newsgroup ())
{select_group ();
call("quit");}}
call("quit");}
As you can see, they both define the group_mode_startup_hook, so the latter
is used when running slrnpull, the former when running slrn. Then here is the
make_clean_thread function:
define make_clean_threads ()
{
variable amd, dma, hhh, list;
list = {};
call ("header_bob");
do
{
if (not ("" == extract_article_header ("References")))
{
if (1 == get_body_status ())
{
call ("delete");
header_up (1);
}
else
{
amd = extract_article_header ("Message-ID");
list_insert (list, amd);
}
}
else if (1 == thread_size ())
set_header_flags (HEADER_HIGH_SCORE);
}
while (header_down (1));
call ("expunge");
hhh = length (list);
while (hhh)
{
hhh--;
dma = list[hhh];
() = locate_header_by_msgid (dma,0);
set_prefix_argument (2);
call ("get_parent_header");
}
collapse_threads ();
call("header_bob");
() = header_next_unread ();
}
The difference between this definition and the one given in the true offline
mode thread is that it sets a high score on posts that have no replies, and
moves the cursor to the next unread post. This is all that is required for
the Icon program to work. The others, mentioned below are complementary to
the offline mode way of doing things. It really doesn't make sense using this
unless some configuration variables are set in slrn:
server 'your slrnpull spool directory' 'your newsrc file'
set server_object "spool"
set sorting_method 12
set custom_sort_by_threads 1
set custom_sort_order "Highscore,body,lines|Body"
The capitalized body entry above ensures that articles with bodies will be
displayed first inside the threads.
set post_object "nntp"
set read_active 1
The read_active is set because you will use it instead of the nntp server to
subscribe to new groups. To add a group first add it to the slrnpull conf
file, as mentioned previously, then it will add it to the active
file, and unless this is set slrn will not find it.
set spool_inn_root "your slrnpull spool directory"
set spool_root "the spool directory news directory"
set spool_nov_root "same as above"
% These are relative to spool_inn_root unless they start with "/".
set spool_active_file "data/active"
% This value is relative to the directories under spool_nov_root:
set spool_nov_file ".overview"
set spool_check_up_on_nov 1
header_display_format 0 "%F%B %?C?%3c? %?P?%T%3l&%3l%15g%s? %r"
set overview_date_format " %d %b %H:%M"
set top_status_line " %d%-9g%t"
set header_status_line " Group: %n%-4g%P"
set art_status_line " %s %-4g%P"
set group_status_line " "
set group_help_line ""
set header_help_line ""
set art_help_line ""
set use_header_numbers 0
visible_headers ""
setkey article article_line_down "<Down>"
setkey article article_line_up "<Up>" % Scroll article up one line
setkey article article_page_down "<Space>" % Scroll article down one page
setkey article article_page_up "b" % Scroll article up one page
setkey article article_left "<" % Pan article to the left
setkey article article_right ">" % Pan article to the right
setkey article header_line_down "<PageDown>" % Move to next article
setkey article header_line_up "<PageUp>" % Move to previous article
setkey article header_page_up "<Backspace>"
% setkey article delete ( see below ) "d" % Mark article as read
setkey article hide_article "/" % Hide/Show the article window
setkey article toggle_collapse_threads "<Return>" % Collapse/Uncollapse thread
Here are some more definitions from the cleanthreads macro that
deal with posting, they call another Icon program that writes an slrnpull
scorefile to retrieve replies to it ( given below ).
define mycont_followup ()
{
variable cmd = "mycont", mdo, amd = current_newsgroup ();
call ("followup");
mdo = get_variable_value ("save_posts");
() = system (sprintf ("%s '%s' '%s'", cmd, mdo, amd));
}
define mycont_post ()
{
variable cmd = "mycont", mdo, amd = current_newsgroup ();
call ("post");
mdo = get_variable_value ("save_posts");
() = system (sprintf ("%s '%s' '%s'", cmd, mdo, amd));
}
define fudge_save_file ()
{
variable tm = localtime (_time ());
set_string_variable ("save_posts",
sprintf ("/home/roy/News/sent/%d%02d%02d-%02d%02d%02d.news",
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
tm.tm_hour, tm.tm_min, tm.tm_sec ));
}
() = register_hook ("post_file_hook", "fudge_save_file");
These are some definitions for navigating threads that have read articles:
define going_down ()
{
header_down (1);
article_line_down (1);
}
define going_up ()
{
header_up (1);
article_line_down (1);
}
This is one that replaces the delete function so that the next unread header
isn't jumped to after deleting one.
define del_my_tagged ()
{
variable amd;
if (0 == is_thread_collapsed ())
{
set_header_flags (HEADER_READ);
header_down (1);
}
else
{
uncollapse_thread ();
amd = thread_size ();
amd--;
while (amd)
{
amd--;
set_header_flags (HEADER_READ);
header_down (1);
}
set_header_flags (HEADER_READ);
collapse_thread ();
header_down (1);
}
}
definekey ("mycont_followup", "8", "article");
definekey ("mycont_post", "9", "article");
definekey ("going_down", "<Right>", "article");
definekey ("going_up", "<Left>", "article");
definekey ("del_my_tagged", "d", "article");
And finally here is the Icon program that writes the slrnpull scorefile:
procedure main( s )
r := open( s[ 1 ], "rw" ) | exit()
n := open( "/home/roy/spool/score", "rw" )
while b := read( r ) do {
case b[ 1:9 ] of {
"Subject:" : sub := b
"Message-" : mes := b[ 13:0 ] }
\sub & \mes & break
}
seek( n, 0 )
write( n, "[", s[ 2 ], "]", "\n",
"Score: 1", "\n",
"% ", sub, "\n",
"References: ", mes )
close( r )
close( n )
end
--
"The world of existence is an emanation of the merciful attribute of God."
Abdu'l-Baha
http://www.costarricense.cr/pagina/ernobe
Re: [slrnpull] Logging of retrieved articles?
Author: ernobe
Date: Fri, 06 Aug 2010 14:52
Date: Fri, 06 Aug 2010 14:52
30 lines
2874 bytes
2874 bytes
> set read_active 1 > > The read_active is set because you will use it instead of the nntp server to > subscribe to new groups. To add a group first add it to the slrnpull conf > file, as mentioned previously, then it will add it to the active > file, and unless this is set slrn will not find it. > 'As mentioned previously': I meant that the program first reads the slrnpull conf file, the only additional requirement of which is that entries begin at the beginning of the line. Slrnpull is called, and then the program checks to see if there are new article bodies present in the spool. If there are, it writes an slrn macro to tag them, and if there aren't, it does nothing to the existing slrn setup. Tagged articles will continue to have tags until you explicitly delete the article or newer article bodies are received, at which point the Icon program will renew the slrn macro thus removing the tags. So you will always be seeing two sorts of unread articles with bodies: old ones and not so old ones. This is one reason I don't set a date in the header display format, since I'm always up-to-date with the newest articles, via tags. If I'd have a very complicated slrnpull scorefile to download all sorts of articles, I suppose it would be because I would be keeping track of a-lot more than the date. That's the good thing of offline mode: the complications arrive if and when you choose them, and not because of the complication in threads extraneous to the threads of interest. -- "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