<commit_before>class ActivityAppView extends KDScrollView


  headerHeight = 0


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

    options.cssClass   = "content-page activity"
    options.domId      = "content-page-activity"

    super options, data

    # FIXME: disable live updates - SY
    @appStorage = KD.getSingleton("appStorageController").storage 'Activity', '1.0.1'
    @appStorage.setValue 'liveUpdates', off


  viewAppended:->

    {entryPoint}      = KD.config
    windowController  = KD.singleton 'windowController'

    @feedWrapper      = new ActivityListContainer
    @inputWidget      = new ActivityInputWidget

    @referalBox       = new ReferalBox
    @groupListBox     = new UserGroupList
    @topicsBox        = new ActiveTopics
    @usersBox         = new ActiveUsers
    @tickerBox        = new ActivityTicker
    # TODO : if not on private group DO NOT create those ~EA
    @groupDescription = new GroupDescription
    @groupMembers     = new GroupMembers

    @mainBlock        = new KDCustomHTMLView tagName : "main" #"activity-left-block"
    @sideBlock        = new KDCustomHTMLView tagName : "aside"   #"activity-right-block"

    @groupCoverView   = new FeedCoverPhotoView

    @mainController   = KD.getSingleton("mainController")
    @mainController.on "AccountChanged", @bound "decorate"
    @mainController.on "JoinedGroup", => @inputWidget.show()

    @feedWrapper.ready =>
      @activityHeader  = @feedWrapper.controller.activityHeader
      {@filterWarning} = @feedWrapper
      {feedFilterNav}  = @activityHeader
      feedFilterNav.unsetClass 'multiple-choice on-off'

    @tickerBox.once 'viewAppended', =>
      topOffset = @tickerBox.$().position().top
      windowController.on 'ScrollHappened', =>
        # sanity check
        topOffset = @tickerBox.$().position().top  if topOffset < 200
        if document.documentElement.scrollTop > topOffset
        then @tickerBox.setClass 'fixed'
        else @tickerBox.unsetClass 'fixed'

    @decorate()

    @setLazyLoader 200

    @addSubView @groupCoverView
    @addSubView @mainBlock
    @addSubView @sideBlock

    topWidgetPlaceholder  = new KDCustomHTMLView
    leftWidgetPlaceholder = new KDCustomHTMLView

    @mainBlock.addSubView topWidgetPlaceholder
    @mainBlock.addSubView @inputWidget
    @mainBlock.addSubView @feedWrapper

    @sideBlock.addSubView @referalBox  if KD.isLoggedIn() and not @isPrivateGroup()
    @sideBlock.addSubView leftWidgetPlaceholder
    @sideBlock.addSubView @groupDescription if @isPrivateGroup()
    @sideBlock.addSubView @groupMembers if @isPrivateGroup() and ("list members" in KD.config.permissions)
    @sideBlock.addSubView @groupListBox
    @sideBlock.addSubView @topicsBox
    @sideBlock.addSubView @usersBox if "list members" in KD.config.permissions
    @sideBlock.addSubView @tickerBox

    KD.getSingleton("widgetController").showWidgets [
      { view: topWidgetPlaceholder,  key: "ActivityTop"  }
      { view: leftWidgetPlaceholder, key: "ActivityLeft" }
    ]

  isPrivateGroup :->
    {entryPoint} = KD.config
    if entryPoint?.slug isnt "koding" and entryPoint?.type is "group" then yes else no

  decorate:->
    @unsetClass "guest"
    {entryPoint, roles} = KD.config
    @setClass "guest" unless "member" in roles
    # if KD.isLoggedIn()
    @setClass 'loggedin'
    if entryPoint?.type is 'group' and 'member' not in roles
    then @inputWidget.hide()
    else @inputWidget.show()
    # else
    #   @unsetClass 'loggedin'
    #   @inputWidget.hide()
    @_windowDidResize()

  setTopicTag: (slug) ->
    return  if not slug or slug is ""
    KD.remote.api.JTag.one {slug}, null, (err, tag) =>
      @inputWidget.input.setDefaultTokens tags: [tag]

  unsetTopicTag: ->
    @inputWidget.input.setDefaultTokens tags: []


class ActivityListContainer extends JView

  constructor:(options = {}, data)->
    options.cssClass = "activity-content feeder-tabs"

    super options, data

    @controller = new ActivityListController
      delegate          : @
      itemClass         : ActivityListItemView
      showHeader        : yes
      # wrapper           : no
      # scrollView        : no

    @listWrapper = @controller.getView()
    @filterWarning = new FilterWarning

    @controller.ready => @emit "ready"

  setSize:(newHeight)->
    # @controller.scrollView.setHeight newHeight - 28 # HEIGHT OF THE LIST HEADER

  pistachio:->
    """
      {{> @filterWarning}}
      {{> @listWrapper}}
    """

class FilterWarning extends JView

  constructor:->
    super cssClass : 'filter-warning hidden'

    @warning   = new KDCustomHTMLView
    @goBack    = new KDButtonView
      cssClass : 'goback-button'
      # todo - add group context here!
      callback : => KD.singletons.router.handleRoute '/Activity'

  pistachio:->
    """
    {{> @warning}}
    {{> @goBack}}
    """

  showWarning:({text, type})->
    partialText = switch type
      when "search" then "Results for <strong>\"#{text}\"</strong>"
      else "You are now looking at activities tagged with <strong>##{text}</strong>"

    @warning.updatePartial "#{partialText}"

    @show()
<commit_msg>activity: list user groups only in "koding" group<commit_after>class ActivityAppView extends KDScrollView


  headerHeight = 0


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

    options.cssClass   = "content-page activity"
    options.domId      = "content-page-activity"

    super options, data

    # FIXME: disable live updates - SY
    @appStorage = KD.getSingleton("appStorageController").storage 'Activity', '1.0.1'
    @appStorage.setValue 'liveUpdates', off


  viewAppended:->

    {entryPoint}      = KD.config
    windowController  = KD.singleton 'windowController'

    @feedWrapper      = new ActivityListContainer
    @inputWidget      = new ActivityInputWidget

    @referalBox       = new ReferalBox
    @groupListBox     = new UserGroupList
    @topicsBox        = new ActiveTopics
    @usersBox         = new ActiveUsers
    @tickerBox        = new ActivityTicker
    # TODO : if not on private group DO NOT create those ~EA
    @groupDescription = new GroupDescription
    @groupMembers     = new GroupMembers

    @mainBlock        = new KDCustomHTMLView tagName : "main" #"activity-left-block"
    @sideBlock        = new KDCustomHTMLView tagName : "aside"   #"activity-right-block"

    @groupCoverView   = new FeedCoverPhotoView

    @mainController   = KD.getSingleton("mainController")
    @mainController.on "AccountChanged", @bound "decorate"
    @mainController.on "JoinedGroup", => @inputWidget.show()

    @feedWrapper.ready =>
      @activityHeader  = @feedWrapper.controller.activityHeader
      {@filterWarning} = @feedWrapper
      {feedFilterNav}  = @activityHeader
      feedFilterNav.unsetClass 'multiple-choice on-off'

    @tickerBox.once 'viewAppended', =>
      topOffset = @tickerBox.$().position().top
      windowController.on 'ScrollHappened', =>
        # sanity check
        topOffset = @tickerBox.$().position().top  if topOffset < 200
        if document.documentElement.scrollTop > topOffset
        then @tickerBox.setClass 'fixed'
        else @tickerBox.unsetClass 'fixed'

    @decorate()

    @setLazyLoader 200

    @addSubView @groupCoverView
    @addSubView @mainBlock
    @addSubView @sideBlock

    topWidgetPlaceholder  = new KDCustomHTMLView
    leftWidgetPlaceholder = new KDCustomHTMLView

    @mainBlock.addSubView topWidgetPlaceholder
    @mainBlock.addSubView @inputWidget
    @mainBlock.addSubView @feedWrapper

    @sideBlock.addSubView @referalBox  if KD.isLoggedIn() and not @isPrivateGroup()
    @sideBlock.addSubView leftWidgetPlaceholder
    @sideBlock.addSubView @groupDescription if @isPrivateGroup()
    @sideBlock.addSubView @groupMembers if @isPrivateGroup() and ("list members" in KD.config.permissions)
    @sideBlock.addSubView @groupListBox  if KD.getGroup().slug is "koding"
    @sideBlock.addSubView @topicsBox
    @sideBlock.addSubView @usersBox if "list members" in KD.config.permissions
    @sideBlock.addSubView @tickerBox

    KD.getSingleton("widgetController").showWidgets [
      { view: topWidgetPlaceholder,  key: "ActivityTop"  }
      { view: leftWidgetPlaceholder, key: "ActivityLeft" }
    ]

  isPrivateGroup :->
    {entryPoint} = KD.config
    if entryPoint?.slug isnt "koding" and entryPoint?.type is "group" then yes else no

  decorate:->
    @unsetClass "guest"
    {entryPoint, roles} = KD.config
    @setClass "guest" unless "member" in roles
    # if KD.isLoggedIn()
    @setClass 'loggedin'
    if entryPoint?.type is 'group' and 'member' not in roles
    then @inputWidget.hide()
    else @inputWidget.show()
    # else
    #   @unsetClass 'loggedin'
    #   @inputWidget.hide()
    @_windowDidResize()

  setTopicTag: (slug) ->
    return  if not slug or slug is ""
    KD.remote.api.JTag.one {slug}, null, (err, tag) =>
      @inputWidget.input.setDefaultTokens tags: [tag]

  unsetTopicTag: ->
    @inputWidget.input.setDefaultTokens tags: []


class ActivityListContainer extends JView

  constructor:(options = {}, data)->
    options.cssClass = "activity-content feeder-tabs"

    super options, data

    @controller = new ActivityListController
      delegate          : @
      itemClass         : ActivityListItemView
      showHeader        : yes
      # wrapper           : no
      # scrollView        : no

    @listWrapper = @controller.getView()
    @filterWarning = new FilterWarning

    @controller.ready => @emit "ready"

  setSize:(newHeight)->
    # @controller.scrollView.setHeight newHeight - 28 # HEIGHT OF THE LIST HEADER

  pistachio:->
    """
      {{> @filterWarning}}
      {{> @listWrapper}}
    """

class FilterWarning extends JView

  constructor:->
    super cssClass : 'filter-warning hidden'

    @warning   = new KDCustomHTMLView
    @goBack    = new KDButtonView
      cssClass : 'goback-button'
      # todo - add group context here!
      callback : => KD.singletons.router.handleRoute '/Activity'

  pistachio:->
    """
    {{> @warning}}
    {{> @goBack}}
    """

  showWarning:({text, type})->
    partialText = switch type
      when "search" then "Results for <strong>\"#{text}\"</strong>"
      else "You are now looking at activities tagged with <strong>##{text}</strong>"

    @warning.updatePartial "#{partialText}"

    @show()

{'fraction_non_alphanumeric': 0.10781174187287725, 'fraction_numerical': 0.0023289665211062593, 'mean_word_length': 3.068693249111725, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 59, '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': '7375055', 'n_tokens_mistral': 3180, 'n_tokens_neox': 3041, 'n_words': 727}