cremefraiche 1.1.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +114 -0
  3. data/bin/cremefraiche +117 -0
  4. data/bin/cremefraicheGui +26 -0
  5. data/cremefraiche.gemspec +24 -0
  6. data/doc/gui_howto.pdf +0 -0
  7. data/lib/LANG +1 -0
  8. data/lib/basic_logging.rb +170 -0
  9. data/lib/busy_indicator/.busy_function_test.rb.swp +0 -0
  10. data/lib/busy_indicator/.busy_indicator.rb.swp +0 -0
  11. data/lib/busy_indicator/.color_output.rb.swp +0 -0
  12. data/lib/busy_indicator/busy_function_test.rb +50 -0
  13. data/lib/busy_indicator/busy_indicator.rb +89 -0
  14. data/lib/busy_indicator/color_output.rb +45 -0
  15. data/lib/cfprawn.rb +387 -0
  16. data/lib/confcheck.rb +103 -0
  17. data/lib/config +187 -0
  18. data/lib/configuration.rb +234 -0
  19. data/lib/configuration.rb~ +247 -0
  20. data/lib/cremefraiche.rb +181 -0
  21. data/lib/emlfile.rb +136 -0
  22. data/lib/file_checking.rb +82 -0
  23. data/lib/gui/.ButtonLabel.rb.swp +0 -0
  24. data/lib/gui/.conf_value.rb.swp +0 -0
  25. data/lib/gui/.cremefraicheGui.rb.swp +0 -0
  26. data/lib/gui/.message_dialog.rb.swp +0 -0
  27. data/lib/gui/AboutDialog.rb +63 -0
  28. data/lib/gui/ButtonLabel.rb +41 -0
  29. data/lib/gui/ConfDialog.rb +610 -0
  30. data/lib/gui/HowtoDialog.rb +183 -0
  31. data/lib/gui/conf_option.rb +274 -0
  32. data/lib/gui/conf_value.rb +58 -0
  33. data/lib/gui/cremefraicheGui.rb +568 -0
  34. data/lib/gui/gtk-about.xpm +90 -0
  35. data/lib/gui/gtk-close.xpm +90 -0
  36. data/lib/gui/gtk-execute.xpm +118 -0
  37. data/lib/gui/gtk-open.xpm +147 -0
  38. data/lib/gui/gtk-properties.xpm +378 -0
  39. data/lib/gui/gtk-quit.xpm +352 -0
  40. data/lib/gui/gtk-remove.xpm +123 -0
  41. data/lib/gui/gtk-save.xpm +214 -0
  42. data/lib/gui/gtk-stop.xpm +344 -0
  43. data/lib/gui/help.xpm +463 -0
  44. data/lib/gui/icon.xpm +300 -0
  45. data/lib/gui/message_dialog.rb +34 -0
  46. data/lib/gui/okay.xpm +49 -0
  47. data/lib/gui/preferences-color.xpm +252 -0
  48. data/lib/gui/view.xpm +75 -0
  49. data/lib/html2text.rb +195 -0
  50. data/lib/icon/icon.xpm +300 -0
  51. data/lib/icon/icon_big.xpm +661 -0
  52. data/lib/license.rb +38 -0
  53. data/lib/log.conf +65 -0
  54. data/lib/tag_munging.rb +89 -0
  55. data/lib/translating.rb +78 -0
  56. data/lib/translations +609 -0
  57. data/lib/version.rb +25 -0
  58. metadata +221 -0
data/lib/license.rb ADDED
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env ruby #encoding: UTF-8
2
+ =begin
3
+ /***************************************************************************
4
+ * ©2023-2023, Michael Uplawski <michael.uplawski@uplawski.eu> *
5
+ * *
6
+ * This program is free software; you can redistribute it and/or modify *
7
+ * it under the terms of the WTFPL 2.0 or later version of the LICENSE. *
8
+ * See https://wtfpl2.com/ for details. *
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
+ # the DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE, version 2
17
+ LICENSE_TEXT = %+
18
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
19
+ Version 2, December 2004
20
+
21
+ Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
22
+
23
+ Everyone is permitted to copy and distribute verbatim or modified
24
+ copies of this license document, and changing it is allowed as long
25
+ as the name is changed.
26
+
27
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
28
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
29
+
30
+ 0. You just DO WHAT THE FUCK YOU WANT TO.+
31
+
32
+
33
+ if __FILE__ == $0
34
+ puts license_text
35
+ end
36
+
37
+
38
+
data/lib/log.conf ADDED
@@ -0,0 +1,65 @@
1
+ #encoding: UTF-8
2
+ =begin
3
+ /***************************************************************************
4
+ * ©2013-2020 Michael Uplawski <michael.uplawski@uplawski.eu> *
5
+ * *
6
+ * This program is free software; you can redistribute it and/or modify *
7
+ * it under the terms of the GNU General Public License as published by *
8
+ * the Free Software Foundation; either version 3 of the License, or *
9
+ * (at your option) any later version. *
10
+ * *
11
+ * This program is distributed in the hope that it will be useful, *
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
+ * GNU General Public License for more details. *
15
+ * *
16
+ * You should have received a copy of the GNU General Public License *
17
+ * along with this program; if not, write to the *
18
+ * Free Software Foundation, Inc., *
19
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
20
+ ***************************************************************************/
21
+
22
+ A simplified logger configuration. Set the level for each individual logger
23
+ below. Choose a different log-device or log-file if you like. Keep the
24
+ formatting intact. Do not change other sections of this file.
25
+ =end
26
+
27
+ # Do not touch from here ----->
28
+ require 'logger'
29
+
30
+ debug = Logger::DEBUG
31
+ info = Logger::INFO
32
+ error = Logger::ERROR
33
+ fatal = Logger::FATAL
34
+ warn = Logger::WARN
35
+ unknown = Logger::UNKNOWN
36
+ {
37
+ # <---------------- to here !
38
+
39
+ # Enter your settings here, but take into consideration that not all
40
+ # the named classes will really produce readable output. Well, you can
41
+ # always try... Either name just the log-level or make the log-level
42
+ # precede the output-device or output-file like in the examples.
43
+ # PAY ATTENTION to the fact, that these settings overwrite any other
44
+ # way to configure the loggers.
45
+
46
+ # Example: naming a log-file
47
+ # :HtmlBuilder => [info, 'C:\temp\htmlbuilder.log']
48
+ # :HtmlBuilder => [debug, '/tmp/htmlbuilder.log'],
49
+
50
+ :Configuration => info,
51
+ :ConfDialog => info,
52
+ :ConfOption => info,
53
+ :EmlFile => info,
54
+ :CremeFraiche => info,
55
+ :CremeFraicheGui => info,
56
+ :CFPrawn => info,
57
+ :Html2Text => info,
58
+ :TagMunging => info,
59
+ :ButtonLabel => info,
60
+ :HowtoDialog => info,
61
+
62
+ # And ignore the remainder, too.
63
+ }
64
+
65
+ #eof
@@ -0,0 +1,89 @@
1
+ #encoding: UTF-8
2
+ =begin
3
+ /***************************************************************************
4
+ * ©2013-2023, Michael Uplawski <michael.uplawski@uplawski.eu> *
5
+ * *
6
+ * This program is free software; you can redistribute it and/or modify *
7
+ * it under the terms of the WTFPL 2.0 or later version of the LICENSE. *
8
+ * See https://wtfpl2.com/ for details. *
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
+ require_relative 'translating'
17
+ require 'nokogiri'
18
+ require 'singleton'
19
+
20
+ =begin
21
+ A utility module for recurring tag-specific tasks.
22
+ =end
23
+ module TagMunging
24
+
25
+ def remove_empty_rows(table)
26
+ all_body_rows(table) do |tr|
27
+ cells = tr.xpath("./td").dup
28
+ empty = true
29
+ cells.each{|cell| empty = false if !cell.children.empty? }
30
+ tr.remove if empty
31
+ end
32
+ end
33
+
34
+ def all_row_cells(tr, &b)
35
+ tds = tr.xpath('./td')
36
+ tds.each do |td|
37
+ yield(td, tds.index(td) )
38
+ end
39
+ end
40
+
41
+ def all_body_rows(table, &b)
42
+ trs = table.xpath("./tbody/tr")
43
+ debug('table contains ' << trs.size.to_s << ' data-rows') if self.respond_to?(:log)
44
+ trs.each do |tr|
45
+ yield(tr, trs.index(tr) )
46
+ end
47
+ end
48
+
49
+ def all_body_cells(table, &b)
50
+ trs = table.xpath("./tbody/tr")
51
+ debug('table contains ' << trs.size.to_s << ' data-rows') if self.respond_to?(:log)
52
+ trs.each do |tr|
53
+ all_row_cells(tr) do |td|
54
+ yield(td, trs.index(td) )
55
+ end
56
+ end
57
+ end
58
+
59
+ def remove_empty_sub_tags(parent, tag)
60
+ tags = parent.xpath(".//" << tag)
61
+ tags.each{|t| t.remove if t.content.chomp.strip.empty?}
62
+ end
63
+
64
+ def right_align_numbers(tags, symbol)
65
+ tags.each do |tag|
66
+ if(tag.content.chomp.match(/^-?[^\D]\d*(\.?\d*)?[^\D]?$/) )
67
+ tag['class'] = (tag['class'] ? tag['class'] : '') << ' ' << 'right'
68
+ cont = tag.content
69
+ tag.content = cont << symbol if cont && symbol
70
+ end
71
+ end
72
+ end
73
+
74
+ def new_tag(doc, tag, options = nil)
75
+ ntag = Nokogiri::XML::Node.new(tag, doc)
76
+ if(options && options.respond_to?(:to_hash))
77
+ ntag.content = options.delete(:content) if options[:content]
78
+ ntag.parent = options.delete(:parent) if options[:parent]
79
+ options.each do |k,v|
80
+ ntag[k.to_s] = v
81
+ end
82
+ end
83
+ return ntag
84
+ end
85
+
86
+ def tag_by_content(doc, tagname, content)
87
+ return doc.xpath("//" << tagname.to_s).detect{|tag| tag.content.strip == content}
88
+ end
89
+ end
@@ -0,0 +1,78 @@
1
+ #encoding: UTF-8
2
+ =begin
3
+ /***************************************************************************
4
+ * ©2011-2016, Michael Uplawski *
5
+ * <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 GNU General Public License as published by *
9
+ * the Free Software Foundation; either version 3 of the License, or *
10
+ * (at your option) any later version. *
11
+ * *
12
+ * This program is distributed in the hope that it will be useful, *
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15
+ * GNU General Public License for more details. *
16
+ * *
17
+ * You should have received a copy of the GNU General Public License *
18
+ * along with this program; if not, write to the *
19
+ * Free Software Foundation, Inc., *
20
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21
+ ***************************************************************************/
22
+ =end
23
+
24
+
25
+ RD = File.expand_path(File.dirname(__FILE__) ) + File::SEPARATOR if !defined?(RD)
26
+
27
+ require 'yaml'
28
+ require_relative 'file_checking'
29
+
30
+
31
+ # A way to produce translated text in a ruby-program.
32
+ # Translations are read from a file "translations" in the program folder.
33
+ module Translating
34
+ # There are better ways to extend a translated
35
+ # string, but I keep the 'wild-card' for
36
+ # historical reasons.
37
+
38
+ @@lang = nil
39
+ @@lang_file = format("%s%s", RD, 'LANG')
40
+ @@tr = YAML::load_file("#{RD}translations")
41
+
42
+ # find the current language-setting and return it.
43
+ def self.language()
44
+ if @@lang == nil
45
+ r = ENV['LANG']
46
+ if(r)
47
+ @@lang = r[0, 2]
48
+ elsif( !File_Checking::file_check(@@lang_file, [:exist?, :readable?]) && File::size(@@lang_file) >= 2)
49
+ File::open(@@lang_file, 'r') {|f| @@lang = f.readline}
50
+ @@lang.chomp!.downcase! if @@lang
51
+ end
52
+ end
53
+ @@lang = 'en' if !@@lang
54
+ end
55
+
56
+ # Translate a string to the currently set langage. If 'warn' is true
57
+ # (default), a missing translation provokes a message on STDOUT,
58
+ # indicating the string that needs translating.
59
+ def self.trl(t, warn = true)
60
+ Translating::language()
61
+ lt = @@tr[t]
62
+ if(lt)
63
+ lt = lt[@@lang]
64
+ elsif warn
65
+ # File.open('/tmp/mtf', 'a+') {|f| f << t << "\n"}
66
+ puts "\nTRANSLATION MISSING: \"" << t << "\""
67
+ end
68
+ lt ||= t
69
+ return lt
70
+ end
71
+
72
+ # Translate a string to the currently set langage. If 'warn' is true
73
+ # (default), a missing translation provokes a message on STDOUT,
74
+ # indicating the string that needs translating.
75
+ def trl(t, warn = true )
76
+ Translating::trl(t, warn)
77
+ end
78
+ end