<commit_before><% he = HTMLEntities.new %>
<h1>Chat Log: <%= he.encode params[:buffer] %> on <%= he.encode params[:network] %> (<%= he.encode params[:date]%>)</h1>
<p><a class='button orange' href="/<%= URI.encode params[:network]%>/<%= URI.encode params[:buffer] %>">Back</a></p>
<%

  path = File.expand_path $opts[:log_dir]

  log = nil

  Dir.new(path).each do |file|
    my_path = "#{path}/#{file}"
    next unless File.file? my_path

    match = file.match $opts[:file_name_regex]

    next unless match and match[:network] == params[:network]
    next unless match[:buffer] == params[:buffer]

    log = my_path

    break
  end

  if log
    even = true
    
    share_url = "#{@env['rack.url_scheme']}://#{@env['HTTP_HOST']}#{@env['REQUEST_PATH']}"
  %>
  <table style="table-layout: fixed; width: 95%;">
    <thead>
      <tr>
        <th style='width: 100px;'>Time</th>
        <th style='width: 150px;'>Prefix</th>
        <th>Text</th>
      </tr>
    </thead>
    <tbody>
      <%
        started = false

        File.open(log, 'r') do |f|
          catch :done do
            f.each_line do |line|
              catch :skip do

                line.fix_encoding!

                match = line.match(/^(?<date>[0-9-]{10}) (?<time>[0-9:]{8})\t(?<prefix>[^\t]*)\t(?<text>.*)$/)
                if match
                  if match[:date].to_s != params[:date]
                    throw :done if started
                    throw :skip
                  end

                  started = true unless started

                  anchor = "#{match[:date]}_#{match[:time]}"

                  case match[:prefix]
                  when '-->'
                    style = 'join'
                  when '<--'
                    style = 'leave'
                  when '--'
                    style = 'misc'
                  when '=!='
                    style = 'error'
                  when ' *'
                    style = 'action'
                  when ''
                    style = 'no-prefix'
                  else
                    style = 'chat'
                  end

                  if even = !even
                    style << ' even'
                  end

                  text = he.encode match[:text]

                  highlight_match = text.match(/^(?<highlight>[^:\s]+[:]\s)(?<remainder>.*)$/)
                  jn_lv_match     = text.match(/^(?<pre>.*?)(?<host>[(][~]?\w+[@][\w-:.]+[)][ ])(?<post>.*)$/)

                  if highlight_match
                    text = "<span class='highlight'>#{highlight_match[:highlight]}</span>#{highlight_match[:remainder].hyperlinks}"
                  elsif ['-->', '<--'].include?(match[:prefix]) && jn_lv_match
                    text = jn_lv_match[:pre] + jn_lv_match[:post]
                  else
                    text.hyperlinks!
                  end
                %>
                <tr class='<%= style %>'>
                  <td class='time center'><a name='<%= anchor %>' href='<%= share_url %>#<%= anchor %>'><%= match[:time] %></a></td>
                  <td class='irc prefix'><%= match[:prefix] %></td><commit_msg>Removed URL-conversion because Google blacklisted us<commit_after><% he = HTMLEntities.new %>
<h1>Chat Log: <%= he.encode params[:buffer] %> on <%= he.encode params[:network] %> (<%= he.encode params[:date]%>)</h1>
<p><a class='button orange' href="/<%= URI.encode params[:network]%>/<%= URI.encode params[:buffer] %>">Back</a></p>
<%

  path = File.expand_path $opts[:log_dir]

  log = nil

  Dir.new(path).each do |file|
    my_path = "#{path}/#{file}"
    next unless File.file? my_path

    match = file.match $opts[:file_name_regex]

    next unless match and match[:network] == params[:network]
    next unless match[:buffer] == params[:buffer]

    log = my_path

    break
  end

  if log
    even = true
    
    share_url = "#{@env['rack.url_scheme']}://#{@env['HTTP_HOST']}#{@env['REQUEST_PATH']}"
  %>
  <table style="table-layout: fixed; width: 95%;">
    <thead>
      <tr>
        <th style='width: 100px;'>Time</th>
        <th style='width: 150px;'>Prefix</th>
        <th>Text</th>
      </tr>
    </thead>
    <tbody>
      <%
        started = false

        File.open(log, 'r') do |f|
          catch :done do
            f.each_line do |line|
              catch :skip do

                line.fix_encoding!

                match = line.match(/^(?<date>[0-9-]{10}) (?<time>[0-9:]{8})\t(?<prefix>[^\t]*)\t(?<text>.*)$/)
                if match
                  if match[:date].to_s != params[:date]
                    throw :done if started
                    throw :skip
                  end

                  started = true unless started

                  anchor = "#{match[:date]}_#{match[:time]}"

                  case match[:prefix]
                  when '-->'
                    style = 'join'
                  when '<--'
                    style = 'leave'
                  when '--'
                    style = 'misc'
                  when '=!='
                    style = 'error'
                  when ' *'
                    style = 'action'
                  when ''
                    style = 'no-prefix'
                  else
                    style = 'chat'
                  end

                  if even = !even
                    style << ' even'
                  end

                  text = he.encode match[:text]

                  highlight_match = text.match(/^(?<highlight>[^:\s]+[:]\s)(?<remainder>.*)$/)
                  jn_lv_match     = text.match(/^(?<pre>.*?)(?<host>[(][~]?\w+[@][\w-:.]+[)][ ])(?<post>.*)$/)

                  if highlight_match
                    text = "<span class='highlight'>#{highlight_match[:highlight]}</span>#{highlight_match[:remainder]}"
                  elsif ['-->', '<--'].include?(match[:prefix]) && jn_lv_match
                    text = jn_lv_match[:pre] + jn_lv_match[:post]
                  end
                %>
                <tr class='<%= style %>'>
                  <td class='time center'><a name='<%= anchor %>' href='<%= share_url %>#<%= anchor %>'><%= match[:time] %></a></td>
                  <td class='irc prefix'><%= match[:prefix] %></td>
{'fraction_non_alphanumeric': 0.18570042057586542, 'fraction_numerical': 0.005499838240051763, 'mean_word_length': 1.48014440433213, 'pattern_counts': {'":': 0, '<': 111, '<?xml version=': 0, '>': 107, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4701061', 'n_tokens_mistral': 2022, 'n_tokens_neox': 1812, 'n_words': 366}