flnews_post_proc 1.54 → 1.55
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 +4 -4
- data/bin/flnews_post_proc +46 -34
- data/lib/body.rb +3 -1
- data/lib/flnews_post_proc.conf +2 -2
- data/lib/flnews_post_proc.rb +3 -2
- data/lib/headers.rb +21 -1
- data/lib/override.rb +2 -1
- data/lib/ruby_dlg +29 -12
- data/lib/version.rb +2 -2
- data/lib/whiptail_dlg +4 -2
- data/lib/yad_dlg +11 -3
- data/lib/zenity_dlg +11 -2
- metadata +23 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7893f5a913ec2f1682d699180984ffa61603c01722c7f88edd7840b4f3cce797
|
4
|
+
data.tar.gz: a71ea92cc87014b4f75cd99e01d6bafd6b368cb076e5f1420a9e1105c95b97ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4606de5db3e9f9ea86777e60135f4e80b5d6437380692e446493752d461a8ff0c5e08b042f14ed3de33f52eb6290a89cbd2443c8d0dcb55e36b6819c20e90462
|
7
|
+
data.tar.gz: 8f9a783124f7ec6a1256488fde0bcead47868621506e8b23a7558aa87cca65881afeb9aa13280257a0bc5a7915917b5c592ee98d5ee2aa4fdd30e0dc25e31208
|
data/bin/flnews_post_proc
CHANGED
@@ -23,6 +23,7 @@ if ! /linux/ =~ RUBY_PLATFORM
|
|
23
23
|
end
|
24
24
|
|
25
25
|
require 'tempfile'
|
26
|
+
require 'filemagic'
|
26
27
|
require_relative '../lib/override'
|
27
28
|
require_relative '../lib/flnews_post_proc'
|
28
29
|
require_relative '../lib/basic_logging'
|
@@ -31,6 +32,15 @@ require_relative '../lib/version'
|
|
31
32
|
|
32
33
|
self.extend(BasicLogging)
|
33
34
|
|
35
|
+
def usage
|
36
|
+
usage = "\nWhat do you want me to do? Where is the article to post-process?"
|
37
|
+
usage << "\nUsage: "
|
38
|
+
usage << "\n\t#{$0} < article.text"
|
39
|
+
info usage
|
40
|
+
STDERR.puts usage
|
41
|
+
exit false
|
42
|
+
end
|
43
|
+
|
34
44
|
msg = PROGNAME.dup << ' ' << PROGVERSION << ' starting'
|
35
45
|
msg = "–––––– " << msg << " ––––––"
|
36
46
|
info msg
|
@@ -44,46 +54,48 @@ config = Configuration::instance
|
|
44
54
|
if (!STDIN.tty?)
|
45
55
|
# read from STDIN
|
46
56
|
artext = ARGF.read
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
if
|
53
|
-
|
54
|
-
|
55
|
-
if
|
56
|
-
|
57
|
-
OverrideDlg.
|
58
|
-
|
59
|
-
|
60
|
-
|
57
|
+
|
58
|
+
# There is content, create the post-processor.
|
59
|
+
if !artext.strip.empty?
|
60
|
+
mime = FileMagic.mime.buffer artext
|
61
|
+
debug('mime is ' << mime)
|
62
|
+
if mime.start_with?('message/news')
|
63
|
+
#----------->
|
64
|
+
# Allow to override the configuration,
|
65
|
+
# if not disabled (default is true)
|
66
|
+
if config.OVERRIDE_CONFIG != false
|
67
|
+
cdlg = OverrideDlg.new
|
68
|
+
discarded = cdlg.show
|
69
|
+
if discarded && !discarded.empty?
|
70
|
+
debug('options overriden ' << discarded)
|
71
|
+
OverrideDlg.cvars.each do |v|
|
72
|
+
if discarded.include?(v.to_s)
|
73
|
+
debug('removing ' << v.to_s)
|
74
|
+
config.set(v, nil)
|
75
|
+
end
|
61
76
|
end
|
62
77
|
end
|
78
|
+
debug('new config: ' << config.inspect)
|
63
79
|
end
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
80
|
+
#<--------------
|
81
|
+
pp = PostProcessor.new(artext)
|
82
|
+
# ... and print its result.
|
83
|
+
article = pp.article
|
84
|
+
if article
|
85
|
+
# -------------> The main objective <------
|
86
|
+
puts article
|
87
|
+
# <------------- over and out ------>
|
88
|
+
exit true
|
89
|
+
end
|
90
|
+
# whatever.
|
91
|
+
exit false
|
92
|
+
else
|
93
|
+
error ("Input is of wrong mime-type" << mime)
|
75
94
|
end
|
76
|
-
# whatever.
|
77
|
-
exit false
|
78
95
|
else
|
79
|
-
error( "Cannot read the article, no content" )
|
96
|
+
error( "Cannot read the article, no content" )
|
80
97
|
end
|
81
98
|
else
|
82
|
-
usage
|
83
|
-
usage << "\nUsage: "
|
84
|
-
usage << "\n\t#{$0} < article.text"
|
85
|
-
info usage
|
86
|
-
STDERR.puts usage
|
87
|
-
exit false
|
99
|
+
usage()
|
88
100
|
end
|
89
101
|
# Ω
|
data/lib/body.rb
CHANGED
@@ -146,8 +146,10 @@ class Body
|
|
146
146
|
# Simple.
|
147
147
|
def handle_uris()
|
148
148
|
# Determine here or elsewhere if URLs shall be verified.
|
149
|
-
# Default is
|
149
|
+
# Default is no. nil or '' do qualify as default.
|
150
|
+
debug 'verify URLs ? ' << @@config.VFY_URLS.to_s
|
150
151
|
if @@config.VFY_URLS
|
152
|
+
debug 'verifying URLs'
|
151
153
|
@lines.each_with_index do | l, i |
|
152
154
|
# leave cited lines as they are.
|
153
155
|
if !l.start_with?( '>')
|
data/lib/flnews_post_proc.conf
CHANGED
@@ -152,9 +152,9 @@ REFERENCE_FORMAT: " ➤%s"
|
|
152
152
|
#
|
153
153
|
# If the variable is not set, a value 'yes' is assumed.
|
154
154
|
# CONTENT: One of YES, yes, NO, no, and other variations of case.
|
155
|
-
# DEFAULT:
|
155
|
+
# DEFAULT: No
|
156
156
|
# Example: ... I let you guess.
|
157
|
-
VFY_URLS:
|
157
|
+
VFY_URLS: No
|
158
158
|
|
159
159
|
# OVERRIDE_CONFIG
|
160
160
|
# A Boolean constant. You can choose to override the following
|
data/lib/flnews_post_proc.rb
CHANGED
@@ -54,8 +54,9 @@ class PostProcessor
|
|
54
54
|
body.handle_references
|
55
55
|
body.set_signature(newsgroups.signature)
|
56
56
|
|
57
|
-
# verify and eventually correct
|
58
|
-
|
57
|
+
# verify and eventually correct URIs.
|
58
|
+
# ----- DANGEROUS, disabled for the time. ----
|
59
|
+
# body.handle_uris
|
59
60
|
|
60
61
|
# get the headers and the body as a string.
|
61
62
|
# Assemble.
|
data/lib/headers.rb
CHANGED
@@ -30,11 +30,31 @@ class Headers
|
|
30
30
|
# transform the article to an array.
|
31
31
|
debug('before split, article_text is : ' << article_text)
|
32
32
|
line_array = article_text.split($LN)
|
33
|
+
|
34
|
+
# Emsure that all three headers are present.
|
35
|
+
missing_header = ['From:', 'Newsgroups:', 'Message-ID:'].detect{|h| ! line_array.any?{|l| l.match(h) } }
|
36
|
+
if(missing_header)
|
37
|
+
msg = "Input does not look like a news-article, no #{missing_header.delete(':')}; aborting."
|
38
|
+
STDERR.puts msg
|
39
|
+
error(msg)
|
40
|
+
exit false
|
41
|
+
end
|
42
|
+
|
33
43
|
debug('after split, line_array is : ' << line_array.inspect)
|
34
44
|
# find the first empty line
|
35
45
|
end_index = line_array.index {|ele| ele.strip == ''}
|
36
46
|
# keep the preceding lines.
|
37
|
-
|
47
|
+
begin
|
48
|
+
@lines = line_array.slice!(0, end_index)
|
49
|
+
rescue Exception => ex
|
50
|
+
msg = 'ERROR: cannot split the input into lines: ' << self.class.name << ': ' << ex.message
|
51
|
+
# console
|
52
|
+
STDERR.puts msg
|
53
|
+
# log
|
54
|
+
error(msg)
|
55
|
+
exit false
|
56
|
+
end
|
57
|
+
|
38
58
|
debug('headers: ' << @lines.to_s)
|
39
59
|
|
40
60
|
# headername: headervalue
|
data/lib/override.rb
CHANGED
@@ -40,7 +40,8 @@ class OverrideDlg
|
|
40
40
|
@@LIBDIR = File::dirname(__FILE__)
|
41
41
|
# The configuration variables that can be unset.
|
42
42
|
# This class instance variable is exposed via a getter.
|
43
|
-
@cvars = [:GROUP_SIGS, :CUSTOM_HEADERS, :NO_ARCHIVE_GROUPS, :
|
43
|
+
@cvars = [:GROUP_SIGS, :CUSTOM_HEADERS, :NO_ARCHIVE_GROUPS, :DEBUG_LOG]
|
44
|
+
# @cvars = [:GROUP_SIGS, :CUSTOM_HEADERS, :NO_ARCHIVE_GROUPS, :VFY_URLS, :DEBUG_LOG]
|
44
45
|
|
45
46
|
# ... here
|
46
47
|
# For the record: this is rather cool.
|
data/lib/ruby_dlg
CHANGED
@@ -50,14 +50,14 @@ if !ARGV.empty? && ARGV.length > 0
|
|
50
50
|
|
51
51
|
opt_array = []
|
52
52
|
message = ''
|
53
|
+
|
53
54
|
menu ||= %=
|
54
55
|
1 Unset Signature GROUP_SIGS
|
55
56
|
2 Unset Custom headers CUSTOM_HEADERS
|
56
57
|
3 Unset No Archive NO_ARCHIVE_GROUPS
|
57
|
-
4
|
58
|
-
5 Disable log DEBUG_LOG
|
58
|
+
4 Disable log DEBUG_LOG
|
59
59
|
––––––––––––––––––––––––––––––––––––––––––––––
|
60
|
-
|
60
|
+
5 Summary
|
61
61
|
––––––––––––––––––––––––––––––––––––––––––––––
|
62
62
|
0 Okay, use settings.
|
63
63
|
––––––––––––––––––––––––––––––––––––––––––––––––
|
@@ -65,6 +65,21 @@ if !ARGV.empty? && ARGV.length > 0
|
|
65
65
|
and no changes will be applied.
|
66
66
|
=
|
67
67
|
|
68
|
+
# menu ||= %=
|
69
|
+
# 1 Unset Signature GROUP_SIGS
|
70
|
+
# 2 Unset Custom headers CUSTOM_HEADERS
|
71
|
+
# 3 Unset No Archive NO_ARCHIVE_GROUPS
|
72
|
+
# 4 Do not correct URLs VFY_URLS
|
73
|
+
# 5 Disable log DEBUG_LOG
|
74
|
+
# ––––––––––––––––––––––––––––––––––––––––––––––
|
75
|
+
# 6 Summary
|
76
|
+
# ––––––––––––––––––––––––––––––––––––––––––––––
|
77
|
+
# 0 Okay, use settings.
|
78
|
+
#––––––––––––––––––––––––––––––––––––––––––––––––
|
79
|
+
##{bold("Esc, Ctrl+C and 'q'")} terminate the Post-processor
|
80
|
+
#and no changes will be applied.
|
81
|
+
# =
|
82
|
+
|
68
83
|
loop do
|
69
84
|
system 'clear'
|
70
85
|
puts yellow(menu)
|
@@ -111,15 +126,16 @@ and no changes will be applied.
|
|
111
126
|
message = "X-No-Archive #{active ? 'removed' : 'is added'}!"
|
112
127
|
menu.sub!("Unset X-No-Archive", "Add X-No-Archive ") if active
|
113
128
|
menu.sub!("Add X-No-Archive ", "Unset X-No-Archive") if !active
|
129
|
+
# when 4
|
130
|
+
# active = !opt_array.include?(:VFY_URLS)
|
131
|
+
# opt_array << :VFY_URLS if active
|
132
|
+
# opt_array.delete(:VFY_URLS) if !active
|
133
|
+
#
|
134
|
+
# message = "URLS will #{active ? 'not ' : ''}" << "be verified!"
|
135
|
+
# menu.sub!("Do not correct URLs", "Correct URLs ") if active
|
136
|
+
# menu.sub!("Correct URLs ", "Do not correct URLs") if !active
|
137
|
+
# when 5
|
114
138
|
when 4
|
115
|
-
active = !opt_array.include?(:VFY_URLS)
|
116
|
-
opt_array << :VFY_URLS if active
|
117
|
-
opt_array.delete(:VFY_URLS) if !active
|
118
|
-
|
119
|
-
message = "URLS will #{active ? 'not ' : ''}" << "be verified!"
|
120
|
-
menu.sub!("Do not correct URLs", "Correct URLs ") if active
|
121
|
-
menu.sub!("Correct URLs ", "Do not correct URLs") if !active
|
122
|
-
when 5
|
123
139
|
active = !opt_array.include?(:DEBUG_LOG)
|
124
140
|
opt_array << :DEBUG_LOG if active
|
125
141
|
opt_array.delete(:DEBUG_LOG) if !active
|
@@ -127,7 +143,8 @@ and no changes will be applied.
|
|
127
143
|
message = "Log is #{ active ? 'not ' : ''} " << "written!"
|
128
144
|
menu.sub!("Disable log", "Enable log ") if active
|
129
145
|
menu.sub!("Enable log ", "Disable log") if !active
|
130
|
-
|
146
|
+
# when 6
|
147
|
+
when 5
|
131
148
|
message = "Summary of " << bold('disabled') << " options: " << opt_array.join(' ')
|
132
149
|
end
|
133
150
|
end
|
data/lib/version.rb
CHANGED
@@ -14,8 +14,8 @@
|
|
14
14
|
=end
|
15
15
|
|
16
16
|
PROGNAME = 'flnews_post_proc'
|
17
|
-
PROGVERSION = "1.
|
17
|
+
PROGVERSION = "1.55"
|
18
18
|
AUTHORS = "Michael Uplawski"
|
19
19
|
EMAIL = "michael.uplawski@uplawski.eu"
|
20
20
|
YEARS = "2023 - 2024"
|
21
|
-
SUMMARY = "
|
21
|
+
SUMMARY = "more checks on the input data, URI corrections disabled"
|
data/lib/whiptail_dlg
CHANGED
@@ -30,10 +30,12 @@ TITLE="Override post-processor configuration"
|
|
30
30
|
CHECKTITLE="Deselect to disable. Esc or Cancel close the dialog and no changes will be applied."
|
31
31
|
|
32
32
|
# These are the configuration variables which can be unset.
|
33
|
-
VARS=(GROUP_SIGS CUSTOM_HEADERS NO_ARCHIVE_GROUPS VFY_URLS DEBUG_LOG)
|
33
|
+
# VARS=(GROUP_SIGS CUSTOM_HEADERS NO_ARCHIVE_GROUPS VFY_URLS DEBUG_LOG)
|
34
|
+
VARS=(GROUP_SIGS CUSTOM_HEADERS NO_ARCHIVE_GROUPS DEBUG_LOG)
|
34
35
|
|
35
36
|
# 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
|
+
# 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)
|
38
|
+
options=(GROUP_SIGS 'Signatures' ON CUSTOM_HEADERS 'Custom headers' ON NO_ARCHIVE_GROUPS 'No Archive' ON DEBUG_LOG 'Log' ON)
|
37
39
|
|
38
40
|
# show dialog and store results
|
39
41
|
result=$(whiptail --title "$TITLE" --checklist "$CHECKTITLE" 13 55 5 "${options[@]}" 3>&1 1>&2 2>&3)
|
data/lib/yad_dlg
CHANGED
@@ -19,14 +19,22 @@ TITLE="Override post-processor configuration"
|
|
19
19
|
GROUP_SIGS=1
|
20
20
|
CUSTOM_HEADERS=2
|
21
21
|
NO_ARCHIVE_GROUPS=3
|
22
|
-
VFY_URLS=4
|
23
|
-
DEBUG_LOG=
|
22
|
+
#VFY_URLS=4
|
23
|
+
DEBUG_LOG=4
|
24
|
+
|
25
|
+
#CONF=$(yad --item-separator=" " --title "$TITLE" --image="" --window-icon="" --form \
|
26
|
+
# --field="Uncheck to disable options\n<b>Esc and Cancel</b> terminate the post-processor.":LBL ""\
|
27
|
+
# --field="Signature":CHK 'true' \
|
28
|
+
# --field="Custom-headers":CHK 'true' \
|
29
|
+
# --field="No Archive":CHK 'true' \
|
30
|
+
# --field="URL Correction":CHK 'true' \
|
31
|
+
# --field="Log":CHK 'true')
|
32
|
+
|
24
33
|
CONF=$(yad --item-separator=" " --title "$TITLE" --image="" --window-icon="" --form \
|
25
34
|
--field="Uncheck to disable options\n<b>Esc and Cancel</b> terminate the post-processor.":LBL ""\
|
26
35
|
--field="Signature":CHK 'true' \
|
27
36
|
--field="Custom-headers":CHK 'true' \
|
28
37
|
--field="No Archive":CHK 'true' \
|
29
|
-
--field="URL Correction":CHK 'true' \
|
30
38
|
--field="Log":CHK 'true')
|
31
39
|
|
32
40
|
if [ $? == 0 ]
|
data/lib/zenity_dlg
CHANGED
@@ -16,14 +16,22 @@
|
|
16
16
|
TITLE="Override post-processor configuration"
|
17
17
|
# The options are the configuration variables which can be unset.
|
18
18
|
|
19
|
+
#CONF=$(zenity --title "$TITLE" --text "Deselect options to disable.\n<b>Esc and Cancel</b> terminate the post-processor."\
|
20
|
+
# --height 450 --list --checklist --column 'set' --column 'Option' --column '' \
|
21
|
+
# TRUE GROUP_SIGS Signature\
|
22
|
+
# TRUE CUSTOM_HEADERS "Custom Headers"\
|
23
|
+
# TRUE NO_ARCHIVE_GROUPS "No Archive"\
|
24
|
+
# TRUE VFY_URLS "Correct URLs"\
|
25
|
+
# TRUE DEBUG_LOG Log)
|
26
|
+
|
19
27
|
CONF=$(zenity --title "$TITLE" --text "Deselect options to disable.\n<b>Esc and Cancel</b> terminate the post-processor."\
|
20
28
|
--height 450 --list --checklist --column 'set' --column 'Option' --column '' \
|
21
29
|
TRUE GROUP_SIGS Signature\
|
22
30
|
TRUE CUSTOM_HEADERS "Custom Headers"\
|
23
31
|
TRUE NO_ARCHIVE_GROUPS "No Archive"\
|
24
|
-
TRUE VFY_URLS "Correct URLs"\
|
25
32
|
TRUE DEBUG_LOG Log)
|
26
33
|
|
34
|
+
|
27
35
|
if [ $? == 0 ]
|
28
36
|
then
|
29
37
|
IFS="|"
|
@@ -33,7 +41,8 @@ then
|
|
33
41
|
# echo ${C_ARR[@]}
|
34
42
|
# <-------------
|
35
43
|
|
36
|
-
for c in GROUP_SIGS CUSTOM_HEADERS NO_ARCHIVE_GROUPS VFY_URLS DEBUG_LOG
|
44
|
+
# for c in GROUP_SIGS CUSTOM_HEADERS NO_ARCHIVE_GROUPS VFY_URLS DEBUG_LOG
|
45
|
+
for c in GROUP_SIGS CUSTOM_HEADERS NO_ARCHIVE_GROUPS DEBUG_LOG
|
37
46
|
do
|
38
47
|
# disable only the options which are missing in
|
39
48
|
# the Zenity return value
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flnews_post_proc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.55'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Uplawski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: diffy
|
@@ -30,6 +30,26 @@ dependencies:
|
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 3.4.2
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: ruby-filemagic
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0.7'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 0.7.3
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0.7'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 0.7.3
|
33
53
|
description: Post-processor for Usenet-articles created in flnews
|
34
54
|
email: michael.uplawski@uplawski.eu
|
35
55
|
executables:
|
@@ -85,5 +105,5 @@ requirements: []
|
|
85
105
|
rubygems_version: 3.5.3
|
86
106
|
signing_key:
|
87
107
|
specification_version: 4
|
88
|
-
summary:
|
108
|
+
summary: more checks on the input data, URI corrections disabled
|
89
109
|
test_files: []
|