Commit 4f3a614a51eb9164b45cc257a1cdf2667d1b6fa7
1 parent
ee7faa1aad
Exists in
master
Premier essai de template Wize S5
Showing 13 changed files with 919 additions and 1 deletions Inline Diff
- templates/html/Wize_S5.html
- templates/html/Wize_S5/ui/default/blank.gif
- templates/html/Wize_S5/ui/default/bodybg.gif
- templates/html/Wize_S5/ui/default/framing.css
- templates/html/Wize_S5/ui/default/iepngfix.htc
- templates/html/Wize_S5/ui/default/opera.css
- templates/html/Wize_S5/ui/default/outline.css
- templates/html/Wize_S5/ui/default/pretty.css
- templates/html/Wize_S5/ui/default/print.css
- templates/html/Wize_S5/ui/default/s5-core.css
- templates/html/Wize_S5/ui/default/slides.css
- templates/html/Wize_S5/ui/default/slides.js
- wize.rb
templates/html/Wize_S5.html
File was created | 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" | ||
2 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |||
3 | ||||
4 | <html xmlns="http://www.w3.org/1999/xhtml"> | |||
5 | ||||
6 | <head> | |||
7 | <title>[% title %]</title> | |||
8 | <!-- metadata --> | |||
9 | <meta name="generator" content="[% generator.name %]" /> | |||
10 | <meta charset="utf-8"/> | |||
11 | <meta name="version" content="S5 1.1" /> | |||
12 | <meta name="presdate" content="" /> | |||
13 | <meta name="author" content="" /> | |||
14 | <meta name="company" content="" /> | |||
15 | <!-- configuration parameters --> | |||
16 | <meta name="defaultView" content="slideshow" /> | |||
17 | <meta name="controlVis" content="hidden" /> | |||
18 | <!-- style sheet links --> | |||
19 | <link rel="stylesheet" | |||
20 | href="[% resource('common-spec/zim-variables.css') %]" > | |||
21 | ||||
22 | <link rel="stylesheet" href="[% resource('ui/default/slides.css') %]" type="text/css" media="projection" id="slideProj" /> | |||
23 | <link rel="stylesheet" href="[% resource('ui/default/outline.css') %]" type="text/css" media="screen" id="outlineStyle" /> | |||
24 | <link rel="stylesheet" href="[% resource('ui/default/print.css') %]" type="text/css" media="print" id="slidePrint" /> | |||
25 | <link rel="stylesheet" href="[% resource('ui/default/opera.css') %]" type="text/css" media="projection" id="operaFix" /> | |||
26 | ||||
27 | <link rel="stylesheet" | |||
28 | href="[% resource('common/zim-style.css') %]" > | |||
29 | <link rel="stylesheet" | |||
30 | href="[% resource('common/zim-table-style.css') %]" > | |||
31 | <link rel="stylesheet" | |||
32 | href="[% resource('common/zim-special.css') %]" > | |||
33 | <link rel="stylesheet" | |||
34 | href="[% resource('common/zim-hljs.css') %]" > | |||
35 | <link rel="stylesheet" | |||
36 | href="[% resource('common-spec/zim-pres-override.css') %]" > | |||
37 | ||||
38 | <link rel="stylesheet" | |||
39 | href="[% resource('common/hljs/styles/sunburst.css') %]" > | |||
40 | ||||
41 | <!-- hljs --> | |||
42 | <script src="[% resource('common/hljs/highlight.pack.js') %]"></script> | |||
43 | ||||
44 | <script src="[% resource('common/wizefunc.js') %]"></script> | |||
45 | ||||
46 | <!-- S5 JS --> | |||
47 | <script src="[% resource('ui/default/slides.js') %]" type="text/javascript"></script> | |||
48 | <style type='text/css'> | |||
49 | * { font-family: sans-serif } | |||
50 | img { | |||
51 | display: block; | |||
52 | margin-left: auto; | |||
53 | margin-right: auto; | |||
54 | } | |||
55 | tt { | |||
56 | font-size: inherit; | |||
57 | } | |||
58 | ||||
59 | td, th { | |||
60 | font-size:80%; | |||
61 | } | |||
62 | ||||
63 | code { | |||
64 | font-size:80%; | |||
65 | } | |||
66 | body { | |||
67 | background: var(--main-pres-background-color); | |||
68 | background-image: url('[% resource("common-spec/fond-pres.jpg") %]'); | |||
69 | background-repeat: var(--main-pres-background-repeat); | |||
70 | background-size: var(--main-pres-background-size); | |||
71 | } | |||
72 | ||||
73 | </style> | |||
74 | </head> | |||
75 | <body> | |||
76 | ||||
77 | <div class="layout"> | |||
78 | <div id="controls"><!-- DO NOT EDIT --></div> | |||
79 | <div id="currentSlide"><!-- DO NOT EDIT --></div> | |||
80 | <div id="header"> | |||
81 | <div id="logoDivId" style="position: absolute; right: 1em;"> | |||
82 | <img id="logoImgId" src='[% resource("common-spec/logo-pres.png") %]' alt=' '> | |||
83 | </div> | |||
84 | </div> | |||
85 | <div id="footer"> | |||
86 | <h2 id="footinfo1"></h2> | |||
87 | <h2 id="footinfo2"></h2> | |||
88 | </div> | |||
89 | ||||
90 | </div> | |||
91 |
templates/html/Wize_S5/ui/default/blank.gif
49 Bytes
templates/html/Wize_S5/ui/default/bodybg.gif
9.88 KB
templates/html/Wize_S5/ui/default/framing.css
File was created | 1 | /* The following styles size, place, and layer the slide components. | ||
2 | Edit these if you want to change the overall slide layout. | |||
3 | The commented lines can be uncommented (and modified, if necessary) | |||
4 | to help you with the rearrangement process. */ | |||
5 | ||||
6 | /* target = 1024x768 */ | |||
7 | ||||
8 | div#header, div#footer, .slide {width: 100%; top: 0; left: 0;} | |||
9 | div#header {top: 0; height: 3em; z-index: 1;} | |||
10 | div#footer {top: auto; bottom: 0; height: 2.5em; z-index: 5;} | |||
11 | .slide {top: 0; width: 92%; padding: 3.5em 4% 4%; z-index: 2; list-style: none;} | |||
12 | div#controls {left: 50%; bottom: 0; width: 50%; z-index: 100;} | |||
13 | div#controls form {position: absolute; bottom: 0; right: 0; width: 100%; | |||
14 | margin: 0;} | |||
15 | #currentSlide {position: absolute; width: 10%; left: 45%; bottom: 1em; z-index: 10;} | |||
16 | html>body #currentSlide {position: fixed;} | |||
17 | ||||
18 | /* | |||
19 | div#header {background: #FCC;} | |||
20 | div#footer {background: #CCF;} |
templates/html/Wize_S5/ui/default/iepngfix.htc
File was created | 1 | <public:component> | ||
2 | <public:attach event="onpropertychange" onevent="doFix()" /> | |||
3 | ||||
4 | <script> | |||
5 | ||||
6 | // IE5.5+ PNG Alpha Fix v1.0 by Angus Turnbull http://www.twinhelix.com | |||
7 | // Free usage permitted as long as this notice remains intact. | |||
8 | ||||
9 | // This must be a path to a blank image. That's all the configuration you need here. | |||
10 | var blankImg = 'ui/default/blank.gif'; | |||
11 | ||||
12 | var f = 'DXImageTransform.Microsoft.AlphaImageLoader'; | |||
13 | ||||
14 | function filt(s, m) { | |||
15 | if (filters[f]) { | |||
16 | filters[f].enabled = s ? true : false; | |||
17 | if (s) with (filters[f]) { src = s; sizingMethod = m } | |||
18 | } else if (s) style.filter = 'progid:'+f+'(src="'+s+'",sizingMethod="'+m+'")'; | |||
19 | } | |||
20 | ||||
21 | function doFix() { | |||
22 | if ((parseFloat(navigator.userAgent.match(/MSIE (\S+)/)[1]) < 5.5) || | |||
23 | (event && !/(background|src)/.test(event.propertyName))) return; | |||
24 | ||||
25 | if (tagName == 'IMG') { | |||
26 | if ((/\.png$/i).test(src)) { | |||
27 | filt(src, 'image'); // was 'scale' | |||
28 | src = blankImg; | |||
29 | } else if (src.indexOf(blankImg) < 0) filt(); | |||
30 | } else if (style.backgroundImage) { | |||
31 | if (style.backgroundImage.match(/^url[("']+(.*\.png)[)"']+$/i)) { | |||
32 | var s = RegExp.$1; | |||
33 | style.backgroundImage = ''; |
templates/html/Wize_S5/ui/default/opera.css
File was created | 1 | /* DO NOT CHANGE THESE unless you really want to break Opera Show */ | ||
2 | .slide { | |||
3 | visibility: visible !important; | |||
4 | position: static !important; | |||
5 | page-break-before: always; | |||
6 | } | |||
7 | #slide0 {page-break-before: avoid;} |
templates/html/Wize_S5/ui/default/outline.css
File was created | 1 | /* don't change this unless you want the layout stuff to show up in the outline view! */ | ||
2 | ||||
3 | .layout div, #footer *, #controlForm * {display: none;} | |||
4 | #footer, #controls, #controlForm, #navLinks, #toggle { | |||
5 | display: block; visibility: visible; margin: 0; padding: 0;} | |||
6 | #toggle {float: right; padding: 0.5em;} | |||
7 | html>body #toggle {position: fixed; top: 0; right: 0;} | |||
8 | ||||
9 | /* making the outline look pretty-ish */ | |||
10 | ||||
11 | #slide0 h1, #slide0 h2, #slide0 h3, #slide0 h4 {border: none; margin: 0;} | |||
12 | #slide0 h1 {padding-top: 1.5em;} |
templates/html/Wize_S5/ui/default/pretty.css
File was created | 1 | /* Following are the presentation styles -- edit away! */ | ||
2 | ||||
3 | /* body {background: #FFF url(bodybg.gif) -16px 0 no-repeat; color: #000; font-size: 2em;} */ | |||
4 | body {background: #FFF;} | |||
5 | ||||
6 | :link, :visited {text-decoration: none; color: #00C;} | |||
7 | #controls :active {color: #88A !important;} | |||
8 | #controls :focus {outline: 1px dotted #227;} | |||
9 | ||||
10 | /* h1, h2, h3, h4 {font-size: 100%; margin: 0; padding: 0; font-weight: inherit;} */ | |||
11 | ||||
12 | /* ul, pre {margin: 0; line-height: 1em;} */ | |||
13 | ||||
14 | ul, pre {margin: 0;} | |||
15 | ||||
16 | html, body {margin: 0; padding: 0;} | |||
17 | ||||
18 | blockquote, q {font-style: italic;} | |||
19 | blockquote {padding: 0 2em 0.5em; margin: 0 1.5em 0.5em; text-align: center; font-size: 1em;} | |||
20 | blockquote p {margin: 0;} | |||
21 | blockquote i {font-style: normal;} | |||
22 | blockquote b {display: block; margin-top: 0.5em; font-weight: normal; font-size: smaller; font-style: normal;} | |||
23 | blockquote b i {font-style: italic;} | |||
24 | ||||
25 | kbd {font-weight: bold; font-size: 1em;} | |||
26 | sup {font-size: smaller; line-height: 1px;} | |||
27 | ||||
28 | /*.slide code {padding: 2px 0.25em; font-weight: bold; color: #533;}*/ | |||
29 | ||||
30 | ||||
31 | .slide code.bad, code del {color: red;} | |||
32 | .slide code.old {color: silver;} | |||
33 | ||||
34 | /* .slide pre {padding: 0; margin: 0.25em 0 0.5em 0.5em; color: #533; font-size: 90%;} */ | |||
35 | .slide pre { | |||
36 | padding: 0.2em; | |||
37 | margin: 0.25em 0 0.5em 0.5em; | |||
38 | color: var(--main-pre-color); | |||
39 | font-size: 90%; | |||
40 | } | |||
41 | ||||
42 | .slide pre code {display: block;} | |||
43 | .slide ul {margin-left: 5%; margin-right: 7%; list-style: disc;} | |||
44 | .slide li {margin-top: 0.75em; margin-right: 0;} | |||
45 | .slide ul ul {line-height: 1;} | |||
46 | .slide ul ul li {margin: .2em; font-size: 85%; list-style: square;} | |||
47 | .slide img.leader {display: block; margin: 0 auto;} | |||
48 | ||||
49 | /*div#header, div#footer {background:var(--main-pres-banner-background); color: #AAB; | |||
50 | font-family: Verdana, Helvetica, sans-serif;}*/ | |||
51 | ||||
52 | div#header, div#footer {background:var(--main-pres-banner-background); color: #AAB;} | |||
53 | ||||
54 | ||||
55 | /* div#header {background: #005 url(bodybg.gif) -16px 0 no-repeat; | |||
56 | line-height: 1px;} */ | |||
57 | ||||
58 | ||||
59 | div#footer {font-size: 0.5em; font-weight: bold; padding: 1em 0;} | |||
60 | ||||
61 | #footer h1, #footer h2 {display: block; padding: 0 1em;} | |||
62 | ||||
63 | /* #footer h2 {font-style: italic;} */ | |||
64 | #footer h2 {font-style: italic; margin-top:-0.2em;} | |||
65 | ||||
66 | div.long {font-size: 0.75em;} | |||
67 | ||||
68 | /* .slide h1 {position: absolute; top: 0.7em; left: 87px; z-index: 1; | |||
69 | margin: 0; padding: 0.3em 0 0 50px; white-space: nowrap; | |||
70 | font: bold 150%/1em Helvetica, sans-serif; text-transform: capitalize; | |||
71 | color: #DDE; background: #005;} */ | |||
72 | ||||
73 | .slide h1 { position: absolute; | |||
74 | top: 0.2em; | |||
75 | /*left: 87px;*/ | |||
76 | z-index: 1; | |||
77 | margin: 0; | |||
78 | /*padding: 0.3em 0 0 50px;*/ | |||
79 | white-space: nowrap; | |||
80 | /*font: bold 150%/1em Helvetica, sans-serif;*/ | |||
81 | text-transform: capitalize; | |||
82 | color: var(--main-pres-banner-foreground); | |||
83 | text-decoration: none; | |||
84 | } | |||
85 | ||||
86 | ||||
87 | /* .slide h3 {font-size: 130%;} */ | |||
88 | ||||
89 | h1 abbr {font-variant: small-caps;} | |||
90 | ||||
91 | /*div#controls {position: absolute; left: 50%; bottom: 0; | |||
92 | width: 50%; | |||
93 | text-align: right; font: bold 0.9em Verdana, Helvetica, sans-serif;}*/ | |||
94 | ||||
95 | div#controls {position: absolute; left: 50%; bottom: 0; | |||
96 | width: 50%; | |||
97 | text-align: right; font: bold 0.9em;} | |||
98 | ||||
99 | ||||
100 | html>body div#controls {position: fixed; padding: 0 0 1em 0; | |||
101 | top: auto;} | |||
102 | div#controls form {position: absolute; bottom: 0; right: 0; width: 100%; | |||
103 | margin: 0; padding: 0;} | |||
104 | #controls #navLinks a {padding: 0; margin: 0 0.5em; | |||
105 | background: transparent; border: none; color: var(--main-pres-banner-foreground); |
templates/html/Wize_S5/ui/default/print.css
File was created | 1 | /* The following rule is necessary to have all slides appear in print! DO NOT REMOVE IT! */ | ||
2 | .slide, ul {page-break-inside: avoid; visibility: visible !important;} | |||
3 | h1 {page-break-after: avoid;} | |||
4 | ||||
5 | body {font-size: 12pt; background: white;} | |||
6 | * {color: black;} | |||
7 | ||||
8 | #slide0 h1 {font-size: 200%; border: none; margin: 0.5em 0 0.25em;} | |||
9 | #slide0 h3 {margin: 0; padding: 0;} | |||
10 | #slide0 h4 {margin: 0 0 0.5em; padding: 0;} | |||
11 | #slide0 {margin-bottom: 3em;} | |||
12 | ||||
13 | h1 {border-top: 2pt solid gray; border-bottom: 1px dotted silver;} | |||
14 | .extra {background: transparent !important;} | |||
15 | div.extra, pre.extra, .example {font-size: 10pt; color: #333;} | |||
16 | ul.extra a {font-weight: bold;} | |||
17 | p.example {display: none;} | |||
18 | ||||
19 | #header {display: none;} |
templates/html/Wize_S5/ui/default/s5-core.css
File was created | 1 | /* Do not edit or override these styles! The system will likely break if you do. */ | ||
2 | ||||
3 | div#header, div#footer, div#controls, .slide {position: absolute;} | |||
4 | html>body div#header, html>body div#footer, | |||
5 | html>body div#controls, html>body .slide {position: fixed;} | |||
6 | .handout {display: none;} | |||
7 | .layout {display: block;} | |||
8 | .slide, .hideme, .incremental {visibility: hidden;} |
templates/html/Wize_S5/ui/default/slides.css
File was created | 1 | @import url(s5-core.css); /* required to make the slide show run at all */ | ||
2 | @import url(framing.css); /* sets basic placement and size of slide components */ | |||
3 | @import url(pretty.css); /* stuff that makes the slides look better than blah */ |
templates/html/Wize_S5/ui/default/slides.js
File was created | 1 | // S5 v1.1 slides.js -- released into the Public Domain | ||
2 | // | |||
3 | // Please see http://www.meyerweb.com/eric/tools/s5/credits.html for information | |||
4 | // about all the wonderful and talented contributors to this code! | |||
5 | ||||
6 | var undef; | |||
7 | var slideCSS = ''; | |||
8 | var snum = 0; | |||
9 | var smax = 1; | |||
10 | var incpos = 0; | |||
11 | var number = undef; | |||
12 | var s5mode = true; | |||
13 | var defaultView = 'slideshow'; | |||
14 | var controlVis = 'visible'; | |||
15 | ||||
16 | var isIE = navigator.appName == 'Microsoft Internet Explorer' && navigator.userAgent.indexOf('Opera') < 1 ? 1 : 0; | |||
17 | var isOp = navigator.userAgent.indexOf('Opera') > -1 ? 1 : 0; | |||
18 | var isGe = navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('Safari') < 1 ? 1 : 0; | |||
19 | ||||
20 | function hasClass(object, className) { | |||
21 | if (!object.className) return false; | |||
22 | return (object.className.search('(^|\\s)' + className + '(\\s|$)') != -1); | |||
23 | } | |||
24 | ||||
25 | function hasValue(object, value) { | |||
26 | if (!object) return false; | |||
27 | return (object.search('(^|\\s)' + value + '(\\s|$)') != -1); | |||
28 | } | |||
29 | ||||
30 | function removeClass(object,className) { | |||
31 | if (!object) return; | |||
32 | object.className = object.className.replace(new RegExp('(^|\\s)'+className+'(\\s|$)'), RegExp.$1+RegExp.$2); | |||
33 | } | |||
34 | ||||
35 | function addClass(object,className) { | |||
36 | if (!object || hasClass(object, className)) return; | |||
37 | if (object.className) { | |||
38 | object.className += ' '+className; | |||
39 | } else { | |||
40 | object.className = className; | |||
41 | } | |||
42 | } | |||
43 | ||||
44 | function GetElementsWithClassName(elementName,className) { | |||
45 | var allElements = document.getElementsByTagName(elementName); | |||
46 | var elemColl = new Array(); | |||
47 | for (var i = 0; i< allElements.length; i++) { | |||
48 | if (hasClass(allElements[i], className)) { | |||
49 | elemColl[elemColl.length] = allElements[i]; | |||
50 | } | |||
51 | } | |||
52 | return elemColl; | |||
53 | } | |||
54 | ||||
55 | function isParentOrSelf(element, id) { | |||
56 | if (element == null || element.nodeName=='BODY') return false; | |||
57 | else if (element.id == id) return true; | |||
58 | else return isParentOrSelf(element.parentNode, id); | |||
59 | } | |||
60 | ||||
61 | function nodeValue(node) { | |||
62 | var result = ""; | |||
63 | if (node.nodeType == 1) { | |||
64 | var children = node.childNodes; | |||
65 | for (var i = 0; i < children.length; ++i) { | |||
66 | result += nodeValue(children[i]); | |||
67 | } | |||
68 | } | |||
69 | else if (node.nodeType == 3) { | |||
70 | result = node.nodeValue; | |||
71 | } | |||
72 | return(result); | |||
73 | } | |||
74 | ||||
75 | function slideLabel() { | |||
76 | var slideColl = GetElementsWithClassName('*','slide'); | |||
77 | var list = document.getElementById('jumplist'); | |||
78 | smax = slideColl.length; | |||
79 | for (var n = 0; n < smax; n++) { | |||
80 | var obj = slideColl[n]; | |||
81 | ||||
82 | var did = 'slide' + n.toString(); | |||
83 | obj.setAttribute('id',did); | |||
84 | if (isOp) continue; | |||
85 | ||||
86 | var otext = ''; | |||
87 | var menu = obj.firstChild; | |||
88 | if (!menu) continue; // to cope with empty slides | |||
89 | while (menu && menu.nodeType == 3) { | |||
90 | menu = menu.nextSibling; | |||
91 | } | |||
92 | if (!menu) continue; // to cope with slides with only text nodes | |||
93 | ||||
94 | var menunodes = menu.childNodes; | |||
95 | for (var o = 0; o < menunodes.length; o++) { | |||
96 | otext += nodeValue(menunodes[o]); | |||
97 | } | |||
98 | list.options[list.length] = new Option(n + ' : ' + otext, n); | |||
99 | } | |||
100 | } | |||
101 | ||||
102 | function currentSlide() { | |||
103 | var cs; | |||
104 | if (document.getElementById) { | |||
105 | cs = document.getElementById('currentSlide'); | |||
106 | } else { | |||
107 | cs = document.currentSlide; | |||
108 | } | |||
109 | cs.innerHTML = '<span id="csHere">' + snum + '<\/span> ' + | |||
110 | '<span id="csSep">\/<\/span> ' + | |||
111 | '<span id="csTotal">' + (smax-1) + '<\/span>'; | |||
112 | if (snum == 0) { | |||
113 | cs.style.visibility = 'hidden'; | |||
114 | } else { | |||
115 | cs.style.visibility = 'visible'; | |||
116 | } | |||
117 | } | |||
118 | ||||
119 | function go(step) { | |||
120 | if (document.getElementById('slideProj').disabled || step == 0) return; | |||
121 | var jl = document.getElementById('jumplist'); | |||
122 | var cid = 'slide' + snum; | |||
123 | var ce = document.getElementById(cid); | |||
124 | if (incrementals[snum].length > 0) { | |||
125 | for (var i = 0; i < incrementals[snum].length; i++) { | |||
126 | removeClass(incrementals[snum][i], 'current'); | |||
127 | removeClass(incrementals[snum][i], 'incremental'); | |||
128 | } | |||
129 | } | |||
130 | if (step != 'j') { | |||
131 | snum += step; | |||
132 | lmax = smax - 1; | |||
133 | if (snum > lmax) snum = lmax; | |||
134 | if (snum < 0) snum = 0; | |||
135 | } else | |||
136 | snum = parseInt(jl.value); | |||
137 | var nid = 'slide' + snum; | |||
138 | var ne = document.getElementById(nid); | |||
139 | if (!ne) { | |||
140 | ne = document.getElementById('slide0'); | |||
141 | snum = 0; | |||
142 | } | |||
143 | if (step < 0) {incpos = incrementals[snum].length} else {incpos = 0;} | |||
144 | if (incrementals[snum].length > 0 && incpos == 0) { | |||
145 | for (var i = 0; i < incrementals[snum].length; i++) { | |||
146 | if (hasClass(incrementals[snum][i], 'current')) | |||
147 | incpos = i + 1; | |||
148 | else | |||
149 | addClass(incrementals[snum][i], 'incremental'); | |||
150 | } | |||
151 | } | |||
152 | if (incrementals[snum].length > 0 && incpos > 0) | |||
153 | addClass(incrementals[snum][incpos - 1], 'current'); | |||
154 | ce.style.visibility = 'hidden'; | |||
155 | ne.style.visibility = 'visible'; | |||
156 | jl.selectedIndex = snum; | |||
157 | currentSlide(); | |||
158 | number = 0; | |||
159 | } | |||
160 | ||||
161 | function goTo(target) { | |||
162 | if (target >= smax || target == snum) return; | |||
163 | go(target - snum); | |||
164 | } | |||
165 | ||||
166 | function subgo(step) { | |||
167 | if (step > 0) { | |||
168 | removeClass(incrementals[snum][incpos - 1],'current'); | |||
169 | removeClass(incrementals[snum][incpos], 'incremental'); | |||
170 | addClass(incrementals[snum][incpos],'current'); | |||
171 | incpos++; | |||
172 | } else { | |||
173 | incpos--; | |||
174 | removeClass(incrementals[snum][incpos],'current'); | |||
175 | addClass(incrementals[snum][incpos], 'incremental'); | |||
176 | addClass(incrementals[snum][incpos - 1],'current'); | |||
177 | } | |||
178 | } | |||
179 | ||||
180 | function toggle() { | |||
181 | var slideColl = GetElementsWithClassName('*','slide'); | |||
182 | var slides = document.getElementById('slideProj'); | |||
183 | var outline = document.getElementById('outlineStyle'); | |||
184 | if (!slides.disabled) { | |||
185 | slides.disabled = true; | |||
186 | outline.disabled = false; | |||
187 | s5mode = false; | |||
188 | fontSize('1em'); | |||
189 | for (var n = 0; n < smax; n++) { | |||
190 | var slide = slideColl[n]; | |||
191 | slide.style.visibility = 'visible'; | |||
192 | } | |||
193 | } else { | |||
194 | slides.disabled = false; | |||
195 | outline.disabled = true; | |||
196 | s5mode = true; | |||
197 | fontScale(); | |||
198 | for (var n = 0; n < smax; n++) { | |||
199 | var slide = slideColl[n]; | |||
200 | slide.style.visibility = 'hidden'; | |||
201 | } | |||
202 | slideColl[snum].style.visibility = 'visible'; | |||
203 | } | |||
204 | } | |||
205 | ||||
206 | function showHide(action) { | |||
207 | var obj = GetElementsWithClassName('*','hideme')[0]; | |||
208 | switch (action) { | |||
209 | case 's': obj.style.visibility = 'visible'; break; | |||
210 | case 'h': obj.style.visibility = 'hidden'; break; | |||
211 | case 'k': | |||
212 | if (obj.style.visibility != 'visible') { | |||
213 | obj.style.visibility = 'visible'; | |||
214 | } else { | |||
215 | obj.style.visibility = 'hidden'; | |||
216 | } | |||
217 | break; | |||
218 | } | |||
219 | } | |||
220 | ||||
221 | // 'keys' code adapted from MozPoint (http://mozpoint.mozdev.org/) | |||
222 | function keys(key) { | |||
223 | if (!key) { | |||
224 | key = event; | |||
225 | key.which = key.keyCode; | |||
226 | } | |||
227 | if (key.which == 84) { | |||
228 | toggle(); | |||
229 | return; | |||
230 | } | |||
231 | if (s5mode) { | |||
232 | switch (key.which) { | |||
233 | case 10: // return | |||
234 | case 13: // enter | |||
235 | if (window.event && isParentOrSelf(window.event.srcElement, 'controls')) return; | |||
236 | if (key.target && isParentOrSelf(key.target, 'controls')) return; | |||
237 | if(number != undef) { | |||
238 | goTo(number); | |||
239 | break; | |||
240 | } | |||
241 | case 32: // spacebar | |||
242 | case 34: // page down | |||
243 | case 39: // rightkey | |||
244 | case 40: // downkey | |||
245 | if(number != undef) { | |||
246 | go(number); | |||
247 | } else if (!incrementals[snum] || incpos >= incrementals[snum].length) { | |||
248 | go(1); | |||
249 | } else { | |||
250 | subgo(1); | |||
251 | } | |||
252 | break; | |||
253 | case 33: // page up | |||
254 | case 37: // leftkey | |||
255 | case 38: // upkey | |||
256 | if(number != undef) { | |||
257 | go(-1 * number); | |||
258 | } else if (!incrementals[snum] || incpos <= 0) { | |||
259 | go(-1); | |||
260 | } else { | |||
261 | subgo(-1); | |||
262 | } | |||
263 | break; | |||
264 | case 36: // home | |||
265 | goTo(0); | |||
266 | break; | |||
267 | case 35: // end | |||
268 | goTo(smax-1); | |||
269 | break; | |||
270 | case 67: // c | |||
271 | showHide('k'); | |||
272 | break; | |||
273 | } | |||
274 | if (key.which < 48 || key.which > 57) { | |||
275 | number = undef; | |||
276 | } else { | |||
277 | if (window.event && isParentOrSelf(window.event.srcElement, 'controls')) return; | |||
278 | if (key.target && isParentOrSelf(key.target, 'controls')) return; | |||
279 | number = (((number != undef) ? number : 0) * 10) + (key.which - 48); | |||
280 | } | |||
281 | } | |||
282 | return false; | |||
283 | } | |||
284 | ||||
285 | function clicker(e) { | |||
286 | number = undef; | |||
287 | var target; | |||
288 | if (window.event) { | |||
289 | target = window.event.srcElement; | |||
290 | e = window.event; | |||
291 | } else target = e.target; | |||
292 | if (target.getAttribute('href') != null || hasValue(target.rel, 'external') || isParentOrSelf(target, 'controls') || isParentOrSelf(target,'embed') || isParentOrSelf(target,'object')) return true; | |||
293 | if (!e.which || e.which == 1) { | |||
294 | if (!incrementals[snum] || incpos >= incrementals[snum].length) { | |||
295 | go(1); | |||
296 | } else { | |||
297 | subgo(1); | |||
298 | } | |||
299 | } | |||
300 | } | |||
301 | ||||
302 | function findSlide(hash) { | |||
303 | var target = null; | |||
304 | var slides = GetElementsWithClassName('*','slide'); | |||
305 | for (var i = 0; i < slides.length; i++) { | |||
306 | var targetSlide = slides[i]; | |||
307 | if ( (targetSlide.name && targetSlide.name == hash) | |||
308 | || (targetSlide.id && targetSlide.id == hash) ) { | |||
309 | target = targetSlide; | |||
310 | break; | |||
311 | } | |||
312 | } | |||
313 | while(target != null && target.nodeName != 'BODY') { | |||
314 | if (hasClass(target, 'slide')) { | |||
315 | return parseInt(target.id.slice(5)); | |||
316 | } | |||
317 | target = target.parentNode; | |||
318 | } | |||
319 | return null; | |||
320 | } | |||
321 | ||||
322 | function slideJump() { | |||
323 | if (window.location.hash == null) return; | |||
324 | var sregex = /^#slide(\d+)$/; | |||
325 | var matches = sregex.exec(window.location.hash); | |||
326 | var dest = null; | |||
327 | if (matches != null) { | |||
328 | dest = parseInt(matches[1]); | |||
329 | } else { | |||
330 | dest = findSlide(window.location.hash.slice(1)); | |||
331 | } | |||
332 | if (dest != null) | |||
333 | go(dest - snum); | |||
334 | } | |||
335 | ||||
336 | function fixLinks() { | |||
337 | var thisUri = window.location.href; | |||
338 | thisUri = thisUri.slice(0, thisUri.length - window.location.hash.length); | |||
339 | var aelements = document.getElementsByTagName('A'); | |||
340 | for (var i = 0; i < aelements.length; i++) { | |||
341 | var a = aelements[i].href; | |||
342 | var slideID = a.match('\#slide[0-9]{1,2}'); | |||
343 | if ((slideID) && (slideID[0].slice(0,1) == '#')) { | |||
344 | var dest = findSlide(slideID[0].slice(1)); | |||
345 | if (dest != null) { | |||
346 | if (aelements[i].addEventListener) { | |||
347 | aelements[i].addEventListener("click", new Function("e", | |||
348 | "if (document.getElementById('slideProj').disabled) return;" + | |||
349 | "go("+dest+" - snum); " + | |||
350 | "if (e.preventDefault) e.preventDefault();"), true); | |||
351 | } else if (aelements[i].attachEvent) { | |||
352 | aelements[i].attachEvent("onclick", new Function("", | |||
353 | "if (document.getElementById('slideProj').disabled) return;" + | |||
354 | "go("+dest+" - snum); " + | |||
355 | "event.returnValue = false;")); | |||
356 | } | |||
357 | } | |||
358 | } | |||
359 | } | |||
360 | } | |||
361 | ||||
362 | function externalLinks() { | |||
363 | if (!document.getElementsByTagName) return; | |||
364 | var anchors = document.getElementsByTagName('a'); | |||
365 | for (var i=0; i<anchors.length; i++) { | |||
366 | var anchor = anchors[i]; | |||
367 | if (anchor.getAttribute('href') && hasValue(anchor.rel, 'external')) { | |||
368 | anchor.target = '_blank'; | |||
369 | addClass(anchor,'external'); | |||
370 | } | |||
371 | } | |||
372 | } | |||
373 | ||||
374 | function createControls() { | |||
375 | var controlsDiv = document.getElementById("controls"); | |||
376 | if (!controlsDiv) return; | |||
377 | var hider = ' onmouseover="showHide(\'s\');" onmouseout="showHide(\'h\');"'; | |||
378 | var hideDiv, hideList = ''; | |||
379 | if (controlVis == 'hidden') { | |||
380 | hideDiv = hider; | |||
381 | } else { | |||
382 | hideList = hider; | |||
383 | } | |||
384 | controlsDiv.innerHTML = '<form action="#" id="controlForm"' + hideDiv + '>' + | |||
385 | '<div id="navLinks">' + | |||
386 | '<a accesskey="t" id="toggle" href="javascript:toggle();">Ø<\/a>' + | |||
387 | '<a accesskey="z" id="prev" href="javascript:go(-1);">«<\/a>' + | |||
388 | '<a accesskey="x" id="next" href="javascript:go(1);">»<\/a>' + | |||
389 | '<div id="navList"' + hideList + '><select id="jumplist" onchange="go(\'j\');"><\/select><\/div>' + | |||
390 | '<\/div><\/form>'; | |||
391 | if (controlVis == 'hidden') { | |||
392 | var hidden = document.getElementById('navLinks'); | |||
393 | } else { | |||
394 | var hidden = document.getElementById('jumplist'); | |||
395 | } | |||
396 | addClass(hidden,'hideme'); | |||
397 | } | |||
398 | ||||
399 | function fontScale() { // causes layout problems in FireFox that get fixed if browser's Reload is used; same may be true of other Gecko-based browsers | |||
400 | if (!s5mode) return false; | |||
401 | var vScale = 22; // both yield 32 (after rounding) at 1024x768 | |||
402 | var hScale = 32; // perhaps should auto-calculate based on theme's declared value? | |||
403 | if (window.innerHeight) { | |||
404 | var vSize = window.innerHeight; | |||
405 | var hSize = window.innerWidth; | |||
406 | } else if (document.documentElement.clientHeight) { | |||
407 | var vSize = document.documentElement.clientHeight; | |||
408 | var hSize = document.documentElement.clientWidth; | |||
409 | } else if (document.body.clientHeight) { | |||
410 | var vSize = document.body.clientHeight; | |||
411 | var hSize = document.body.clientWidth; | |||
412 | } else { | |||
413 | var vSize = 700; // assuming 1024x768, minus chrome and such | |||
414 | var hSize = 1024; // these do not account for kiosk mode or Opera Show | |||
415 | } | |||
416 | var newSize = Math.min(Math.round(vSize/vScale),Math.round(hSize/hScale)); | |||
417 | fontSize(newSize + 'px'); | |||
418 | if (isGe) { // hack to counter incremental reflow bugs | |||
419 | var obj = document.getElementsByTagName('body')[0]; | |||
420 | obj.style.display = 'none'; | |||
421 | obj.style.display = 'block'; | |||
422 | } | |||
423 | } | |||
424 | ||||
425 | function fontSize(value) { | |||
426 | if (!(s5ss = document.getElementById('s5ss'))) { | |||
427 | if (!isIE) { | |||
428 | document.getElementsByTagName('head')[0].appendChild(s5ss = document.createElement('style')); | |||
429 | s5ss.setAttribute('media','screen, projection'); | |||
430 | s5ss.setAttribute('id','s5ss'); | |||
431 | } else { | |||
432 | document.createStyleSheet(); | |||
433 | document.s5ss = document.styleSheets[document.styleSheets.length - 1]; | |||
434 | } | |||
435 | } | |||
436 | if (!isIE) { | |||
437 | while (s5ss.lastChild) s5ss.removeChild(s5ss.lastChild); | |||
438 | s5ss.appendChild(document.createTextNode('body {font-size: ' + value + ' !important;}')); | |||
439 | } else { | |||
440 | document.s5ss.addRule('body','font-size: ' + value + ' !important;'); | |||
441 | } | |||
442 | } | |||
443 | ||||
444 | function notOperaFix() { | |||
445 | slideCSS = document.getElementById('slideProj').href; | |||
446 | var slides = document.getElementById('slideProj'); | |||
447 | var outline = document.getElementById('outlineStyle'); | |||
448 | slides.setAttribute('media','screen'); | |||
449 | outline.disabled = true; | |||
450 | if (isGe) { | |||
451 | slides.setAttribute('href','null'); // Gecko fix | |||
452 | slides.setAttribute('href',slideCSS); // Gecko fix | |||
453 | } | |||
454 | if (isIE && document.styleSheets && document.styleSheets[0]) { | |||
455 | document.styleSheets[0].addRule('img', 'behavior: url(ui/default/iepngfix.htc)'); | |||
456 | document.styleSheets[0].addRule('div', 'behavior: url(ui/default/iepngfix.htc)'); | |||
457 | document.styleSheets[0].addRule('.slide', 'behavior: url(ui/default/iepngfix.htc)'); | |||
458 | } | |||
459 | } | |||
460 | ||||
461 | function getIncrementals(obj) { | |||
462 | var incrementals = new Array(); | |||
463 | if (!obj) | |||
464 | return incrementals; | |||
465 | var children = obj.childNodes; | |||
466 | for (var i = 0; i < children.length; i++) { | |||
467 | var child = children[i]; | |||
468 | if (hasClass(child, 'incremental')) { | |||
469 | if (child.nodeName == 'OL' || child.nodeName == 'UL') { | |||
470 | removeClass(child, 'incremental'); | |||
471 | for (var j = 0; j < child.childNodes.length; j++) { | |||
472 | if (child.childNodes[j].nodeType == 1) { | |||
473 | addClass(child.childNodes[j], 'incremental'); | |||
474 | } | |||
475 | } | |||
476 | } else { | |||
477 | incrementals[incrementals.length] = child; | |||
478 | removeClass(child,'incremental'); | |||
479 | } | |||
480 | } | |||
481 | if (hasClass(child, 'show-first')) { | |||
482 | if (child.nodeName == 'OL' || child.nodeName == 'UL') { | |||
483 | removeClass(child, 'show-first'); | |||
484 | if (child.childNodes[isGe].nodeType == 1) { | |||
485 | removeClass(child.childNodes[isGe], 'incremental'); | |||
486 | } | |||
487 | } else { | |||
488 | incrementals[incrementals.length] = child; | |||
489 | } | |||
490 | } | |||
491 | incrementals = incrementals.concat(getIncrementals(child)); | |||
492 | } | |||
493 | return incrementals; | |||
494 | } | |||
495 | ||||
496 | function createIncrementals() { | |||
497 | var incrementals = new Array(); | |||
498 | for (var i = 0; i < smax; i++) { | |||
499 | incrementals[i] = getIncrementals(document.getElementById('slide'+i)); | |||
500 | } | |||
501 | return incrementals; | |||
502 | } | |||
503 | ||||
504 | function defaultCheck() { | |||
505 | var allMetas = document.getElementsByTagName('meta'); | |||
506 | for (var i = 0; i< allMetas.length; i++) { | |||
507 | if (allMetas[i].name == 'defaultView') { | |||
508 | defaultView = allMetas[i].content; | |||
509 | } | |||
510 | if (allMetas[i].name == 'controlVis') { | |||
511 | controlVis = allMetas[i].content; | |||
512 | } | |||
513 | } | |||
514 | } | |||
515 | ||||
516 | // Key trap fix, new function body for trap() | |||
517 | function trap(e) { | |||
518 | if (!e) { | |||
519 | e = event; | |||
520 | e.which = e.keyCode; |
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", | |
" - crée le fichier Wize_Print.html à partir", | 33 | 33 | " - crée le fichier Wize_Print.html à partir", | |
"du fichier template correspondant en", | 34 | 34 | "du fichier template correspondant en", | |
"remplaçant %%HOME%% par la valeur de $HOME.", | 35 | 35 | "remplaçant %%HOME%% par la valeur de $HOME.", | |
" - Installe un lien symbolique dans", | 36 | 36 | " - Installe un lien symbolique dans", | |
"le dossier de config de zim.", | 37 | 37 | "le dossier de config de zim.", | |
" - Applique le thème wize de base", | 38 | 38 | " - Applique le thème wize de base", | |
"A éxécuter a priori une seule fois .") do |l| | 39 | 39 | "A éxécuter a priori une seule fois .") do |l| | |
options[:install] = l | 40 | 40 | options[:install] = l | |
end | 41 | 41 | end | |
42 | 42 | |||
opts.on("-l", | 43 | 43 | opts.on("-l", | |
"--list", | 44 | 44 | "--list", | |
"Liste les configurations disponibles") do |l| | 45 | 45 | "Liste les configurations disponibles") do |l| | |
options[:list] = l | 46 | 46 | options[:list] = l | |
end | 47 | 47 | end | |
48 | 48 | |||
opts.on("-p", | 49 | 49 | opts.on("-p", | |
"--print", | 50 | 50 | "--print", | |
"Affiche la configuration actuelle") do |p| | 51 | 51 | "Affiche la configuration actuelle") do |p| | |
options[:print] = p | 52 | 52 | options[:print] = p | |
end | 53 | 53 | end | |
54 | 54 | |||
opts.on("-a", | 55 | 55 | opts.on("-a", | |
"--apply CONF", | 56 | 56 | "--apply CONF", | |
"applique la config CONF") do |conf| | 57 | 57 | "applique la config CONF") do |conf| | |
options[:conf] = conf | 58 | 58 | options[:conf] = conf | |
end | 59 | 59 | end | |
60 | 60 | |||
opts.separator "" | 61 | 61 | opts.separator "" | |
opts.separator " Options standard:" | 62 | 62 | opts.separator " Options standard:" | |
opts.on_tail("-h", "--help", "Affiche ce message") do | 63 | 63 | opts.on_tail("-h", "--help", "Affiche ce message") do | |
puts opts | 64 | 64 | puts opts | |
puts "" | 65 | 65 | puts "" | |
exit | 66 | 66 | exit | |
end | 67 | 67 | end | |
opts.on_tail("-v", "--version", "Affiche la version") do | 68 | 68 | opts.on_tail("-v", "--version", "Affiche la version") do | |
puts "Version : " + $version | 69 | 69 | puts "Version : " + $version | |
puts "Auteur : " + $auteur | 70 | 70 | puts "Auteur : " + $auteur | |
puts "Date : " + $date | 71 | 71 | puts "Date : " + $date | |
puts "" | 72 | 72 | puts "" | |
exit | 73 | 73 | exit | |
end | 74 | 74 | end | |
end | 75 | 75 | end | |
76 | 76 | |||
opt_parser.parse!(args) | 77 | 77 | opt_parser.parse!(args) | |
options | 78 | 78 | options | |
end | 79 | 79 | end | |
end | 80 | 80 | end | |
81 | 81 | |||
# Get the config list | 82 | 82 | # Get the config list | |
def listConfigs | 83 | 83 | def listConfigs | |
Dir.chdir($zimHtmlTemplateDir) | 84 | 84 | Dir.chdir($zimHtmlTemplateDir) | |
a = `ls`.split(/\n/) | 85 | 85 | a = `ls`.split(/\n/) | |
names = [] | 86 | 86 | names = [] | |
r = /^common-(.+)$/ | 87 | 87 | r = /^common-(.+)$/ | |
a.each { |f| | 88 | 88 | a.each { |f| | |
if f =~ r | 89 | 89 | if f =~ r | |
names.push($1) | 90 | 90 | names.push($1) | |
end | 91 | 91 | end | |
} | 92 | 92 | } | |
names | 93 | 93 | names | |
end | 94 | 94 | end | |
95 | 95 | |||
# Get the current config by looking at print-common | 96 | 96 | # Get the current config by looking at print-common | |
def getCurrent | 97 | 97 | def getCurrent | |
Dir.chdir($zimHtmlTemplateDir) | 98 | 98 | Dir.chdir($zimHtmlTemplateDir) | |
File.readlink("print-common") =~ /^common-(.+)$/ | 99 | 99 | File.readlink("print-common") =~ /^common-(.+)$/ | |
$1 | 100 | 100 | $1 | |
end | 101 | 101 | end | |
102 | 102 | |||
# Apply a config | 103 | 103 | # Apply a config | |
def applyConfig(name) | 104 | 104 | def applyConfig(name) | |
Dir.chdir($zimHtmlTemplateDir) | 105 | 105 | Dir.chdir($zimHtmlTemplateDir) | |
list = ["Wize", "Wize_with_index", "Wize_with_index_sod"] | 106 | 106 | list = ["Wize", "Wize_with_index", "Wize_with_index_sod", "Wize_S5"] | |
list.each { |l| | 107 | 107 | list.each { |l| | |
# Removing previous content | 108 | 108 | # Removing previous content | |
system("rm -rf #{l}/common") | 109 | 109 | system("rm -rf #{l}/common") | |
system("rm -rf #{l}/common-spec") | 110 | 110 | system("rm -rf #{l}/common-spec") | |
# Copying new content | 111 | 111 | # Copying new content | |
system("cp -r common #{l}/common") | 112 | 112 | system("cp -r common #{l}/common") | |
system("cp -r common-#{name} #{l}/common-spec") | 113 | 113 | system("cp -r common-#{name} #{l}/common-spec") | |
} | 114 | 114 | } | |
# For print | 115 | 115 | # For print | |
system("rm -f print-common") | 116 | 116 | system("rm -f print-common") | |
system("ln -s common-#{name} print-common") | 117 | 117 | system("ln -s common-#{name} print-common") | |
end | 118 | 118 | end | |
119 | 119 | |||
# Is the name a valid config? | 120 | 120 | # Is the name a valid config? | |
def configInList?(name, names) | 121 | 121 | def configInList?(name, names) | |
names.include? name | 122 | 122 | names.include? name | |
end | 123 | 123 | end | |
124 | 124 | |||
# Re-create Wize_Print.html from template | 125 | 125 | # Re-create Wize_Print.html from template | |
# and initialize link into zim config directory | 126 | 126 | # and initialize link into zim config directory | |
def installWize | 127 | 127 | def installWize | |
Dir.chdir($zimHtmlTemplateDir) | 128 | 128 | Dir.chdir($zimHtmlTemplateDir) | |
begin | 129 | 129 | begin | |
printTemplate = File.new("Wize_Print_Template.tpl", "r") | 130 | 130 | printTemplate = File.new("Wize_Print_Template.tpl", "r") | |
rescue | 131 | 131 | rescue | |
puts "cannot open print file for reading" | 132 | 132 | puts "cannot open print file for reading" | |
exit | 133 | 133 | exit | |
end | 134 | 134 | end | |
tabfile = [] | 135 | 135 | tabfile = [] | |
stor = '%%HOME%%' | 136 | 136 | stor = '%%HOME%%' | |
rby = ENV['HOME'] | 137 | 137 | rby = ENV['HOME'] | |
printTemplate.readlines.each { |line| | 138 | 138 | printTemplate.readlines.each { |line| | |
line.gsub!(stor,rby) | 139 | 139 | line.gsub!(stor,rby) | |
tabfile.push(line) | 140 | 140 | tabfile.push(line) | |
} | 141 | 141 | } | |
printTemplate.close | 142 | 142 | printTemplate.close | |
begin | 143 | 143 | begin | |
printFile = File.new("Wize_Print.html", "w") | 144 | 144 | printFile = File.new("Wize_Print.html", "w") | |
rescue | 145 | 145 | rescue | |
puts "cannot open print file for writing" | 146 | 146 | puts "cannot open print file for writing" | |
exit | 147 | 147 | exit | |
end | 148 | 148 | end | |
tabfile.each { |line| | 149 | 149 | tabfile.each { |line| | |
printFile.write line | 150 | 150 | printFile.write line | |
} | 151 | 151 | } | |
printFile.close | 152 | 152 | printFile.close | |
153 | 153 | |||
Dir.chdir($zimConfigDir) | 154 | 154 | Dir.chdir($zimConfigDir) | |
system("rm -f style.conf") | 155 | 155 | system("rm -f style.conf") | |
system("ln -s #{$zimShareDir}/style.conf style.conf") | 156 | 156 | system("ln -s #{$zimShareDir}/style.conf style.conf") | |
157 | 157 | |||
# Now apply wize theme | 158 | 158 | # Now apply wize theme | |
applyConfig("wize") | 159 | 159 | applyConfig("wize") | |
createStyleFile("wize") | 160 | 160 | createStyleFile("wize") | |
end | 161 | 161 | end | |
162 | 162 | |||
# Create style-name.conf according to common-name/zim-variables.css | 163 | 163 | # Create style-name.conf according to common-name/zim-variables.css | |
def createStyleFile(name) | 164 | 164 | def createStyleFile(name) | |
lfTags = ["--main-header-color", | 165 | 165 | lfTags = ["--main-header-color", | |
"--main-menu-u-decoration", | 166 | 166 | "--main-menu-u-decoration", | |
"--main-menu-u-background-color", | 167 | 167 | "--main-menu-u-background-color", | |
"--main-strike-color", | 168 | 168 | "--main-strike-color", | |
"--main-tt-color", | 169 | 169 | "--main-tt-color", | |
"--main-pre-color", | 170 | 170 | "--main-pre-color", | |
"--main-link-color"] | 171 | 171 | "--main-link-color"] | |
172 | 172 | |||
# First we load the css file and parse it | 173 | 173 | # First we load the css file and parse it | |
Dir.chdir($zimHtmlTemplateDir) | 174 | 174 | Dir.chdir($zimHtmlTemplateDir) | |
begin | 175 | 175 | begin | |
nameCSS = File.new("common-#{name}/zim-variables.css", "r") | 176 | 176 | nameCSS = File.new("common-#{name}/zim-variables.css", "r") | |
rescue | 177 | 177 | rescue | |
puts "cannot open common-#{name}/zim-variables.css for reading" | 178 | 178 | puts "cannot open common-#{name}/zim-variables.css for reading" | |
exit | 179 | 179 | exit | |
end | 180 | 180 | end | |
sCSS = nameCSS.read | 181 | 181 | sCSS = nameCSS.read | |
regComment = /\/\*.*?\*\//m | 182 | 182 | regComment = /\/\*.*?\*\//m | |
sCSS.gsub!(regComment, '') | 183 | 183 | sCSS.gsub!(regComment, '') | |
sTags = {} | 184 | 184 | sTags = {} | |
lfTags.each { |tag| | 185 | 185 | lfTags.each { |tag| | |
var = Regexp.escape(tag) | 186 | 186 | var = Regexp.escape(tag) | |
reg = /#{var}\s*:\s*(\S+)\s*;/ | 187 | 187 | reg = /#{var}\s*:\s*(\S+)\s*;/ | |
sCSS =~ reg | 188 | 188 | sCSS =~ reg | |
sTags[tag] = $1 | 189 | 189 | sTags[tag] = $1 | |
# On traite le cas particulier du u-decoration | 190 | 190 | # On traite le cas particulier du u-decoration | |
if tag == "--main-menu-u-decoration" | 191 | 191 | if tag == "--main-menu-u-decoration" | |
sTags[tag] = sTags[tag] == 'underline' ? 'PANGO_UNDERLINE_SINGLE' : '' | 192 | 192 | sTags[tag] = sTags[tag] == 'underline' ? 'PANGO_UNDERLINE_SINGLE' : '' | |
end | 193 | 193 | end | |
} | 194 | 194 | } | |
195 | 195 | |||
# know read the style template | 196 | 196 | # know read the style template | |
Dir.chdir($zimShareDir) | 197 | 197 | Dir.chdir($zimShareDir) | |
begin | 198 | 198 | begin | |
styleTemplate = File.new("style-template.conf", "r") | 199 | 199 | styleTemplate = File.new("style-template.conf", "r") | |
rescue | 200 | 200 | rescue | |
puts "cannot open style-template.conf for reading" | 201 | 201 | puts "cannot open style-template.conf for reading" | |
exit | 202 | 202 | exit | |
end | 203 | 203 | end | |
styleTemplateString = styleTemplate.read | 204 | 204 | styleTemplateString = styleTemplate.read | |
lfTags.each { |tag| | 205 | 205 | lfTags.each { |tag| | |
styleTemplateString.gsub!("%%#{tag}%%", sTags[tag]) | 206 | 206 | styleTemplateString.gsub!("%%#{tag}%%", sTags[tag]) | |
} | 207 | 207 | } | |
# Now write the file | 208 | 208 | # Now write the file | |
begin | 209 | 209 | begin | |
styleOutput = File.new("style-#{name}.conf", "w") | 210 | 210 | styleOutput = File.new("style-#{name}.conf", "w") | |
rescue | 211 | 211 | rescue | |
puts "cannot open style-#{name}.conf for writing" | 212 | 212 | puts "cannot open style-#{name}.conf for writing" | |
exit | 213 | 213 | exit | |
end | 214 | 214 | end | |
styleOutput.write styleTemplateString | 215 | 215 | styleOutput.write styleTemplateString | |
styleOutput.close | 216 | 216 | styleOutput.close | |
# Now create the symbolic link | 217 | 217 | # Now create the symbolic link | |
system("rm style.conf") | 218 | 218 | system("rm style.conf") | |
system("ln -s style-#{name}.conf style.conf") | 219 | 219 | system("ln -s style-#{name}.conf style.conf") | |
end | 220 | 220 | end | |
221 | 221 | |||
# Parse arguments using the class and get results in a hash | 222 | 222 | # Parse arguments using the class and get results in a hash | |
options = ParseOptions.parse(ARGV) | 223 | 223 | options = ParseOptions.parse(ARGV) | |
if options.length == 0 | 224 | 224 | if options.length == 0 | |
puts "Utiliser -h pour l'aide" | 225 | 225 | puts "Utiliser -h pour l'aide" | |
exit | 226 | 226 | exit | |
end | 227 | 227 | end | |
228 | 228 | |||
# get existing configs | 229 | 229 | # get existing configs | |
configs = listConfigs | 230 | 230 | configs = listConfigs | |
231 | 231 | |||
# Installation | 232 | 232 | # Installation | |
if options[:install] | 233 | 233 | if options[:install] | |
installWize | 234 | 234 | installWize | |
exit | 235 | 235 | exit | |
end | 236 | 236 | end | |
237 | 237 | |||
# List | 238 | 238 | # List |