<commit_before>

require 'labwiki/theme/col_content_renderer'

module OMF::Web::Theme
  class ColumnRenderer < Erector::Widget


    def initialize(title, widget, col_name, position)
      @title = title
      @widget = widget
      @col_name = col_name
      @position = position
      @content_renderer = ColumnContentRenderer.new(widget, col_name)
    end

    def content
      title = @title
      #widget = @widget
      pos = @position
      width = 400
      style = "overflow-y: hidden; left: #{width * pos}px; width: #{width}px; display: block; "
      div :class => "k-panel k-focus", :id => "kp#{pos}", :style => style do
        render_panel_titlebar(title)
        render_alert_panel
        render_panel_selector_bar
        rawtext @content_renderer.to_html()
        div :class => "mask", :style => "display: none; " do
          div :class => "loader"
        end
      end
      opts = {:sid => OMF::Web::SessionStore.session_id, :col => @col_name}
      if @widget
        opts.merge!(@widget.content_descriptor)
        # if cd = @widget.content_url
          # opts[:content] = cd
        # end
      end
      javascript %{
        require(['theme/labwiki/js/labwiki'], function(lw) {
          lw.#{@col_name}_controller.init('lw#{object_id}', #{opts.to_json});
        });
      }

    end

    def render_panel_titlebar(title)
      prefix = "kp#{@position}_"<commit_msg>If the renderer for a widget can't be created return something renderable to the front.<commit_after>

require 'labwiki/theme/col_content_renderer'

module OMF::Web::Theme
  class ColumnRenderer < Erector::Widget
    include OMF::Base::Loggable

    def initialize(title, widget, col_name, position)
      @title = title
      @widget = widget
      @col_name = col_name
      @position = position
      @content_renderer = nil
      begin
        @content_renderer = ColumnContentRenderer.new(widget, col_name)
      rescue => ex
        error "While creating renderer for '#{widget}' - #{ex}"
        debug ex.backtrace.join("\n\t")
      end
    end

    def content
      title = @title
      #widget = @widget
      pos = @position
      width = 400
      style = "overflow-y: hidden; left: #{width * pos}px; width: #{width}px; display: block; "
      div :class => "k-panel k-focus", :id => "kp#{pos}", :style => style do
        render_panel_titlebar(title)
        render_alert_panel
        render_panel_selector_bar
        if @content_renderer
          rawtext @content_renderer.to_html()
        else
          div "Internal Error", class: 'internal-error'
        end
        div :class => "mask", :style => "display: none; " do
          div :class => "loader"
        end
      end
      opts = {:sid => OMF::Web::SessionStore.session_id, :col => @col_name}
      if @widget
        opts.merge!(@widget.content_descriptor)
        # if cd = @widget.content_url
          # opts[:content] = cd
        # end
      end
      javascript %{
        require(['theme/labwiki/js/labwiki'], function(lw) {
          lw.#{@col_name}_controller.init('lw#{object_id}', #{opts.to_json});
        });
      }

    end

    def render_panel_titlebar(title)
      prefix = "kp#{@position}_"
{'fraction_non_alphanumeric': 0.12641154328732748, 'fraction_numerical': 0.0018820577164366374, 'mean_word_length': 2.421673819742489, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 20, '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': '5698269', 'n_tokens_mistral': 988, 'n_tokens_neox': 978, 'n_words': 231}