3 # A.k.a `Best web-album Of the world, Or your money back, Humerus'.
5 # The acronyn sucks, however this is a tribute to Dragon Ball by
6 # Akira Toriyama, where the last enemy beaten by heroes of Dragon
7 # Ball is named "Boo". But there was already a free software project
8 # called Boo, so this one will be it "Booh". Or whatever.
11 # Copyright (c) 2004 Guillaume Cottenceau <gc3 at bluewin.ch>
13 # This software may be freely redistributed under the terms of the GNU
14 # public license version 2.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 require 'rexml/document'
27 bindtextdomain("booh")
29 require 'booh/config.rb'
30 require 'booh/version.rb'
37 require 'booh/libadds'
44 $CURRENT_CHARSET = `locale charmap`.chomp
45 $convert = 'convert -interlace line +profile "*"'
46 $convert_enhance = '-contrast -enhance -normalize'
49 return Iconv::iconv("UTF-8", $CURRENT_CHARSET, string).to_s
52 def utf8cut(string, maxlen)
54 return Iconv::iconv("UTF-8", $CURRENT_CHARSET, string[0..maxlen-1]).to_s
55 rescue Iconv::InvalidCharacter
56 return utf8cut(string, maxlen-1)
61 #- fake for gettext to find these; if themes need more sizes, english name for them should be added here
62 sizenames = { 'small' => utf8(_("small")), 'medium' => utf8(_("medium")), 'large' => utf8(_("large")),
63 'x-large' => utf8(_("x-large")), 'xx-large' => utf8(_("xx-large")),
64 'original' => utf8(_("original")) }
65 return sizenames[key] || key
69 return Iconv::iconv($CURRENT_CHARSET, "UTF-8", string).to_s
72 def from_utf8_safe(string)
74 return Iconv::iconv($CURRENT_CHARSET, "UTF-8", string).to_s
75 rescue Iconv::IllegalSequence
80 def make_dest_filename_old(orig_filename)
81 #- we remove non alphanumeric characters but need to do that
82 #- cleverly to not end up with two similar dest filenames. we won't
83 #- urlencode because urldecode might happen in the browser.
84 return orig_filename.unpack("C*").collect { |v| v.chr =~ /[a-zA-Z\-_0-9\.\/]/ ? v.chr : sprintf("%2X", v) }.to_s
87 def make_dest_filename(orig_filename)
88 #- we remove non alphanumeric characters but need to do that
89 #- cleverly to not end up with two similar dest filenames. we won't
90 #- urlencode because urldecode might happen in the browser.
91 return orig_filename.unpack("C*").collect { |v| v.chr =~ /[a-zA-Z\-_0-9\.\/]/ ? v.chr : sprintf("~%02X", v) }.to_s
94 def msg(verbose_level, msg)
95 if verbose_level <= $verbose_level
97 warn _("\t***ERROR***: %s\n") % msg
98 elsif verbose_level == 1
99 warn _("\tWarning: %s\n") % msg
106 def msg_(verbose_level, msg)
107 if verbose_level <= $verbose_level
108 if verbose_level == 0
109 warn _("\t***ERROR***: %s") % msg
110 elsif verbose_level == 1
111 warn _("\tWarning: %s") % msg
123 def select_theme(name, limit_sizes, optimizefor32, nperrow)
125 msg 3, _("Selecting theme '%s'") % $theme
126 themedir = "#{$FPATH}/themes/#{$theme}"
127 if !File.directory?(themedir)
128 die _("Theme was not found (tried %s directory).") % themedir
130 eval File.open("#{themedir}/metadata/parameters.rb").readlines.join
133 if limit_sizes != 'all'
134 sizes = limit_sizes.split(/,/)
135 $images_size = $images_size.find_all { |e| sizes.include?(e['name']) }
136 if $images_size.length == 0
137 die _("Can't carry on, no valid size selected.")
141 $images_size = $images_size.find_all { |e| !e['optional'] }
145 $images_size.each { |e|
146 e['fullscreen'].gsub!(/(\d+x)(\d+)/) { $1 + ($2.to_f*8/9).to_i.to_s }
147 e['thumbnails'].gsub!(/(\d+x)(\d+)/) { $1 + ($2.to_f*8/9).to_i.to_s }
149 $albums_thumbnail_size.gsub!(/(\d+x)(\d+)/) { $1 + ($2.to_f*8/9).to_i.to_s }
152 if nperrow && nperrow != $default_N
153 ratio = nperrow.to_f / $default_N.to_f
154 $images_size.each { |e|
155 e['thumbnails'].gsub!(/(\d+)x(\d+)/) { ($1.to_f/ratio).to_i.to_s + 'x' + ($2.to_f/ratio).to_i.to_s }
159 $default_size = $images_size.detect { |sizeobj| sizeobj['default'] }
160 if $default_size == nil
161 $default_size = $images_size[0]
165 def entry2type(entry)
166 if entry =~ /\.(jpg|jpeg|jpe|gif|bmp|png)$/i && entry !~ /['"\[\]]/
168 elsif !$ignore_videos && entry =~ /\.(mov|avi|mpg|mpeg|mpe|wmv|asx|3gp|mp4)$/i && entry !~ /['"\[\]]/
169 #- might consider using file magic later..
182 finished = Process.wait2
183 $pids.delete(finished[0])
184 $pids = $pids.find_all { |pid| Process.waitpid(pid, Process::WNOHANG) == nil }
188 while $pids && $pids.length > 0
193 #- parallelizable sys
203 if $pids.length == $mproc
211 #- grab the results of a command but don't sleep forever on a runaway process
212 def subproc_runaway_aware(command)
217 rescue Timeout::Error
218 msg 1, _("forgetting runaway process (transcode sucks again?)")
219 #- todo should slay transcode but dunno how to do that
224 def get_image_size(fullpath)
229 if $sizes_cache[fullpath].nil?
230 #- identify is slow, try with gdk if available (negligible vs 35ms)
232 if `identify '#{fullpath}'` =~ / JPEG (\d+)x(\d+) /
233 $sizes_cache[fullpath] = { :x => $1.to_i, :y => $2.to_i }
236 format, width, height = Gdk::Pixbuf.get_file_info(fullpath)
238 $sizes_cache[fullpath] = { :x => width, :y => height }
242 return $sizes_cache[fullpath]
248 #- commify from http://pleac.sourceforge.net/ (pleac rulz)
250 n.to_s =~ /([^\.]*)(\..*)?/
251 int, dec = $1.reverse, $2 ? $2 : ""
252 while int.gsub!(/(,|\.|^)(\d{3})(\d)/, '\1\2' + _(",") + '\3')
257 def guess_rotate(filename)
258 #- identify is slow, try with libexif if available (4ms vs 35ms)
263 orientation = `identify -format "%[EXIF:orientation]" '#{filename}'`.chomp.to_i
265 orientation = Exif.orientation(filename)
270 elsif orientation == 8
276 #- remove rotate if image is obviously already in portrait (situation can come from gthumb)
277 size = get_image_size(filename)
278 if size && size[:x] < size[:y]
285 def rotate_pixbuf(pixbuf, angle)
286 return pixbuf.rotate(angle == 90 ? Gdk::Pixbuf::ROTATE_CLOCKWISE :
287 angle == 180 ? Gdk::Pixbuf::ROTATE_UPSIDEDOWN :
288 (angle == 270 || angle == -90) ? Gdk::Pixbuf::ROTATE_COUNTERCLOCKWISE :
289 Gdk::Pixbuf::ROTATE_NONE)
292 def gen_thumbnails_element(orig, xmldirorelem, allow_background, dests)
293 if xmldirorelem.name == 'dir'
294 xmldirorelem = xmldirorelem.elements["*[@filename='#{utf8(File.basename(orig))}']"]
296 gen_thumbnails(orig, allow_background, dests, xmldirorelem, '')
299 def gen_thumbnails_subdir(orig, xmldirorelem, allow_background, dests, type)
300 #- type can be `subdirs' or `thumbnails'
301 gen_thumbnails(orig, allow_background, dests, xmldirorelem, type + '-')
304 def gen_video_thumbnail(orig, dest_dir, orig_base, colorswap, frame_offset)
305 transcode_options = ''
307 transcode_options += '-k '
309 cmd = "mencoder '#{orig}' -nosound -ovc lavc -lavcopts vcodec=mjpeg -o '#{dest_dir}/#{orig_base}.avi' -frames #{frame_offset+26} -fps 25 >/dev/null 2>/dev/null"
312 if File.exists?("#{dest_dir}/#{orig_base}.avi")
313 cmd = "transcode -a 0 -c #{frame_offset}-#{frame_offset+1} -i '#{dest_dir}/#{orig_base}.avi' -y jpg -o '#{dest_dir}/#{orig_base}.jpg' #{transcode_options} 2>&1"
315 results = subproc_runaway_aware(cmd)
316 File.delete(File.join(dest_dir, "#{orig_base}.avi"))
317 if results =~ /skipping frames/ && results =~ /encoded 0 frames/
318 msg 0, _("specified frame-offset too large? max frame was: %s. that may also be another probleme. try another value.") % results.scan(/skipping frames \[000000-(\d+)\]/)[-1]
320 elsif results =~ /V: import format.*unknown/ || !File.exists?("#{dest_dir}/#{orig_base}.jpg000000.jpg")
321 msg 0, _("could not extract first image of video %s encoded by mencoder") % "#{dest_dir}/#{orig_base}.avi"
325 msg 0, _("could not make mencoder to encode %s to mjpeg") % orig
331 def gen_thumbnails(orig, allow_background, dests, felem, attributes_prefix)
332 if !dests.detect { |dest| !File.exists?(dest['filename']) }
337 dest_dir = make_dest_filename(File.dirname(dests[0]['filename']))
339 if entry2type(orig) == 'image'
341 if whitebalance = felem.attributes["#{attributes_prefix}white-balance"]
342 neworig = "#{dest_dir}/#{File.basename(orig)}-whitebalance#{whitebalance}.jpg"
343 cmd = "booh-fix-whitebalance '#{orig}' '#{neworig}' #{whitebalance}"
345 if File.exists?(neworig)
349 if gammacorrect = felem.attributes["#{attributes_prefix}gamma-correction"]
350 neworig = "#{dest_dir}/#{File.basename(orig)}-gammacorrect#{gammacorrect}.jpg"
351 cmd = "booh-gamma-correction '#{orig}' '#{neworig}' #{gammacorrect}"
353 if File.exists?(neworig)
357 rotate = felem.attributes["#{attributes_prefix}rotate"]
359 felem.add_attribute("#{attributes_prefix}rotate", rotate = guess_rotate(orig).to_s)
361 convert_options += "-rotate #{rotate} "
362 if felem.attributes["#{attributes_prefix}enhance"]
363 convert_options += ($config['convert-enhance'] || $convert_enhance) + " "
367 if !File.exists?(dest['filename'])
369 cmd ||= "#{$convert} #{convert_options}-size #{dest['size']} -resize '#{dest['size']}>' '#{orig}' '#{dest['filename']}'"
385 elsif entry2type(orig) == 'video'
387 #- frame-offset is an attribute that allows to specify which frame to use for the thumbnail
388 frame_offset = felem.attributes["#{attributes_prefix}frame-offset"]
390 felem.add_attribute("#{attributes_prefix}frame-offset", frame_offset = "0")
392 frame_offset = frame_offset.to_i
393 if rotate = felem.attributes["#{attributes_prefix}rotate"]
394 convert_options += "-rotate #{rotate} "
396 if felem.attributes["#{attributes_prefix}enhance"]
397 convert_options += ($config['convert-enhance'] || $convert_enhance) + " "
400 orig_base = File.basename(dests[0]['filename']) + File.basename(orig)
401 orig_image = "#{dest_dir}/#{orig_base}.jpg000000.jpg"
402 File.delete(orig_image)
404 if ! File.exists?(orig_image)
405 if ! gen_video_thumbnail(orig, dest_dir, orig_base, felem && felem.attributes["#{attributes_prefix}color-swap"], frame_offset)
408 if felem && whitebalance = felem.attributes["#{attributes_prefix}white-balance"]
409 if whitebalance.to_f != 0
410 neworig = "#{dest_dir}/#{orig_base}-whitebalance#{whitebalance}.jpg"
411 cmd = "booh-fix-whitebalance '#{orig_image}' '#{neworig}' #{whitebalance}"
413 if File.exists?(neworig)
418 if felem && gammacorrect = felem.attributes["#{attributes_prefix}gamma-correction"]
419 if gammacorrect.to_f != 0
420 neworig = "#{dest_dir}/#{orig_base}-gammacorrect#{gammacorrect}.jpg"
421 cmd = "booh-gamma-correction '#{orig_image}' '#{neworig}' #{gammacorrect}"
423 if File.exists?(neworig)
429 if !File.exists?(dest['filename'])
430 sys("#{$convert} #{convert_options}-size #{dest['size']} -resize #{dest['size']} '#{orig_image}' '#{dest['filename']}'")
440 def invornil(obj, methodname)
444 return obj.method(methodname).call
448 def find_subalbum_info_type(xmldir)
449 #- first look for subdirs info; if not, means there is no subdir
450 if xmldir.attributes['subdirs-caption']
457 def find_subalbum_caption_info(xmldir)
458 type = find_subalbum_info_type(xmldir)
459 return [ from_utf8(xmldir.attributes["#{type}-captionfile"]), xmldir.attributes["#{type}-caption"] ]
464 return File.size(path)
475 n < a ? a : n > b ? b : n
478 def pano_amount(elem)
479 if pano_amount = elem.attributes['pano-amount']
481 return clamp(pano_amount.to_f, 1, $N_per_row.to_i)
483 return clamp(pano_amount.to_f, 1, $default_N.to_i)
490 def substInFile(name)
491 newcontent = IO.readlines(name).collect { |l| yield l }
492 ios = File.open(name, "w")
493 ios.write(newcontent)
498 cmd = $config['browser'].gsub('%f', "'#{url}'") + ' &'
505 GNU GENERAL PUBLIC LICENSE
508 Copyright (C) 1989, 1991 Free Software Foundation, Inc.
509 675 Mass Ave, Cambridge, MA 02139, USA
510 Everyone is permitted to copy and distribute verbatim copies
511 of this license document, but changing it is not allowed.
515 The licenses for most software are designed to take away your
516 freedom to share and change it. By contrast, the GNU General Public
517 License is intended to guarantee your freedom to share and change free
518 software--to make sure the software is free for all its users. This
519 General Public License applies to most of the Free Software
520 Foundation's software and to any other program whose authors commit to
521 using it. (Some other Free Software Foundation software is covered by
522 the GNU Library General Public License instead.) You can apply it to
525 When we speak of free software, we are referring to freedom, not
526 price. Our General Public Licenses are designed to make sure that you
527 have the freedom to distribute copies of free software (and charge for
528 this service if you wish), that you receive source code or can get it
529 if you want it, that you can change the software or use pieces of it
530 in new free programs; and that you know you can do these things.
532 To protect your rights, we need to make restrictions that forbid
533 anyone to deny you these rights or to ask you to surrender the rights.
534 These restrictions translate to certain responsibilities for you if you
535 distribute copies of the software, or if you modify it.
537 For example, if you distribute copies of such a program, whether
538 gratis or for a fee, you must give the recipients all the rights that
539 you have. You must make sure that they, too, receive or can get the
540 source code. And you must show them these terms so they know their
543 We protect your rights with two steps: (1) copyright the software, and
544 (2) offer you this license which gives you legal permission to copy,
545 distribute and/or modify the software.
547 Also, for each author's protection and ours, we want to make certain
548 that everyone understands that there is no warranty for this free
549 software. If the software is modified by someone else and passed on, we
550 want its recipients to know that what they have is not the original, so
551 that any problems introduced by others will not reflect on the original
552 authors' reputations.
554 Finally, any free program is threatened constantly by software
555 patents. We wish to avoid the danger that redistributors of a free
556 program will individually obtain patent licenses, in effect making the
557 program proprietary. To prevent this, we have made it clear that any
558 patent must be licensed for everyone's free use or not licensed at all.
560 The precise terms and conditions for copying, distribution and
564 GNU GENERAL PUBLIC LICENSE
565 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
567 0. This License applies to any program or other work which contains
568 a notice placed by the copyright holder saying it may be distributed
569 under the terms of this General Public License. The "Program", below,
570 refers to any such program or work, and a "work based on the Program"
571 means either the Program or any derivative work under copyright law:
572 that is to say, a work containing the Program or a portion of it,
573 either verbatim or with modifications and/or translated into another
574 language. (Hereinafter, translation is included without limitation in
575 the term "modification".) Each licensee is addressed as "you".
577 Activities other than copying, distribution and modification are not
578 covered by this License; they are outside its scope. The act of
579 running the Program is not restricted, and the output from the Program
580 is covered only if its contents constitute a work based on the
581 Program (independent of having been made by running the Program).
582 Whether that is true depends on what the Program does.
584 1. You may copy and distribute verbatim copies of the Program's
585 source code as you receive it, in any medium, provided that you
586 conspicuously and appropriately publish on each copy an appropriate
587 copyright notice and disclaimer of warranty; keep intact all the
588 notices that refer to this License and to the absence of any warranty;
589 and give any other recipients of the Program a copy of this License
590 along with the Program.
592 You may charge a fee for the physical act of transferring a copy, and
593 you may at your option offer warranty protection in exchange for a fee.
595 2. You may modify your copy or copies of the Program or any portion
596 of it, thus forming a work based on the Program, and copy and
597 distribute such modifications or work under the terms of Section 1
598 above, provided that you also meet all of these conditions:
600 a) You must cause the modified files to carry prominent notices
601 stating that you changed the files and the date of any change.
603 b) You must cause any work that you distribute or publish, that in
604 whole or in part contains or is derived from the Program or any
605 part thereof, to be licensed as a whole at no charge to all third
606 parties under the terms of this License.
608 c) If the modified program normally reads commands interactively
609 when run, you must cause it, when started running for such
610 interactive use in the most ordinary way, to print or display an
611 announcement including an appropriate copyright notice and a
612 notice that there is no warranty (or else, saying that you provide
613 a warranty) and that users may redistribute the program under
614 these conditions, and telling the user how to view a copy of this
615 License. (Exception: if the Program itself is interactive but
616 does not normally print such an announcement, your work based on
617 the Program is not required to print an announcement.)
620 These requirements apply to the modified work as a whole. If
621 identifiable sections of that work are not derived from the Program,
622 and can be reasonably considered independent and separate works in
623 themselves, then this License, and its terms, do not apply to those
624 sections when you distribute them as separate works. But when you
625 distribute the same sections as part of a whole which is a work based
626 on the Program, the distribution of the whole must be on the terms of
627 this License, whose permissions for other licensees extend to the
628 entire whole, and thus to each and every part regardless of who wrote it.
630 Thus, it is not the intent of this section to claim rights or contest
631 your rights to work written entirely by you; rather, the intent is to
632 exercise the right to control the distribution of derivative or
633 collective works based on the Program.
635 In addition, mere aggregation of another work not based on the Program
636 with the Program (or with a work based on the Program) on a volume of
637 a storage or distribution medium does not bring the other work under
638 the scope of this License.
640 3. You may copy and distribute the Program (or a work based on it,
641 under Section 2) in object code or executable form under the terms of
642 Sections 1 and 2 above provided that you also do one of the following:
644 a) Accompany it with the complete corresponding machine-readable
645 source code, which must be distributed under the terms of Sections
646 1 and 2 above on a medium customarily used for software interchange; or,
648 b) Accompany it with a written offer, valid for at least three
649 years, to give any third party, for a charge no more than your
650 cost of physically performing source distribution, a complete
651 machine-readable copy of the corresponding source code, to be
652 distributed under the terms of Sections 1 and 2 above on a medium
653 customarily used for software interchange; or,
655 c) Accompany it with the information you received as to the offer
656 to distribute corresponding source code. (This alternative is
657 allowed only for noncommercial distribution and only if you
658 received the program in object code or executable form with such
659 an offer, in accord with Subsection b above.)
661 The source code for a work means the preferred form of the work for
662 making modifications to it. For an executable work, complete source
663 code means all the source code for all modules it contains, plus any
664 associated interface definition files, plus the scripts used to
665 control compilation and installation of the executable. However, as a
666 special exception, the source code distributed need not include
667 anything that is normally distributed (in either source or binary
668 form) with the major components (compiler, kernel, and so on) of the
669 operating system on which the executable runs, unless that component
670 itself accompanies the executable.
672 If distribution of executable or object code is made by offering
673 access to copy from a designated place, then offering equivalent
674 access to copy the source code from the same place counts as
675 distribution of the source code, even though third parties are not
676 compelled to copy the source along with the object code.
679 4. You may not copy, modify, sublicense, or distribute the Program
680 except as expressly provided under this License. Any attempt
681 otherwise to copy, modify, sublicense or distribute the Program is
682 void, and will automatically terminate your rights under this License.
683 However, parties who have received copies, or rights, from you under
684 this License will not have their licenses terminated so long as such
685 parties remain in full compliance.
687 5. You are not required to accept this License, since you have not
688 signed it. However, nothing else grants you permission to modify or
689 distribute the Program or its derivative works. These actions are
690 prohibited by law if you do not accept this License. Therefore, by
691 modifying or distributing the Program (or any work based on the
692 Program), you indicate your acceptance of this License to do so, and
693 all its terms and conditions for copying, distributing or modifying
694 the Program or works based on it.
696 6. Each time you redistribute the Program (or any work based on the
697 Program), the recipient automatically receives a license from the
698 original licensor to copy, distribute or modify the Program subject to
699 these terms and conditions. You may not impose any further
700 restrictions on the recipients' exercise of the rights granted herein.
701 You are not responsible for enforcing compliance by third parties to
704 7. If, as a consequence of a court judgment or allegation of patent
705 infringement or for any other reason (not limited to patent issues),
706 conditions are imposed on you (whether by court order, agreement or
707 otherwise) that contradict the conditions of this License, they do not
708 excuse you from the conditions of this License. If you cannot
709 distribute so as to satisfy simultaneously your obligations under this
710 License and any other pertinent obligations, then as a consequence you
711 may not distribute the Program at all. For example, if a patent
712 license would not permit royalty-free redistribution of the Program by
713 all those who receive copies directly or indirectly through you, then
714 the only way you could satisfy both it and this License would be to
715 refrain entirely from distribution of the Program.
717 If any portion of this section is held invalid or unenforceable under
718 any particular circumstance, the balance of the section is intended to
719 apply and the section as a whole is intended to apply in other
722 It is not the purpose of this section to induce you to infringe any
723 patents or other property right claims or to contest validity of any
724 such claims; this section has the sole purpose of protecting the
725 integrity of the free software distribution system, which is
726 implemented by public license practices. Many people have made
727 generous contributions to the wide range of software distributed
728 through that system in reliance on consistent application of that
729 system; it is up to the author/donor to decide if he or she is willing
730 to distribute software through any other system and a licensee cannot
733 This section is intended to make thoroughly clear what is believed to
734 be a consequence of the rest of this License.
737 8. If the distribution and/or use of the Program is restricted in
738 certain countries either by patents or by copyrighted interfaces, the
739 original copyright holder who places the Program under this License
740 may add an explicit geographical distribution limitation excluding
741 those countries, so that distribution is permitted only in or among
742 countries not thus excluded. In such case, this License incorporates
743 the limitation as if written in the body of this License.
745 9. The Free Software Foundation may publish revised and/or new versions
746 of the General Public License from time to time. Such new versions will
747 be similar in spirit to the present version, but may differ in detail to
748 address new problems or concerns.
750 Each version is given a distinguishing version number. If the Program
751 specifies a version number of this License which applies to it and "any
752 later version", you have the option of following the terms and conditions
753 either of that version or of any later version published by the Free
754 Software Foundation. If the Program does not specify a version number of
755 this License, you may choose any version ever published by the Free Software
758 10. If you wish to incorporate parts of the Program into other free
759 programs whose distribution conditions are different, write to the author
760 to ask for permission. For software which is copyrighted by the Free
761 Software Foundation, write to the Free Software Foundation; we sometimes
762 make exceptions for this. Our decision will be guided by the two goals
763 of preserving the free status of all derivatives of our free software and
764 of promoting the sharing and reuse of software generally.
768 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
769 FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
770 OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
771 PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
772 OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
773 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
774 TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
775 PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
776 REPAIR OR CORRECTION.
778 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
779 WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
780 REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
781 INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
782 OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
783 TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
784 YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
785 PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
786 POSSIBILITY OF SUCH DAMAGES.
791 Gtk::AboutDialog.set_url_hook { |dialog, url| open_url(url) }
792 Gtk::AboutDialog.show($main_window, { :name => 'booh',
793 :version => $VERSION,
794 :copyright => 'Copyright (c) 2005-2007 Guillaume Cottenceau',
795 :license => get_license,
796 :website => 'http://booh.org/',
797 :authors => [ 'Guillaume Cottenceau' ],
798 :artists => [ 'Ayo73' ],
799 :comments => utf8(_("''The Web-Album of choice for discriminating Linux users''")),
800 :translator_credits => utf8(_('Esperanto: Stephane Fillod
801 Japanese: Masao Mutoh
802 German: Roland Eckert
803 French: Guillaume Cottenceau')),
804 :logo => Gdk::Pixbuf.new("#{$FPATH}/images/logo.png") })
810 def File.reduce_path(path)
811 return path.gsub(/\w+\/\.\.\//, '')
816 def collect_with_index
818 each_with_index { |e,i|
828 each { |v| retval += v.to_i }
834 def previous_element_byname(name)
836 while n = n.previous_element
844 def previous_element_byname_notattr(name, attr)
846 while n = n.previous_element
847 if n.name == name && !n.attributes[attr]
854 def next_element_byname(name)
856 while n = n.next_element
864 def next_element_byname_notattr(name, attr)
866 while n = n.next_element
867 if n.name == name && !n.attributes[attr]
874 def child_byname_notattr(name, attr)
875 elements.each(name) { |element|
876 if !element.attributes[attr]