mizuho-0.9.20/0000755000004100000410000000000012261241511013140 5ustar www-datawww-datamizuho-0.9.20/Rakefile0000644000004100000410000004054212261241511014612 0ustar www-datawww-data$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/lib")) require 'mizuho' PACKAGE_NAME = "mizuho" PACKAGE_VERSION = Mizuho::VERSION_STRING PACKAGE_SIGNING_KEY = "0x0A212A8C" MAINTAINER_NAME = "Hongli Lai" MAINTAINER_EMAIL = "hongli@phusion.nl" desc "Run unit tests" task :test do ruby "-Ilib -S rspec -f s -c test/*_spec.rb" end desc "Build, sign & upload gem" task 'package:release' do sh "git tag -s release-#{PACKAGE_VERSION}" sh "gem build #{PACKAGE_NAME}.gemspec --sign --key #{PACKAGE_SIGNING_KEY}" puts "Proceed with pushing tag to Github and uploading the gem? [y/n]" if STDIN.readline == "y\n" sh "git push origin release-#{PACKAGE_VERSION}" sh "gem push #{PACKAGE_NAME}-#{PACKAGE_VERSION}.gem" else puts "Did not upload the gem." end end ##### Utilities ##### def string_option(name, default_value = nil) value = ENV[name] if value.nil? || value.empty? return default_value else return value end end def boolean_option(name, default_value = false) value = ENV[name] if value.nil? || value.empty? return default_value else return value == "yes" || value == "on" || value == "true" || value == "1" end end ##### Debian packaging support ##### PKG_DIR = string_option('PKG_DIR', "pkg") DEBIAN_NAME = PACKAGE_NAME DEBIAN_PACKAGE_REVISION = 1 ALL_DISTRIBUTIONS = string_option('DEBIAN_DISTROS', 'saucy precise lucid').split(/[ ,]/) ORIG_TARBALL_FILES = lambda do require 'mizuho/packaging' Dir[*MIZUHO_FILES] - Dir[*MIZUHO_DEBIAN_EXCLUDE_FILES] end # Implements a simple preprocessor language which combines elements in the C # preprocessor with ERB: # # Today # #if @today == :fine # is a fine day. # #elif @today == :good # is a good day. # #else # is a sad day. # #endif # Let's go walking. # Today is <%= Time.now %>. # # When run with... # # Preprocessor.new.start('input.txt', 'output.txt', :today => :fine) # # ...will produce: # # Today # is a fine day. # Let's go walking. # Today is 2013-08-11 22:37:06 +0200. # # Highlights: # # * #if blocks can be nested. # * Expressions are Ruby expressions, evaluated within the binding of a # Preprocessor::Evaluator object. # * Text inside #if/#elif/#else are automatically unindented. # * ERB compatible. class Preprocessor def initialize require 'erb' if !defined?(ERB) @indentation_size = 4 @debug = boolean_option('DEBUG') end def start(filename, output_filename, variables = {}) if output_filename temp_output_filename = "#{output_filename}._new" output = File.open(temp_output_filename, 'w') else output = STDOUT end the_binding = create_binding(variables) context = [] @filename = filename @lineno = 1 @indentation = 0 each_line(filename, the_binding) do |line| debug("context=#{context.inspect}, line=#{line.inspect}") name, args_string, cmd_indentation = recognize_command(line) case name when "if" case context.last when nil, :if_true, :else_true check_indentation(cmd_indentation) result = the_binding.eval(args_string, filename, @lineno) context.push(result ? :if_true : :if_false) inc_indentation when :if_false, :else_false, :if_ignore check_indentation(cmd_indentation) inc_indentation context.push(:if_ignore) else terminate "#if is not allowed in this context" end when "elif" case context.last when :if_true dec_indentation check_indentation(cmd_indentation) inc_indentation context[-1] = :if_false when :if_false dec_indentation check_indentation(cmd_indentation) inc_indentation result = the_binding.eval(args_string, filename, @lineno) context[-1] = result ? :if_true : :if_false when :else_true, :else_false terminate "#elif is not allowed after #else" when :if_ignore dec_indentation check_indentation(cmd_indentation) inc_indentation else terminate "#elif is not allowed outside #if block" end when "else" case context.last when :if_true dec_indentation check_indentation(cmd_indentation) inc_indentation context[-1] = :else_false when :if_false dec_indentation check_indentation(cmd_indentation) inc_indentation context[-1] = :else_true when :else_true, :else_false terminate "it is not allowed to have multiple #else clauses in one #if block" when :if_ignore dec_indentation check_indentation(cmd_indentation) inc_indentation else terminate "#else is not allowed outside #if block" end when "endif" case context.last when :if_true, :if_false, :else_true, :else_false, :if_ignore dec_indentation check_indentation(cmd_indentation) context.pop else terminate "#endif is not allowed outside #if block" end when "DEBHELPER" output.puts(line) when "", nil # Either a comment or not a preprocessor command. case context.last when nil, :if_true, :else_true output.puts(unindent(line)) else # Check indentation but do not output. unindent(line) end else terminate "Unrecognized preprocessor command ##{name.inspect}" end @lineno += 1 end ensure if output_filename && output output.close stat = File.stat(filename) File.chmod(stat.mode, temp_output_filename) File.chown(stat.uid, stat.gid, temp_output_filename) rescue nil File.rename(temp_output_filename, output_filename) end end private UBUNTU_DISTRIBUTIONS = { "lucid" => "10.04", "maverick" => "10.10", "natty" => "11.04", "oneiric" => "11.10", "precise" => "12.04", "quantal" => "12.10", "raring" => "13.04", "saucy" => "13.10", "trusty" => "14.04" } DEBIAN_DISTRIBUTIONS = { "squeeze" => "20110206", "wheezy" => "20130504" } REDHAT_ENTERPRISE_DISTRIBUTIONS = { "el6" => "el6.0" } AMAZON_DISTRIBUTIONS = { "amazon" => "amazon" } # Provides the DSL that's accessible within. class Evaluator def _infer_distro_table(name) if UBUNTU_DISTRIBUTIONS.has_key?(name) return UBUNTU_DISTRIBUTIONS elsif DEBIAN_DISTRIBUTIONS.has_key?(name) return DEBIAN_DISTRIBUTIONS elsif REDHAT_ENTERPRISE_DISTRIBUTIONS.has_key?(name) return REDHAT_ENTERPRISE_DISTRIBUTIONS elsif AMAZON_DISTRIBUTIONS.has_key?(name) return AMAZON_DISTRIBUTIONS end end def is_distribution?(expr) if @distribution.nil? raise "The :distribution variable must be set" else if expr =~ /^(>=|>|<=|<|==|\!=)[\s]*(.+)/ comparator = $1 name = $2 else raise "Invalid expression #{expr.inspect}" end table1 = _infer_distro_table(@distribution) table2 = _infer_distro_table(name) raise "Distribution name #{@distribution.inspect} not recognized" if !table1 raise "Distribution name #{name.inspect} not recognized" if !table2 return false if table1 != table2 v1 = table1[@distribution] v2 = table2[name] case comparator when ">" return v1 > v2 when ">=" return v1 >= v2 when "<" return v1 < v2 when "<=" return v1 <= v2 when "==" return v1 == v2 when "!=" return v1 != v2 else raise "BUG" end end end end def each_line(filename, the_binding) data = File.open(filename, 'r') do |f| erb = ERB.new(f.read, nil, "-") erb.filename = filename erb.result(the_binding) end data.each_line do |line| yield line.chomp end end def recognize_command(line) if line =~ /^([\s\t]*)#(.+)/ indentation_str = $1 command = $2 # Declare tabs as equivalent to 4 spaces. This is necessary for # Makefiles in which the use of tabs is required. indentation_str.gsub!("\t", " ") name = command.scan(/^\w+/).first # Ignore shebangs and comments. return if name.nil? args_string = command.sub(/^#{Regexp.escape(name)}[\s\t]*/, '') return [name, args_string, indentation_str.to_s.size] else return nil end end def create_binding(variables) object = Evaluator.new variables.each_pair do |key, val| object.send(:instance_variable_set, "@#{key}", val) end return object.instance_eval do binding end end def inc_indentation @indentation += @indentation_size end def dec_indentation @indentation -= @indentation_size end def check_indentation(expected) if expected != @indentation terminate "wrong indentation: found #{expected} characters, should be #{@indentation}" end end def unindent(line) line =~ /^([\s\t]*)/ # Declare tabs as equivalent to 4 spaces. This is necessary for # Makefiles in which the use of tabs is required. found = $1.to_s.gsub("\t", " ").size if found >= @indentation # Tab-friendly way to remove indentation. remaining = @indentation line = line.dup while remaining > 0 if line[0..0] == " " remaining -= 1 else # This is a tab. remaining -= 4 end line.slice!(0, 1) end return line else terminate "wrong indentation: found #{found} characters, should be at least #{@indentation}" end end def debug(message) puts "DEBUG:#{@lineno}: #{message}" if @debug end def terminate(message) abort "*** ERROR: #{@filename} line #{@lineno}: #{message}" end end def recursive_copy_files(files, destination_dir, preprocess = false, variables = {}) require 'fileutils' if !defined?(FileUtils) files.each_with_index do |filename, i| dir = File.dirname(filename) if !File.exist?("#{destination_dir}/#{dir}") FileUtils.mkdir_p("#{destination_dir}/#{dir}") end if !File.directory?(filename) if preprocess && filename =~ /\.template$/ real_filename = filename.sub(/\.template$/, '') FileUtils.install(filename, "#{destination_dir}/#{real_filename}") Preprocessor.new.start(filename, "#{destination_dir}/#{real_filename}", variables) else FileUtils.install(filename, "#{destination_dir}/#{filename}") end end printf "\r[%5d/%5d] [%3.0f%%] Copying files...", i + 1, files.size, i * 100.0 / files.size STDOUT.flush end printf "\r[%5d/%5d] [%3.0f%%] Copying files...\n", files.size, files.size, 100 end def create_debian_package_dir(distribution) require 'time' variables = { :distribution => distribution } root = "#{PKG_DIR}/#{distribution}" sh "rm -rf #{root}" sh "mkdir -p #{root}" recursive_copy_files(ORIG_TARBALL_FILES.call, root) recursive_copy_files(Dir["debian.template/**/*"], root, true, variables) sh "mv #{root}/debian.template #{root}/debian" changelog = File.read("#{root}/debian/changelog") changelog = "#{DEBIAN_NAME} (#{PACKAGE_VERSION}-#{DEBIAN_PACKAGE_REVISION}~#{distribution}1) #{distribution}; urgency=low\n" + "\n" + " * Package built.\n" + "\n" + " -- #{MAINTAINER_NAME} <#{MAINTAINER_EMAIL}> #{Time.now.rfc2822}\n\n" + changelog File.open("#{root}/debian/changelog", "w") do |f| f.write(changelog) end end task 'debian:orig_tarball' do if File.exist?("#{PKG_DIR}/#{DEBIAN_NAME}_#{PACKAGE_VERSION}.orig.tar.gz") puts "Debian orig tarball #{PKG_DIR}/#{DEBIAN_NAME}_#{PACKAGE_VERSION}.orig.tar.gz already exists." else sh "rm -rf #{PKG_DIR}/#{DEBIAN_NAME}_#{PACKAGE_VERSION}" sh "mkdir -p #{PKG_DIR}/#{DEBIAN_NAME}_#{PACKAGE_VERSION}" recursive_copy_files(ORIG_TARBALL_FILES.call, "#{PKG_DIR}/#{DEBIAN_NAME}_#{PACKAGE_VERSION}") sh "cd #{PKG_DIR} && find #{DEBIAN_NAME}_#{PACKAGE_VERSION} -print0 | xargs -0 touch -d '2013-10-27 00:00:00 UTC'" sh "cd #{PKG_DIR} && tar -c #{DEBIAN_NAME}_#{PACKAGE_VERSION} | gzip --no-name --best > #{DEBIAN_NAME}_#{PACKAGE_VERSION}.orig.tar.gz" end end desc "Build Debian source and binary package(s) for local testing" task 'debian:dev' do sh "rm -f #{PKG_DIR}/#{DEBIAN_NAME}_#{PACKAGE_VERSION}.orig.tar.gz" Rake::Task["debian:clean"].invoke Rake::Task["debian:orig_tarball"].invoke case distro = string_option('DISTRO', 'current') when 'current' distributions = [File.read("/etc/lsb-release").scan(/^DISTRIB_CODENAME=(.+)/).first.first] when 'all' distributions = ALL_DISTRIBUTIONS else distributions = distro.split(',') end distributions.each do |distribution| create_debian_package_dir(distribution) sh "cd #{PKG_DIR}/#{distribution} && dpkg-checkbuilddeps" end distributions.each do |distribution| sh "cd #{PKG_DIR}/#{distribution} && debuild -F -us -uc" end end desc "Build Debian source packages" task 'debian:source_packages' => 'debian:orig_tarball' do ALL_DISTRIBUTIONS.each do |distribution| create_debian_package_dir(distribution) end ALL_DISTRIBUTIONS.each do |distribution| sh "cd #{PKG_DIR}/#{distribution} && debuild -S -us -uc" end end desc "Build Debian source packages to be uploaded to Launchpad" task 'debian:launchpad' => 'debian:orig_tarball' do ALL_DISTRIBUTIONS.each do |distribution| create_debian_package_dir(distribution) sh "cd #{PKG_DIR}/#{distribution} && dpkg-checkbuilddeps" end ALL_DISTRIBUTIONS.each do |distribution| sh "cd #{PKG_DIR}/#{distribution} && debuild -S -sa -k#{PACKAGE_SIGNING_KEY}" end end desc "Clean Debian packaging products, except for orig tarball" task 'debian:clean' do files = Dir["#{PKG_DIR}/*.{changes,build,deb,dsc,upload}"] sh "rm -f #{files.join(' ')}" sh "rm -rf #{PKG_DIR}/dev" ALL_DISTRIBUTIONS.each do |distribution| sh "rm -rf #{PKG_DIR}/#{distribution}" end sh "rm -rf #{PKG_DIR}/*.debian.tar.gz" end ##### RPM packaging support ##### RPM_NAME = "rubygem-mizuho" RPMBUILD_ROOT = File.expand_path("~/rpmbuild") MOCK_OFFLINE = boolean_option('MOCK_OFFLINE', false) ALL_RPM_DISTROS = { "el6" => { :mock_chroot_name => "epel-6", :distro_name => "Enterprise Linux 6" }, "amazon" => { :mock_chroot_name => "epel-6", :distro_name => "Amazon Linux" } } desc "Build gem for use in RPM building" task 'rpm:gem' do rpm_source_dir = "#{RPMBUILD_ROOT}/SOURCES" sh "gem build #{PACKAGE_NAME}.gemspec" sh "cp #{PACKAGE_NAME}-#{PACKAGE_VERSION}.gem #{rpm_source_dir}/" end desc "Build RPM for local machine" task 'rpm:local' => 'rpm:gem' do distro_id = `./rpm/get_distro_id.py`.strip rpm_spec_dir = "#{RPMBUILD_ROOT}/SPECS" spec_target_dir = "#{rpm_spec_dir}/#{distro_id}" spec_target_file = "#{spec_target_dir}/#{RPM_NAME}.spec" sh "mkdir -p #{spec_target_dir}" puts "Generating #{spec_target_file}" Preprocessor.new.start("rpm/#{RPM_NAME}.spec.template", spec_target_file, :distribution => distro_id) sh "rpmbuild -ba #{spec_target_file}" end def create_rpm_build_task(distro_id, mock_chroot_name, distro_name) desc "Build RPM for #{distro_name}" task "rpm:#{distro_id}" => 'rpm:gem' do rpm_spec_dir = "#{RPMBUILD_ROOT}/SPECS" spec_target_dir = "#{rpm_spec_dir}/#{distro_id}" spec_target_file = "#{spec_target_dir}/#{RPM_NAME}.spec" maybe_offline = MOCK_OFFLINE ? "--offline" : nil sh "mkdir -p #{spec_target_dir}" puts "Generating #{spec_target_file}" Preprocessor.new.start("rpm/#{RPM_NAME}.spec.template", spec_target_file, :distribution => distro_id) sh "rpmbuild -bs #{spec_target_file}" sh "mock --verbose #{maybe_offline} " + "-r #{mock_chroot_name}-x86_64 " + "--resultdir '#{PKG_DIR}/#{distro_id}' " + "rebuild #{RPMBUILD_ROOT}/SRPMS/#{RPM_NAME}-#{PACKAGE_VERSION}-1#{distro_id}.src.rpm" end end ALL_RPM_DISTROS.each_pair do |distro_id, info| create_rpm_build_task(distro_id, info[:mock_chroot_name], info[:distro_name]) end desc "Build RPMs for all distributions" task "rpm:all" => ALL_RPM_DISTROS.keys.map { |x| "rpm:#{x}" } desc "Publish RPMs for all distributions" task "rpm:publish" do server = "juvia-helper.phusion.nl" remote_dir = "/srv/oss_binaries_passenger/yumgems/phusion-misc" rsync = "rsync -z -r --delete --progress" ALL_RPM_DISTROS.each_key do |distro_id| if !File.exist?("#{PKG_DIR}/#{distro_id}") abort "No packages built for #{distro_id}. Please run 'rake rpm:all' first." end end ALL_RPM_DISTROS.each_key do |distro_id| sh "rpm --resign --define '%_signature gpg' --define '%_gpg_name #{PACKAGE_SIGNING_KEY}' #{PKG_DIR}/#{distro_id}/*.rpm" end sh "#{rsync} #{server}:#{remote_dir}/latest/ #{PKG_DIR}/yumgems/" ALL_RPM_DISTROS.each_key do |distro_id| distro_dir = "#{PKG_DIR}/#{distro_id}" repo_dir = "#{PKG_DIR}/yumgems/#{distro_id}" sh "mkdir -p #{repo_dir}" sh "cp #{distro_dir}/#{RPM_NAME}*.rpm #{repo_dir}/" sh "createrepo #{repo_dir}" end sh "ssh #{server} 'rm -rf #{remote_dir}/new && cp -dpR #{remote_dir}/latest #{remote_dir}/new'" sh "#{rsync} #{PKG_DIR}/yumgems/ #{server}:#{remote_dir}/new/" sh "ssh #{server} 'rm -rf #{remote_dir}/previous && mv #{remote_dir}/latest #{remote_dir}/previous && mv #{remote_dir}/new #{remote_dir}/latest'" end mizuho-0.9.20/bin/0000755000004100000410000000000012261241511013710 5ustar www-datawww-datamizuho-0.9.20/bin/mizuho-asciidoc0000755000004100000410000000237112261241511016730 0ustar www-datawww-data#!/usr/bin/env ruby # Copyright (c) 2013 Hongli Lai # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib")) require 'mizuho' require 'mizuho/source_highlight' exec(*[Mizuho::ASCIIDOC, ARGV].flatten)mizuho-0.9.20/bin/mizuho0000755000004100000410000000643012261241511015154 0ustar www-datawww-data#!/usr/bin/env ruby # Copyright (c) 2008-2013 Hongli Lai # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib")) require 'optparse' begin require 'rubygems' rescue LoadError end require 'mizuho' require 'mizuho/generator' $KCODE = 'UTF-8' if RUBY_VERSION < '1.9' options = { :topbar => true, :attributes => [] } parser = OptionParser.new do |opts| nl = "\n" + ' ' * 37 opts.banner = "Usage: mizuho [options] INPUT" opts.separator "" opts.separator "Options:" opts.on("-c", "--comments SYSTEM", "Use a commenting system. The only#{nl}" + "supported commenting system right now is#{nl}" + "'juvia'.") do |value| if value != 'juvia' abort "The only supported commenting system right now is 'juvia'." end options[:commenting_system] = value end opts.on("--juvia-url URL", "When using Juvia as the commenting system,#{nl}" + "specify the Juvia base URL here.") do |value| options[:juvia_url] = value end opts.on("--juvia-site-key KEY", "When using Juvia as the commenting system,#{nl}" + "specify the Juvia site key here.") do |value| options[:juvia_site_key] = value end #opts.on("-m", "--multi-page", "Generate one file per chapter.") do |value| # options[:multi_page] = value #end opts.on("--icons-dir DIR", "Specify the directory in which icons#{nl}" << "should be searched. Defaults to#{nl}" << "'images/icons'.") do |value| options[:icons_dir] = value end opts.on("-a", "--attribute=ATTRIBUTE", "Define or delete document attribute. Uses#{nl}" << "same syntax as asciidoc's '-a' option.") do |value| options[:attributes] << value end opts.on("-o", "--output FILE", String, "Specify the output filename.") do |value| options[:output] = value end opts.on("--index", "Generate a full-text index.") do options[:index] = true end opts.on("--no-run", "Do not run Asciidoc. Developer option#{nl}" << "only, don't use.") do options[:no_run] = true end end begin parser.parse! rescue OptionParser::ParseError => e STDERR.puts e STDERR.puts STDERR.puts "Please see '--help' for valid options." exit 1 end begin if ARGV.empty? puts parser exit 1 else Mizuho::Generator.new(ARGV[0], options).start end rescue Mizuho::GenerationError STDERR.puts "*** ERROR" exit 2 end mizuho-0.9.20/data.tar.gz.asc0000644000004100000410000000102712261241511015745 0ustar www-datawww-data-----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.17 (Darwin) Comment: GPGTools - http://gpgtools.org iQEcBAABAgAGBQJSqu2oAAoJECrHRaUKISqMn08H/39H2vkKwZBwTILuA5mgshAZ VjSB4IhQcy+4pyXhRXuArO6363nJgWSWqAVuCFP2/x8rOf91ydnTF5PRRB0ONs1Q D5BodSCZ6fya1aSexO4/kWTCJntO+SJ+x9fHdlyPJO6bhxm5N9lxxdvblwf+3T2A PZE83Uqqimb/4OP6HqpNvDjpyWffUl6qjQbTRR6ppFexSmDroYWIU8F75a0Z2TF3 6exS62o4ivDHboHz8ZfzZ05ZaWlEBWMYWWNvlCEfNjW2r2vYlavXjkjV8Gw4C/vl bmsxzlRJQ5XMUPYHi0+8o4jci6AXm359cfbeBwEjAIzBAUU88E7VXbxaSoB3EmA= =3qVe -----END PGP SIGNATURE----- mizuho-0.9.20/LICENSE.txt0000644000004100000410000000204312261241511014762 0ustar www-datawww-dataCopyright (c) 2008-2013 Hongli Lai Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. mizuho-0.9.20/templates/0000755000004100000410000000000012261241511015136 5ustar www-datawww-datamizuho-0.9.20/templates/topbar.js0000644000004100000410000001156112261241511016767 0ustar www-datawww-dataMizuho.initializeTopBar = $.proxy(function() { var $window = this.$window; var $document = this.$document; var self = this; var $topbar = $('#topbar'); var $title = $('#header h1'); var $currentSection = $('#current_section'); var isMobileDevice = this.isMobileDevice(); var timerId; // Create the floating table of contents used in the top bar. var $floattoc = $('
').html($('#toc').html()); $floattoc.find('#toctitle').remove(); $floattoc.find('.comments').remove(); $floattoc.css('visibility', 'hidden'); $floattoc.insertAfter($topbar); var $floattoclinks = $floattoc.find('a'); $floattoclinks.each(function() { // Firefox changes '#!' to '#%21' so change that back. var $this = $(this); var href = $this.attr('href'); if (href.match(/^#%21/)) { $this.attr('href', href.replace(/^#%21/, '#!')); } }); $floattoclinks.click(function(event) { self.internalLinkClicked(this, event); }); // Callback for when the user clicks on the Table of Contents // button on the top bar. function showFloatingToc() { var scrollUpdateTimerId; function reposition() { if (isMobileDevice) { $floattoc.css({ top: $currentSection.offset().top + $currentSection.innerHeight() + 'px', height: $window.height() * 0.7 + 'px' }); } } function highlightCurrentTocEntry() { var currentSubsection = self.currentSubsection(); $floattoclinks.removeClass('current'); if (currentSubsection) { var currentSubsectionTitle = $(currentSubsection).text(); var $link; $floattoclinks.each(function() { if ($(this).text() == currentSubsectionTitle) { $link = $(this); return false; } }); if ($link) { $link.addClass('current'); self.setScrollTop( $floattoc.scrollTop() + $link.position().top - $floattoc.height() * 0.45, $floattoc); return false; } } } function hideFloatingToc() { $currentSection.removeClass('pressed'); $floattoc.css('visibility', 'hidden'); $floattoclinks.unbind('click', hideFloatingToc); $document.unbind('mousedown', onMouseDown); $document.unbind('touchdown', onMouseDown); $document.unbind('mizuho:hideTopBar', hideFloatingToc); $window.unbind('scroll', onScroll); if (scrollUpdateTimerId !== undefined) { clearTimeout(scrollUpdateTimerId); scrollUpdateTimerId = undefined; } } function onMouseDown(event) { if (event.target != $floattoc[0] && $(event.target).closest('#floattoc').length == 0) { hideFloatingToc(); } } function onScroll(event) { if (scrollUpdateTimerId === undefined) { scrollUpdateTimerId = setTimeout(function() { scrollUpdateTimerId = undefined; reposition(); highlightCurrentTocEntry(); }, 100); } } // Layout and display floating TOC. highlightCurrentTocEntry(); var origScrollTop = $document.scrollTop(); var windowWidth = $window.width(); var maxRight = windowWidth - Math.floor(windowWidth * 0.1); if ($currentSection.offset().left + $floattoc.outerWidth() > maxRight) { $floattoc.css('left', maxRight - $floattoc.outerWidth()); } else { $floattoc.css('left', $currentSection.offset().left + 'px'); } reposition(); $floattoc.css('visibility', 'visible'); $currentSection.addClass('pressed'); $floattoclinks.bind('click', hideFloatingToc); $document.bind('mousedown', onMouseDown) $document.bind('touchdown', onMouseDown); $document.bind('mizuho:hideTopBar', hideFloatingToc); $window.bind('scroll', onScroll); } // Called whenever the user scrolls. Updates the title of the // Table of Contents button in the top bar to the section that // the user is currently reading. function update() { if ($title.offset().top + $title.height() < $document.scrollTop()) { if (!$topbar.is(':visible')) { $topbar.slideDown(250); $document.trigger('mizuho:showTopBar'); } } else { if ($topbar.is(':visible')) { $topbar.slideUp(); $document.trigger('mizuho:hideTopBar'); } } if (isMobileDevice) { $topbar.css({ top: $document.scrollTop() + 'px', width: $window.width() - parseInt($topbar.css('padding-left')) - parseInt($topbar.css('padding-right')) + 'px' }); } var header = self.currentSubsection(); var name; if (header) { name = $(header).text(); } else { name = 'Preamble'; } $currentSection.text(name); } function scheduleUpdate() { if (timerId !== undefined) { return; } timerId = setTimeout(function() { timerId = undefined; update(); }, 100); } if (isMobileDevice) { // Mobile devices don't support position fixed. $topbar.css('position', 'absolute'); $floattoc.css('position', 'absolute'); } $currentSection.click(showFloatingToc); $window.scroll(scheduleUpdate); $document.bind('mizuho:updateTopBar', update); }, Mizuho); $(document).ready(Mizuho.initializeTopBar); mizuho-0.9.20/templates/arrow-up.png0000644000004100000410000000042312261241511017417 0ustar www-datawww-dataPNG  IHDR sRGBbKGD pHYs  tIME  "tEXtCommentCreated with GIMP on a MacwCeIDAT}K "W򀾞<]Rs68al*!Q 6{4xlUl̺/ 5<1n֐" in?(U>W}®|,}}}gOh<IENDB`mizuho-0.9.20/templates/balloon.png0000644000004100000410000000244612261241511017300 0ustar www-datawww-dataPNG  IHDR$ zڎsBIT|d pHYssoztEXtSoftwarewww.inkscape.org<IDATXOhU?olmwKXBmQ bj)GAj{RPH٫O%wo%SXiƅvukٙy2o}yVgg}~yRJtBDhZ j$KRӯe2R p[ 8AVeaanjOt0!T0ŋ'OPR@0 ÐFWܼw҅ h"@J)]._6Ϗ1ߡ.`~^kڃg~2АRBro B>H˲, ۶m{[tum`}9bqҥKI!pk~~IucoꥎeY2CA>wR~0f~)S@q0@{E-e F-l`|(]AQH=: cMev(3nUZ_ ]^0qPӡ6 [(d&zӁ<'Q;_zA=|psyyysl6LL7`[?~쯬-@:@877Ñ#GM^ V&Fǩw=8 =[Cquuu@xqnnn>;H$L&gff(/ L&cVO\XV+;! A.[@2[7]RΝr gYs֭qhI b/SJz(0v̙;q6͍7MRܼ|g@ S dG`i {'N$Mˋ_QixVstTի7]Cf `u/b<`/PԩSD@_OY/ҩ6Vn*e+1} mqF5]IENDB`mizuho-0.9.20/templates/topbar.css0000644000004100000410000000471412261241511017145 0ustar www-datawww-data#topbar { position: fixed; left: 0; top: 0; right: 0; height: 2.5em; padding-left: 10%; padding-right: 10%; z-index: 1; background: #880000; overflow: hidden; white-space: nowrap; box-shadow: 0px 3px 6px #555555; -moz-box-shadow: 0px 3px 6px #555555; -webkit-box-shadow: 0px 3px 6px #555555; -o-box-shadow: 0px 3px 6px #555555; } #topbar .title { display: inline-block; margin: 0.6em 1em 0 0; vertical-align: top; } #topbar .title img { display: none; margin-right: 6px; vertical-align: middle; } #topbar .title a { color: #fffafa; border: 0; } #topbar .title:hover img, .mobile #topbar .title img { display: inline-block; margin-left: -17px; } #topbar .title:hover a, .mobile #topbar .title a { color: #ffffdd; } #floattoc { position: fixed; z-index: 1; top: 2em; bottom: 20%; width: 50%; background: #f0f0f0; color: black; box-shadow: 0px 6px 6px #555555; -moz-box-shadow: 0px 6px 6px #555555; -webkit-box-shadow: 0px 6px 6px #555555; -o-box-shadow: 0px 6px 6px #555555; overflow: auto; padding: 1em; border-radius: 6px; -webkit-border-radius: 8px; -webkit-border-top-left-radius: 0; -webkit-border-top-right-radius: 0; -moz-border-radius: 8px; -moz-border-radius-topleft: 0; -moz-border-top-right-radius: 0; -o-border-radius: 8px; -o-border-radius-topleft: 0; -o-border-top-right-radius: 0; border-radius: 8px; border-top-left-radius: 0; border-top-right-radius: 0; } #floattoc a.current { font-weight: bold; color: black; } #current_section { display: inline-block; margin: 0.5em 0 0 0; padding: 0.2em 0.5em 0.2em 0.5em; background: #550000; font-size: 90%; vertical-align: top; color: white; border: none; -webkit-border-radius: 8px; -moz-border-radius: 8px; -o-border-radius: 8px; border-radius: 8px; } #current_section:hover { text-decoration: none; border: none; } #current_section.pressed { background: #f0f0f0; color: black; -webkit-border-top-left-radius: 8px; -webkit-border-top-right-radius: 8px; -webkit-border-bottom-left-radius: 0; -webkit-border-bottom-right-radius: 0; -moz-border-radius-topleft: 8px; -moz-border-radius-topright: 8px; -moz-border-bottom-left-radius: 0; -moz-border-bottom-right-radius: 0; border-top-left-radius: 8px; border-top-right-radius: 8px; border-bottom-left-radius: 0; border-bottom-right-radius: 0; } /* http://nicolasgallagher.com/jump-links-and-viewport-positioning/ */ .anchor_helper { position: relative; display: block; top: -50px; width: 1px; height: 1px; } mizuho-0.9.20/templates/balloon.svg0000644000004100000410000001340112261241511017304 0ustar www-datawww-data image/svg+xml mizuho-0.9.20/templates/topbar.html0000644000004100000410000000054412261241511017316 0ustar www-datawww-datamizuho-0.9.20/templates/toc.html0000644000004100000410000000000012261241511016577 0ustar www-datawww-datamizuho-0.9.20/templates/juvia.js0000644000004100000410000001064512261241511016620 0ustar www-datawww-datavar disqus_identifier; var disqus_title; var disqus_url; var disqus_developer = 1; Mizuho.initializeCommenting = $.proxy(function() { var self = this; this.commentBalloons = $('.comments'); this.commentBalloons.click(function() { self.showCommentsPopup(this); }); this.reloadCommentCount(); }, Mizuho); Mizuho.showLightbox = $.proxy(function(creationCallback, closeCallback) { var lightbox = $( '
' + '
' + '
' + '
'); var shadow = $('#comments_lightbox_shadow', lightbox); var contents = $('#comments_lightbox_contents > .shell', lightbox); function close() { if (lightbox) { lightbox.remove(); lightbox = undefined; if (closeCallback) { closeCallback(); } } } shadow.click(close); lightbox.bind('lightbox:close', close); lightbox.appendTo(document.body); creationCallback(contents); }, Mizuho); Mizuho.getCommentThreadInfo = $.proxy(function(balloon) { var info = {}; if ($(balloon).closest('#toc').length > 0) { info.id = 'toctitle'; info.topic = 'toctitle'; info.title = $('#header h1').text() + " - " + $('#toctitle').text(); } else { var header = $(balloon).next('h2, h3, h4'); if (header.length > 0) { info.id = header.attr('id'); info.topic = header.data('comment-topic'); info.title = $('#header h1').text() + " - " + header.text(); } else { info = undefined; } } return info; }, Mizuho); Mizuho.callJuviaApi = function(action, options) { function makeQueryString(options) { var key, params = []; for (key in options) { params.push( encodeURIComponent(key) + '=' + encodeURIComponent(options[key])); } return params.join('&'); } // Makes sure that each call generates a unique URL, otherwise // the browser may not actually perform the request. if (!('_juviaRequestCounter' in window)) { window._juviaRequestCounter = 0; } var url = JUVIA_URL + '/api/' + action + '?_c=' + window._juviaRequestCounter + '&' + makeQueryString(options); window._juviaRequestCounter++; var s = document.createElement('script'); s.async = true; s.type = 'text/javascript'; s.className = 'juvia'; s.src = url; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(s); } Mizuho.showCommentsPopup = $.proxy(function(balloon) { var info = this.getCommentThreadInfo(balloon); if (!info) { return; } var self = this; this.showLightbox(function(element) { // We install a 'Close' button in the Juvia comment form after it has loaded. function installCloseButton() { if ($('#comments .juvia-form-actions').size() > 0) { // The Juvia form is now loaded. Install the button. var div = $('
'); var button = $('').appendTo(div); div.insertBefore('#comments .juvia-form-actions .juvia-error'); button.click(function() { $(element).trigger('lightbox:close'); }); } else { // Continue polling. setTimeout(installCloseButton, 50); } } setTimeout(installCloseButton, 50); // Now load the Juvia comments form. element.html('
Loading comments...
'); self.changingHash = true; location.hash = '#!/' + info.id; self.callJuviaApi('show_topic.js', { container : '#comments', site_key : JUVIA_SITE_KEY, topic_key : info.topic, topic_url : location.href, topic_title : info.topic, include_base: !window.Juvia, include_css : !window.Juvia }); }, function() { self.reloadCommentCount(); }); }, Mizuho); Mizuho.reloadCommentCount = $.proxy(function() { this.callJuviaApi('list_topics.jsonp', { site_key: JUVIA_SITE_KEY, jsonp : 'Mizuho.topicListReceived' }); }, Mizuho); Mizuho.topicListReceived = $.proxy(function(result) { var self = this; var i, topic, map = {}; for (i = 0; i < result.topics.length; i++) { topic = result.topics[i]; map[topic.key] = topic; } this.commentBalloons.each(function() { var info = self.getCommentThreadInfo(this); if (info) { topic = map[info.topic]; if (topic) { var balloon = $(this); $('.count', balloon).text(topic.comment_count); balloon.removeClass('empty'); balloon.addClass('nonempty'); balloon.attr('title', null); } } }); }, Mizuho); $(document).ready(Mizuho.initializeCommenting); mizuho-0.9.20/templates/mizuho.js0000644000004100000410000001141112261241511017005 0ustar www-datawww-data// IE... if (!Date.now) { Date.now = function() { return new Date().getTime(); } } var Mizuho = { /** Cached DOM elements so that we don't have to re-find them over and over. */ $document: undefined, $window: undefined, $mainSections: undefined, $sectionHeaders: undefined, /** Constants */ MAX_TOC_LEVEL: 3, sectionHeadersSelector: undefined, scrollMemory: {}, changingHash: false, activeHash: undefined, /** Whether in single-page or multi-page mode. Either 'single' or 'multi'. */ mode: 'single', /** Whether smooth scrolling is enabled. It is always enabled except right * after page load: when the page is scrolled to the section as pointed to * by location.hash. */ smoothScrolling: true, initialize: function() { this.sectionHeadersSelector = ''; for (var i = 0; i < this.MAX_TOC_LEVEL; i++) { if (i != 0) { this.sectionHeadersSelector += ', '; } this.sectionHeadersSelector += 'h' + (i + 2); } this.$document = $(document); this.$window = $(window); this.$mainSections = $('.sect1'); this.$sectionHeaders = $(this.sectionHeadersSelector, '#content'); this.$sectionHeaders.sort(function(a, b) { var off_a = $(a).offset(); var off_b = $(b).offset(); return off_a.top - off_b.top; }); if (this.isMobileDevice()) { $(document.body).addClass('mobile'); } }, /********* Generic utility functions *********/ isMobileDevice: function() { return navigator.userAgent.match( /(IEMobile|Windows CE|NetFront|PlayStation|PLAYSTATION|like Mac OS X|MIDP|UP\.Browser|Symbian|Nintendo|Android)/ ); }, virtualAnimate: function(options) { var options = $.extend({ duration: 1000 }, options || {}); var animation_start = Date.now(); var animation_end = Date.now() + options.duration; var interval = animation_end - animation_start; this._virtualAnimate_step(animation_start, animation_end, interval, options); }, _virtualAnimate_step: function(animation_start, animation_end, interval, options) { var self = this; var now = new Date(); var progress = (now - animation_start) / interval; if (progress > 1) { progress = 1; } progress = (1 + Math.sin(-Math.PI / 2 + progress * Math.PI)) / 2; options.step(progress); if (now < animation_end) { setTimeout(function() { self._virtualAnimate_step(animation_start, animation_end, interval, options); }, 15); } else { options.step(1); if (options.finish) { options.finish(); } } }, smoothlyScrollTo: function(top) { if (!this.smoothScrolling) { return this.setScrollTop(top); } var self = this; var $document = this.$document; var current = $document.scrollTop(); this.virtualAnimate({ duration: 300, step: function(x) { $document.scrollTop(Math.floor( top + (1 - x) * (current - top) )); }, finish: function() { self.setScrollTop(top); } }); }, smoothlyScrollToToc: function() { this.smoothlyScrollTo($('#toc').position().top); }, scrollToHeader: function(header) { this.smoothlyScrollTo($(header).offset().top - 50); }, setScrollTop: function(top, element) { // Browsers don't always scroll properly so work around // this with a few timers. var self = this; element = element || this.$document; element = $(element); element.scrollTop(top); setTimeout(function() { element.scrollTop(top); }, 1); setTimeout(function() { element.scrollTop(top); self.$document.trigger('mizuho:updateTopBar'); }, 20); }, /********* Mizuho-specific functions *********/ /** Returns the currently displayed section's header DOM element. */ currentSubsection: function() { var $sectionHeaders = this.$sectionHeaders; var scrollTop = this.$document.scrollTop(); var windowHeight = this.$window.height(); var offset; var low = 0; var high = this.$sectionHeaders.length - 1; var mid = 0; while (low <= high) { mid = Math.floor((low + high) / 2); offset = $($sectionHeaders[mid]).offset(); if (offset.top >= scrollTop) { high = mid - 1; } else { low = mid + 1; } } var $found = $($sectionHeaders[low]); if ($found.offset().top > scrollTop + windowHeight) { if (low > 0) { return $sectionHeaders[low - 1]; } else { return undefined; } } else { return $sectionHeaders[low]; } }, /** Looks up a section's header DOM element corresponding to a hash name. */ lookupHeader: function(hash) { var id = hash.replace(/^#!\//, '#'); if (id == '') { return undefined; } else { var header = $(id); if (header.length == 0) { return undefined; } else { return header; } } } }; for (var key in Mizuho) { if (typeof(Mizuho[key]) == 'function') { Mizuho[key] = $.proxy(Mizuho[key], Mizuho); } } $(document).ready(Mizuho.initialize); //$(document).ready(Mizuho.installHashbangLinks); mizuho-0.9.20/templates/mizuho.css0000644000004100000410000000306712261241511017171 0ustar www-datawww-databody { margin: 1em auto 1em auto; padding: 0 1em 0 1em; max-width: 800px; } a.image { border: none; } .comments { display: block; background: url('balloon.png') top left no-repeat; float: left; margin-left: -55px; width: 36px; height: 48px; line-height: 0; color: black; text-decoration: none !important; border: none !important; } #toc .comments { margin-top: 0.25em; } .sect1 .comments { margin-top: 0.5em; } .sect2 .comments { margin-top: 1.15em; } .sect3 .comments { margin-top: -1em; } .comments.empty { opacity: 0.2; } .comments.empty:hover, .comments.nonempty { opacity: 1; } .comments .count { display: block; font-size: 80%; padding-top: 12px; text-align: center; text-shadow: 1px 1px 2px white; } #comments_lightbox_shadow { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: black; opacity: 0.7; z-index: 10; } #comments_lightbox_contents { position: fixed; top: 10%; left: 20%; right: 20%; bottom: 10%; background: white; overflow: auto; z-index: 11; } #comments_lightbox_contents > .shell { margin: 2em; } pre { overflow: auto; } @media print { body { font-size: 18pt; } #header h1 { page-break-after: always; font-size: 500%; vertical-align: middle; } #header { page-break-after: always; } #toctitle { font-size: 200%; margin-bottom: 1em; } div.toclevel1 { font-size: 100%; } div.toclevel2 { font-size: 90%; } div.toclevel3 { font-size: 80%; } #content .comments { display: none; } @page :left { @bottom-left { content: counter(page); } } } mizuho-0.9.20/templates/jquery.hashchange-1.0.0.js0000644000004100000410000000605512261241511021543 0ustar www-datawww-data/** * jQuery hashchange 1.0.0 * * (based on jquery.history) * * Copyright (c) 2008 Chris Leishman (chrisleishman.com) * Dual licensed under the MIT (MIT-LICENSE.txt) * and GPL (GPL-LICENSE.txt) licenses. */ (function($) { $.fn.extend({ hashchange: function(callback) { this.bind('hashchange', callback) }, openOnClick: function(href) { if (href === undefined || href.length == 0) href = '#'; return this.click(function(ev) { if (href && href.charAt(0) == '#') { // execute load in separate call stack window.setTimeout(function() { $.locationHash(href) }, 0); } else { window.location(href); } ev.stopPropagation(); return false; }); } }); // IE 8 introduces the hashchange event natively - so nothing more to do if ($.browser.msie && document.documentMode && document.documentMode >= 8) { $.extend({ locationHash: function(hash) { if (!hash) hash = '#'; else if (hash.charAt(0) != '#') hash = '#' + hash; location.hash = hash; } }); return; } var curHash; // hidden iframe for IE (earlier than 8) var iframe; $.extend({ locationHash: function(hash) { if (curHash === undefined) return; if (!hash) hash = '#'; else if (hash.charAt(0) != '#') hash = '#' + hash; location.hash = hash; if (curHash == hash) return; curHash = hash; if ($.browser.msie) updateIEFrame(hash); $.event.trigger('hashchange'); } }); $(document).ready(function() { curHash = location.hash; if ($.browser.msie) { // stop the callback firing twice during init if no hash present if (curHash == '') curHash = '#'; // add hidden iframe for IE iframe = $('