Commit a7fb3dffac9cdb0c92ade7245a1a65c624cefaa8
1 parent
40db629428
Exists in
master
+ On renomme Wize_Print_Template.html avec l'extension tpl pour qu'il
n'apparaisse pas dans la liste des exports possibles. + On remplace le Wize_Print.html original par un message indiquant d'éxécuter wize.rb -i + correction du wize.rb pour tenir compte du changement de nom du template print
Showing 4 changed files with 9 additions and 69 deletions Inline Diff
templates/html/Wize_Print.html
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | 1 | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | |
| <html> | 2 | 2 | <html> | |
| <head> | 3 | 3 | <head> | |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | 4 | 4 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
| <title>[% title %]</title> | 5 | 5 | <title>Need install</title> | |
| <meta name='Generator' content='[% generator.name %]'> | 6 | 6 | <meta name='Generator' content='[% generator.name %]'> | |
| <!-- ATTENTION Le template Print ne supporte pas les ressources, | 7 | 7 | <style> | |
| Il faut mettre des chemins absolus sur les fichiers :( --> | 8 | |||
| <link rel="stylesheet" | 9 | |||
| href="file:////home/daniau/.local/share/zim/templates/html/print-common/zim-variables.css" > | 10 | |||
| <link rel="stylesheet" | 11 | |||
| href="file:////home/daniau/.local/share/zim/templates/html/common/zim-style.css" > | 12 | |||
| <link rel="stylesheet" | 13 | |||
| href="file:////home/daniau/.local/share/zim/templates/html/common/zim-table-style.css" > | 14 | |||
| <link rel="stylesheet" | 15 | |||
| href="file:////home/daniau/.local/share/zim/templates/html/common/zim-special.css" > | 16 | |||
| <link rel="stylesheet" | 17 | |||
| href="file:////home/daniau/.local/share/zim/templates/html/common/zim-hljs.css" > | 18 | |||
| <style type='text/css'> | 19 | |||
| 20 | ||||
| * { font-family: serif } | 21 | 8 | * { font-family: serif } | |
| 22 | ||||
| /* Centre les images mais elles sont coupées aux sauts de page à l'impression */ | 23 | |||
| /*img { | 24 | |||
| display: block; | 25 | |||
| margin-left: auto; | 26 | |||
| margin-right: auto; | 27 | |||
| }*/ | 28 | |||
| 29 | ||||
| </style> | 30 | 9 | </style> | |
| 31 | ||||
| <!-- Themes clair : | 32 | |||
| atom-one-light.css, vs.css | 33 | |||
| Themes sombres : | 34 | |||
| agate.css, vs2015.css, atom-one-dark.css | 35 | |||
| Demo live : https://highlightjs.org/static/demo/ --> | 36 | |||
| <link rel="stylesheet" | 37 | |||
| href="file:////home/daniau/.local/share/zim/templates/html/common/hljs/styles/atom-one-light-wb.css" > | 38 | |||
| 39 | ||||
| <!-- hljs --> | 40 | |||
| <script src="file:////home/daniau/.local/share/zim/templates/html/common/hljs/highlight.pack.js"></script> | 41 | |||
| 42 | ||||
| <script src="file:////home/daniau/.local/share/zim/templates/html/print-common/notice.js"></script> | 43 | |||
| 44 | ||||
| <script> | 45 | |||
| function testLogo() { | 46 | |||
| logo=document.getElementById("logoImgId"); | 47 | |||
| logodiv=document.getElementById("logoDivId"); | 48 | |||
| if (logo.naturalHeight == 0) { | 49 | |||
| logodiv.setAttribute("style","display:none;"); | 50 | |||
| } | 51 | |||
| } | 52 | |||
| </script> | 53 | |||
| </head> | 54 | 10 | </head> | |
| <body onload="testLogo()"> | 55 | 11 | <body> | |
| 56 | 12 | <h1>Need install</h1> | ||
| [% options.empty_lines = "default" %] | 57 | 13 | <p>You need to run first (better quit zim before)</p> | |
| 58 | 14 | <pre> | ||
| <!-- Wiki content --> | 59 | 15 | wize.rb -i | |
| 60 | 16 | </pre> | ||
| <div id="logoDivId" style="float:right"> | 61 | |||
| <img id="logoImgId" src="file:////home/daniau/.local/share/zim/templates/html/print-common/logo.png" alt=' '> | 62 | |||
| </div> | 63 | |||
| 64 | ||||
| 65 | ||||
| [% FOR page IN pages %] | 66 | |||
| [% page.content %] | 67 | |||
| [% END %] | 68 | |||
| 69 | ||||
| <!-- End wiki content --> | 70 |
templates/html/Wize_Print_Template.html
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | 1 | File was deleted | ||
| <html> | 2 | |||
| <head> | 3 | |||
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | 4 | |||
| <title>[% title %]</title> | 5 | |||
| <meta name='Generator' content='[% generator.name %]'> | 6 | |||
| <!-- ATTENTION Le template Print ne supporte pas les ressources, | 7 | |||
| Il faut mettre des chemins absolus sur les fichiers :( --> | 8 | |||
| <link rel="stylesheet" | 9 | |||
| href="file:///%%HOME%%/.local/share/zim/templates/html/print-common/zim-variables.css" > | 10 | |||
| <link rel="stylesheet" | 11 | |||
| href="file:///%%HOME%%/.local/share/zim/templates/html/common/zim-style.css" > | 12 | |||
| <link rel="stylesheet" | 13 | |||
| href="file:///%%HOME%%/.local/share/zim/templates/html/common/zim-table-style.css" > | 14 | |||
| <link rel="stylesheet" | 15 | |||
| href="file:///%%HOME%%/.local/share/zim/templates/html/common/zim-special.css" > | 16 | |||
| <link rel="stylesheet" | 17 | |||
| href="file:///%%HOME%%/.local/share/zim/templates/html/common/zim-hljs.css" > | 18 | |||
| <style type='text/css'> | 19 | |||
| 20 | ||||
| * { font-family: serif } | 21 | |||
| 22 | ||||
| /* Centre les images mais elles sont coupées aux sauts de page à l'impression */ | 23 | |||
| /*img { | 24 | |||
| display: block; | 25 | |||
| margin-left: auto; | 26 | |||
| margin-right: auto; | 27 | |||
| }*/ | 28 | |||
| 29 | ||||
| </style> | 30 | |||
| 31 | ||||
| <!-- Themes clair : | 32 | |||
| atom-one-light.css, vs.css | 33 | |||
| Themes sombres : | 34 | |||
| agate.css, vs2015.css, atom-one-dark.css | 35 | |||
| Demo live : https://highlightjs.org/static/demo/ --> | 36 | |||
| <link rel="stylesheet" | 37 | |||
| href="file:///%%HOME%%/.local/share/zim/templates/html/common/hljs/styles/atom-one-light-wb.css" > | 38 | |||
| 39 | ||||
| <!-- hljs --> | 40 | |||
| <script src="file:///%%HOME%%/.local/share/zim/templates/html/common/hljs/highlight.pack.js"></script> | 41 | |||
| 42 | ||||
| <script src="file:///%%HOME%%/.local/share/zim/templates/html/print-common/notice.js"></script> | 43 | |||
| 44 | ||||
| <script> | 45 | |||
| function testLogo() { | 46 | |||
| logo=document.getElementById("logoImgId"); | 47 | |||
| logodiv=document.getElementById("logoDivId"); | 48 | |||
| if (logo.naturalHeight == 0) { | 49 | |||
| logodiv.setAttribute("style","display:none;"); | 50 | |||
| } | 51 | |||
| } | 52 | |||
| </script> | 53 | |||
| </head> | 54 | |||
| <body onload="testLogo()"> | 55 | |||
| 56 | ||||
| [% options.empty_lines = "default" %] | 57 | |||
| 58 | ||||
| <!-- Wiki content --> | 59 | |||
| 60 | ||||
| <div id="logoDivId" style="float:right"> | 61 | |||
| <img id="logoImgId" src="file:///%%HOME%%/.local/share/zim/templates/html/print-common/logo.png" alt=' '> | 62 |
templates/html/Wize_Print_Template.tpl
| 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 | <script> | |||
| 46 | function testLogo() { | |||
| 47 | logo=document.getElementById("logoImgId"); | |||
| 48 | logodiv=document.getElementById("logoDivId"); | |||
| 49 | if (logo.naturalHeight == 0) { | |||
| 50 | logodiv.setAttribute("style","display:none;"); | |||
| 51 | } | |||
| 52 | } | |||
| 53 | </script> | |||
| 54 | </head> | |||
| 55 | <body onload="testLogo()"> | |||
| 56 | ||||
| 57 | [% options.empty_lines = "default" %] | |||
| 58 | ||||
| 59 | <!-- Wiki content --> | |||
| 60 | ||||
| 61 | <div id="logoDivId" style="float:right"> | |||
| 62 | <img id="logoImgId" 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 | |||
| # Global directory definitions | 10 | 10 | # Global directory definitions | |
| $zimShareDir = "#{ENV['HOME']}/.local/share/zim" | 11 | 11 | $zimShareDir = "#{ENV['HOME']}/.local/share/zim" | |
| $zimHtmlTemplateDir = "#{$zimShareDir}/templates/html" | 12 | 12 | $zimHtmlTemplateDir = "#{$zimShareDir}/templates/html" | |
| $zimConfigDir = "#{ENV['HOME']}/.config/zim" | 13 | 13 | $zimConfigDir = "#{ENV['HOME']}/.config/zim" | |
| 14 | 14 | |||
| # Parse arguments class | 15 | 15 | # Parse arguments class | |
| class ParseOptions | 16 | 16 | class ParseOptions | |
| def self.parse(args) | 17 | 17 | def self.parse(args) | |
| options = Hash.new | 18 | 18 | options = Hash.new | |
| 19 | 19 | |||
| opt_parser = OptionParser.new do |opts| | 20 | 20 | opt_parser = OptionParser.new do |opts| | |
| opts.banner = "\nUtilisation : wize.rb [options]" | 21 | 21 | opts.banner = "\nUtilisation : wize.rb [options]" | |
| opts.separator "" | 22 | 22 | opts.separator "" | |
| whatIDo = <<-AFP | 23 | 23 | whatIDo = <<-AFP | |
| 24 | 24 | |||
| liste ou applique une configuration de template wize pour zim | 25 | 25 | liste ou applique une configuration de template wize pour zim | |
| 26 | 26 | |||
| AFP | 27 | 27 | AFP | |
| 28 | 28 | |||
| opts.separator whatIDo | 29 | 29 | opts.separator whatIDo | |
| 30 | 30 | |||
| opts.on("-i", | 31 | 31 | opts.on("-i", | |
| "--install", | 32 | 32 | "--install", | |
| "modifie le fichier Wize_Print.html en remplaçant", | 33 | 33 | "modifie le fichier Wize_Print.html en remplaçant", | |
| "%%HOME%% par la valeur de $HOME. Installe également", | 34 | 34 | "%%HOME%% par la valeur de $HOME. Installe également", | |
| "un lien symbolique dans le dossier de config de zim.", | 35 | 35 | "un lien symbolique dans le dossier de config de zim.", | |
| "A éxécuter une seule fois a priori.") do |l| | 36 | 36 | "A éxécuter une seule fois a priori.") do |l| | |
| options[:install] = l | 37 | 37 | options[:install] = l | |
| end | 38 | 38 | end | |
| 39 | 39 | |||
| opts.on("-l", | 40 | 40 | opts.on("-l", | |
| "--list", | 41 | 41 | "--list", | |
| "Liste les configurations disponibles") do |l| | 42 | 42 | "Liste les configurations disponibles") do |l| | |
| options[:list] = l | 43 | 43 | options[:list] = l | |
| end | 44 | 44 | end | |
| 45 | 45 | |||
| opts.on("-p", | 46 | 46 | opts.on("-p", | |
| "--print", | 47 | 47 | "--print", | |
| "Affiche la configuration actuelle") do |p| | 48 | 48 | "Affiche la configuration actuelle") do |p| | |
| options[:print] = p | 49 | 49 | options[:print] = p | |
| end | 50 | 50 | end | |
| 51 | 51 | |||
| opts.on("-a", | 52 | 52 | opts.on("-a", | |
| "--apply CONF", | 53 | 53 | "--apply CONF", | |
| "applique la config CONF") do |conf| | 54 | 54 | "applique la config CONF") do |conf| | |
| options[:conf] = conf | 55 | 55 | options[:conf] = conf | |
| end | 56 | 56 | end | |
| 57 | 57 | |||
| opts.separator "" | 58 | 58 | opts.separator "" | |
| opts.separator " Options standard:" | 59 | 59 | opts.separator " Options standard:" | |
| opts.on_tail("-h", "--help", "Affiche ce message") do | 60 | 60 | opts.on_tail("-h", "--help", "Affiche ce message") do | |
| puts opts | 61 | 61 | puts opts | |
| puts "" | 62 | 62 | puts "" | |
| exit | 63 | 63 | exit | |
| end | 64 | 64 | end | |
| opts.on_tail("-v", "--version", "Affiche la version") do | 65 | 65 | opts.on_tail("-v", "--version", "Affiche la version") do | |
| puts "Version : " + $version | 66 | 66 | puts "Version : " + $version | |
| puts "Auteur : " + $auteur | 67 | 67 | puts "Auteur : " + $auteur | |
| puts "Date : " + $date | 68 | 68 | puts "Date : " + $date | |
| puts "" | 69 | 69 | puts "" | |
| exit | 70 | 70 | exit | |
| end | 71 | 71 | end | |
| end | 72 | 72 | end | |
| 73 | 73 | |||
| opt_parser.parse!(args) | 74 | 74 | opt_parser.parse!(args) | |
| options | 75 | 75 | options | |
| end | 76 | 76 | end | |
| end | 77 | 77 | end | |
| 78 | 78 | |||
| # Get the config list | 79 | 79 | # Get the config list | |
| def listConfigs | 80 | 80 | def listConfigs | |
| Dir.chdir($zimHtmlTemplateDir) | 81 | 81 | Dir.chdir($zimHtmlTemplateDir) | |
| a = `ls`.split(/\n/) | 82 | 82 | a = `ls`.split(/\n/) | |
| names = [] | 83 | 83 | names = [] | |
| r = /^common-(.+)$/ | 84 | 84 | r = /^common-(.+)$/ | |
| a.each { |f| | 85 | 85 | a.each { |f| | |
| if f =~ r | 86 | 86 | if f =~ r | |
| names.push($1) | 87 | 87 | names.push($1) | |
| end | 88 | 88 | end | |
| } | 89 | 89 | } | |
| names | 90 | 90 | names | |
| end | 91 | 91 | end | |
| 92 | 92 | |||
| # Get the current config by looking at print-common | 93 | 93 | # Get the current config by looking at print-common | |
| def getCurrent | 94 | 94 | def getCurrent | |
| Dir.chdir($zimHtmlTemplateDir) | 95 | 95 | Dir.chdir($zimHtmlTemplateDir) | |
| File.readlink("print-common") =~ /^common-(.+)$/ | 96 | 96 | File.readlink("print-common") =~ /^common-(.+)$/ | |
| $1 | 97 | 97 | $1 | |
| end | 98 | 98 | end | |
| 99 | 99 | |||
| # Apply a config | 100 | 100 | # Apply a config | |
| def applyConfig(name) | 101 | 101 | def applyConfig(name) | |
| Dir.chdir($zimHtmlTemplateDir) | 102 | 102 | Dir.chdir($zimHtmlTemplateDir) | |
| list = ["Wize", "Wize_with_index", "Wize_with_index_sod"] | 103 | 103 | list = ["Wize", "Wize_with_index", "Wize_with_index_sod"] | |
| list.each { |l| | 104 | 104 | list.each { |l| | |
| com = "rm -f #{l}/common-spec" | 105 | 105 | com = "rm -f #{l}/common-spec" | |
| system(com) | 106 | 106 | system(com) | |
| com = "ln -s ../common-#{name} #{l}/common-spec" | 107 | 107 | com = "ln -s ../common-#{name} #{l}/common-spec" | |
| system(com) | 108 | 108 | system(com) | |
| } | 109 | 109 | } | |
| system("rm -f print-common") | 110 | 110 | system("rm -f print-common") | |
| system("ln -s common-#{name} print-common") | 111 | 111 | system("ln -s common-#{name} print-common") | |
| end | 112 | 112 | end | |
| 113 | 113 | |||
| # Is the name a valid config? | 114 | 114 | # Is the name a valid config? | |
| def configInList?(name, names) | 115 | 115 | def configInList?(name, names) | |
| names.include? name | 116 | 116 | names.include? name | |
| end | 117 | 117 | end | |
| 118 | 118 | |||
| # Re-create Wize_Print.html from template | 119 | 119 | # Re-create Wize_Print.html from template | |
| # and initialize link into zim config directory | 120 | 120 | # and initialize link into zim config directory | |
| def installWize | 121 | 121 | def installWize | |
| Dir.chdir($zimHtmlTemplateDir) | 122 | 122 | Dir.chdir($zimHtmlTemplateDir) | |
| begin | 123 | 123 | begin | |
| printTemplate = File.new("Wize_Print_Template.html", "r") | 124 | 124 | printTemplate = File.new("Wize_Print_Template.tpl", "r") | |
| rescue | 125 | 125 | rescue | |
| puts "cannot open print file for reading" | 126 | 126 | puts "cannot open print file for reading" | |
| exit | 127 | 127 | exit | |
| end | 128 | 128 | end | |
| tabfile = [] | 129 | 129 | tabfile = [] | |
| stor = '%%HOME%%' | 130 | 130 | stor = '%%HOME%%' | |
| rby = ENV['HOME'] | 131 | 131 | rby = ENV['HOME'] | |
| printTemplate.readlines.each { |line| | 132 | 132 | printTemplate.readlines.each { |line| | |
| line.gsub!(stor,rby) | 133 | 133 | line.gsub!(stor,rby) | |
| tabfile.push(line) | 134 | 134 | tabfile.push(line) | |
| } | 135 | 135 | } | |
| printTemplate.close | 136 | 136 | printTemplate.close | |
| begin | 137 | 137 | begin | |
| printFile = File.new("Wize_Print.html", "w") | 138 | 138 | printFile = File.new("Wize_Print.html", "w") | |
| rescue | 139 | 139 | rescue | |
| puts "cannot open print file for writing" | 140 | 140 | puts "cannot open print file for writing" | |
| exit | 141 | 141 | exit | |
| end | 142 | 142 | end | |
| tabfile.each { |line| | 143 | 143 | tabfile.each { |line| | |
| printFile.write line | 144 | 144 | printFile.write line | |
| } | 145 | 145 | } | |
| printFile.close | 146 | 146 | printFile.close | |
| 147 | 147 | |||
| Dir.chdir($zimConfigDir) | 148 | 148 | Dir.chdir($zimConfigDir) | |
| system("rm -f style.conf") | 149 | 149 | system("rm -f style.conf") | |
| system("ln -s #{$zimShareDir}/style.conf style.conf") | 150 | 150 | system("ln -s #{$zimShareDir}/style.conf style.conf") | |
| end | 151 | 151 | end | |
| 152 | 152 | |||
| # Create style-name.conf according to common-name/zim-variables.css | 153 | 153 | # Create style-name.conf according to common-name/zim-variables.css | |
| def createStyleFile(name) | 154 | 154 | def createStyleFile(name) | |
| lfTags = ["--main-header-color", | 155 | 155 | lfTags = ["--main-header-color", | |
| "--main-menu-u-decoration", | 156 | 156 | "--main-menu-u-decoration", | |
| "--main-menu-u-background-color", | 157 | 157 | "--main-menu-u-background-color", | |
| "--main-strike-color", | 158 | 158 | "--main-strike-color", | |
| "--main-tt-color", | 159 | 159 | "--main-tt-color", | |
| "--main-pre-color", | 160 | 160 | "--main-pre-color", | |
| "--main-link-color"] | 161 | 161 | "--main-link-color"] | |
| 162 | 162 | |||
| # First we load the css file and parse it | 163 | 163 | # First we load the css file and parse it | |
| Dir.chdir($zimHtmlTemplateDir) | 164 | 164 | Dir.chdir($zimHtmlTemplateDir) | |
| begin | 165 | 165 | begin | |
| nameCSS = File.new("common-#{name}/zim-variables.css", "r") | 166 | 166 | nameCSS = File.new("common-#{name}/zim-variables.css", "r") | |
| rescue | 167 | 167 | rescue | |
| puts "cannot open common-#{name}/zim-variables.css for reading" | 168 | 168 | puts "cannot open common-#{name}/zim-variables.css for reading" | |
| exit | 169 | 169 | exit | |
| end | 170 | 170 | end | |
| sCSS = nameCSS.read | 171 | 171 | sCSS = nameCSS.read | |
| regComment = /\/\*.*?\*\//m | 172 | 172 | regComment = /\/\*.*?\*\//m | |
| sCSS.gsub!(regComment, '') | 173 | 173 | sCSS.gsub!(regComment, '') | |
| sTags = {} | 174 | 174 | sTags = {} | |
| lfTags.each { |tag| | 175 | 175 | lfTags.each { |tag| | |
| var = Regexp.escape(tag) | 176 | 176 | var = Regexp.escape(tag) | |
| reg = /#{var}\s*:\s*(\S+)\s*;/ | 177 | 177 | reg = /#{var}\s*:\s*(\S+)\s*;/ | |
| sCSS =~ reg | 178 | 178 | sCSS =~ reg | |
| sTags[tag] = $1 | 179 | 179 | sTags[tag] = $1 | |
| # On traite le cas particulier du u-decoration | 180 | 180 | # On traite le cas particulier du u-decoration | |
| if tag == "--main-menu-u-decoration" | 181 | 181 | if tag == "--main-menu-u-decoration" | |
| sTags[tag] = sTags[tag] == 'underline' ? 'PANGO_UNDERLINE_SINGLE' : '' | 182 | 182 | sTags[tag] = sTags[tag] == 'underline' ? 'PANGO_UNDERLINE_SINGLE' : '' | |
| end | 183 | 183 | end | |
| } | 184 | 184 | } | |
| 185 | 185 | |||
| # know read the style template | 186 | 186 | # know read the style template | |
| Dir.chdir($zimShareDir) | 187 | 187 | Dir.chdir($zimShareDir) | |
| begin | 188 | 188 | begin | |
| styleTemplate = File.new("style-template.conf", "r") | 189 | 189 | styleTemplate = File.new("style-template.conf", "r") | |
| rescue | 190 | 190 | rescue | |
| puts "cannot open style-template.conf for reading" | 191 | 191 | puts "cannot open style-template.conf for reading" | |
| exit | 192 | 192 | exit | |
| end | 193 | 193 | end | |
| styleTemplateString = styleTemplate.read | 194 | 194 | styleTemplateString = styleTemplate.read | |
| lfTags.each { |tag| | 195 | 195 | lfTags.each { |tag| | |
| styleTemplateString.gsub!("%%#{tag}%%", sTags[tag]) | 196 | 196 | styleTemplateString.gsub!("%%#{tag}%%", sTags[tag]) | |
| } | 197 | 197 | } | |
| # Now write the file | 198 | 198 | # Now write the file | |
| begin | 199 | 199 | begin | |
| styleOutput = File.new("style-#{name}.conf", "w") | 200 | 200 | styleOutput = File.new("style-#{name}.conf", "w") | |
| rescue | 201 | 201 | rescue | |
| puts "cannot open style-#{name}.conf for writing" | 202 | 202 | puts "cannot open style-#{name}.conf for writing" | |
| exit | 203 | 203 | exit | |
| end | 204 | 204 | end | |
| styleOutput.write styleTemplateString | 205 | 205 | styleOutput.write styleTemplateString | |
| styleOutput.close | 206 | 206 | styleOutput.close | |
| # Now create the symbolic link | 207 | 207 | # Now create the symbolic link | |
| system("rm style.conf") | 208 | 208 | system("rm style.conf") | |
| system("ln -s style-#{name}.conf style.conf") | 209 | 209 | system("ln -s style-#{name}.conf style.conf") | |
| end | 210 | 210 | end | |
| 211 | 211 | |||
| # Parse arguments using the class and get results in a hash | 212 | 212 | # Parse arguments using the class and get results in a hash | |
| options = ParseOptions.parse(ARGV) | 213 | 213 | options = ParseOptions.parse(ARGV) | |
| if options.length == 0 | 214 | 214 | if options.length == 0 | |
| puts "Utiliser -h pour l'aide" | 215 | 215 | puts "Utiliser -h pour l'aide" | |
| exit | 216 | 216 | exit | |
| end | 217 | 217 | end | |
| 218 | 218 | |||
| # get existing configs | 219 | 219 | # get existing configs | |
| configs = listConfigs | 220 | 220 | configs = listConfigs | |
| 221 | 221 | |||
| # Installation | 222 | 222 | # Installation | |
| if options[:install] | 223 | 223 | if options[:install] | |
| installWize | 224 | 224 | installWize | |
| exit | 225 | 225 | exit | |
| end | 226 | 226 | end | |
| 227 | 227 | |||
| # List | 228 | 228 | # List | |
| if options[:list] | 229 | 229 | if options[:list] |