<commit_before>module RailsAdmin
  module Config
    module Fields
      module Types
        class Code < RailsAdmin::Config::Fields::Types::CodeMirror

          register_instance_option :pretty_value do
            code = JSON.pretty_generate(value) rescue value
            if bindings[:view].instance_variable_get(:@action).is_a?(RailsAdmin::Config::Actions::Index)
              code = code.lines[0, 4].join
              if code.length > 50
                code = "#{code.to(50)}..."
              end
            end
            "<pre><code class='#{mode_file}'>#{code}</code></pre>".html_safe
          end

          register_instance_option :js_location do
            bindings[:view].asset_path('codemirror.js')
          end

          register_instance_option :css_location do
            bindings[:view].asset_path('codemirror.css')
          end

          register_instance_option :assets do
            {
              mode: bindings[:view].asset_path("codemirror/modes/#{mode_file}.js"),
              theme: bindings[:view].asset_path("codemirror/themes/#{config[:theme]}.css")
            }
          end

          register_instance_option :config do
            default_config.merge(code_config)
          end

          register_instance_option :default_config do
            {<commit_msg>Cropping codes in embedded index listings<commit_after>module RailsAdmin
  module Config
    module Fields
      module Types
        class Code < RailsAdmin::Config::Fields::Types::CodeMirror

          register_instance_option :pretty_value do
            code = JSON.pretty_generate(value) rescue value
            if bindings[:view].instance_variable_get(:@action).is_a?(RailsAdmin::Config::Actions::Index) ||
            !bindings[:object].is_a?(bindings[:view].controller.abstract_model.model)
              code = code.lines[0, 4].join
              if code.length > 50
                code = "#{code.to(50)}..."
              end
            end
            "<pre><code class='#{mode_file}'>#{code}</code></pre>".html_safe
          end

          register_instance_option :js_location do
            bindings[:view].asset_path('codemirror.js')
          end

          register_instance_option :css_location do
            bindings[:view].asset_path('codemirror.css')
          end

          register_instance_option :assets do
            {
              mode: bindings[:view].asset_path("codemirror/modes/#{mode_file}.js"),
              theme: bindings[:view].asset_path("codemirror/themes/#{config[:theme]}.css")
            }
          end

          register_instance_option :config do
            default_config.merge(code_config)
          end

          register_instance_option :default_config do
            {
{'fraction_non_alphanumeric': 0.1079110462996719, 'fraction_numerical': 0.004374772147283996, 'mean_word_length': 2.0762331838565022, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '1449016', 'n_tokens_mistral': 759, 'n_tokens_neox': 723, 'n_words': 124}