flnews_post_proc 2.02 → 2.03
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.
Potentially problematic release.
This version of flnews_post_proc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/bin/flnews_post_proc +12 -10
- data/changes.txt +8 -1
- data/lib/body.rb +9 -45
- data/lib/color_output.rb +3 -3
- data/lib/configuration.rb +12 -13
- data/lib/flnews_post_proc.conf +12 -12
- data/lib/flnews_post_proc.rb +14 -12
- data/lib/headers.rb +12 -17
- data/lib/newsgroups.rb +12 -12
- data/lib/override.rb +17 -56
- data/lib/ruby_dlg +10 -11
- data/lib/version.rb +12 -12
- metadata +90 -81
- data/lib/whiptail_dlg +0 -87
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f37b5df3705857c5beb712e4e0a98abb59992fc528254a73a733543c84502a19
|
|
4
|
+
data.tar.gz: a9484bb151adcf28bc8548ab1210a2b9c324ae0e52258be15097144b6ae88cb4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f7a31cc97c93e1c0661fccdf811f013cbd81cd87ce6555d9017d3c7ccaf8af5df9aae690343bfd5cc144719e16ae5594ecbf41638c3ed816e45c712d97e0b8fc
|
|
7
|
+
data.tar.gz: 36dccfce186d13b5f8dff277cdde94c4fc3e12008306880cc0cd063e76b0bbe3ac29ec72d035e04cd76c972daf75f02230f8ee0991b15c6d2130fe669879019b
|
data/bin/flnews_post_proc
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
=begin
|
|
5
5
|
/***************************************************************************
|
|
6
|
-
* ©2023-
|
|
6
|
+
* ©2023-2026, Michael Uplawski <michael.uplawski@uplawski.eu> *
|
|
7
7
|
* *
|
|
8
8
|
* This program is free software; you can redistribute it and/or modify *
|
|
9
9
|
* it under the terms of the DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE *
|
|
@@ -22,8 +22,7 @@ if ! (/linux/ =~ RUBY_PLATFORM)
|
|
|
22
22
|
exit false
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
require 'filemagic'
|
|
25
|
+
require 'mimemagic'
|
|
27
26
|
require 'tempfile'
|
|
28
27
|
|
|
29
28
|
require_relative '../lib/override'
|
|
@@ -68,21 +67,24 @@ if (!STDIN.tty?)
|
|
|
68
67
|
if !artext.strip.empty?
|
|
69
68
|
# Be sure to know what you are doing.
|
|
70
69
|
# Ask around in case of doubt.
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
type = ''
|
|
71
|
+
magic = MimeMagic.by_magic(artext)
|
|
72
|
+
# mime = FileMagic.mime.buffer artext
|
|
73
|
+
debug('magic is ' << magic.to_s)
|
|
74
|
+
type = magic.type if magic
|
|
75
|
+
if (['news', 'rfc822'].none? {|m| type.start_with?('message/' << m) } )
|
|
74
76
|
# Not a pure news message
|
|
75
77
|
# Add more reactions, as you stumble upon them ...
|
|
76
|
-
warn ("Input is of wrong
|
|
78
|
+
warn ("Input is of wrong type " << type)
|
|
77
79
|
|
|
78
80
|
# Javascript okay
|
|
79
|
-
if (['javascript'].any? {|m|
|
|
81
|
+
if (['javascript'].any? {|m| type.start_with?('application/' << m)} )
|
|
80
82
|
warn 'Input contains java-script code!'
|
|
81
83
|
# C okay
|
|
82
|
-
elsif(['x-c'].any? {|m|
|
|
84
|
+
elsif(['x-c'].any? {|m| type.start_with?('text/' << m)} )
|
|
83
85
|
warn 'Input contains C- or C++ code!'
|
|
84
86
|
# Ruby okay
|
|
85
|
-
elsif(['x-ruby'].any? {|m|
|
|
87
|
+
elsif(['x-ruby'].any? {|m| type.start_with?('text/' << m) })
|
|
86
88
|
warn 'Input contains Ruby-code!'
|
|
87
89
|
else
|
|
88
90
|
warn 'Input contains other things than plain-text, but I cannot say, what.'
|
data/changes.txt
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
v.2.03
|
|
2
|
+
*) Ruby-Filemagic has been replaced by MimeMagic.
|
|
3
|
+
*) Calls to force_encoding() prior String.gsub have been added
|
|
4
|
+
Ruby 4.1.0 appears to be stricter in handling encoding mismatches.
|
|
5
|
+
*) Bugfix: A typo in a require statement had been corrected.
|
|
6
|
+
*) Whiptail dialog code removed
|
|
7
|
+
|
|
1
8
|
v.2.02
|
|
2
9
|
*) Bugfix: There was output to STDOUT unrelated to the message in
|
|
3
|
-
preparation
|
|
10
|
+
preparation which made Flnews complain. Also, posting was impossible.
|
|
4
11
|
v.2.01
|
|
5
12
|
*) The documentation has been updated.
|
|
6
13
|
*) Corrected behavior when logging is disabled in the interactive dialog
|
data/lib/body.rb
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
=begin
|
|
4
4
|
/***************************************************************************
|
|
5
|
-
* 2023-
|
|
5
|
+
* 2023-2026, Michael Uplawski <michael.uplawski@uplawski.eu> *
|
|
6
6
|
* This program is free software; you can redistribute it and/or modify *
|
|
7
7
|
* it under the terms of the WTFPL 2.0 or later, see *
|
|
8
8
|
* http://www.wtfpl.net/about/ *
|
|
@@ -167,7 +167,8 @@ class Body
|
|
|
167
167
|
end
|
|
168
168
|
|
|
169
169
|
def join
|
|
170
|
-
|
|
170
|
+
lines = @lines.collect{|l| l.force_encoding('utf-8')}
|
|
171
|
+
new_body = lines.join("\r\n") << "\r\n"
|
|
171
172
|
# replace ellipsis
|
|
172
173
|
new_body.gsub!('...', '…')
|
|
173
174
|
return new_body
|
|
@@ -187,21 +188,11 @@ class Body
|
|
|
187
188
|
if @@config.VFY_URLS
|
|
188
189
|
debug 'verifying URLs'
|
|
189
190
|
@lines.each_with_index do | l, i |
|
|
190
|
-
# leave
|
|
191
|
+
# leave quoted lines as they are.
|
|
191
192
|
if !l.start_with?( '>')
|
|
192
|
-
|
|
193
|
-
#
|
|
194
|
-
#
|
|
195
|
-
# IN THE BODY OF A NEWS-POST AND TO NOT PREPEND IT WITH
|
|
196
|
-
# mailto:
|
|
197
|
-
# ... Because I do not know what to do in these cases,
|
|
198
|
-
# and I am the boss!
|
|
199
|
-
# <----------------------------
|
|
200
|
-
|
|
201
|
-
# BUGFIX : Urls with @
|
|
202
|
-
# BUGFIX : email address in the intro
|
|
203
|
-
new_line = handle_news(l) if !@intro || l.strip != @intro.strip
|
|
204
|
-
=end
|
|
193
|
+
# Handling of news- and mail-links has been
|
|
194
|
+
# removed.
|
|
195
|
+
#
|
|
205
196
|
# http(s)
|
|
206
197
|
if l.include?('http')
|
|
207
198
|
new_line = handle_http(l)
|
|
@@ -218,7 +209,8 @@ class Body
|
|
|
218
209
|
ref_delim = @@config.REFERENCES_DELIMITER
|
|
219
210
|
debug('references delimiter is ' << ref_delim)
|
|
220
211
|
references = Array.new
|
|
221
|
-
|
|
212
|
+
# avoids a lot of trouble
|
|
213
|
+
body = @lines.join($LN).force_encoding('utf-8')
|
|
222
214
|
if ref_delim && !ref_delim.strip.empty?
|
|
223
215
|
unless ref_delim == ref_delim.reverse
|
|
224
216
|
ref_delim.strip!
|
|
@@ -276,34 +268,6 @@ class Body
|
|
|
276
268
|
end
|
|
277
269
|
private
|
|
278
270
|
|
|
279
|
-
# handle <news:..@...>
|
|
280
|
-
def handle_news(l)
|
|
281
|
-
# ... “Do not trust nobody!”
|
|
282
|
-
if l.include?('@') && ! l.include?('http:') && ! l.include?('https:')
|
|
283
|
-
# And I forgot how this works. It does.
|
|
284
|
-
l.split.collect do |ele|
|
|
285
|
-
# angular brackets are there alright. Hurra.
|
|
286
|
-
url = ele.match(/\<(.*)\>/)
|
|
287
|
-
unless !url
|
|
288
|
-
debug(' with angular brackets: ' << url.inspect)
|
|
289
|
-
l = l.sub(url[1], 'news:' << url[1]) if !url[1].start_with?('mailto') && !url[1].start_with?('news')
|
|
290
|
-
else
|
|
291
|
-
url = ele.match(/\S+@(\.|[^\p{P}]+)\S+/)
|
|
292
|
-
if url
|
|
293
|
-
debug(' withOUT angular brackets: ' << url.inspect)
|
|
294
|
-
if !url[0].start_with?('mailto') && !url[0].start_with?('news')
|
|
295
|
-
l.sub!(url[0], 'news:' << url[0] )
|
|
296
|
-
end
|
|
297
|
-
l.sub!('news:', '<news:')
|
|
298
|
-
l.sub!(url[0], url[0] << '>')
|
|
299
|
-
end
|
|
300
|
-
end
|
|
301
|
-
end # url_strs = collect
|
|
302
|
-
debug(' news: line is now ' << l)
|
|
303
|
-
return l
|
|
304
|
-
end
|
|
305
|
-
end
|
|
306
|
-
|
|
307
271
|
# formatting http URLs, not much is done here.
|
|
308
272
|
def handle_http(l)
|
|
309
273
|
debug('handle http')
|
data/lib/color_output.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#encoding: UTF-8
|
|
2
2
|
=begin
|
|
3
|
-
|
|
4
|
-
* 2023-
|
|
3
|
+
***************************************************************************
|
|
4
|
+
* 2023-2026, Michael Uplawski <michael.uplawski@uplawski.eu> *
|
|
5
5
|
* This program is free software; you can redistribute it and/or modify *
|
|
6
6
|
* it under the terms of the WTFPL 2.0 or later, see *
|
|
7
7
|
* http://www.wtfpl.net/about/ *
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
11
11
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
|
12
12
|
* *
|
|
13
|
-
|
|
13
|
+
***************************************************************************
|
|
14
14
|
=end
|
|
15
15
|
|
|
16
16
|
# Functions to apply colors to terminal output.
|
data/lib/configuration.rb
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
#encoding: UTF-8
|
|
2
2
|
=begin
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
***************************************************************************
|
|
4
|
+
2023-2026, Michael Uplawski <michael.uplawski@uplawski.eu>
|
|
5
|
+
This program is free software; you can redistribute it and/or modify
|
|
6
|
+
it under the terms of the WTFPL 2.0 or later, see
|
|
7
|
+
http://www.wtfpl.net/about/
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
12
|
+
|
|
13
|
+
***************************************************************************
|
|
14
14
|
=end
|
|
15
15
|
|
|
16
16
|
require_relative 'basic_logging'
|
|
@@ -131,8 +131,7 @@ class Configuration
|
|
|
131
131
|
rescue Exception => ex
|
|
132
132
|
msg = "Cannot use the configuration-file (" << @config_file << ")"
|
|
133
133
|
msg << "\n\t" << ex.message
|
|
134
|
-
# No log.
|
|
135
|
-
# error msg
|
|
134
|
+
# No log. Use STDERR.
|
|
136
135
|
STDERR.puts(msg << "\nAborting, bye\n")
|
|
137
136
|
exit false
|
|
138
137
|
end
|
data/lib/flnews_post_proc.conf
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
#
|
|
3
|
-
#
|
|
4
|
-
#
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
1
|
+
# ***************************************************************************
|
|
2
|
+
# 2023-2026, Michael Uplawski <michael.uplawski@uplawski.eu>
|
|
3
|
+
#
|
|
4
|
+
# This program is free software; you can redistribute it and/or modify
|
|
5
|
+
# it under the terms of the DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
|
6
|
+
#
|
|
7
|
+
# This program is distributed in the hope that it will be useful,
|
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
10
|
+
#
|
|
11
|
+
# ***************************************************************************
|
|
12
12
|
# This is a YAML file. Keep intact these three dashes.
|
|
13
13
|
---
|
|
14
14
|
# CONFIG_VERSION – DO NOT MODIFY
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
# the process, if they are still valid.
|
|
18
18
|
# ATTN! COMMENTS WILL BE REMOVED but a copy of your previous configuration
|
|
19
19
|
# will be saved in a file with a version suffix.
|
|
20
|
-
CONFIG_VERSION:
|
|
20
|
+
CONFIG_VERSION: 2.02
|
|
21
21
|
|
|
22
22
|
# FUP_NAME
|
|
23
23
|
# A Regular Expression, describing the string which contains the name of
|
data/lib/flnews_post_proc.rb
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
#encoding: UTF-8
|
|
2
2
|
=begin
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
***************************************************************************
|
|
4
|
+
2023-2026, Michael Uplawski <michael.uplawski@uplawski.eu> *
|
|
5
|
+
This program is free software; you can redistribute it and/or modify *
|
|
6
|
+
it under the terms of the WTFPL 2.0 or later, see *
|
|
7
|
+
http://www.wtfpl.net/about/ *
|
|
8
|
+
*
|
|
9
|
+
This program is distributed in the hope that it will be useful, *
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
|
12
|
+
*
|
|
13
|
+
***************************************************************************
|
|
14
14
|
=end
|
|
15
15
|
|
|
16
16
|
require 'yaml'
|
|
@@ -50,6 +50,8 @@ class PostProcessor
|
|
|
50
50
|
debug "\thave newsgroups " << @newsgroups.to_s
|
|
51
51
|
rescue Exception => ex
|
|
52
52
|
error "Cannot get Newsgroups: " << ex.message
|
|
53
|
+
error "Aborting, bye"
|
|
54
|
+
exit false
|
|
53
55
|
end
|
|
54
56
|
|
|
55
57
|
# Order matters. These actions work on a
|
|
@@ -68,7 +70,7 @@ class PostProcessor
|
|
|
68
70
|
|
|
69
71
|
# get the headers and the body as a string.
|
|
70
72
|
# Assemble.
|
|
71
|
-
@article = headers.join << $LN << @body.join
|
|
73
|
+
@article = headers.join.force_encoding('utf-8') << $LN << @body.join
|
|
72
74
|
|
|
73
75
|
diff = Diffy::Diff.new(article_text, @article, :context => 2).to_s
|
|
74
76
|
info("\n" << "–" * 20 << "\nDiffs\n" << "–" * 20 << "\n" << diff)
|
data/lib/headers.rb
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
#encoding: UTF-8
|
|
2
2
|
=begin
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
***************************************************************************
|
|
4
|
+
2023-2026, Michael Uplawski <michael.uplawski@uplawski.eu> *
|
|
5
|
+
This program is free software; you can redistribute it and/or modify *
|
|
6
|
+
it under the terms of the WTFPL 2.0 or later, see *
|
|
7
|
+
http://www.wtfpl.net/about/ *
|
|
8
|
+
*
|
|
9
|
+
This program is distributed in the hope that it will be useful, *
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
|
12
|
+
*
|
|
13
|
+
***************************************************************************
|
|
14
14
|
=end
|
|
15
15
|
|
|
16
16
|
require 'rfc_2047'
|
|
@@ -64,10 +64,6 @@ class Headers
|
|
|
64
64
|
rescue Exception => ex
|
|
65
65
|
exit false;
|
|
66
66
|
end
|
|
67
|
-
# Consider the two following fixes as preliminary until proven.
|
|
68
|
-
# Getting older, this kind of problem occupies me a lot more than
|
|
69
|
-
# it should.
|
|
70
|
-
#
|
|
71
67
|
# value is all after the first colon
|
|
72
68
|
val = l.match(/:(.*)/)[1].lstrip
|
|
73
69
|
else # start_with?(' ')
|
|
@@ -196,7 +192,6 @@ class Headers
|
|
|
196
192
|
hv = @headers[:Subject]
|
|
197
193
|
if hv
|
|
198
194
|
debug 'checking for altered Subject'
|
|
199
|
-
|
|
200
195
|
|
|
201
196
|
# Our own very first article with an altered subject line, uses:
|
|
202
197
|
# (old:
|
|
@@ -220,7 +215,7 @@ class Headers
|
|
|
220
215
|
olds << /\s*\(etait\s?:.*/i
|
|
221
216
|
|
|
222
217
|
#decode subject from header value
|
|
223
|
-
subj = Rfc2047.decode(hv)
|
|
218
|
+
subj = Rfc2047.decode(hv.force_encoding('utf-8') )
|
|
224
219
|
debug 'subject encoding: ' << hv.encoding.to_s
|
|
225
220
|
debug 'decoded subject: ' << subj
|
|
226
221
|
# check for each of those regexps
|
data/lib/newsgroups.rb
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
#encoding: UTF-8
|
|
2
2
|
=begin
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
***************************************************************************
|
|
4
|
+
2023-2026, Michael Uplawski <michael.uplawski@uplawski.eu>
|
|
5
|
+
This program is free software; you can redistribute it and/or modify
|
|
6
|
+
it under the terms of the WTFPL 2.0 or later, see
|
|
7
|
+
http://www.wtfpl.net/about/
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
12
|
+
|
|
13
|
+
***************************************************************************
|
|
14
14
|
=end
|
|
15
15
|
|
|
16
16
|
# An object of this class concentrates the specificities of chosen
|
|
@@ -174,7 +174,7 @@ class Newsgroups
|
|
|
174
174
|
|
|
175
175
|
# write a new rearranged version of the signature file for
|
|
176
176
|
# better hazard.
|
|
177
|
-
#
|
|
177
|
+
# UNUSED
|
|
178
178
|
def rearrange_sigs(sigfile, all_sigs)
|
|
179
179
|
if File.writable?(sigfile)
|
|
180
180
|
new_sigs = Array.new(all_sigs.length)
|
data/lib/override.rb
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
#encoding: UTF-8
|
|
2
2
|
=begin
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
***************************************************************************
|
|
4
|
+
2023-2025, Michael Uplawski <michael.uplawski@uplawski.eu> *
|
|
5
|
+
This program is free software; you can redistribute it and/or modify *
|
|
6
|
+
it under the terms of the WTFPL 2.0 or later, see *
|
|
7
|
+
http://www.wtfpl.net/about/ *
|
|
8
|
+
*
|
|
9
|
+
This program is distributed in the hope that it will be useful, *
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
|
12
|
+
*
|
|
13
|
+
***************************************************************************
|
|
14
14
|
=end
|
|
15
15
|
|
|
16
16
|
# This class manages a dialog to alter the behavior of the
|
|
@@ -29,12 +29,10 @@ class OverrideDlg
|
|
|
29
29
|
|
|
30
30
|
XTERM = 'xterm'
|
|
31
31
|
# TERMINAL = 'x-terminal-emulator'
|
|
32
|
-
|
|
33
|
-
#
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
# necessitate that xterm be found, too.
|
|
37
|
-
@@Executables = [WHIPTAIL, XTERM]
|
|
32
|
+
|
|
33
|
+
# There used to be others, but only xterm remained.
|
|
34
|
+
@@Executables = [XTERM]
|
|
35
|
+
|
|
38
36
|
@@LIBDIR = File::dirname(__FILE__)
|
|
39
37
|
# The configuration variables that can be unset.
|
|
40
38
|
# This class instance variable is exposed via a getter.
|
|
@@ -68,17 +66,7 @@ class OverrideDlg
|
|
|
68
66
|
opts = nil
|
|
69
67
|
begin
|
|
70
68
|
if has? XTERM
|
|
71
|
-
|
|
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
|
|
69
|
+
return ruby_dlg
|
|
82
70
|
end
|
|
83
71
|
rescue SystemExit
|
|
84
72
|
msg = 'Process is cancelled (SystemExit)'
|
|
@@ -121,34 +109,7 @@ class OverrideDlg
|
|
|
121
109
|
@executables.include? ex_name
|
|
122
110
|
end
|
|
123
111
|
|
|
124
|
-
###### The following methods call a script, each, in an external process.
|
|
125
|
-
# There appears to be some Exception handling missing, but it does not
|
|
126
|
-
# hurt for the time being. Anyway, I do not care.
|
|
127
|
-
|
|
128
|
-
# creates a whiptail dialog in xterm.
|
|
129
|
-
def whiptail_dlg
|
|
130
|
-
debug('whiptail dialog')
|
|
131
|
-
# tf = Tempfile.new
|
|
132
|
-
tf = File.new('/tmp/whiptail_out', "w+")
|
|
133
|
-
debug 'writing Whiptail output to ' << tf.to_s
|
|
134
|
-
# dlg = @config.BINDIR << File::Separator << 'whiptail_dlg'
|
|
135
|
-
dlg = @@LIBDIR << File::Separator << 'whiptail_dlg'
|
|
136
|
-
dialog = XTERM.dup << ' -e ' << dlg << ' ' << tf.path
|
|
137
|
-
io = IO::popen(dialog)
|
|
138
|
-
Process.wait(io.pid )
|
|
139
|
-
nopts = []
|
|
140
|
-
nopts = tf.readlines
|
|
141
|
-
exit true if(nopts.empty? || 'exit' == nopts[0].strip)
|
|
142
|
-
# tf.unlink
|
|
143
|
-
return nopts
|
|
144
|
-
end
|
|
145
|
-
|
|
146
112
|
# Creates a textual dialog in xterm.
|
|
147
|
-
# Some duplicate code, here, but I am afraid to oversee
|
|
148
|
-
# unique requirements of the external programs. It had
|
|
149
|
-
# not been necessary to correct the global behavior,
|
|
150
|
-
# but adaptations in each single method should be
|
|
151
|
-
# possible.
|
|
152
113
|
def ruby_dlg
|
|
153
114
|
debug('xterm dialog')
|
|
154
115
|
tf = Tempfile.new
|
|
@@ -168,7 +129,7 @@ class OverrideDlg
|
|
|
168
129
|
end
|
|
169
130
|
nopts = tf.readlines
|
|
170
131
|
debug 'nopts is ' << nopts.to_s
|
|
171
|
-
exit true if('exit' == nopts[0].strip)
|
|
132
|
+
exit true if(nopts && !nopts.empty? && 'exit' == nopts[0].strip)
|
|
172
133
|
tf.unlink
|
|
173
134
|
return nopts
|
|
174
135
|
end
|
data/lib/ruby_dlg
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
3
|
=begin
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
***************************************************************************
|
|
5
|
+
This program is free software; you can redistribute it and/or modify
|
|
6
|
+
it under the terms of the WTFPL 2.0 or later, see
|
|
7
|
+
http://www.wtfpl.net/about/
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
12
|
+
|
|
13
|
+
***************************************************************************
|
|
14
14
|
=end
|
|
15
15
|
|
|
16
16
|
require 'readline'
|
|
17
17
|
require_relative 'color_output'
|
|
18
18
|
require 'io/wait'
|
|
19
19
|
require 'io/console'
|
|
20
|
-
require 'configuration'
|
|
21
20
|
|
|
22
21
|
if !ARGV.empty? && ARGV.length > 0
|
|
23
22
|
ofl = nil
|
data/lib/version.rb
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
#encoding: UTF-8
|
|
2
2
|
=begin
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
***************************************************************************
|
|
4
|
+
2023-2025, Michael Uplawski <michael.uplawski@uplawski.eu>
|
|
5
|
+
This program is free software; you can redistribute it and/or modify
|
|
6
|
+
it under the terms of the WTFPL 2.0 or later, see
|
|
7
|
+
http://www.wtfpl.net/about/
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
12
|
+
|
|
13
|
+
***************************************************************************
|
|
14
14
|
=end
|
|
15
15
|
|
|
16
16
|
PROGNAME = 'flnews_post_proc'
|
|
17
|
-
PROGVERSION = "2.
|
|
17
|
+
PROGVERSION = "2.03"
|
|
18
18
|
AUTHORS = "Michael Uplawski"
|
|
19
19
|
EMAIL = "michael.uplawski@uplawski.eu"
|
|
20
20
|
YEARS = "2023 - 2026"
|
metadata
CHANGED
|
@@ -1,106 +1,115 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: flnews_post_proc
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: "2.03"
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
|
-
- Michael Uplawski
|
|
7
|
+
- Michael Uplawski
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-08-
|
|
10
|
+
date: 2026-08-09 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
|
-
- !ruby/object:Gem::Dependency
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: diffy
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
-
|
|
17
|
+
- ~>
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: "3.4"
|
|
20
|
+
-
|
|
21
|
+
- ">="
|
|
22
|
+
- !ruby/object:Gem::Version
|
|
23
|
+
version: 3.4.4
|
|
24
|
+
type: :runtime
|
|
25
|
+
prerelease: false
|
|
26
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
27
|
+
requirements:
|
|
28
|
+
-
|
|
29
|
+
- ~>
|
|
30
|
+
- !ruby/object:Gem::Version
|
|
31
|
+
version: "3.4"
|
|
32
|
+
-
|
|
33
|
+
- ">="
|
|
34
|
+
- !ruby/object:Gem::Version
|
|
35
|
+
version: 3.4.4
|
|
36
|
+
- !ruby/object:Gem::Dependency
|
|
37
|
+
name: mimemagic
|
|
38
|
+
requirement: !ruby/object:Gem::Requirement
|
|
39
|
+
requirements:
|
|
40
|
+
-
|
|
41
|
+
- ~>
|
|
42
|
+
- !ruby/object:Gem::Version
|
|
43
|
+
version: "0.4"
|
|
44
|
+
-
|
|
45
|
+
- ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: 0.4.3
|
|
48
|
+
type: :runtime
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
-
|
|
53
|
+
- ~>
|
|
54
|
+
- !ruby/object:Gem::Version
|
|
55
|
+
version: "0.4"
|
|
56
|
+
-
|
|
57
|
+
- ">="
|
|
58
|
+
- !ruby/object:Gem::Version
|
|
59
|
+
version: 0.4.3
|
|
52
60
|
description: Post-processor for Usenet-articles created in flnews
|
|
53
61
|
email: michael.uplawski@uplawski.eu
|
|
54
62
|
executables:
|
|
55
|
-
- flnews_post_proc
|
|
63
|
+
- flnews_post_proc
|
|
56
64
|
extensions: []
|
|
57
65
|
extra_rdoc_files: []
|
|
58
66
|
files:
|
|
59
|
-
- README.md
|
|
60
|
-
- bin/flnews_post_proc
|
|
61
|
-
- changes.txt
|
|
62
|
-
- doc/fr/html/flnews_post_proc.html
|
|
63
|
-
- doc/fr/man/flnews_post_proc.1.gz
|
|
64
|
-
- doc/fr/pdf/flnews_post_proc.pdf
|
|
65
|
-
- doc/fr/rst/flnews_post_proc.rst
|
|
66
|
-
- doc/html/flnews_post_proc.html
|
|
67
|
-
- doc/license.txt
|
|
68
|
-
- doc/man/flnews_post_proc.1.gz
|
|
69
|
-
- doc/pdf/flnews_post_proc.pdf
|
|
70
|
-
- doc/rst/flnews_post_proc.rst
|
|
71
|
-
- lib/basic_logging.rb
|
|
72
|
-
- lib/body.rb
|
|
73
|
-
- lib/color_output.rb
|
|
74
|
-
- lib/configuration.rb
|
|
75
|
-
- lib/flnews_post_proc.conf
|
|
76
|
-
- lib/flnews_post_proc.rb
|
|
77
|
-
- lib/headers.rb
|
|
78
|
-
- lib/newsgroups.rb
|
|
79
|
-
- lib/override.rb
|
|
80
|
-
- lib/ruby_dlg
|
|
81
|
-
- lib/version.rb
|
|
82
|
-
- lib/whiptail_dlg
|
|
67
|
+
- README.md
|
|
68
|
+
- bin/flnews_post_proc
|
|
69
|
+
- changes.txt
|
|
70
|
+
- doc/fr/html/flnews_post_proc.html
|
|
71
|
+
- doc/fr/man/flnews_post_proc.1.gz
|
|
72
|
+
- doc/fr/pdf/flnews_post_proc.pdf
|
|
73
|
+
- doc/fr/rst/flnews_post_proc.rst
|
|
74
|
+
- doc/html/flnews_post_proc.html
|
|
75
|
+
- doc/license.txt
|
|
76
|
+
- doc/man/flnews_post_proc.1.gz
|
|
77
|
+
- doc/pdf/flnews_post_proc.pdf
|
|
78
|
+
- doc/rst/flnews_post_proc.rst
|
|
79
|
+
- lib/basic_logging.rb
|
|
80
|
+
- lib/body.rb
|
|
81
|
+
- lib/color_output.rb
|
|
82
|
+
- lib/configuration.rb
|
|
83
|
+
- lib/flnews_post_proc.conf
|
|
84
|
+
- lib/flnews_post_proc.rb
|
|
85
|
+
- lib/headers.rb
|
|
86
|
+
- lib/newsgroups.rb
|
|
87
|
+
- lib/override.rb
|
|
88
|
+
- lib/ruby_dlg
|
|
89
|
+
- lib/version.rb
|
|
83
90
|
licenses:
|
|
84
|
-
- WTFPL
|
|
91
|
+
- WTFPL
|
|
85
92
|
metadata:
|
|
86
|
-
homepage_uri: https://www.uplawski.eu/software/flnews_post_proc/
|
|
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/changes.txt
|
|
93
|
+
homepage_uri: "https://www.uplawski.eu/software/flnews_post_proc/"
|
|
94
|
+
documentation_uri: "https://www.uplawski.eu/div/flnews/gem_doc/html/flnews_post_proc.html"
|
|
95
|
+
changelog_uri: "https://www.uplawski.eu/div/flnews/gem_doc/changes.txt"
|
|
89
96
|
rdoc_options: []
|
|
90
97
|
require_paths:
|
|
91
|
-
- lib
|
|
98
|
+
- lib
|
|
92
99
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
93
100
|
requirements:
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
101
|
+
-
|
|
102
|
+
- ">="
|
|
103
|
+
- !ruby/object:Gem::Version
|
|
104
|
+
version: "4.0"
|
|
97
105
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
106
|
requirements:
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
107
|
+
-
|
|
108
|
+
- ">="
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: "0"
|
|
102
111
|
requirements: []
|
|
103
|
-
rubygems_version: 4.0.
|
|
112
|
+
rubygems_version: 4.1.0.dev
|
|
104
113
|
specification_version: 4
|
|
105
|
-
summary: Modify news posts, before flnews sends them.
|
|
114
|
+
summary: "Modify news posts, before flnews sends them."
|
|
106
115
|
test_files: []
|
data/lib/whiptail_dlg
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
#/**************************************************************************
|
|
4
|
-
#* This program is free software; you can redistribute it and/or modify *
|
|
5
|
-
#* it under the terms of the WTFPL 2.0 or later, see *
|
|
6
|
-
#* http://www.wtfpl.net/about/ *
|
|
7
|
-
#* *
|
|
8
|
-
#* This program is distributed in the hope that it will be useful, *
|
|
9
|
-
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
10
|
-
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
|
11
|
-
#* *
|
|
12
|
-
#***************************************************************************/
|
|
13
|
-
|
|
14
|
-
# A dialog to override configuration options.
|
|
15
|
-
# Whiptail is not as easily deployed here, as other dialogs.
|
|
16
|
-
# The main difficulty arises from the fact that positive defaults
|
|
17
|
-
# are negated, while a checklist wants to give positive results.
|
|
18
|
-
|
|
19
|
-
if [ $# -eq 0 ]
|
|
20
|
-
then
|
|
21
|
-
echo "ERROR: file-argument missing"
|
|
22
|
-
exit 1
|
|
23
|
-
fi
|
|
24
|
-
OUTFILE="$1"
|
|
25
|
-
|
|
26
|
-
# empty the file
|
|
27
|
-
truncate $OUTFILE -s0
|
|
28
|
-
|
|
29
|
-
TITLE="Override post-processor configuration"
|
|
30
|
-
CHECKTITLE="Deselect to disable. Esc or Cancel close the dialog and no changes will be applied."
|
|
31
|
-
|
|
32
|
-
# These are the configuration variables which can be unset.
|
|
33
|
-
VARS=(GROUP_SIGS CUSTOM_HEADERS NO_ARCHIVE_GROUPS VFY_URLS DEBUG_LOG)
|
|
34
|
-
|
|
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)
|
|
37
|
-
|
|
38
|
-
# show dialog and store results
|
|
39
|
-
result=$(whiptail --title "$TITLE" --checklist "$CHECKTITLE" 13 55 6 "${options[@]}" 3>&1 1>&2 2>&3)
|
|
40
|
-
# which button had been pushed?
|
|
41
|
-
okcancel=$?
|
|
42
|
-
|
|
43
|
-
# make an array
|
|
44
|
-
read -ra opts <<< $result
|
|
45
|
-
|
|
46
|
-
# comment out -------->
|
|
47
|
-
echo "cancel/ok ? $okcancel"
|
|
48
|
-
echo $result
|
|
49
|
-
echo "${opts[@]}"
|
|
50
|
-
echo "${#opts[@]}"
|
|
51
|
-
echo "VARS: (${VARS[@]})"
|
|
52
|
-
# <--------
|
|
53
|
-
|
|
54
|
-
# Find deselected options which shall be written to the outfile.
|
|
55
|
-
# Looks complicated.
|
|
56
|
-
if [ "$okcancel" -eq 0 ]
|
|
57
|
-
then
|
|
58
|
-
disable_list=''
|
|
59
|
-
enable_list=''
|
|
60
|
-
# 1) check each of the configuration variables ...
|
|
61
|
-
for c in ${OVARS[@]}
|
|
62
|
-
do
|
|
63
|
-
ignore=FALSE
|
|
64
|
-
# ... against the result from the dialog
|
|
65
|
-
for o in ${opts[@]}
|
|
66
|
-
do
|
|
67
|
-
if [ "$o" == "\"$c\"" ]
|
|
68
|
-
then
|
|
69
|
-
# ignore if a variable remained checked ...
|
|
70
|
-
ignore=TRUE
|
|
71
|
-
fi
|
|
72
|
-
done
|
|
73
|
-
if [ ! ignore ]
|
|
74
|
-
then
|
|
75
|
-
disable_list="$disable_list $c"
|
|
76
|
-
fi
|
|
77
|
-
done
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
# Heureka.
|
|
81
|
-
echo -e "$disable_list" > "$OUTFILE"
|
|
82
|
-
echo -e "$enable_list" >> "$OUTFILE"
|
|
83
|
-
else
|
|
84
|
-
echo "exit" > "$OUTFILE"
|
|
85
|
-
fi
|
|
86
|
-
|
|
87
|
-
# Ω
|