<commit_before>class TopicsListItemView extends KDListItemView
  constructor:(options,data)->
    options = options ? {} 
    options.type = "topics"
    options.bind = "mouseenter mouseleave"
    super options,data
    
    @titleLink = new KDCustomHTMLView
      tagName     : 'a'
      attributes  :
        href      : '#'
      pistachio   : '{{#(title)}}'
    , data
    
    @titleLink.registerListener
      KDEventTypes  : 'click'
      listener      : @
      callback      : (pubInst, event)=>
        @titleReceivedClick()
        event.stopPropagation()
        no

  titleReceivedClick:(event)->
    tag = @getData()
    @propagateEvent KDEventType: 'TopicWantsToExpand', tag
  
  viewAppended:->
    @setClass "topic-item"
    
    @setTemplate @pistachio()
    @template.update()
    
    if @getData().followee
      @unfollowTheButton()
    else
      @followTheButton()
  
  followTheButton:->
    {profile} = topic = @getData()
    
    @followButton.destroy() if @followButton?
    @followButton = new KDButtonView 
      style : 'follow-btn'
      title : "Follow"
      icon  : no
      callback: =>
        if KD.isLoggedIn()
          topic.followee = yes
          @unfollowTheButton()
          topic.follow (err,res)=>
            if err
              topic.followee = no
              @followTheButton()

    @addSubView @followButton, '.button-container'
  
  unfollowTheButton:()->
    {profile} = topic = @getData()
    
    @followButton.destroy() if @followButton?
    @followButton = new KDButtonView 
      style : 'follow-btn following-btn following-topic'
      title : "Following"
      callback: =>
        topic.followee = no
        if KD.isLoggedIn()
          @followTheButton()
          topic.followee = no
          topic.unfollow (err,res)=>
            if err
              topic.followee = yes
              @unfollowTheButton()
    @addSubView @followButton, '.button-container'
  
  setFollowerCount:(count)->
    @$('.followers a').html count

  mouseEnter:->
    # @_mouseenterIntent = setTimeout ()=>
    #   @expandItem()
    # ,500

  mouseLeave:->
    # clearTimeout @_mouseenterIntent if @_mouseenterIntent
    # @collapseItem()
  
  expandItem:->
    return unless @_trimmedBody
    list = @getDelegate()
    $item   = @$()
    $parent = list.$()
    @$clone = $clone = $item.clone()

    pos = $item.position()
    pos.height = $item.outerHeight()
    $clone.addClass "clone"
    $clone.css pos
    $clone.css "background-color" : "white"
    $clone.find('.topictext article').html @getData().body
    $parent.append $clone
    $clone.addClass "expand"
    $clone.on "mouseleave",=>@collapseItem()

  collapseItem:->
    return unless @_trimmedBody
    # @$clone.remove()

  pistachio:->
    """
    <div class="topictext">
      {h3{> @titleLink}}
      {article{#(body)}}
      <div class="topicmeta clearfix">
        <div class="topicstats">
          <p class="posts">
            <span class="icon"></span>
            <a href="#">{{#(counts.tagged) or 0}}</a> Posts
          </p>
          <p class="followers">
            <span class="icon"></span>
            <a href="#">{{#(counts.followers) or 0}}</a> Followers
          </p>
        </div>
        <div class="button-container"></div> 
      </div>
    </div>
    """

  # 
  # partial:(data)->
  #   counts = posts : 223, followers : 4234
  #   data.title or= "couldn't fetch..."
  #   data.body or= "couldn't fetch..."
  #   # @_trimmedBody = "#{data.body.slice 0,110}... <i><a href='#'>See more</a></i>" if data.body.length > 110
  #   @_trimmedBody = "#{data.body.slice 0,110}..." if data.body.length > 110
  #   """
  #     <div class="topictext">
  #       <h3><a href="#">#{data.title}</a></h3>
  #       <article>#{@_trimmedBody ? data.body}</article>
  # 
  #       <div class="topicmeta clearfix">
  # 
  #         <div class="topicstats">
  #           <p class="posts">
  #             <span class="icon"></span>
  #             <a href="#">#{counts.posts}</a> Posts
  #           </p>
  #           <p class="followers">
  #             <span class="icon"></span>
  #             <a href="#">#{counts.followers}</a> Followers
  #           </p>
  #         </div>
  #         <div class="button-container"></div> 
  #       </div>
  #     </div>
  #   """
    
  refreshPartial: ->
    @skillList?.destroy()
    @locationList?.destroy()
    super
    @_addSkillList()
    @_addLocationsList()
    
  _addSkillList: ->
    @skillList = new ProfileSkillsList {}, {KDDataPath:"Data.skills", KDDataSource: @getData()}
    @addSubView @skillList, '.profile-meta'
  
  _addLocationsList: ->
    @locationList = new TopicsLocationView {}, @getData().locations 
    @addSubView @locationList, '.personal'

class ModalTopicsListItem extends TopicsListItemView

  pistachio:->
    """
    <div class="topictext">
      <div class="topicmeta">
        <div class="button-container"></div>
        {span.ttag{> @titleLink}}
        <div class="stats">
          <p class="posts">
            <span class="icon"></span>
            <a href="#">{{#(counts.tagged) or 0}}</a> Posts
          </p>
          <p class="fers">
            <span class="icon"></span>
            <a href="#">{{#(counts.followers) or 0}}</a> Followers
          </p>
        </div>
      </div>
    </div>
    """<commit_msg> - Make titleLinks clickable in more tags window<commit_after>class TopicsListItemView extends KDListItemView
  constructor:(options,data)->
    options = options ? {} 
    options.type = "topics"
    options.bind = "mouseenter mouseleave"
    super options,data
    
    @titleLink = new KDCustomHTMLView
      tagName     : 'a'
      attributes  :
        href      : '#'
      pistachio   : '{{#(title)}}'
    , data
    
    @titleLink.registerListener
      KDEventTypes  : 'click'
      listener      : @
      callback      : (pubInst, event)=>
        @titleReceivedClick()
        event.stopPropagation()
        no

  titleReceivedClick:(event)->
    tag = @getData()
    @propagateEvent KDEventType: 'TopicWantsToExpand', tag
  
  viewAppended:->
    @setClass "topic-item"
    
    @setTemplate @pistachio()
    @template.update()
    
    if @getData().followee
      @unfollowTheButton()
    else
      @followTheButton()
  
  followTheButton:->
    {profile} = topic = @getData()
    
    @followButton.destroy() if @followButton?
    @followButton = new KDButtonView 
      style : 'follow-btn'
      title : "Follow"
      icon  : no
      callback: =>
        if KD.isLoggedIn()
          topic.followee = yes
          @unfollowTheButton()
          topic.follow (err,res)=>
            if err
              topic.followee = no
              @followTheButton()

    @addSubView @followButton, '.button-container'
  
  unfollowTheButton:()->
    {profile} = topic = @getData()
    
    @followButton.destroy() if @followButton?
    @followButton = new KDButtonView 
      style : 'follow-btn following-btn following-topic'
      title : "Following"
      callback: =>
        topic.followee = no
        if KD.isLoggedIn()
          @followTheButton()
          topic.followee = no
          topic.unfollow (err,res)=>
            if err
              topic.followee = yes
              @unfollowTheButton()
    @addSubView @followButton, '.button-container'
  
  setFollowerCount:(count)->
    @$('.followers a').html count

  mouseEnter:->
    # @_mouseenterIntent = setTimeout ()=>
    #   @expandItem()
    # ,500

  mouseLeave:->
    # clearTimeout @_mouseenterIntent if @_mouseenterIntent
    # @collapseItem()
  
  expandItem:->
    return unless @_trimmedBody
    list = @getDelegate()
    $item   = @$()
    $parent = list.$()
    @$clone = $clone = $item.clone()

    pos = $item.position()
    pos.height = $item.outerHeight()
    $clone.addClass "clone"
    $clone.css pos
    $clone.css "background-color" : "white"
    $clone.find('.topictext article').html @getData().body
    $parent.append $clone
    $clone.addClass "expand"
    $clone.on "mouseleave",=>@collapseItem()

  collapseItem:->
    return unless @_trimmedBody
    # @$clone.remove()

  pistachio:->
    """
    <div class="topictext">
      {h3{> @titleLink}}
      {article{#(body)}}
      <div class="topicmeta clearfix">
        <div class="topicstats">
          <p class="posts">
            <span class="icon"></span>
            <a href="#">{{#(counts.tagged) or 0}}</a> Posts
          </p>
          <p class="followers">
            <span class="icon"></span>
            <a href="#">{{#(counts.followers) or 0}}</a> Followers
          </p>
        </div>
        <div class="button-container"></div> 
      </div>
    </div>
    """

  # 
  # partial:(data)->
  #   counts = posts : 223, followers : 4234
  #   data.title or= "couldn't fetch..."
  #   data.body or= "couldn't fetch..."
  #   # @_trimmedBody = "#{data.body.slice 0,110}... <i><a href='#'>See more</a></i>" if data.body.length > 110
  #   @_trimmedBody = "#{data.body.slice 0,110}..." if data.body.length > 110
  #   """
  #     <div class="topictext">
  #       <h3><a href="#">#{data.title}</a></h3>
  #       <article>#{@_trimmedBody ? data.body}</article>
  # 
  #       <div class="topicmeta clearfix">
  # 
  #         <div class="topicstats">
  #           <p class="posts">
  #             <span class="icon"></span>
  #             <a href="#">#{counts.posts}</a> Posts
  #           </p>
  #           <p class="followers">
  #             <span class="icon"></span>
  #             <a href="#">#{counts.followers}</a> Followers
  #           </p>
  #         </div>
  #         <div class="button-container"></div> 
  #       </div>
  #     </div>
  #   """
    
  refreshPartial: ->
    @skillList?.destroy()
    @locationList?.destroy()
    super
    @_addSkillList()
    @_addLocationsList()
    
  _addSkillList: ->
    @skillList = new ProfileSkillsList {}, {KDDataPath:"Data.skills", KDDataSource: @getData()}
    @addSubView @skillList, '.profile-meta'
  
  _addLocationsList: ->
    @locationList = new TopicsLocationView {}, @getData().locations
    @addSubView @locationList, '.personal'

class ModalTopicsListItem extends TopicsListItemView

  constructor:(options,data)->

    super options,data

    @titleLink = new KDCustomHTMLView
      tagName     : 'a'
      attributes  :
        href      : '#'
        class     : 'ttag'
      pistachio   : '{{#(title)}}'
    , data

    @titleLink.registerListener
      KDEventTypes  : 'click'
      listener      : @
      callback      : (pubInst, event)=>
        tag = @getData()
        appManager.tell "Topics", "createContentDisplay", tag
        event.stopPropagation()
        no

  pistachio:->
    """
    <div class="topictext">
      <div class="topicmeta">
        <div class="button-container"></div>
        {{> @titleLink}}
        <div class="stats">
          <p class="posts">
            <span class="icon"></span>
            <a href="#">{{#(counts.tagged) or 0}}</a> Posts
          </p>
          <p class="fers">
            <span class="icon"></span>
            <a href="#">{{#(counts.followers) or 0}}</a> Followers
          </p>
        </div>
      </div>
    </div>
    """
{'fraction_non_alphanumeric': 0.16143176733780762, 'fraction_numerical': 0.005548098434004474, 'mean_word_length': 2.09070796460177, 'pattern_counts': {'":': 0, '<': 143, '<?xml version=': 0, '>': 199, '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': '2373010', 'n_tokens_mistral': 3671, 'n_tokens_neox': 3558, 'n_words': 694}