multi languages, in backend only for the moment
[booh] / lib / booh / html-merges.rb
1 #
2 #                         *  BOOH  *
3 #
4 # A.k.a `Best web-album Of the world, Or your money back, Humerus'.
5 #
6 # The acronyn sucks, however this is a tribute to Dragon Ball by
7 # Akira Toriyama, where the last enemy beaten by heroes of Dragon
8 # Ball is named "Boo". But there was already a free software project
9 # called Boo, so this one will be it "Booh". Or whatever.
10 #
11 #
12 # Copyright (c) 2004 Guillaume Cottenceau <gc3 at bluewin.ch>
13 #
14 # This software may be freely redistributed under the terms of the GNU
15 # public license version 2.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 # holds static data to merge in the html "themes"
22
23 require 'gettext'
24 bindtextdomain("booh")
25
26 require 'booh/booh-lib'
27 require 'booh/version.rb'
28 include Booh
29
30 $image_head_code = '<meta name="generator" content="Booh-' + $VERSION + <<'EOF'
31  http://booh.org/"/>
32
33 <script language="JavaScript1.1" type="text/JavaScript">
34 images = new Array(~~images~~);
35 ~~other_images~~
36 thumbnailspages = new Array(~~thumbnailspages~~);
37 other_sizes = new Array(~~other_sizes~~);
38 captions = new Array(~~captions~~);
39
40 dbltilda_current_size = '~~current_size~~';
41 dbltilda_theme = '~~theme~~';
42 dbltilda_stop_slideshow = '~~stop_slideshow~~';
43 dbltilda_run_slideshow = '~~run_slideshow~~';
44 dbltilda_htmlsuffix = '~~htmlsuffix~~';
45 </script>
46 EOF
47
48 $image_head_code.sub!('~~run_slideshow~~', defer_translation(N_('Run slideshow!')))
49 $image_head_code.sub!('~~stop_slideshow~~', defer_translation(N_('Stop slideshow')))
50
51 $body_additions = <<'EOF'
52 onload="init()" id="body"
53 EOF
54
55 $button_first = '
56     <form action="fake"><input type="button"
57                  onclick="first()"
58                  value="' + defer_translation(N_('<<- First')) + '"
59                  id="b_first"/></form>'
60
61 $button_previous = '
62     <form action="fake"><input type="button"
63                  onclick="previous()"
64                  value="' + defer_translation(N_('<- Previous')) + '"
65                  id="b_previous"/></form>'
66
67 $button_next = '
68     <form action="fake"><input type="button"
69                  onclick="next()"
70                  value="' + defer_translation(N_('Next ->')) + '"
71                  id="b_next"/></form>'
72
73 $button_last = '
74     <form action="fake"><input type="button"
75                  onclick="last()"
76                  value="' + defer_translation(N_('Last ->>')) + '"
77                  id="b_last"/></form>'
78
79 $button_slideshow = '
80     <input type="button"
81            onclick="toggle_slideshow(true)"
82            value="' + defer_translation(N_('Run slideshow!')) + '"
83            id="b_slideshow"/>'
84
85 $pause_slideshow = '
86     <font size="-2">' + defer_translation(N_('pause:')) + '<input type="text" id="secs" size="1" value="3"/>' + defer_translation(N_('secs')) + '</font>'
87
88
89 $image = <<'EOF'
90   <img name="main_img" src="fake" alt="main image"/>
91 EOF
92
93 $image_counter_additions = <<'EOF'
94   id="image_counter"
95 EOF
96
97 $caption_additions = <<'EOF'
98   id="main_text"
99 EOF
100
101 $body_code = <<'EOF'
102 EOF
103
104
105 $thumbnails_head_code = '<meta name="generator" content="Booh-' + $VERSION + <<'EOF'
106  http://booh.org/"/>
107
108 <script language="JavaScript1.1" type="text/JavaScript">
109 function set_preferred_size(val) {
110     var expires = new Date(new Date().getTime() + (30 * 86400000));  // 30 days
111     document.cookie = 'booh-preferred-size-~~theme~~='
112                       + val
113                       + '; expires=' + expires.toGMTString()
114                       + '; path=/';
115 }
116 </script>
117 EOF
118
119
120 $preferred_size_reloader = <<'EOF'
121 <html>
122     <body>
123     </body>
124         <script language="JavaScript1.1" type="text/JavaScript">
125
126 var sizes = new Array(~~all_sizes~~);
127
128 function getPreferredSize() {
129     if (document.cookie) {
130         var index = document.cookie.indexOf('booh-preferred-size-~~theme~~');
131         if (index != -1) {
132             var oleft = document.cookie.indexOf('=', index) + 1;
133             var oright = document.cookie.indexOf(';', index);
134             if (oright == -1) {
135                 oright = document.cookie.length;
136             }
137             size = document.cookie.substring(oleft, oright);
138             for (i = 0; i < sizes.length; i++) {
139                 if (sizes[i] == size) {
140                     return 'thumbnails-' + size + '-0~~htmlsuffix~~';
141                 }
142             }
143         }
144     }
145     w = document.body.offsetWidth;
146     ~~size_auto_chooser~~
147     return 'thumbnails-~~default_size~~-0~~htmlsuffix~~';
148 }
149
150 window.location.href = getPreferredSize();
151
152         </script>
153
154         <meta http-equiv="refresh" content="0.1;url=thumbnails-~~default_size~~-nojs-0~~htmlsuffix~~">
155 </html>
156 EOF
157
158
159 $index_head_code = '<meta name="generator" content="Booh-' + $VERSION + ' http://booh.org/"/>
160 <script language="JavaScript1.1" type="text/JavaScript">
161 function init() {
162     if (!document.cookie || document.cookie.indexOf("booh-not-a-newbie") == -1) {
163         document.getElementById("title").innerHTML += "<br/><br/>' + defer_translation(N_("<i>Hint: you can click on the images to open the albums!</i>")) + '";
164     }
165     var expires = new Date(new Date().getTime() + (10 * 86400000));  // 10 days
166     document.cookie = "booh-not-a-newbie=true"
167                       + "; expires=" + expires.toGMTString()
168                       + "; path=/";
169 }
170 </script>'