<commit_before>class AppsListItemView extends KDListItemView

  constructor:(options = {},data)->

    options.type = "appstore"

    super options,data

    {icns, name, version, authorNick} = @getData().manifest
    if icns and (icns['256'] or icns['512'] or icns['128'] or icns['160'] or icns['64'])
      thumb = "#{KD.appsUri}/#{authorNick}/#{name}/#{version}/#{if icns then icns['160'] or icns['128'] or icns['256'] or icns['512'] or icns['64']}"
    else
      thumb = "#{KD.apiUri + '/images/default.app.listthumb.png'}"

    @thumbnail = new KDCustomHTMLView
      tagName     : "img"
      bind        : "error"
      error       : =>
        @thumbnail.$().attr "src", "/images/default.app.listthumb.png"
      attributes  :
        src       : thumb

  click:(event)->
    if $(event.target).is ".appdetails h3 a"
      event.stopPropagation()
      event.preventDefault()
      list = @getDelegate()
      app  = @getData()
      list.propagateEvent KDEventType : "AppWantsToExpand", app

  viewAppended:->

    # for i in [0,1]
    #   titleView = new KDCustomHTMLView opts
    #   @["title#{i}"] = titleView

    @setClass "waits-approve"  if not @getData().approved

    @setTemplate @pistachio()
    @template.update()


    if @getData().installed
      @alreadyInstalledText()
    else
      @createInstallButton()

  createInstallButton:->
    app = @getData()

    @installButton.destroy() if @installButton?
    @installButton = new KDButtonView
      title : "Install"
      icon  : no
      callback: =>
        list = @getDelegate()
        list.propagateEvent KDEventType : "AppWantsToExpand", app

    @addSubView @installButton, '.button-container'

  alreadyInstalledText:->

    @installButton.destroy() if @installButton?
    @installButton = new KDButtonView
      title     : "Installed"
      icon      : no
      disabled  : yes
    @addSubView @installButton, '.button-container'

  pistachio:->
    """
    <figure>
      {{> @thumbnail}}
    </figure>
    <div class="appmeta clearfix">
      <h3>{a[href=#]{#(title)}}</h3>
      <div class="appstats">
        <p class="installs">
          <span class="icon"></span>
          <a href="#">{{#(counts.installed) or 0}}</a> Installs
        </p>
        <p class="followers">
          <span class="icon"></span>
          <a href="#">{{#(counts.followers) or 0}}</a> Followers
        </p>
      </div>
    </div>
    <div class="appdetails">
      <h3>{a[href=#]{#(title)}}</h3>
      <article>{{@utils.shortenText #(body)}}</article>
      <div class="button-container">
      </div>
    </div>
    """<commit_msg>hrmmm<commit_after>class AppsListItemView extends KDListItemView

  constructor:(options = {},data)->

    options.type = "appstore"

    super options,data

    {icns, name, version, authorNick} = @getData().manifest
    if icns and (icns['256'] or icns['512'] or icns['128'] or icns['160'] or icns['64'])
      thumb = "#{KD.appsUri}/#{authorNick}/#{name}/#{version}/#{if icns then icns['160'] or icns['128'] or icns['256'] or icns['512'] or icns['64']}"
    else
      thumb = "#{KD.apiUri + '/images/default.app.listthumb.png'}"

    @thumbnail = new KDCustomHTMLView
      tagName     : "img"
      bind        : "error"
      error       : =>
        @thumbnail.$().attr "src", "/images/default.app.listthumb.png"
      attributes  :
        src       : thumb

  click:(event)->
    if $(event.target).is ".appdetails h3 a"
      event.stopPropagation()
      event.preventDefault()
      list = @getDelegate()
      app  = @getData()
      list.propagateEvent KDEventType : "AppWantsToExpand", app

  viewAppended:->

    # for i in [0,1]
    #   titleView = new KDCustomHTMLView opts
    #   @["title#{i}"] = titleView

    @setClass "waits-approve"  if not @getData().approved

    @setTemplate @pistachio()
    @template.update()


    if @getData().installed
      @alreadyInstalledText()
    else
      @createInstallButton()

  createInstallButton:->
    app = @getData()

    @installButton.destroy() if @installButton?
    @installButton = new KDButtonView
      title : "Install"
      icon  : no
      callback: =>
        list = @getDelegate()
        list.propagateEvent KDEventType : "AppWantsToExpand", app

    @addSubView @installButton, '.button-container'

  alreadyInstalledText:->

    @installButton.destroy() if @installButton?
    @installButton = new KDButtonView
      title     : "Installed"
      icon      : no
      disabled  : yes
    @addSubView @installButton, '.button-container'

  pistachio:->
    """
    <figure>
      {{> @thumbnail}}
    </figure>
    <div class="appmeta clearfix">
      <h3>{a[href="#"]{#(title)}}</h3>
      <div class="appstats">
        <p class="installs">
          <span class="icon"></span>
          <a href="#">{{#(counts.installed) || 0}}</a> Installs
        </p>
        <p class="followers">
          <span class="icon"></span>
          <a href="#">{{#(counts.followers) || 0}}</a> Followers
        </p>
      </div>
    </div>
    <div class="appdetails">
      <h3>{a[href="#"]{#(title)}}</h3>
      <article>{{@utils.shortenText #(body)}}</article>
      <div class="button-container">
      </div>
    </div>
    """
{'fraction_non_alphanumeric': 0.17018824433346139, 'fraction_numerical': 0.014214368036880523, 'mean_word_length': 2.563997262149213, 'pattern_counts': {'":': 0, '<': 59, '<?xml version=': 0, '>': 77, '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': '2772991', 'n_tokens_mistral': 1793, 'n_tokens_neox': 1688, 'n_words': 354}