Commit 2623019d52fd3bf95a3d86562a7128ef062ed4db
1 parent
894cbe327f
Exists in
master
Amélioration de wize.rb
Showing 7 changed files with 356 additions and 91 deletions Inline Diff
style-blue.conf
# | 1 | 1 | # | |
# Regarder l'aide de zim section Config Files | 2 | 2 | # Regarder l'aide de zim section Config Files | |
# | 3 | 3 | # | |
[TextView] | 4 | 4 | [TextView] | |
indent=30 | 5 | 5 | indent=30 | |
tabs=None | 6 | 6 | tabs=None | |
font= | 7 | 7 | font= | |
justify= | 8 | 8 | justify= | |
linespacing=3 | 9 | 9 | linespacing=3 | |
bullet_icon_size=GTK_ICON_SIZE_MENU | 10 | 10 | bullet_icon_size=GTK_ICON_SIZE_MENU | |
11 | 11 | |||
[Tag strong] | 12 | 12 | [Tag strong] | |
weight=PANGO_WEIGHT_BOLD | 13 | 13 | weight=PANGO_WEIGHT_BOLD | |
14 | 14 | |||
[Tag emphasis] | 15 | 15 | [Tag emphasis] | |
style=PANGO_STYLE_ITALIC | 16 | 16 | style=PANGO_STYLE_ITALIC | |
17 | 17 | |||
[Tag mark] | 18 | 18 | [Tag mark] | |
underline=PANGO_UNDERLINE_SINGLE | 19 | 19 | underline=PANGO_UNDERLINE_SINGLE | |
background=white | 20 | 20 | background=white | |
21 | 21 | |||
[Tag strike] | 22 | 22 | [Tag strike] | |
strikethrough=True | 23 | 23 | strikethrough=True | |
foreground=grey | 24 | 24 | foreground=grey | |
25 | 25 | |||
[Tag code] | 26 | 26 | [Tag code] | |
foreground=#8B008B | 27 | 27 | foreground=darkmagenta | |
family=monospace | 28 | 28 | family=monospace | |
29 | 29 | |||
[Tag pre] | 30 | 30 | [Tag pre] | |
foreground=#8B008B | 31 | 31 | foreground=darkmagenta | |
family=monospace | 32 | 32 | family=monospace | |
wrap-mode=GTK_WRAP_NONE | 33 | 33 | wrap-mode=GTK_WRAP_NONE | |
indent=20 | 34 | 34 | indent=20 | |
35 | 35 | |||
[Tag link] | 36 | 36 | [Tag link] | |
foreground=#008ab8 | 37 | 37 | foreground=#008ab8 | |
38 | 38 | |||
[Tag tag] | 39 | 39 | [Tag tag] | |
foreground=#ce5c00 | 40 | 40 | foreground=#ce5c00 | |
41 | 41 | |||
[Tag h1] | 42 | 42 | [Tag h1] | |
foreground=#437484 | 43 | 43 | foreground=#437484 | |
underline=PANGO_UNDERLINE_SINGLE | 44 | 44 | underline=PANGO_UNDERLINE_SINGLE | |
weight=PANGO_WEIGHT_BOLD | 45 | 45 | weight=PANGO_WEIGHT_BOLD | |
scale=1.75 | 46 | 46 | scale=1.75 | |
47 | 47 | |||
[Tag h2] | 48 | 48 | [Tag h2] | |
foreground=#437484 | 49 | 49 | foreground=#437484 | |
weight=PANGO_WEIGHT_BOLD | 50 | 50 | weight=PANGO_WEIGHT_BOLD | |
scale=1.52 | 51 | 51 | scale=1.52 | |
indent=20 | 52 | 52 | indent=20 | |
53 | 53 | |||
[Tag h3] | 54 | 54 | [Tag h3] | |
foreground=#437484 | 55 | 55 | foreground=#437484 | |
style=PANGO_STYLE_ITALIC | 56 | 56 | style=PANGO_STYLE_ITALIC | |
weight=PANGO_WEIGHT_BOLD | 57 | 57 | weight=PANGO_WEIGHT_BOLD | |
scale=1.32 | 58 | 58 | scale=1.32 | |
indent=40 | 59 | 59 | indent=40 | |
60 | 60 | |||
[Tag h4] | 61 | 61 | [Tag h4] | |
foreground=#437484 | 62 | 62 | foreground=#437484 | |
weight=PANGO_WEIGHT_BOLD | 63 | 63 | weight=PANGO_WEIGHT_BOLD | |
scale=1.15 | 64 | 64 | scale=1.15 | |
indent=60 | 65 | 65 | indent=60 |
style-template.conf
File was created | 1 | # | ||
2 | # Regarder l'aide de zim section Config Files | |||
3 | # | |||
4 | [TextView] | |||
5 | indent=30 | |||
6 | tabs=None | |||
7 | font= | |||
8 | justify= | |||
9 | linespacing=3 | |||
10 | bullet_icon_size=GTK_ICON_SIZE_MENU | |||
11 | ||||
12 | [Tag strong] | |||
13 | weight=PANGO_WEIGHT_BOLD | |||
14 | ||||
15 | [Tag emphasis] | |||
16 | style=PANGO_STYLE_ITALIC | |||
17 | ||||
18 | [Tag mark] | |||
19 | underline=%%--main-menu-u-decoration%% | |||
20 | background=%%--main-menu-u-background-color%% | |||
21 | ||||
22 | [Tag strike] | |||
23 | strikethrough=True | |||
24 | foreground=%%--main-strike-color%% | |||
25 | ||||
26 | [Tag code] | |||
27 | foreground=%%--main-tt-color%% | |||
28 | family=monospace | |||
29 | ||||
30 | [Tag pre] | |||
31 | foreground=%%--main-pre-color%% | |||
32 | family=monospace | |||
33 | wrap-mode=GTK_WRAP_NONE | |||
34 | indent=20 | |||
35 | ||||
36 | [Tag link] | |||
37 | foreground=%%--main-link-color%% | |||
38 | ||||
39 | [Tag tag] | |||
40 | foreground=#ce5c00 | |||
41 | ||||
42 | [Tag h1] | |||
43 | foreground=%%--main-header-color%% | |||
44 | underline=PANGO_UNDERLINE_SINGLE | |||
45 | weight=PANGO_WEIGHT_BOLD | |||
46 | scale=1.75 | |||
47 | ||||
48 | [Tag h2] | |||
49 | foreground=%%--main-header-color%% | |||
50 | weight=PANGO_WEIGHT_BOLD | |||
51 | scale=1.52 | |||
52 | indent=20 | |||
53 | ||||
54 | [Tag h3] | |||
55 | foreground=%%--main-header-color%% | |||
56 | style=PANGO_STYLE_ITALIC | |||
57 | weight=PANGO_WEIGHT_BOLD | |||
58 | scale=1.32 | |||
59 | indent=40 | |||
60 | ||||
61 | [Tag h4] | |||
62 | foreground=%%--main-header-color%% | |||
63 | weight=PANGO_WEIGHT_BOLD |
style-wize.conf
File was created | 1 | # | ||
2 | # Regarder l'aide de zim section Config Files | |||
3 | # | |||
4 | [TextView] | |||
5 | indent=30 | |||
6 | tabs=None | |||
7 | font= | |||
8 | justify= | |||
9 | linespacing=3 | |||
10 | bullet_icon_size=GTK_ICON_SIZE_MENU | |||
11 | ||||
12 | [Tag strong] | |||
13 | weight=PANGO_WEIGHT_BOLD | |||
14 | ||||
15 | [Tag emphasis] | |||
16 | style=PANGO_STYLE_ITALIC | |||
17 | ||||
18 | [Tag mark] | |||
19 | underline=PANGO_UNDERLINE_SINGLE | |||
20 | background=white | |||
21 | ||||
22 | [Tag strike] | |||
23 | strikethrough=True | |||
24 | foreground=grey | |||
25 | ||||
26 | [Tag code] | |||
27 | foreground=darkmagenta | |||
28 | family=monospace | |||
29 | ||||
30 | [Tag pre] | |||
31 | foreground=darkmagenta | |||
32 | family=monospace | |||
33 | wrap-mode=GTK_WRAP_NONE | |||
34 | indent=20 | |||
35 | ||||
36 | [Tag link] | |||
37 | foreground=blue | |||
38 | ||||
39 | [Tag tag] | |||
40 | foreground=#ce5c00 | |||
41 | ||||
42 | [Tag h1] | |||
43 | foreground=#4e9a06 | |||
44 | underline=PANGO_UNDERLINE_SINGLE | |||
45 | weight=PANGO_WEIGHT_BOLD | |||
46 | scale=1.75 | |||
47 | ||||
48 | [Tag h2] | |||
49 | foreground=#4e9a06 | |||
50 | weight=PANGO_WEIGHT_BOLD | |||
51 | scale=1.52 | |||
52 | indent=20 | |||
53 | ||||
54 | [Tag h3] | |||
55 | foreground=#4e9a06 | |||
56 | style=PANGO_STYLE_ITALIC | |||
57 | weight=PANGO_WEIGHT_BOLD | |||
58 | scale=1.32 | |||
59 | indent=40 | |||
60 | ||||
61 | [Tag h4] | |||
62 | foreground=#4e9a06 | |||
63 | weight=PANGO_WEIGHT_BOLD |
style.conf
# | 1 | File was deleted | ||
# Regarder l'aide de zim section Config Files | 2 | |||
# | 3 | |||
[TextView] | 4 | |||
indent=30 | 5 | |||
tabs=None | 6 | |||
font= | 7 | |||
justify= | 8 | |||
linespacing=3 | 9 | |||
bullet_icon_size=GTK_ICON_SIZE_MENU | 10 | |||
11 | ||||
[Tag strong] | 12 | |||
weight=PANGO_WEIGHT_BOLD | 13 | |||
14 | ||||
[Tag emphasis] | 15 | |||
style=PANGO_STYLE_ITALIC | 16 | |||
17 | ||||
[Tag mark] | 18 | |||
underline=PANGO_UNDERLINE_SINGLE | 19 | |||
background=white | 20 | |||
21 | ||||
[Tag strike] | 22 | |||
strikethrough=True | 23 | |||
foreground=grey | 24 | |||
25 | ||||
[Tag code] | 26 | |||
foreground=#8B008B | 27 | |||
family=monospace | 28 | |||
29 | ||||
[Tag pre] | 30 | |||
foreground=#8B008B | 31 | |||
family=monospace | 32 | |||
wrap-mode=GTK_WRAP_NONE | 33 | |||
indent=20 | 34 | |||
35 | ||||
[Tag link] | 36 | |||
foreground=blue | 37 | |||
38 | ||||
[Tag tag] | 39 | |||
foreground=#ce5c00 | 40 | |||
41 | ||||
[Tag h1] | 42 | |||
foreground=#4e9a06 | 43 | |||
underline=PANGO_UNDERLINE_SINGLE | 44 | |||
weight=PANGO_WEIGHT_BOLD | 45 | |||
scale=1.75 | 46 | |||
47 | ||||
[Tag h2] | 48 | |||
foreground=#4e9a06 | 49 | |||
weight=PANGO_WEIGHT_BOLD | 50 | |||
scale=1.52 | 51 | |||
indent=20 | 52 | |||
53 | ||||
[Tag h3] | 54 | |||
foreground=#4e9a06 | 55 | |||
style=PANGO_STYLE_ITALIC | 56 | |||
weight=PANGO_WEIGHT_BOLD | 57 | |||
scale=1.32 | 58 | |||
indent=40 | 59 | |||
60 | ||||
[Tag h4] | 61 | |||
foreground=#4e9a06 | 62 | |||
weight=PANGO_WEIGHT_BOLD | 63 |
style.conf
File was created | 1 | style-wize.conf | ||
# | 1 | |||
# Regarder l'aide de zim section Config Files | 2 | |||
# | 3 | |||
[TextView] | 4 | |||
indent=30 | 5 | |||
tabs=None | 6 | |||
font= | 7 | |||
justify= | 8 | |||
linespacing=3 | 9 | |||
bullet_icon_size=GTK_ICON_SIZE_MENU | 10 | |||
11 | ||||
[Tag strong] | 12 | |||
weight=PANGO_WEIGHT_BOLD | 13 | |||
14 | ||||
[Tag emphasis] | 15 | |||
style=PANGO_STYLE_ITALIC | 16 | |||
17 | ||||
[Tag mark] | 18 | |||
underline=PANGO_UNDERLINE_SINGLE | 19 | |||
background=white | 20 | |||
21 | ||||
[Tag strike] | 22 | |||
strikethrough=True | 23 | |||
foreground=grey | 24 | |||
25 | ||||
[Tag code] | 26 | |||
foreground=#8B008B | 27 | |||
family=monospace | 28 | |||
29 | ||||
[Tag pre] | 30 | |||
foreground=#8B008B | 31 | |||
family=monospace | 32 | |||
wrap-mode=GTK_WRAP_NONE | 33 | |||
indent=20 | 34 | |||
35 | ||||
[Tag link] | 36 | |||
foreground=blue | 37 | |||
38 | ||||
[Tag tag] | 39 | |||
foreground=#ce5c00 | 40 | |||
41 | ||||
[Tag h1] | 42 | |||
foreground=#4e9a06 | 43 | |||
underline=PANGO_UNDERLINE_SINGLE | 44 | |||
weight=PANGO_WEIGHT_BOLD | 45 | |||
scale=1.75 | 46 | |||
47 | ||||
[Tag h2] | 48 | |||
foreground=#4e9a06 | 49 | |||
weight=PANGO_WEIGHT_BOLD | 50 | |||
scale=1.52 | 51 | |||
indent=20 | 52 | |||
53 | ||||
[Tag h3] | 54 | |||
foreground=#4e9a06 | 55 | |||
style=PANGO_STYLE_ITALIC | 56 | |||
weight=PANGO_WEIGHT_BOLD | 57 | |||
scale=1.32 | 58 | |||
indent=40 | 59 | |||
60 | ||||
[Tag h4] | 61 | |||
foreground=#4e9a06 | 62 | |||
weight=PANGO_WEIGHT_BOLD | 63 |
templates/html/Wize_Print_Template.html
File was created | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | ||
2 | <html> | |||
3 | <head> | |||
4 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |||
5 | <title>[% title %]</title> | |||
6 | <meta name='Generator' content='[% generator.name %]'> | |||
7 | <!-- ATTENTION Le template Print ne supporte pas les ressources, | |||
8 | Il faut mettre des chemins absolus sur les fichiers :( --> | |||
9 | <link rel="stylesheet" | |||
10 | href="file:///%%HOME%%/.local/share/zim/templates/html/print-common/zim-variables.css" > | |||
11 | <link rel="stylesheet" | |||
12 | href="file:///%%HOME%%/.local/share/zim/templates/html/common/zim-style.css" > | |||
13 | <link rel="stylesheet" | |||
14 | href="file:///%%HOME%%/.local/share/zim/templates/html/common/zim-table-style.css" > | |||
15 | <link rel="stylesheet" | |||
16 | href="file:///%%HOME%%/.local/share/zim/templates/html/common/zim-special.css" > | |||
17 | <link rel="stylesheet" | |||
18 | href="file:///%%HOME%%/.local/share/zim/templates/html/common/zim-hljs.css" > | |||
19 | <style type='text/css'> | |||
20 | ||||
21 | * { font-family: serif } | |||
22 | ||||
23 | /* Centre les images mais elles sont coupées aux sauts de page à l'impression */ | |||
24 | /*img { | |||
25 | display: block; | |||
26 | margin-left: auto; | |||
27 | margin-right: auto; | |||
28 | }*/ | |||
29 | ||||
30 | </style> | |||
31 | ||||
32 | <!-- Themes clair : | |||
33 | atom-one-light.css, vs.css | |||
34 | Themes sombres : | |||
35 | agate.css, vs2015.css, atom-one-dark.css | |||
36 | Demo live : https://highlightjs.org/static/demo/ --> | |||
37 | <link rel="stylesheet" | |||
38 | href="file:///%%HOME%%/.local/share/zim/templates/html/common/hljs/styles/atom-one-light-wb.css" > | |||
39 | ||||
40 | <!-- hljs --> | |||
41 | <script src="file:///%%HOME%%/.local/share/zim/templates/html/common/hljs/highlight.pack.js"></script> | |||
42 | ||||
43 | <script src="file:///%%HOME%%/.local/share/zim/templates/html/print-common/notice.js"></script> | |||
44 | ||||
45 | </head> | |||
46 | <body> | |||
47 | ||||
48 | [% options.empty_lines = "default" %] | |||
49 | ||||
50 | <!-- Wiki content --> | |||
51 | ||||
52 | <div style="float:right"> | |||
53 | <img src="file:///%%HOME%%/.local/share/zim/templates/html/print-common/logo.png" alt=' '> |
wize.rb
#!/usr/bin/env ruby | 1 | 1 | #!/usr/bin/env ruby | |
2 | 2 | |||
require 'optparse' | 3 | 3 | require 'optparse' | |
4 | 4 | |||
# Variables globales $version, $auteur et $date | 5 | 5 | # Variables globales $version, $auteur et $date | |
$version = "0.1" | 6 | 6 | $version = "0.1" | |
$auteur = "William Daniau" | 7 | 7 | $auteur = "William Daniau" | |
$date = "2019 10 11" | 8 | 8 | $date = "2019 10 11" | |
9 | 9 | |||
10 | # Global directory definitions | |||
11 | $zimShareDir = "#{ENV['HOME']}/.local/share/zim" | |||
12 | $zimHtmlTemplateDir = "#{$zimShareDir}/templates/html" | |||
13 | $zimConfigDir = "#{ENV['HOME']}/.config/zim" | |||
14 | ||||
# Parse arguments class | 10 | 15 | # Parse arguments class | |
class ParseOptions | 11 | 16 | class ParseOptions | |
def self.parse(args) | 12 | 17 | def self.parse(args) | |
options = Hash.new | 13 | 18 | options = Hash.new | |
14 | 19 | |||
opt_parser = OptionParser.new do |opts| | 15 | 20 | opt_parser = OptionParser.new do |opts| | |
opts.banner = "\nUtilisation : wize.rb [options]" | 16 | 21 | opts.banner = "\nUtilisation : wize.rb [options]" | |
opts.separator "" | 17 | 22 | opts.separator "" | |
whatIDo = <<-AFP | 18 | 23 | whatIDo = <<-AFP | |
19 | 24 | |||
liste ou applique une configuartion de template wize pour zim | 20 | 25 | liste ou applique une configuartion de template wize pour zim | |
21 | 26 | |||
AFP | 22 | 27 | AFP | |
23 | 28 | |||
opts.separator whatIDo | 24 | 29 | opts.separator whatIDo | |
25 | 30 | |||
31 | opts.on("-i", | |||
32 | "--install", | |||
33 | "modifie le fichier Wize_Print.html en remplaçant", | |||
34 | "%%HOME%% par la valeur de $HOME") do |l| | |||
35 | options[:install] = l | |||
36 | end | |||
37 | ||||
opts.on("-l", | 26 | 38 | opts.on("-l", | |
"--list", | 27 | 39 | "--list", | |
"Liste les configurations disponibles") do |l| | 28 | 40 | "Liste les configurations disponibles") do |l| | |
options[:list] = l | 29 | 41 | options[:list] = l | |
end | 30 | 42 | end | |
31 | 43 | |||
opts.on("-a", | 32 | 44 | opts.on("-a", | |
"--apply CONF", | 33 | 45 | "--apply CONF", | |
"applique la config CONF") do |conf| | 34 | 46 | "applique la config CONF") do |conf| | |
options[:conf] = conf | 35 | 47 | options[:conf] = conf | |
end | 36 | 48 | end | |
37 | 49 | |||
opts.separator "" | 38 | 50 | opts.separator "" | |
opts.separator " Options standard:" | 39 | 51 | opts.separator " Options standard:" | |
opts.on_tail("-h", "--help", "Affiche ce message") do | 40 | 52 | opts.on_tail("-h", "--help", "Affiche ce message") do | |
puts opts | 41 | 53 | puts opts | |
puts "" | 42 | 54 | puts "" | |
exit | 43 | 55 | exit | |
end | 44 | 56 | end | |
opts.on_tail("-v", "--version", "Affiche la version") do | 45 | 57 | opts.on_tail("-v", "--version", "Affiche la version") do | |
puts "Version : " + $version | 46 | 58 | puts "Version : " + $version | |
puts "Auteur : " + $auteur | 47 | 59 | puts "Auteur : " + $auteur | |
puts "Date : " + $date | 48 | 60 | puts "Date : " + $date | |
puts "" | 49 | 61 | puts "" | |
exit | 50 | 62 | exit | |
end | 51 | 63 | end | |
end | 52 | 64 | end | |
53 | 65 | |||
opt_parser.parse!(args) | 54 | 66 | opt_parser.parse!(args) | |
options | 55 | 67 | options | |
end | 56 | 68 | end | |
end | 57 | 69 | end | |
58 | 70 | |||
71 | # Get the config list | |||
def listConfigs | 59 | 72 | def listConfigs | |
73 | Dir.chdir($zimHtmlTemplateDir) | |||
a = `ls`.split(/\n/) | 60 | 74 | a = `ls`.split(/\n/) | |
names = [] | 61 | 75 | names = [] | |
r = /^common-(.+)$/ | 62 | 76 | r = /^common-(.+)$/ | |
a.each { |f| | 63 | 77 | a.each { |f| | |
if f =~ r | 64 | 78 | if f =~ r | |
names.push($1) | 65 | 79 | names.push($1) | |
end | 66 | 80 | end | |
} | 67 | 81 | } | |
names | 68 | 82 | names | |
end | 69 | 83 | end | |
70 | 84 | |||
85 | # Apply a config | |||
def applyConfig(name) | 71 | 86 | def applyConfig(name) | |
87 | Dir.chdir($zimHtmlTemplateDir) | |||
list = ["Wize", "Wize_with_index", "Wize_with_index_sod"] | 72 | 88 | list = ["Wize", "Wize_with_index", "Wize_with_index_sod"] | |
list.each { |l| | 73 | 89 | list.each { |l| | |
com = "rm -f #{l}/common-spec" | 74 | 90 | com = "rm -f #{l}/common-spec" | |
system(com) | 75 | 91 | system(com) | |
com = "ln -s ../common-#{name} #{l}/common-spec" | 76 | 92 | com = "ln -s ../common-#{name} #{l}/common-spec" | |
system(com) | 77 | 93 | system(com) | |
} | 78 | 94 | } | |
system("rm -f print-common") | 79 | 95 | system("rm -f print-common") | |
system("ln -s common-#{name} print-common") | 80 | 96 | system("ln -s common-#{name} print-common") | |
end | 81 | 97 | end | |
82 | 98 | |||
99 | # Is the name a valid config? | |||
def configInList?(name, names) | 83 | 100 | def configInList?(name, names) | |
names.include? name | 84 | 101 | names.include? name | |
end | 85 | 102 | end | |
86 | 103 | |||
104 | # Re-create Wize_Print.html from template | |||
105 | # and initialize link into zim config directory | |||
106 | def installWize | |||
107 | Dir.chdir($zimHtmlTemplateDir) | |||
108 | begin | |||
109 | printTemplate = File.new("Wize_Print_Template.html", "r") | |||
110 | rescue | |||
111 | puts "cannot open print file for reading" | |||
112 | exit | |||
113 | end | |||
114 | tabfile = [] | |||
115 | stor = '%%HOME%%' | |||
116 | rby = ENV['HOME'] | |||
117 | printTemplate.readlines.each { |line| | |||
118 | line.gsub!(stor,rby) | |||
119 | tabfile.push(line) | |||
120 | } | |||
121 | printTemplate.close | |||
122 | begin | |||
123 | printFile = File.new("Wize_Print.html", "w") | |||
124 | rescue | |||
125 | puts "cannot open print file for writing" | |||
126 | exit | |||
127 | end | |||
128 | tabfile.each { |line| | |||
129 | printFile.write line | |||
130 | } | |||
131 | printFile.close | |||
132 | ||||
133 | Dir.chdir($zimConfigDir) | |||
134 | system("rm -f style.conf") | |||
135 | system("ln -s #{$zimShareDir}/style.conf style.conf") | |||
136 | end | |||
137 | ||||
138 | # Create style-name.conf according to common-name/zim-variables.css | |||
139 | def createStyleFile(name) | |||
140 | lfTags = ["--main-header-color", | |||
141 | "--main-menu-u-decoration", | |||
142 | "--main-menu-u-background-color", | |||
143 | "--main-strike-color", | |||
144 | "--main-tt-color", | |||
145 | "--main-pre-color", | |||
146 | "--main-link-color"] | |||
147 | ||||
148 | # First we load the css file and parse it | |||
149 | Dir.chdir($zimHtmlTemplateDir) | |||
150 | begin | |||
151 | nameCSS = File.new("common-#{name}/zim-variables.css", "r") | |||
152 | rescue | |||
153 | puts "cannot open common-#{name}/zim-variables.css for reading" | |||
154 | exit | |||
155 | end | |||
156 | sCSS = nameCSS.read | |||
157 | regComment = /\/\*.*?\*\//m | |||
158 | sCSS.gsub!(regComment, '') | |||
159 | sTags = {} | |||
160 | lfTags.each { |tag| | |||
161 | var = Regexp.escape(tag) | |||
162 | reg = /#{var}\s*:\s*(\S+)\s*;/ | |||
163 | sCSS =~ reg | |||
164 | sTags[tag] = $1 | |||
165 | # On traite le cas particulier du u-decoration | |||
166 | if tag == "--main-menu-u-decoration" | |||
167 | sTags[tag] = sTags[tag] == 'underline' ? 'PANGO_UNDERLINE_SINGLE' : '' | |||
168 | end | |||
169 | } | |||
170 | ||||
171 | # know read the style template | |||
172 | Dir.chdir($zimShareDir) | |||
173 | begin | |||
174 | styleTemplate = File.new("style-template.conf", "r") | |||
175 | rescue | |||
176 | puts "cannot open style-template.conf for reading" | |||
177 | exit | |||
178 | end | |||
179 | styleTemplateString = styleTemplate.read | |||
180 | lfTags.each { |tag| | |||
181 | styleTemplateString.gsub!("%%#{tag}%%", sTags[tag]) | |||
182 | } | |||
183 | # Now write the file | |||
184 | begin | |||
185 | styleOutput = File.new("style-#{name}.conf", "w") | |||
186 | rescue | |||
187 | puts "cannot open style-#{name}.conf for writing" | |||
188 | exit | |||
189 | end | |||
190 | styleOutput.write styleTemplateString | |||
191 | styleOutput.close | |||
192 | # Now create the symbolic link | |||
193 | system("rm style.conf") | |||
194 | system("ln -s style-#{name}.conf style.conf") | |||
195 | end | |||
196 | ||||
# Parse arguments using the class and get results in a hash | 87 | 197 | # Parse arguments using the class and get results in a hash | |
options = ParseOptions.parse(ARGV) | 88 | 198 | options = ParseOptions.parse(ARGV) | |
if options.length == 0 | 89 | 199 | if options.length == 0 | |
puts "Utiliser -h pour l'aide" | 90 | 200 | puts "Utiliser -h pour l'aide" | |
exit | 91 | 201 | exit | |
end | 92 | 202 | end | |
93 | 203 | |||
# Directory definitions | 94 | |||
zimShareDir = "#{ENV['HOME']}/.local/share/zim" | 95 | |||
zimHtmlTemplateDir = "#{zimShareDir}/templates/html" | 96 | |||
zimConfigDir = "#{ENV['HOME']}/.config/zim" | 97 | |||
98 | ||||
# go into template dir | 99 | |||
Dir.chdir(zimHtmlTemplateDir) | 100 | |||
101 | ||||
# get existing configs | 102 | 204 | # get existing configs | |
configs = listConfigs | 103 | 205 | configs = listConfigs | |
104 | 206 | |||
207 | # Installation | |||
208 | if options[:install] | |||
209 | installPrintFile | |||
210 | exit | |||
211 | end | |||
212 | ||||
# List | 105 | 213 | # List | |
if options[:list] | 106 | 214 | if options[:list] | |
configs.each { |c| | 107 | 215 | configs.each { |c| | |
puts c | 108 | 216 | puts c |