<commit_before>class ShowOffUtils

  # Helper method to parse a comma separated options string and stores
  # the result in a dictionrary
  #
  # Example:
  #
  #    "tpl=hpi,title=Over the rainbow"
  #
  #    will be stored as
  #
  #      { "tpl" => "hpi", "title" => "Over the rainbow" }
  def self.parse_options(option_string="")
    result = {}

    if option_string
      option_string.split(",").each do |element|
        pair = element.split("=")
        result[pair[0]] = pair.size > 1 ? pair[1] : nil
      end
    end

    result
  end

  def self.presentation_config_file
    @presentation_config_file ||= 'showoff.json'
  end

  def self.presentation_config_file=(filename)
    @presentation_config_file = filename
  end

  def self.create(dirname,create_samples,dir='one')
    Dir.mkdir(dirname) if !File.exist?(dirname)
    Dir.chdir(dirname) do
      if create_samples
        # create section
        Dir.mkdir(dir)

        # create markdown file
        File.open("#{dir}/01_slide.md", 'w+') do |f|
          f.puts make_slide("My Presentation")
          f.puts make_slide("Bullet Points","bullets incremental",["first point","second point","third point"])
        end
      end

      # create showoff.json
      File.open(ShowOffUtils.presentation_config_file, 'w+') do |f|
        f.puts "{ \"name\": \"My Preso\", \"sections\": [ {\"section\":\"#{dir}\"} ]}"
      end
    end
  end

  HEROKU_GEMS_FILE = '.gems'
  HEROKU_BUNDLER_GEMS_FILE = 'Gemfile'
  HEROKU_CONFIG_FILE = 'config.ru'

	# Setup presentation to run on Heroku
  #
  # name         - String containing heroku name
  # force        - boolean if .gems/Gemfile and config.ru should be overwritten if they don't exist
  # password     - String containing password to protect your heroku site; nil means no password protection
  # use_dot_gems - boolean that, if true, indicates we should use the old, deprecated .gems file instead of Bundler
  def self.heroku(name, force = false, password = <PASSWORD>, use_dot_gems = false)
    modified_something = false

    if use_dot_gems
      modified_something = create_gems_file(HEROKU_GEMS_FILE,
                                            !password.nil?,
                                            force,
                                            lambda{ |gem| gem })
    else
      modified_something = create_gems_file(HEROKU_BUNDLER_GEMS_FILE,
                                            !password.nil?,
                                            force,
                                            lambda{ |gem| "gem '#{gem}'" },
                                            lambda{ "source :rubygems" })
    end

    create_file_if_needed(HEROKU_CONFIG_FILE,force) do |file|
      modified_something = true
      file.puts 'require "showoff"'
      if password.nil?
        file.puts 'run ShowOff.new'
      else
        file.puts 'require "rack"'
        file.puts 'showoff_app = ShowOff.new'
        file.puts 'protected_showoff = Rack::Auth::Basic.new(showoff_app) do |username, password|'
        file.puts	"\tpassword == '#{password}'"
        file.puts 'end'
        file.puts 'run protected_showoff'
      end
    end

    modified_something
  end

  # generate a static version of the site into the gh-pages branch
  def self.github
    ShowOff.do_static(nil)
    `git add -f static`
    sha = `git write-tree`.chomp<commit_msg>disable jekyll on github pages<commit_after>class ShowOffUtils

  # Helper method to parse a comma separated options string and stores
  # the result in a dictionrary
  #
  # Example:
  #
  #    "tpl=hpi,title=Over the rainbow"
  #
  #    will be stored as
  #
  #      { "tpl" => "hpi", "title" => "Over the rainbow" }
  def self.parse_options(option_string="")
    result = {}

    if option_string
      option_string.split(",").each do |element|
        pair = element.split("=")
        result[pair[0]] = pair.size > 1 ? pair[1] : nil
      end
    end

    result
  end

  def self.presentation_config_file
    @presentation_config_file ||= 'showoff.json'
  end

  def self.presentation_config_file=(filename)
    @presentation_config_file = filename
  end

  def self.create(dirname,create_samples,dir='one')
    Dir.mkdir(dirname) if !File.exist?(dirname)
    Dir.chdir(dirname) do
      if create_samples
        # create section
        Dir.mkdir(dir)

        # create markdown file
        File.open("#{dir}/01_slide.md", 'w+') do |f|
          f.puts make_slide("My Presentation")
          f.puts make_slide("Bullet Points","bullets incremental",["first point","second point","third point"])
        end
      end

      # create showoff.json
      File.open(ShowOffUtils.presentation_config_file, 'w+') do |f|
        f.puts "{ \"name\": \"My Preso\", \"sections\": [ {\"section\":\"#{dir}\"} ]}"
      end
    end
  end

  HEROKU_GEMS_FILE = '.gems'
  HEROKU_BUNDLER_GEMS_FILE = 'Gemfile'
  HEROKU_CONFIG_FILE = 'config.ru'

	# Setup presentation to run on Heroku
  #
  # name         - String containing heroku name
  # force        - boolean if .gems/Gemfile and config.ru should be overwritten if they don't exist
  # password     - String containing password to protect your heroku site; nil means no password protection
  # use_dot_gems - boolean that, if true, indicates we should use the old, deprecated .gems file instead of Bundler
  def self.heroku(name, force = false, password = nil, use_dot_gems = false)
    modified_something = false

    if use_dot_gems
      modified_something = create_gems_file(HEROKU_GEMS_FILE,
                                            !password.nil?,
                                            force,
                                            lambda{ |gem| gem })
    else
      modified_something = create_gems_file(HEROKU_BUNDLER_GEMS_FILE,
                                            !password.nil?,
                                            force,
                                            lambda{ |gem| "gem '#{gem}'" },
                                            lambda{ "source :rubygems" })
    end

    create_file_if_needed(HEROKU_CONFIG_FILE,force) do |file|
      modified_something = true
      file.puts 'require "showoff"'
      if password.nil?
        file.puts 'run ShowOff.new'
      else
        file.puts 'require "rack"'
        file.puts 'showoff_app = ShowOff.new'
        file.puts 'protected_showoff = Rack::Auth::Basic.new(showoff_app) do |username, password|'
        file.puts	"\tpassword == '#{password}'"
        file.puts 'end'
        file.puts 'run protected_showoff'
      end
    end

    modified_something
  end

  # generate a static version of the site into the gh-pages branch
  def self.github
    ShowOff.do_static(nil)
    FileUtils.touch 'static/.nojekyll'
    `git add -f static`
    sha = `git write-tree`.chomp
{'fraction_non_alphanumeric': 0.10313373547153155, 'fraction_numerical': 0.0014712373105781962, 'mean_word_length': 2.092811646951774, 'pattern_counts': {'":': 6, '<': 4, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 28, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7207969', 'n_tokens_mistral': 2073, 'n_tokens_neox': 1997, 'n_words': 523}