flnews_post_proc 2.0 → 2.02

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f9d2ff5d6f33555a5059614972dcd6f01920b1a7274662509154e7092db9ca22
4
- data.tar.gz: 9a75540a2daf3b02cd91d2a11f8087a8ddeabc1ccea42be76af23127e0bd9d06
3
+ metadata.gz: 8817d100431b3efc184a9d04d9dd4e9f167522bedc1c18fafe73f8f53aa6a593
4
+ data.tar.gz: c4edcbcff7e0aa31e9a98a1b77009a8e34fba8697d652b5723285e6e5ec7c1ff
5
5
  SHA512:
6
- metadata.gz: 78e67d90fbacd419f0b7d543bb4ea66ea6c06440b6eff215159462f725eef8eb736db604587aa1980929c1f9a65b64fd37ded814735398a84784125acc700da4
7
- data.tar.gz: 45cec798380b42fd1b795a90c3dfd712a9b5f09da94ef592eb0123f9ec615204849781454ca50c386319edbbe280dab10a613e5c358fe2fb605891400a8c5163
6
+ metadata.gz: 415eb0c42645803f583cdafbfb6972d524175cb1ce7968f9089081ed946e9f5058e12181cea53ce978aed25942c64e52aad18f152276c967fe1b4cbdb08a86da
7
+ data.tar.gz: ca800a99b820edbdef0eaff62dde3aca16b790593cc3358cc6da8399b8730b4d73fb6e925338ca046bb6a4ee45b6f535af302e11e5cae299ac2a6813786528b5
data/bin/flnews_post_proc CHANGED
@@ -98,16 +98,31 @@ if (!STDIN.tty?)
98
98
  # if not disabled (default is true)
99
99
  if config.OVERRIDE_CONFIG != false
100
100
  cdlg = OverrideDlg.new
101
- discarded = cdlg.show
102
- if discarded && !discarded.empty?
101
+ dlg_result = cdlg.show
102
+ discarded = ''
103
+ enabled = ''
104
+ discarded = dlg_result[0]
105
+ enabled = dlg_result[1]
106
+ if discarded && discarded.respond_to?(:to_str) && !discarded.empty?
103
107
  debug('options overriden ' << discarded)
104
108
  OverrideDlg.cvars.each do |v|
105
- if discarded.include?(v.to_s)
106
- debug('removing ' << v.to_s)
109
+ vstr = v.to_s.strip
110
+ if discarded.include?(vstr)
107
111
  config.set(v, nil)
112
+ if v == :DEBUG_LOG
113
+ info 'will stop logging now!'
114
+ clear_log
115
+ set_target nil
116
+ end
108
117
  end
109
118
  end
110
119
  end
120
+ if enabled && enabled.respond_to?(:to_str) && !enabled.empty?
121
+ debug('additional options: ' << enabled)
122
+ enabled.split do |opt|
123
+ config.set(opt.to_sym, true)
124
+ end
125
+ end
111
126
  debug('new config: ' << config.inspect)
112
127
  end
113
128
  #<--------------
@@ -116,9 +131,58 @@ if (!STDIN.tty?)
116
131
  # and get a result.
117
132
  article = pp.article
118
133
  if article
119
- # -------------> The main objective <------
120
- puts article
121
- # <------------- over and out ------>
134
+ if config.DRAFT_ONLY
135
+ draft_dir = config.DRAFT_DIR
136
+ if !draft_dir || draft_dir.empty?
137
+ draft_dir = ENV['TEMP']
138
+ warn 'Will write a draft to the temporary directory ' << draft_dir
139
+ end
140
+ if draft_dir
141
+ draft_dir = File.expand_path(draft_dir)
142
+ debug 'article is a draft, writing to ' << draft_dir
143
+ draft_dir << File::Separator if !draft_dir.strip.end_with?(File::Separator)
144
+ mode = 'w+'
145
+ begin
146
+ Dir.mkdir(draft_dir) if !File::exist?(draft_dir)
147
+ ext = '.draft'
148
+ nbr = 1
149
+ if File.exist?(draft_dir) && File.directory?(draft_dir)
150
+ nbr = Dir::children(draft_dir).collect do |dc|
151
+ debug ' found file ' << dc
152
+ File::file?(dc) && dc.strip.end_with?(ext)
153
+ end.length + 1
154
+
155
+ groups = pp.newsgroups.groups
156
+ fname = draft_dir + nbr.to_s << '_' << groups[0]
157
+ fname << '++' if groups.length > 1
158
+ fname << ext
159
+ debug 'Draft will be ' << fname
160
+ debug 'newsgroups are ' << pp.newsgroups.groups.to_s
161
+ text = pp.newsgroups.groups.join(", ") << $LN << $LN << pp.body.join
162
+ File::write(fname, text)
163
+ info 'Draft written alright' if File::exist?(fname)
164
+ else
165
+ fatal 'draft_dir does not exist and could not be created'
166
+ exit false
167
+ end
168
+ rescue Exception => ex
169
+ fatal "Cannot write draft (" << ex.message << ")"
170
+ exit false
171
+ end
172
+ # Post-Processing ends here ...
173
+ else
174
+ fatal "ABORTING: Directory for draft messages is not set!\nSee configuration, option DRAFT_DIR."
175
+ info "Nothing saved, nothing posted!"
176
+ # ... or here
177
+ exit false
178
+ end
179
+ else
180
+ debug 'writing article to STDOUT'
181
+ # -------------> The main objective <------
182
+ puts article
183
+ # ... or here
184
+ # <------------- over and out ------>
185
+ end
122
186
  exit true
123
187
  end
124
188
  # whatever.
data/changes.txt ADDED
@@ -0,0 +1,34 @@
1
+ v.2.02
2
+ *) Bugfix: There was output to STDOUT unrelated to the message in
3
+ preparation and made Flnews complain. Also, posting was impossible.
4
+ v.2.01
5
+ *) The documentation has been updated.
6
+ *) Corrected behavior when logging is disabled in the interactive dialog
7
+ (pure text only, see next).
8
+ *) Whiptail dialog disabled.
9
+ The “Override-dialog” must be extended to honor new options. Whiptail is
10
+ too mind bending for me. The code is still there, but will probably
11
+ disappear in future program versions.
12
+ *) Draft messages.
13
+ - New configuration option DRAFT_DIR defaults to $TEMP from the
14
+ current environment.
15
+ - Override-dialog as pure text shows new option DRAFT_ONLY.
16
+ When explicitly activated, nothing is posted, but the message stored
17
+ in the DRAFT_DIR (see documentation for more).
18
+ *) This file renamed 'changes.txt'
19
+ *) Pure text dialog to override settings corrected:
20
+ - Option "No Archive" is toggled correctly
21
+ - Unbuffered input from STDIN simplified
22
+ v.2.0
23
+ *) Supersedes will have a new signature by default
24
+ *) Obsolete code for Yad and Zenity dialogs removed.
25
+ v 1.99
26
+ *) Bugfix: The value of a custom header can include a colon.
27
+ Example: x-my-header: apples: 2,90, peers: 3,10
28
+ (before, the value would have been clipped after the first ':')
29
+ v 1.98
30
+ *) New change log (this file)
31
+ *) In the configuration file, log levels can be in upper case.
32
+ v 1.97
33
+ *) Custom headers are RFC 2047 encoded, if need be.
34
+ (before, they had to be ASCII only or were discarded).
@@ -266,17 +266,22 @@
266
266
  <h3>Dialog for Overriding Settings</h3>
267
267
 
268
268
  <blockquote>
269
- <p><strong>IMPORTANT</strong>: As of version 1.72, YAD or
270
- Zenity cannot be used for the dialog interface.</p>
269
+ <p><strong>IMPORTANT</strong>: As of version 2.01, only
270
+ the text interface remains to display the dialog.
271
+ <a class="reference external" href=
272
+ "https://xterm.dev/">XTerm</a> must be installed to use
273
+ the dialog.</p>
271
274
 
272
275
  <p>Before the post-processor runs, a dialog can be
273
276
  displayed to allow users to <strong>disable</strong>
274
277
  certain <a class="reference internal" href=
275
- "#configuration">CONFIGURATION</a> options. If Whiptail
276
- or xterm are available, you can choose to disable the
278
+ "#configuration">CONFIGURATION</a> options and – as of
279
+ version 2.01 to <strong>enable</strong> others . If
280
+ XTerm is available, you can choose to disable the
277
281
  following options. You <strong>cannot</strong> enable
278
282
  options that haven't already been set in the
279
- configuration.</p>
283
+ configuration. But you can choose to add an option that
284
+ is not present in the configuration file:</p>
280
285
 
281
286
  <blockquote>
282
287
  <ul class="simple">
@@ -306,6 +311,27 @@
306
311
  </ul>
307
312
  </blockquote>
308
313
 
314
+ <p>There is 1 additional option, which is disabled by
315
+ default, that you can enable only in the dialog and
316
+ nowhere else:</p>
317
+
318
+ <blockquote>
319
+ <ul class="simple">
320
+ <li>
321
+ <p>The current message can be saved as a draft,
322
+ <strong>instead</strong> of being posted to
323
+ Usenet.</p>
324
+ </li>
325
+ </ul>
326
+ </blockquote>
327
+
328
+ <p>When your configuration contains the path to a
329
+ directory for these drafts (option <a class=
330
+ "reference internal" href="#draft-dir">DRAFT_DIR</a>), it
331
+ will be used to store these draft messages, otherwise the
332
+ temporary directory from the environment variable
333
+ $TEMP.</p>
334
+
309
335
  <p>Pressing Esc or the Cancel button on the dialog will
310
336
  interrupt the process, and flnews will not post the
311
337
  article.</p>
@@ -584,6 +610,37 @@ comp.*: /home/[user]/.my_sigs</pre>
584
610
 
585
611
  <p>EXAMPLE: yes</p>
586
612
  </blockquote>
613
+
614
+ <p id="draft-dir"><strong>DRAFT_DIR</strong>
615
+ </p>
616
+
617
+ <blockquote>
618
+ <p>The path to a directory for draft messages. You can
619
+ activate an option DRAFT_ONLY in the <a class=
620
+ "reference internal" href=
621
+ "#dialog-for-overriding-settings">Dialog for Overriding
622
+ Settings</a>. The current message will then be saved to
623
+ this directory, <strong>instead</strong> of being posted
624
+ to Usenet. If you leave this option empty, a temporary
625
+ directory ($TEMP) will be used instead. The draft files
626
+ will be named according to this schema:</p>
627
+
628
+ <blockquote>
629
+ <p>[n][1st_group][++].draft</p>
630
+ </blockquote>
631
+
632
+ <p>where <em>n</em> is the number of files in this
633
+ directory, <em>1st_group</em> the first newsgroup that
634
+ the message was addressed to and <em>++</em> an optional
635
+ suffix, indicating that there are more newsgroups in the
636
+ list (cross post). The content of a draft file is the
637
+ current body of the message, preceded by the list of
638
+ newsgroups.</p>
639
+
640
+ <p>DEFAULT: empty</p>
641
+
642
+ <p>EXAMPLE: ~/.flnews_drafts</p>
643
+ </blockquote>
587
644
  </section>
588
645
  </section>
589
646
 
@@ -657,43 +714,10 @@ comp.*: /home/[user]/.my_sigs</pre>
657
714
  <span id="signatures-in-supersedes"></span>
658
715
  <h3>Signatures in Supersedes</h3>
659
716
 
660
- <blockquote>
661
- <p>When superseding an existing post, the post-processor
662
- will NOT automatically add a signature. This preserves
663
- the original post content as much as possible.</p>
664
-
665
- <p>To retain the signature from the original post:</p>
666
-
667
- <ol class="arabic simple">
668
- <li>
669
- <p>In flnews, select the entire article body with the
670
- mouse—from the first line (including any
671
- introductions) down to the last line of the
672
- signature.</p>
673
- </li>
674
-
675
- <li>
676
- <p>From the Article menu, select
677
- <strong>Supersede</strong>.</p>
678
- </li>
679
-
680
- <li>
681
- <p>Edit the article text as needed. The signature
682
- will be included in te editable text (normally,
683
- flnews strips signatures before opening the
684
- editor).</p>
685
- </li>
686
-
687
- <li>
688
- <p>Send the article.</p>
689
- </li>
690
- </ol>
691
-
692
- <p><strong>Note:</strong> The <a class=
693
- "reference internal" href="#override-dialog">override
694
- dialog</a> (see above) does not affect signatures in
695
- superseding posts.</p>
696
- </blockquote>
717
+ <p>Since version 2.0, signatures in supersedes are not
718
+ handled differently from other articles. This paragraph
719
+ will be removed in the next version of the
720
+ documentation.</p>
697
721
  </section>
698
722
 
699
723
  <section id="testing-1">
@@ -711,13 +735,13 @@ comp.*: /home/[user]/.my_sigs</pre>
711
735
  <p><strong>:~$ /usr/local/bin/[post-processor] &lt;
712
736
  [test-article]</strong>
713
737
  </p>
714
- </li>
715
- </ol>
716
738
 
717
- <p>This will show the modified article, and you can pipe
718
- it into another file for further testing.</p>
739
+ <blockquote>
740
+ <p>This will show the modified article, and you can
741
+ pipe it into another file for further testing.</p>
742
+ </blockquote>
743
+ </li>
719
744
 
720
- <ol class="arabic simple" start="2">
721
745
  <li>
722
746
  <p>Post directly to a test newsgroup (e.g.,
723
747
  alt.test). This is essential before posting to real
@@ -801,7 +825,7 @@ comp.*: /home/[user]/.my_sigs</pre>
801
825
  "https://creativecommons.org/licenses/by-nd/4.0/">CC
802
826
  BY-ND 4.0</a></p>
803
827
 
804
- <p>Date: 2026-07-16</p>
828
+ <p>Date: 2026-08-01</p>
805
829
  </blockquote>
806
830
 
807
831
  <p><strong>Ω</strong>
@@ -811,7 +835,7 @@ comp.*: /home/[user]/.my_sigs</pre>
811
835
  </main>
812
836
 
813
837
  <div id='page_dt'>
814
- 2026-07-16
838
+ 2026-08-01
815
839
  </div>
816
840
  </body>
817
841
  </html>
Binary file
Binary file
@@ -10,6 +10,7 @@ flnews_post_proc
10
10
  .. _CC By-ND 4.0: https://creativecommons.org/licenses/by-nd/4.0/
11
11
  .. _rubygems.org: https://rubygems.org/gems/flnews_post_proc
12
12
  .. _en Français: https://www.uplawski.eu/div/flnews/gem_doc/fr
13
+ .. _XTerm: https://xterm.dev/
13
14
 
14
15
 
15
16
  ------------------------------------------
@@ -100,13 +101,15 @@ Limitations of Basic Newsreaders
100
101
 
101
102
  Dialog for Overriding Settings
102
103
  ------------------------------
103
- **IMPORTANT**: As of version 1.72, YAD or Zenity cannot be used for the dialog
104
- interface.
104
+ **IMPORTANT**: As of version 2.01, only the text interface remains to display the dialog.
105
+ `XTerm`_ must be installed to use the dialog.
105
106
 
106
107
  Before the post-processor runs, a dialog can be displayed to allow users to
107
- **disable** certain `CONFIGURATION`_ options. If Whiptail or xterm are available,
108
- you can choose to disable the following options. You **cannot** enable options
109
- that haven't already been set in the configuration.
108
+ **disable** certain `CONFIGURATION`_ options and as of version 2.01 – to
109
+ **enable** others . If XTerm is available, you can choose to disable the
110
+ following options. You **cannot** enable options that haven't already been
111
+ set in the configuration. But you can choose to add an option that is not present
112
+ in the configuration file:
110
113
 
111
114
  * Signatures (if set in the `CONFIGURATION`_) can be **ignored**. A default signature will be used, or no signature at all.
112
115
 
@@ -116,6 +119,13 @@ Dialog for Overriding Settings
116
119
 
117
120
  * Logging can be **disabled**, if enabled.
118
121
 
122
+ There is 1 additional option, which is disabled by default, that you can enable only in the dialog and nowhere else:
123
+
124
+ * The current message can be saved as a draft, **instead** of being posted to Usenet.
125
+
126
+ When your configuration contains the path to a directory for these drafts (option `DRAFT_DIR`_), it will be used to store
127
+ these draft messages, otherwise the temporary directory from the environment variable $TEMP.
128
+
119
129
  Pressing Esc or the Cancel button on the dialog will interrupt the process, and
120
130
  flnews will not post the article.
121
131
 
@@ -325,6 +335,28 @@ Configuration Options
325
335
 
326
336
  EXAMPLE: yes
327
337
 
338
+ .. _DRAFT_DIR:
339
+
340
+ **DRAFT_DIR**
341
+
342
+ The path to a directory for draft messages. You can activate an option
343
+ DRAFT_ONLY in the `Dialog for Overriding Settings`_. The current message will
344
+ then be saved to this directory, **instead** of being posted to Usenet.
345
+ If you leave this option empty, a temporary directory ($TEMP) will be used instead.
346
+ The draft files will be named according to this schema:
347
+
348
+ [n][1st_group][++].draft
349
+
350
+ where *n* is the number of files in this directory, *1st_group* the first
351
+ newsgroup that the message was addressed to and *++* an optional suffix,
352
+ indicating that there are more newsgroups in the list (cross post). The
353
+ content of a draft file is the current body of the message, preceded by the
354
+ list of newsgroups.
355
+
356
+ DEFAULT: empty
357
+
358
+ EXAMPLE: ~/.flnews_drafts
359
+
328
360
  .. _Other Information:
329
361
 
330
362
  Other Information
@@ -377,20 +409,9 @@ Editing footnotes
377
409
 
378
410
  Signatures in Supersedes
379
411
  ------------------------
380
- When superseding an existing post, the post-processor will NOT automatically add a signature.
381
- This preserves the original post content as much as possible.
382
-
383
- To retain the signature from the original post:
384
-
385
- 1. In flnews, select the entire article body with the mouse—from the first line (including any introductions) down to the last line of the signature.
386
-
387
- 2. From the Article menu, select **Supersede**.
388
-
389
- 3. Edit the article text as needed. The signature will be included in te editable text (normally, flnews strips signatures before opening the editor).
390
-
391
- 4. Send the article.
392
-
393
- **Note:** The `override dialog`_ (see above) does not affect signatures in superseding posts.
412
+ Since version 2.0, signatures in supersedes are not handled differently from
413
+ other articles. This paragraph will be removed in the next version of the
414
+ documentation.
394
415
 
395
416
  .. _Testing:
396
417
 
@@ -402,8 +423,8 @@ Testing
402
423
 
403
424
  **:~$ /usr/local/bin/[post-processor] < [test-article]**
404
425
 
405
- This will show the modified article, and you can pipe it into another file
406
- for further testing.
426
+ This will show the modified article, and you can pipe it into another file
427
+ for further testing.
407
428
 
408
429
  2. Post directly to a test newsgroup (e.g., alt.test). This is essential before posting to real newsgroups,
409
430
  especially when the post-processor will alter the article.
data/lib/basic_logging.rb CHANGED
@@ -60,18 +60,19 @@ module BasicLogging
60
60
  msg = calling_method << ": ERROR : invalid log level \"" << lv.to_s << "\""
61
61
  msg << "\n" << "Keepinng old log level " << Levels.keys.detect {| k| Levels[k] == @@log_level}.to_s
62
62
  STDERR.puts msg
63
- puts msg
63
+ # puts msg
64
64
  end
65
65
  end
66
66
 
67
67
  # set the log target
68
68
  def set_target(tg)
69
- if tg.respond_to?(:to_io)
69
+ # STDOUT.puts 'BASICLOGGING : Setting target to ' << tg.to_s
70
+ if tg && tg.respond_to?(:to_io)
70
71
  @@target = tg
71
- elsif(!File::exist?(tg) || ( File.file?(tg) && File.writable?(tg) ) )
72
- @@target = File.open(tg, 'w+')
73
72
  elsif !tg || tg.respond_to?(:to_str) && tg.strip.empty?
74
73
  @@target = nil
74
+ elsif(!File::exist?(tg) || ( File.file?(tg) && File.writable?(tg) ) )
75
+ @@target = File.open(tg, 'w+')
75
76
  else
76
77
  STDERR.puts calling_method << ': ERROR : target ' << tg.to_str << ' cannot be set'
77
78
  STDERR.puts "Keeping old target " << @@target.inspect
data/lib/configuration.rb CHANGED
@@ -66,6 +66,7 @@ class Configuration
66
66
  if @conf
67
67
  @conf[key] = value
68
68
  if key == 'DEBUG_LOG'
69
+ debug ' setting DEBUG_LOG to ' << value.to_s
69
70
  set_target value
70
71
  end
71
72
  end
@@ -122,7 +123,8 @@ class Configuration
122
123
  clevel = @conf[:LOG_LEVEL]
123
124
  set_level clevel
124
125
  target_string = @conf[:DEBUG_LOG]
125
- set_target (target_string == 'STDOUT' ? STDOUT : target_string)
126
+ set_target (target_string == 'STDOUT' ? STDOUT : target_string) if target_string
127
+ set_target nil if !target_string || target_string.empty?
126
128
  # clear the log file.
127
129
  clear_log
128
130
  debug('log target and -level set: ' << @@log_level.to_s << ', ' << target_string)
@@ -183,5 +183,14 @@ OVERRIDE_CONFIG: YES
183
183
  # DEFAULT: No
184
184
  USE_OLD: false
185
185
 
186
+ # Draft_DIR
187
+ # The path to a directory for draft messages.
188
+ # ONLY if OVERRIDE_CONFIG, above, is active, you can choose to *not send* but only
189
+ # to save the current message to a file in this directory.
190
+ # If left empty, the temporary directory from the environment variable $TEMP will
191
+ # be used to store draft messages.
192
+ # DEFAULT: empty
193
+ DRAFT_DIR:
194
+
186
195
  # EOF
187
196
 
@@ -39,15 +39,15 @@ class PostProcessor
39
39
  debug ' initializing headers'
40
40
  headers = Headers.new(article_text)
41
41
  debug('headers is ' << headers.inspect)
42
- body = Body.new(article_text)
42
+ @body = Body.new(article_text)
43
43
 
44
44
  debug('calling headers.update')
45
45
  headers.update()
46
46
 
47
47
  debug 'getting newsgroups'
48
48
  begin
49
- newsgroups = headers.newsgroups
50
- debug "\thave newsgroups " << newsgroups.to_s
49
+ @newsgroups = headers.newsgroups
50
+ debug "\thave newsgroups " << @newsgroups.to_s
51
51
  rescue Exception => ex
52
52
  error "Cannot get Newsgroups: " << ex.message
53
53
  end
@@ -55,25 +55,25 @@ class PostProcessor
55
55
  # Order matters. These actions work on a
56
56
  # preliminary version of the article, each
57
57
  # one on the result of the previous !
58
- body.set_intro(newsgroups.intro)
58
+ @body.set_intro(@newsgroups.intro)
59
59
 
60
60
  # if need be, extract references and footnotes.
61
- body.handle_references
61
+ @body.handle_references
62
62
  # signatures are ignored in Supersedes
63
- body.set_signature(newsgroups.signature)
63
+ @body.set_signature(@newsgroups.signature)
64
64
 
65
65
  # verify and eventually correct URIs.
66
66
  # Will only handle http(s) for the time.
67
- body.handle_uris
67
+ @body.handle_uris
68
68
 
69
69
  # get the headers and the body as a string.
70
70
  # Assemble.
71
- @article = headers.join << $LN << body.join
71
+ @article = headers.join << $LN << @body.join
72
72
 
73
73
  diff = Diffy::Diff.new(article_text, @article, :context => 2).to_s
74
74
  info("\n" << "–" * 20 << "\nDiffs\n" << "–" * 20 << "\n" << diff)
75
75
  end
76
76
 
77
- attr_reader :article
77
+ attr_reader :article, :body, :newsgroups
78
78
  end
79
79
  # EOF
data/lib/override.rb CHANGED
@@ -68,12 +68,17 @@ class OverrideDlg
68
68
  opts = nil
69
69
  begin
70
70
  if has? XTERM
71
- if has?(WHIPTAIL)
72
- return whiptail_dlg.split.collect {|o| o.to_s}.join(' ')
73
- else
74
- debug 'using naked xterm'
75
- return ruby_dlg.split.collect {|o| o.to_s}.join(' ')
76
- end
71
+ # if has?(WHIPTAIL)
72
+ ########
73
+ # Version 2.01 needs additional options in the override dialog.
74
+ # The whiptail dialog is too cumbersome.
75
+ ########
76
+ # return whiptail_dlg
77
+ #else
78
+ # debug 'using naked xterm'
79
+ #return ruby_dlg.split.collect {|o| o.to_s}.join(' ')
80
+ return ruby_dlg
81
+ #end
77
82
  end
78
83
  rescue SystemExit
79
84
  msg = 'Process is cancelled (SystemExit)'
@@ -123,15 +128,18 @@ class OverrideDlg
123
128
  # creates a whiptail dialog in xterm.
124
129
  def whiptail_dlg
125
130
  debug('whiptail dialog')
126
- tf = Tempfile.new
131
+ # tf = Tempfile.new
132
+ tf = File.new('/tmp/whiptail_out', "w+")
133
+ debug 'writing Whiptail output to ' << tf.to_s
127
134
  # dlg = @config.BINDIR << File::Separator << 'whiptail_dlg'
128
135
  dlg = @@LIBDIR << File::Separator << 'whiptail_dlg'
129
136
  dialog = XTERM.dup << ' -e ' << dlg << ' ' << tf.path
130
137
  io = IO::popen(dialog)
131
138
  Process.wait(io.pid )
132
- nopts = tf.read
133
- exit true if('exit' == nopts.strip)
134
- tf.unlink
139
+ nopts = []
140
+ nopts = tf.readlines
141
+ exit true if(nopts.empty? || 'exit' == nopts[0].strip)
142
+ # tf.unlink
135
143
  return nopts
136
144
  end
137
145
 
@@ -149,16 +157,18 @@ class OverrideDlg
149
157
  begin
150
158
  dialog = XTERM.dup << ' -e ' << dlg << ' ' << tf.path
151
159
  debug('dialog will be ' << dialog)
160
+ io = IO::popen(dialog)
161
+ debug('wait for ' << io.pid.to_s)
162
+ Process.wait(io.pid )
152
163
  rescue Exception => ex
153
164
  error ex.message
165
+ puts 'error'
154
166
  wait_for_user
155
167
  exit false
156
168
  end
157
- io = IO::popen(dialog)
158
- debug('wait for ' << io.pid.to_s)
159
- Process.wait(io.pid )
160
- nopts = tf.read
161
- exit true if('exit' == nopts.strip)
169
+ nopts = tf.readlines
170
+ debug 'nopts is ' << nopts.to_s
171
+ exit true if('exit' == nopts[0].strip)
162
172
  tf.unlink
163
173
  return nopts
164
174
  end
data/lib/ruby_dlg CHANGED
@@ -14,27 +14,11 @@
14
14
  =end
15
15
 
16
16
  require 'readline'
17
- require_relative '../lib/color_output'
17
+ require_relative 'color_output'
18
18
  require 'io/wait'
19
19
  require 'io/console'
20
+ require 'configuration'
20
21
 
21
- def wait_for_user()
22
- char = nil
23
- # There is a difference which makes me prefer the below code from STDIN.raw(args)
24
- # You can try
25
- # char = STDIN.raw(&:getc)
26
- # .., which does *not* work the same way and it won't for me.
27
-
28
- STDIN.raw do
29
- STDIN.noecho do
30
- until (STDIN.ready?)
31
- sleep(0.1)
32
- end
33
- char = (STDIN.read_nonblock(1).ord rescue nil)
34
- end
35
- end
36
- return char
37
- end
38
22
  if !ARGV.empty? && ARGV.length > 0
39
23
  ofl = nil
40
24
  begin
@@ -44,32 +28,40 @@ if !ARGV.empty? && ARGV.length > 0
44
28
  puts red ('cannot open ' << ARGV[1])
45
29
  puts ex.message
46
30
  puts 'hit any key to exit'
47
- wait_for_user
31
+ $stdin.getch
48
32
  exit false
49
33
  end
50
34
 
51
- opt_array = []
35
+ disable_array = []
36
+ enable_array = []
52
37
  message = ''
53
- menu ||= %=
38
+ menu = %=
39
+ ––––– Configured options –––––––––––––
40
+
54
41
  1 Unset Signature GROUP_SIGS
55
42
  2 Unset Custom headers CUSTOM_HEADERS
56
43
  3 Unset No Archive NO_ARCHIVE_GROUPS
57
44
  4 Do not correct URLs VFY_URLS
58
45
  5 Disable log DEBUG_LOG
46
+
47
+ ––––– Add options ––––––––––––––––––––––––––––
48
+
49
+ 6 Draft only DRAFT_ONLY
50
+
59
51
  ––––––––––––––––––––––––––––––––––––––––––––––
60
- 6 Summary
52
+ 7 Summary, so far
61
53
  ––––––––––––––––––––––––––––––––––––––––––––––
62
54
  0 Okay, use settings.
63
55
  ––––––––––––––––––––––––––––––––––––––––––––––––
64
- {bold("Esc, Ctrl+C and 'q'")} terminate the Post-processor
56
+ #{bold("Esc, Ctrl+C and 'q'")} terminate the Post-processor
65
57
  and no changes will be applied.
66
- =
58
+ =
67
59
 
68
60
  loop do
69
61
  system 'clear'
70
62
  puts yellow(menu)
71
63
  puts cyan(message)
72
- option = wait_for_user - 48
64
+ option = $stdin.getch.to_i
73
65
  case option
74
66
  # Esc, Ctrl+C, 'q'
75
67
  when -21, -45, 65
@@ -78,9 +70,12 @@ and no changes will be applied.
78
70
  ofl.close
79
71
  exit true
80
72
  when 0
81
- puts green('Applying changes.') if !opt_array.empty?
73
+ if !disable_array.empty? || !enable_array.empty?
74
+ puts green('Applying changes.')
75
+ end
82
76
  # write the list of variables to unset (others remain)
83
- ofl.write opt_array.join(' ')
77
+ ofl.write disable_array.join(' ')
78
+ ofl.write "\n" << enable_array.join(' ')
84
79
  ofl.close
85
80
  exit true
86
81
 
@@ -88,47 +83,57 @@ and no changes will be applied.
88
83
  # ADD option to the option array, if it should be *removed*
89
84
  # from the configuration, else remove it from the array.
90
85
  when 1
91
- active = !opt_array.include?(:GROUP_SIGS)
92
- opt_array << :GROUP_SIGS if active
93
- opt_array.delete(:GROUP_SIGS) if !active
86
+ active = !disable_array.include?(:GROUP_SIGS)
87
+ disable_array << :GROUP_SIGS if active
88
+ disable_array.delete(:GROUP_SIGS) if !active
94
89
 
95
90
  message = "Signature #{active ? 'unset' : 'as configured'}!"
96
91
  menu.sub!("Unset Signature", "Set Signature ") if active
97
92
  menu.sub!("Set Signature ", "Unset Signature") if !active
98
93
  when 2
99
- active = !opt_array.include?(:CUSTOM_HEADERS)
100
- opt_array << :CUSTOM_HEADERS if active
101
- opt_array.delete(:CUSTOM_HEADERS) if !active
94
+ active = !disable_array.include?(:CUSTOM_HEADERS)
95
+ disable_array << :CUSTOM_HEADERS if active
96
+ disable_array.delete(:CUSTOM_HEADERS) if !active
102
97
 
103
98
  message = "Custom headers #{active ? 'removed' : 'are added'}!"
104
99
  menu.sub!("Unset Custom headers", "Add Custom headers ") if active
105
100
  menu.sub!("Add Custom headers ", "Unset Custom headers") if !active
106
101
  when 3
107
- active = !opt_array.include?(:NO_ARCHIVE_GROUPS)
108
- opt_array << :NO_ARCHIVE_GROUPS if active
109
- opt_array.delete(:NO_ARCHIVE_GROUPS) if !active
102
+ active = !disable_array.include?(:NO_ARCHIVE_GROUPS)
103
+ disable_array << :NO_ARCHIVE_GROUPS if active
104
+ disable_array.delete(:NO_ARCHIVE_GROUPS) if !active
110
105
 
111
106
  message = "X-No-Archive #{active ? 'removed' : 'is added'}!"
112
- menu.sub!("Unset X-No-Archive", "Add X-No-Archive ") if active
113
- menu.sub!("Add X-No-Archive ", "Unset X-No-Archive") if !active
107
+ menu.sub!("Unset No Archive", "Add No Archive ") if active
108
+ menu.sub!("Add No Archive ", "Unset No Archive") if !active
114
109
  when 4
115
- active = !opt_array.include?(:VFY_URLS)
116
- opt_array << :VFY_URLS if active
117
- opt_array.delete(:VFY_URLS) if !active
110
+ active = !disable_array.include?(:VFY_URLS)
111
+ disable_array << :VFY_URLS if active
112
+ disable_array.delete(:VFY_URLS) if !active
118
113
 
119
114
  message = "URLS will #{active ? 'not ' : ''}" << "be verified!"
120
115
  menu.sub!("Do not correct URLs", "Correct URLs ") if active
121
116
  menu.sub!("Correct URLs ", "Do not correct URLs") if !active
122
117
  when 5
123
- active = !opt_array.include?(:DEBUG_LOG)
124
- opt_array << :DEBUG_LOG if active
125
- opt_array.delete(:DEBUG_LOG) if !active
118
+ active = !disable_array.include?(:DEBUG_LOG)
119
+ disable_array << :DEBUG_LOG if active
120
+ disable_array.delete(:DEBUG_LOG) if !active
126
121
 
127
122
  message = "Log is #{ active ? 'not ' : ''} " << "written!"
128
123
  menu.sub!("Disable log", "Enable log ") if active
129
124
  menu.sub!("Enable log ", "Disable log") if !active
130
125
  when 6
131
- message = "Summary of " << bold('disabled') << " options: " << opt_array.join(' ')
126
+ active = !enable_array.include?(:DRAFT_ONLY)
127
+ enable_array << :DRAFT_ONLY if active
128
+ enable_array.delete(:DRAFT_ONLY) if !active
129
+
130
+ message = "Post is #{ active ? '' : 'not '}" << "saved as a draft!"
131
+ menu.sub!("Draft only", "No Draft") if active
132
+ menu.sub!("No Draft", "Draft only") if !active
133
+ when 7
134
+ message = "Summary:"
135
+ message << bold(cyan("\n\tdisabled")) << " options: " << disable_array.join(' ') if !disable_array.empty?
136
+ message << bold(cyan("\n\tenabled") )<< " options: " << enable_array.join(' ') if !enable_array.empty?
132
137
  end
133
138
  end
134
139
  else # ARGV
data/lib/version.rb CHANGED
@@ -14,7 +14,7 @@
14
14
  =end
15
15
 
16
16
  PROGNAME = 'flnews_post_proc'
17
- PROGVERSION = "2.0"
17
+ PROGVERSION = "2.02"
18
18
  AUTHORS = "Michael Uplawski"
19
19
  EMAIL = "michael.uplawski@uplawski.eu"
20
20
  YEARS = "2023 - 2026"
data/lib/whiptail_dlg CHANGED
@@ -33,10 +33,10 @@ CHECKTITLE="Deselect to disable. Esc or Cancel close the dialog and no changes w
33
33
  VARS=(GROUP_SIGS CUSTOM_HEADERS NO_ARCHIVE_GROUPS VFY_URLS DEBUG_LOG)
34
34
 
35
35
  # Checklist options
36
- options=(GROUP_SIGS 'Signatures' ON CUSTOM_HEADERS 'Custom headers' ON NO_ARCHIVE_GROUPS 'No Archive' ON VFY_URLS 'Correct URLs' ON DEBUG_LOG 'Log' ON)
36
+ options=(GROUP_SIGS 'Signatures' ON CUSTOM_HEADERS "Custom headers" ON NO_ARCHIVE_GROUPS "No Archive" ON VFY_URLS "Correct URLs" ON DEBUG_LOG 'Log' ON)
37
37
 
38
38
  # show dialog and store results
39
- result=$(whiptail --title "$TITLE" --checklist "$CHECKTITLE" 13 55 5 "${options[@]}" 3>&1 1>&2 2>&3)
39
+ result=$(whiptail --title "$TITLE" --checklist "$CHECKTITLE" 13 55 6 "${options[@]}" 3>&1 1>&2 2>&3)
40
40
  # which button had been pushed?
41
41
  okcancel=$?
42
42
 
@@ -44,39 +44,42 @@ okcancel=$?
44
44
  read -ra opts <<< $result
45
45
 
46
46
  # comment out -------->
47
- #echo "cancel/ok ? $okcancel"
48
- #echo $result
49
- #echo "${opts[@]}"
50
- #echo "${#opts[@]}"
47
+ echo "cancel/ok ? $okcancel"
48
+ echo $result
49
+ echo "${opts[@]}"
50
+ echo "${#opts[@]}"
51
+ echo "VARS: (${VARS[@]})"
51
52
  # <--------
52
53
 
53
54
  # Find deselected options which shall be written to the outfile.
54
55
  # Looks complicated.
55
56
  if [ "$okcancel" -eq 0 ]
56
57
  then
57
- list=''
58
- # check each available variable ...
59
- for c in ${VARS[@]}
58
+ disable_list=''
59
+ enable_list=''
60
+ # 1) check each of the configuration variables ...
61
+ for c in ${OVARS[@]}
60
62
  do
61
- deactivate=TRUE
63
+ ignore=FALSE
62
64
  # ... against the result from the dialog
63
65
  for o in ${opts[@]}
64
66
  do
65
- if [ "$o" == "\"$c\"" ]
66
- then
67
- # ignore if a variable remained checked ...
68
- deactivate=FALSE
69
- fi
67
+ if [ "$o" == "\"$c\"" ]
68
+ then
69
+ # ignore if a variable remained checked ...
70
+ ignore=TRUE
71
+ fi
70
72
  done
71
- # ... else write it to the list.
72
- if [ "$deactivate" == TRUE ]
73
- then
74
-
75
- list="$list $c"
76
- fi
73
+ if [ ! ignore ]
74
+ then
75
+ disable_list="$disable_list $c"
76
+ fi
77
77
  done
78
+
79
+
78
80
  # Heureka.
79
- echo "$list" > "$OUTFILE"
81
+ echo -e "$disable_list" > "$OUTFILE"
82
+ echo -e "$enable_list" >> "$OUTFILE"
80
83
  else
81
84
  echo "exit" > "$OUTFILE"
82
85
  fi
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flnews_post_proc
3
3
  version: !ruby/object:Gem::Version
4
- version: '2.0'
4
+ version: '2.02'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Uplawski
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-07-28 00:00:00.000000000 Z
10
+ date: 2026-08-04 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: diffy
@@ -58,7 +58,7 @@ extra_rdoc_files: []
58
58
  files:
59
59
  - README.md
60
60
  - bin/flnews_post_proc
61
- - changelog.txt
61
+ - changes.txt
62
62
  - doc/fr/html/flnews_post_proc.html
63
63
  - doc/fr/man/flnews_post_proc.1.gz
64
64
  - doc/fr/pdf/flnews_post_proc.pdf
@@ -85,7 +85,7 @@ licenses:
85
85
  metadata:
86
86
  homepage_uri: https://www.uplawski.eu/software/flnews_post_proc/
87
87
  documentation_uri: https://www.uplawski.eu/div/flnews/gem_doc/html/flnews_post_proc.html
88
- changelog_uri: https://www.uplawski.eu/div/flnews/gem_doc/changelog.txt
88
+ changelog_uri: https://www.uplawski.eu/div/flnews/gem_doc/changes.txt
89
89
  rdoc_options: []
90
90
  require_paths:
91
91
  - lib
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
100
  - !ruby/object:Gem::Version
101
101
  version: '0'
102
102
  requirements: []
103
- rubygems_version: 4.0.16
103
+ rubygems_version: 4.0.17
104
104
  specification_version: 4
105
105
  summary: Modify news posts, before flnews sends them.
106
106
  test_files: []
data/changelog.txt DELETED
@@ -1,13 +0,0 @@
1
- v.2.0
2
- *) Supersedes will have a new signature by default
3
- *) Obsolete code for Yad and Zenity dialogs removed.
4
- v 1.99
5
- *) Bugfix: The value of a custom header can include a colon.
6
- Example: x-my-header: apples: 2,90, peers: 3,10
7
- (before, the value would have been clipped after the first ':')
8
- v 1.98
9
- *) New change log (this file)
10
- *) In the configuration file, log levels can be in upper case.
11
- v 1.97
12
- *) Custom headers are RFC 2047 encoded, if need be.
13
- (before, they had to be ASCII only or were discarded).