flnews_post_proc 1.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f76e4432bd460f49ef15abd469ac4f79e1c4887c99229620b0a79ec9cb8ad836
4
+ data.tar.gz: a6416c6b5f53bdfb9995e1b64accadf97a18fbb2b2dc69b36f4aff86e38f35e3
5
+ SHA512:
6
+ metadata.gz: 4f331c0092c7ffeb7ac6b8ee485de68a8ad30534166b65b6be049d6b1d16a3a0a7754396da615dc397a6dd17ffdbf555363e4d41576a604963d09b21c4834031
7
+ data.tar.gz: 057cf2f67069ac2708d8b2444a6339b4671415bd55e86662f23d2ced0d95e5a7e80b69c3514123dab71a1edceab3717f346de7c876119c7c68bb6f31179dc3bb
data/README.md ADDED
@@ -0,0 +1,374 @@
1
+ flnews_post_proc
2
+ =======================
3
+ Post-Processor for the flnews newsreader
4
+ ------------------------------------------
5
+
6
+ **IMPORTANT**
7
+ Please give priority to the documentation which is delivered with the gem
8
+ file, as the markdown syntax plays tricks, sometimes, and I may not be
9
+ quick enough to correct this file. This applies especially to the section
10
+ [_Configuration_](#CONFIGURATION), below.
11
+
12
+ The gem-file contains different formats of the man-page in English and French.
13
+ See section [_Source Code_](Source-Code), below, for instructions to access
14
+ these texts. Or see the same files [on the
15
+ Web](https://www.uplawski.eu/div/flnews/).
16
+
17
+ SYNOPSIS
18
+ =======================
19
+
20
+ An article is piped-in to the post-processor. This is normally done
21
+ automatically as soon as the variable “post_proc“ in the flnews configuration
22
+ file is set to the flnews_post_proc executable, i.e.:
23
+
24
+ **post_proc : /usr/local/bin/flnews_post_proc**
25
+
26
+ Locally stored articles can be piped in to the post-processor, as needed
27
+ for testing purposes, with a command-line like the following:
28
+
29
+ **flnews_post_proc < article**
30
+
31
+ INSTALLATION
32
+ =============
33
+ You must have a Ruby interpreter installed (see [ruby-lang.org](https://www.ruby-lang.org) ).
34
+ Your Linux distribution will probably let you choose one from its
35
+ software resources. Use the package management utility of your choice.
36
+
37
+ While you can download the current gem file for flnews_post_proc from
38
+ *[rubygems.org](https://www.rubygems.org)*, it is probably best to use the “gem”-utility
39
+ for the installation. It should be available from the same source as your
40
+ Ruby interpreter.
41
+
42
+ With the interpreter and the gem utility in place, the installation effort is
43
+ reduced to a simple command:
44
+ user@machine:~$ **sudo gem install flnews_post_proc**
45
+
46
+ This way, the gem file will be downloaded from rubygems.org and installed in
47
+ the designated path for ruby-gems. If the installation completes without
48
+ errors, the command **flnews_post_proc** will become immediately available.
49
+
50
+ For other uses of the gem utility, see the output of
51
+ user@machine:~$ **gem --help**
52
+
53
+ DESCRIPTION
54
+ =======================
55
+ The flnews newsreader is sufficient for Usenet access, i.e. to receive and read
56
+ articles from -, as well as to write and post articles to newsgroups.
57
+
58
+ When you compare news-clients, you will always notice the differences and
59
+ choose the software that you prefer. Flnews however, has the charm that you can
60
+ influence how the program itself works but also modify posts that flnews
61
+ produces, just before the program will transmit them to the chosen nntp-server.
62
+
63
+ The flnews_post_proc can add and change details of a post, in ways that are
64
+ currently not possible with flnews alone. As the program is configurable, it
65
+ can probably respond to the needs of some Usenet users. You should, however,
66
+ rather take it as an example for what can be done and an inspiration for your
67
+ own creations.
68
+
69
+ The limits of a basic newsreader — what the program can do
70
+ ----------------------------------------------------------
71
+ While the articles that flnews creates, are complete and ready to be posted,
72
+ some users may not always agree with the result and for arbitrary reasons:
73
+
74
+ * There may be inconveniences when you post to different newsgroups in
75
+ different languages, as an introductory line which refers to a previous
76
+ post can only be set once in the flnews configuration. The consequence
77
+ can be that your post to a french newsgroup begins with an introduction
78
+ in English.
79
+ The post-processor program can set an introductory line specifically
80
+ chosen for one or several newsgroups.
81
+
82
+ * The same conflict arises, when you have set a standard signature text and
83
+ would like to replace it against another, based on the newsgroup you are
84
+ about to post to.
85
+ The post-processor program sets specific signatures as configured for one
86
+ or several newsgroups.
87
+
88
+ * Some custom headers may serve to convey additional information to
89
+ interested readers of your post, like GnuPG key IDs, your language skills
90
+ or the like. The signature may be a better choice than custom headers.
91
+ You are free. I just mention face and x-face but prefer that you do not
92
+ remember I did.
93
+ Custom headers may be defined in the configuration file for the program
94
+ and will then be added to each outgoing post.
95
+
96
+ * The X-No-Archive header is sometimes set to avoid that an article be
97
+ saved and stays available to search-engines (Google, notably). Test-
98
+ postings, for example, do probably not justify at all that they would be
99
+ referenced in search results.
100
+ The post-processor program can impose the X-No-Archive header for all
101
+ posts to certain newsgroups.
102
+
103
+ **ATTN** As of 2024, this header might serve no purpose any more.
104
+
105
+ * If a news post contains many references to either other posts or Web
106
+ pages, the text can be cluttered with URLs.
107
+ The post-processor can identify marked text fragments and transform them
108
+ into footnotes, which will be attached as a list at the bottom of the
109
+ post.
110
+ This works almost like the references-link in Wikipedia, but the delimiter
111
+ can be determined in the configuration file.
112
+ Example (with %=):
113
+ _This is an object %=and this becomes the footnote, describing the object
114
+ further=%_
115
+
116
+ * The program can attempt to correct ill formatted references. This is an
117
+ option, you can disable it by setting the option VFY_URLS to “no” in the
118
+ configuration. Beware that mailto: links are not recognized and cannot be
119
+ corrected. See the explanations for VFY_URLS, below.
120
+
121
+ Dialog to override settings
122
+ ---------------------------
123
+ You can have a dialog displayed just before the post-processor is invoked, to
124
+ **disable** some configuration options. Provided that either YAD, Zenity,
125
+ Whiptail or only xterm are available on your computer, you can choose from
126
+ the following options. You **cannot** use the dialog to enable options which
127
+ have not yet been set in the configuration.
128
+
129
+ * Signatures, as set in the configuration **can be ignored**. Either
130
+ a default signature will appear as set in flnews or none.
131
+ * Custom Headers, if configured, can be **omitted**.
132
+ * The X-No-Archive header, if set for the current newsgroup, **can be
133
+ ignored**.
134
+ * The verification & correction of references **can be disabled**.
135
+ * Logging can be **switched off**, if set.
136
+
137
+ Pushing Esc or the cancle-button of the dialog interrupts the process, flnews
138
+ will not post the article.
139
+
140
+ You can disable the dialog, which ensures that all configured options will be
141
+ applied, without the need for further interaction (see below, option
142
+ OVERRIDE_CONFIG).
143
+
144
+ CONFIGURATION
145
+ ===============
146
+ On first execution of the program, a copy of the original configuration file is
147
+ created in */home/[user]/.flnews_post_proc.conf*
148
+ It is this file which is used from then on. If you delete it, it will be
149
+ recreated, on the next occasion, but your own changes will be lost.
150
+
151
+ The configuration file is in YAML syntax and full of explanations. The
152
+ variables defined in this file can be classified as belonging to one of two
153
+ categories:
154
+
155
+ * Variables describing values originally set by flnews, which should be used or
156
+ replaced. The important elements are usually matched in a capture group.
157
+
158
+ * Variables defining the new or altered content.
159
+
160
+ **FUP_NAME**
161
+ A Regular Expression, describing the string which contains the name of
162
+ previous poster who is the author of a quoted post. This string is
163
+ recognized in the original article and may be used with the fitting element
164
+ rom *GROUP_INTRO*, below. The Regexp format is that of the Regexp class in
165
+ Ruby, noted as a String. Beware to mask a backslash '\\' by another one,
166
+ ike in the example. A capture-group '()' serves to extract the name from the
167
+ match result.
168
+
169
+ Leave this field empty to keep the default from the FLNews configuration
170
+ intact.
171
+
172
+ CONTENT: A String equivalent of a regular expression.
173
+
174
+ DEFAULT: EMPTY
175
+
176
+ EXAMPLE1: _"On \\d+.\\d+.\\d{2,4} at \\d+:\\d+ **(.*)** wrote:"_
177
+
178
+ EXAMPLE2: _"**(.*)** wrote:"_
179
+
180
+ **FUP_GROUP**
181
+ A Regular Expression, describing the string which contains the newsgroup
182
+ where the previous post, that you are referring to in the followup, had been
183
+ published.
184
+
185
+ Leave this field empty to ignore the precise group.
186
+
187
+ CONTENT: A String equivalent of a regular expression.
188
+
189
+ DEFAULT: EMPTY
190
+
191
+ EXAMPLE: "wrote in **(.*)**:"
192
+
193
+ **GROUP_INTROS**
194
+ Introductory strings, referring to the previous poster who is the author of a
195
+ quoted post. If you match the newsgroup of the post (see FUP_GROUP), you can
196
+ use these variables in the result.
197
+ Currently only %fup_name% and %fup_group% are reproduced in the resulting
198
+ introductory string.
199
+
200
+ CONTENT: A newsgroup or regexp per line, followed by a colon, a space and a String
201
+
202
+ DEFAULT: As configured in FLNews
203
+
204
+ EXAMPLE: _alt.test: "Thus spoke #\{fup_name\} on that baleful #\{fup_date\}:"_
205
+
206
+ **GROUP_SIGS**
207
+ A signature line per Newsgroup.
208
+ ATTN! In multi line signatures, you have to use \r\n for line breaks.
209
+
210
+ CONTENT: A newsgroup or regexp per line, followed by a colon, a space and a String.
211
+
212
+ DEFAULT: As configured in flnews
213
+
214
+ EXAMPLE: alt.test: _"Signature for alt.test\\\\r\\\\nsecond line"_
215
+
216
+ **CUSTOM_HEADERS**
217
+ Additional headers for the outgoing article
218
+
219
+ CONTENT: 1 line per header : a dash and space, then a String, comprising the
220
+ name of the header, ending in a colon and the value of the header.
221
+
222
+ DEFAULT: undefined
223
+
224
+ EXAMPLE (2 headers):
225
+ _\- 'X-My-Header: nothing fancy'_
226
+ _\- 'X-Another-Header: care not!'_
227
+
228
+ **XNAY_GROUPS**
229
+ The newsgroups, where a header X-No-Archive: YES shall be set.
230
+ **ATTN** As of 2024, this header might serve no purpose any more.
231
+
232
+ CONTENT: a dash and space, then a String, containing the name of the group or
233
+ a regexp.
234
+
235
+ DEFAULT: empty
236
+
237
+ EXAMPLE (1 group, 1 hierarchy):
238
+ _\- "alt.test"_
239
+ _\- "^news.*"_
240
+
241
+
242
+ **DEBUG_LOG**
243
+ The name of a file, where debug messages are written. Setting this
244
+ variable will enable the log. Leave empty to disable logging.
245
+
246
+ CONTENT: The name of a writable file, which will be created if inexistent
247
+ and overwritten if need be.
248
+
249
+ DEFAULT: empty
250
+
251
+ EXAMPLE: _'/tmp/a_log-file.txt'_
252
+
253
+ **LOG LEVEL**
254
+ One of debug, fatal, error, info, warn
255
+
256
+ **REFERENCES_SEPARATOR**
257
+ A sequence of 2 or more symbols marking the end of the message-body and the
258
+ beginning of a list of “references” or “footnotes”. It will only appear, if
259
+ the original message-body contains text marked for use as such a footnote. See
260
+ *REFERENCES_DELIMITER*.
261
+
262
+ If the option is not defined or empty, the list of footnotes will appear
263
+ below the last line of the message body and no separator will be inserted.
264
+
265
+ CONTENT: A quoted symbol or sequence of symbols.
266
+
267
+ DEFAULT: empty
268
+
269
+ EXAMPLE: _'---------'_
270
+
271
+ **REFERENCES_DELIMITER**
272
+ A symbol or sequence of symbols marking the beginning of a text which will
273
+ serve as footnote (or reference). The **reversed sequence** musst be used to
274
+ mark the end of the text. The presence of this sequence or symbol in the
275
+ original message body will cause the enclosed text to be moved below the
276
+ message body.
277
+ The *REFERENCES_SEPARATOR*, if defined, will separate the message from the
278
+ list of footnotes.
279
+
280
+ If this option is not defined or empty, footnotes are not created.
281
+
282
+ CONTENT a quoted symbol or sequence of symbols.
283
+
284
+ DEFAULT: none/empty
285
+
286
+ EXAMPLE: _'%?'_
287
+
288
+ **REFERENCE_FORMAT**
289
+ A format-string, using %s for a number, replacing the reference text in the
290
+ message body.
291
+
292
+ DEFAULT: " %s)" -> becomes 1) ... 2) ... 3)
293
+
294
+ EXAMPLE: _"(%s)" -> becomes (1) ... (2) ... (3)_
295
+
296
+ **VFY_URLS**
297
+ A Boolean constant. It determines if the program shall verify and possibly
298
+ try to correct URLs. Even if URLs are identified as such, only a few
299
+ manipulations are attempted :
300
+
301
+ * Angular brackets '<' and '>' are added, if missing
302
+ * Article-references are prepended with "news:", if missing
303
+ * Slashes are added, if they are found missing after "http(s):"
304
+
305
+ ATTN! The program is unable to discern "mailto:" and "news:" references. If
306
+ neither is given, but '@' is present, "news:" is automatically prepended.
307
+
308
+ If the variable is not set, a value 'yes' is assumed.
309
+
310
+ CONTENT: One of YES, yes, NO, no, and other variations of case.
311
+
312
+ DEFAULT: yes
313
+
314
+ EXAMPLE: ... I let you guess.
315
+
316
+ **OVERRIDE_CONFIG**
317
+ GROUP_SIGS, XNAY_GROUPS, CUSTOM_HEADERS and DEBUG_LOG.
318
+ A dialog may be displayed which allows you to disable any of these
319
+ four options, so that the defaults from flnews prevail.
320
+
321
+ ATTN! Canceling the dialog or pushing the Esc-key does interrupt
322
+ the process. Flnews will not post the article.
323
+
324
+ Set this option to no, NO or similar to disable the dialog.
325
+
326
+ DEFAULT: yes
327
+
328
+ EXAMPLE: No
329
+
330
+ Other Information
331
+ =================
332
+
333
+ Testing
334
+ -------
335
+ The effects that the execution of the program will have on a posting can be
336
+ verified in two ways:
337
+
338
+ 1. By piping-in a post that had previously been saved to a file:
339
+ **:~$ /usr/local/bin/[post-processor] < [test-article]**
340
+ This will show the resulting new version of the article on screen, but you
341
+ can also pipe the output into another file. This is a great way to test a
342
+ program during development or to test your own configuration of the program.
343
+
344
+ 2. By posting directly into a test-newsgroup (like alt.test or similar). This
345
+ is mandatory before you really post to thematic newsgroups and when the
346
+ settings of the post-processor will affect the article.
347
+
348
+
349
+ Source-Code
350
+ -----------
351
+ The gem-file that you get with the gem-utility or from rubygems.org contains
352
+ all the code of the program and some documentation (this page notably). To read
353
+ its content, you must
354
+
355
+ 1. untar the gem-file with tar _-xf flnews_post_proc-0.1.gem_
356
+ 2. uncompress the data.gz archive: _gunzip data.gz_
357
+ 3. untar the resultig data.tar archive: _tar -xf data.tar_
358
+
359
+ This creates the directories bin, doc and lib.
360
+
361
+ License
362
+ -------
363
+ flnews_post_proc is distributed under the conditions of the WTFPL-2.0 or later
364
+ License (see http://www.wtfpl.net/txt/copying/ or license-text in the doc
365
+ directory of the gem-file).
366
+
367
+ Author
368
+ -----
369
+ flnews_post_proc has been developed by
370
+ Michael Uplawski <michael.uplawski@uplawski.eu>
371
+
372
+ Ω
373
+ ==
374
+
@@ -0,0 +1,84 @@
1
+ #!/bin/env ruby
2
+ #encoding: UTF-8
3
+ =begin
4
+ /***************************************************************************
5
+ * ©2023-2023, Michael Uplawski <michael.uplawski@uplawski.eu> *
6
+ * *
7
+ * This program is free software; you can redistribute it and/or modify *
8
+ * it under the terms of the DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE *
9
+ * *
10
+ * This program is distributed in the hope that it will be useful, *
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
13
+ * *
14
+ ***************************************************************************/
15
+ =end
16
+ # This program is Linux only
17
+ if ! /linux/ =~ RUBY_PLATFORM
18
+ msg = "ERROR ! This script #{$0} cannot be used with #{RUBY_PLATFORM}"
19
+ msg << "\n\tABORTING! Bye."
20
+ STDERR.puts msg
21
+ exit false
22
+ end
23
+
24
+ require 'tempfile'
25
+ require_relative '../lib/override'
26
+ require_relative '../lib/flnews_post_proc'
27
+ require_relative '../lib/basic_logging'
28
+ require_relative '../lib/configuration'
29
+
30
+ self.extend(BasicLogging)
31
+ # Get a configuration
32
+ config = Configuration::instance
33
+
34
+ # store the path to the main executable
35
+ # config.set(:BINDIR, File::dirname(__FILE__) )
36
+
37
+ # Only if data is on STDIN
38
+ if (!STDIN.tty?)
39
+ # read from STDIN
40
+ artext = ARGF.read
41
+ # There is content, create the post-processor.
42
+ if !artext.strip.empty?
43
+ #----------->
44
+ # Allow to override the configuration,
45
+ # if not disabled (default is true)
46
+ if config.OVERRIDE_CONFIG != false
47
+ cdlg = OverrideDlg.new
48
+ discarded = cdlg.show
49
+ if discarded && !discarded.empty?
50
+ debug('options overriden ' << discarded)
51
+ OverrideDlg.cvars.each do |v|
52
+ if discarded.include?(v.to_s)
53
+ debug('removing ' << v.to_s)
54
+ config.set(v, nil)
55
+ end
56
+ end
57
+ end
58
+ debug('new config: ' << config.inspect)
59
+ end
60
+ #<--------------
61
+ pp = PostProcessor.new(artext)
62
+ # ... and print its result.
63
+ article = pp.article
64
+ if article
65
+ # -------------> The main objective <------
66
+ puts article
67
+ # <------------- over and out ------>
68
+ exit true
69
+ end
70
+ # whatever.
71
+ exit false
72
+ else
73
+ error( "Cannot read the article, no content" )
74
+ end
75
+ else
76
+ usage = "\nWhat do you want me to do? Where is the article to post-process?"
77
+ usage << "\nUsage: "
78
+ usage << "\n\t#{$0} < article.text"
79
+ info usage
80
+ STDERR.puts usage
81
+ exit false
82
+ end
83
+
84
+ # Ω