<commit_before>module Pyha
  module Helpers
    include Rack::Utils

    alias :h :escape_html

    def index?;     @theme_types.include?(:index); end
    def search?;    @theme_types.include?(:search); end
    def category?;  @theme_types.include?(:category); end
    def tag?;       @theme_types.include?(:tag); end
    def yearly?;    @theme_types.include?(:yearly); end
    def monthly?;   @theme_types.include?(:monthly); end
    def daily?;     @theme_types.include?(:daily); end
    def entry?;     @theme_types.include?(:entry); end
    def entries?;   @theme_types.include?(:entries); end

    def hash_to_query_string(hash)
      hash.collect {|k,v| "#{k}=#{v}"}.join('&')
    end

    # h + n2br
    def hbr(str)
      str.gsub(/\r\n|\r|\n/, "<br />\n")
    end

    def login_required
      if current_user.class != GuestUser
        return true
      else
        session[:return_to] = request.fullpath
        redirect '/admin/login'
        return false
      end
    end

    def current_user
      if session[:user]
        User.get(session[:user])
      else
        GuestUser.new
      end
    end

    def logged_in?
      !!session[:user]
    end

    def bread_crumb
      html = '<ol>'
      @bread_crumbs.each do |bread|
        html += '<li>'
        if bread.last?
          html += bread.name<commit_msg>escape comment html.<commit_after>module Pyha
  module Helpers
    include Rack::Utils

    alias :h :escape_html

    def index?;     @theme_types.include?(:index); end
    def search?;    @theme_types.include?(:search); end
    def category?;  @theme_types.include?(:category); end
    def tag?;       @theme_types.include?(:tag); end
    def yearly?;    @theme_types.include?(:yearly); end
    def monthly?;   @theme_types.include?(:monthly); end
    def daily?;     @theme_types.include?(:daily); end
    def entry?;     @theme_types.include?(:entry); end
    def entries?;   @theme_types.include?(:entries); end

    def hash_to_query_string(hash)
      hash.collect {|k,v| "#{k}=#{v}"}.join('&')
    end

    # h + n2br
    def hbr(str)
      h(str.gsub(/\r\n|\r|\n/, "<br />\n"))
    end

    def login_required
      if current_user.class != GuestUser
        return true
      else
        session[:return_to] = request.fullpath
        redirect '/admin/login'
        return false
      end
    end

    def current_user
      if session[:user]
        User.get(session[:user])
      else
        GuestUser.new
      end
    end

    def logged_in?
      !!session[:user]
    end

    def bread_crumb
      html = '<ol>'
      @bread_crumbs.each do |bread|
        html += '<li>'
        if bread.last?
          html += bread.name
{'fraction_non_alphanumeric': 0.13660179640718562, 'fraction_numerical': 0.0007485029940119761, 'mean_word_length': 2.2677261613691932, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '1159385', 'n_tokens_mistral': 879, 'n_tokens_neox': 876, 'n_words': 203}