correctly handle newlines in captions
authorgc <gc>
Thu, 19 May 2005 19:02:58 +0000 (19:02 +0000)
committergc <gc>
Thu, 19 May 2005 19:02:58 +0000 (19:02 +0000)
bin/booh-backend
lib/booh/html-merges.rb

index a5e1a08ae962b46f4941ac3e0ca88f8559afcbf9..49226d3c5c00466295a2a35bd7d6267ad5c8178f 100755 (executable)
@@ -281,7 +281,11 @@ def build_html_skeletons
 end
 
 def find_caption_value(xmldir, filename)
-    xmldir.elements["[@filename='#{utf8(filename)}']"].attributes['caption']
+    if cap = xmldir.elements["[@filename='#{utf8(filename)}']"].attributes['caption']
+        return cap.gsub("\n", '<br/>')
+    else
+        return nil
+    end
 end
 
 def find_captions(xmldir, images)
@@ -713,7 +717,7 @@ def walk_source_dir
 
             #- generate image.html (page with fullscreen images)
             if images.size > 0
-                captions4js = find_captions(xmldir, images).collect { |e| e ? '"' + e.gsub('"', '\"' ) + '"' : '""' }.join(', ')
+                captions4js = find_captions(xmldir, images).collect { |e| e ? '"' + e.gsub('"', '\"') + '"' : '""' }.join(', ')
 
                 for sizeobj in $images_size
                     html = $html_images.collect { |l| l.clone }
index e037b9bf970d127dc136f8718dfd9b6470760446..fb81bff2981c9e647e794d87cc41812757619ba7 100644 (file)
@@ -49,7 +49,7 @@ for (i = 0; i < images.length; i++) {
 }
 
 function dbg(t) {
-    document.getElementById('dbg_text').firstChild.data += t + "\n";
+    document.getElementById('dbg_text').innerHTML += t + "\n";
 }
 
 /* load image, return 1 if image is finished loading */
@@ -198,8 +198,8 @@ function show_current_text() {
     /* don't show text if image not yet loaded because navigator
      * won't refresh it during load */
     if (images_loaded[current] == 2) {
-        document.getElementById('image_counter').firstChild.data = ( current + 1 ) + "/" + images.length;
-        document.getElementById('main_text').firstChild.data = captions[current] || images[current];
+        document.getElementById('image_counter').innerHTML = ( current + 1 ) + "/" + images.length;
+        document.getElementById('main_text').innerHTML = captions[current] || images[current];
         for (i = 0; i < other_sizes.length; i++) { 
             if (other_sizes[i] == "original") {
                 document.getElementById('link' + other_sizes[i]).href = eval("images_" + other_sizes[i] + "[current]");