<commit_before>stripLinks = (formatted_content) ->
  $content = $("<span>#{formatted_content}</span>")
  $content.find('a').replaceWith ->
    $span = $("<span>#{@innerHTML}</span>")
    $span.addClass @className
    $span

  $content.html()

window.ReactFeedActivitiesAutoLoading = React.createBackboneClass
  displayName: 'ReactFeedActivitiesAutoLoading'

  # this function loads more activities, if we're almost at the bottom of the list
  checkScrolledPosition: ->
    pixels_under_fold = $(document).height() - ($(window).scrollTop() + $(window).height())

    @model().loadMore() if pixels_under_fold < 700

  componentDidMount: ->
    if !@model().length
      @model().loadMore()
    @model().on "remove stopLoading", @checkScrolledPosition, @
    $(window).on "scroll", @checkScrolledPosition

  componentWillUnmount: ->
    # createBackboneClass unbinds model
    $(window).off "scroll", @checkScrolledPosition

  render: ->
    _div [],
      @model().map (model) =>
        ReactActivity model: model, key: model.id


window.ReactFeedActivitiesFixed = React.createBackboneClass
  displayName: 'ReactFeedActivitiesFixed'

  render: ->
    _div [],
      @model().map (model) =>
        ReactActivity
          key: model.id
          model: model
      ReactLoadingIndicator model: @model()


ReactActivity = React.createBackboneClass
  displayName: 'ReactActivity'

  render: ->
    switch @model().get("action")
      when "created_comment"
        ReactCreatedCommentActivity model: @model()
      when "created_sub_comment"
        ReactCreatedSubCommentActivity model: @model()
      when "followed_user"
        ReactFollowedUserActivity model: @model()


ReactCreatedCommentActivity = React.createBackboneClass
  displayName: 'ReactCreatedCommentActivity'
  mixins: [UpdateOnFeaturesChangeMixin]

  render: ->
    user = new User @model().get('user')
    fact = new Fact @model().get('fact')
    comment = new Comment @model().get('comment')
    proxy_url =
      if @canHaz('ruby_proxy')
        fact.get('proxy_open_url').replace('fct.li', 'beta.fct.li')
      else
        fact.get('proxy_open_url')

    ReactGenericActivity {
        model: user
        time: @model().get('created_at')
        href: proxy_url
        target: '_blank'
        activity_header_action: [
          _span ["feed-activity-description"],
            "commented on"
          ]
      },
      ReactFact model: fact
      _div ["feed-lowest-comment comment-content",
        dangerouslySetInnerHTML: {__html: stripLinks(comment.get('formatted_content'))}]

ReactCreatedSubCommentActivity = React.createBackboneClass
  displayName: 'ReactCreatedSubCommentActivity'
  mixins: [UpdateOnFeaturesChangeMixin]

  render: ->
    user = new User @model().get('user')
    fact = new Fact @model().get('fact')
    comment = new Comment @model().get('comment')
    sub_comment = new Comment @model().get('sub_comment')
    proxy_url =
      if @canHaz('ruby_proxy')
        fact.get('proxy_open_url').replace('fct.li', 'beta.fct.li')
      else
        fact.get('proxy_open_url')

    ReactGenericActivity {
        model: user
        time: @model().get('created_at')
        href: proxy_url
        target: '_blank'
        activity_header_action: [
          _span ["feed-activity-description"],
            "replied to"
          ]
      },
      _div ["feed-comment-box"],
        _img ['feed-comment-box-avatar', src: comment.creator().avatar_url(32)]
        _div ["feed-comment-box-balloon"],
          _div ['feed-activity-username'],
            comment.creator().get('name')
          _div ["comment-content",
            dangerouslySetInnerHTML: {__html: stripLinks(comment.get('formatted_content'))}]
      _div ["feed-lowest-comment sub-comment-content",
        dangerouslySetInnerHTML: {__html: stripLinks(sub_comment.get('formatted_content'))}]

ReactFollowedUserActivity = React.createBackboneClass
  displayName: 'ReactFollowedUserActivity'

  render: ->
    user = new User @model().get('user')
    followed_user = new User @model().get('followed_user')

    ReactGenericActivity {
        model: user,
        time: @model().get('created_at')
        href: followed_user.link()
        activity_header_action: [
            _span ["feed-activity-description"],
              Factlink.Global.t.followed
            " "
            _span ["feed-activity-username"],
              _img ["avatar-image feed-activity-followed-avatar", src: followed_user.avatar_url(32), style: {height: '32px', width: '32px'}]
              " "
              followed_user.get('name')
          ]
      }<commit_msg>Add link to followed username<commit_after>stripLinks = (formatted_content) ->
  $content = $("<span>#{formatted_content}</span>")
  $content.find('a').replaceWith ->
    $span = $("<span>#{@innerHTML}</span>")
    $span.addClass @className
    $span

  $content.html()

window.ReactFeedActivitiesAutoLoading = React.createBackboneClass
  displayName: 'ReactFeedActivitiesAutoLoading'

  # this function loads more activities, if we're almost at the bottom of the list
  checkScrolledPosition: ->
    pixels_under_fold = $(document).height() - ($(window).scrollTop() + $(window).height())

    @model().loadMore() if pixels_under_fold < 700

  componentDidMount: ->
    if !@model().length
      @model().loadMore()
    @model().on "remove stopLoading", @checkScrolledPosition, @
    $(window).on "scroll", @checkScrolledPosition

  componentWillUnmount: ->
    # createBackboneClass unbinds model
    $(window).off "scroll", @checkScrolledPosition

  render: ->
    _div [],
      @model().map (model) =>
        ReactActivity model: model, key: model.id


window.ReactFeedActivitiesFixed = React.createBackboneClass
  displayName: 'ReactFeedActivitiesFixed'

  render: ->
    _div [],
      @model().map (model) =>
        ReactActivity
          key: model.id
          model: model
      ReactLoadingIndicator model: @model()


ReactActivity = React.createBackboneClass
  displayName: 'ReactActivity'

  render: ->
    switch @model().get("action")
      when "created_comment"
        ReactCreatedCommentActivity model: @model()
      when "created_sub_comment"
        ReactCreatedSubCommentActivity model: @model()
      when "followed_user"
        ReactFollowedUserActivity model: @model()


ReactCreatedCommentActivity = React.createBackboneClass
  displayName: 'ReactCreatedCommentActivity'
  mixins: [UpdateOnFeaturesChangeMixin]

  render: ->
    user = new User @model().get('user')
    fact = new Fact @model().get('fact')
    comment = new Comment @model().get('comment')
    proxy_url =
      if @canHaz('ruby_proxy')
        fact.get('proxy_open_url').replace('fct.li', 'beta.fct.li')
      else
        fact.get('proxy_open_url')

    ReactGenericActivity {
        model: user
        time: @model().get('created_at')
        href: proxy_url
        target: '_blank'
        activity_header_action: [
          _span ["feed-activity-description"],
            "commented on"
          ]
      },
      ReactFact model: fact
      _div ["feed-lowest-comment comment-content",
        dangerouslySetInnerHTML: {__html: stripLinks(comment.get('formatted_content'))}]

ReactCreatedSubCommentActivity = React.createBackboneClass
  displayName: 'ReactCreatedSubCommentActivity'
  mixins: [UpdateOnFeaturesChangeMixin]

  render: ->
    user = new User @model().get('user')
    fact = new Fact @model().get('fact')
    comment = new Comment @model().get('comment')
    sub_comment = new Comment @model().get('sub_comment')
    proxy_url =
      if @canHaz('ruby_proxy')
        fact.get('proxy_open_url').replace('fct.li', 'beta.fct.li')
      else
        fact.get('proxy_open_url')

    ReactGenericActivity {
        model: user
        time: @model().get('created_at')
        href: proxy_url
        target: '_blank'
        activity_header_action: [
          _span ["feed-activity-description"],
            "replied to"
          ]
      },
      _div ["feed-comment-box"],
        _img ['feed-comment-box-avatar', src: comment.creator().avatar_url(32)]
        _div ["feed-comment-box-balloon"],
          _div ['feed-activity-username'],
            comment.creator().get('name')
          _div ["comment-content",
            dangerouslySetInnerHTML: {__html: stripLinks(comment.get('formatted_content'))}]
      _div ["feed-lowest-comment sub-comment-content",
        dangerouslySetInnerHTML: {__html: stripLinks(sub_comment.get('formatted_content'))}]

ReactFollowedUserActivity = React.createBackboneClass
  displayName: 'ReactFollowedUserActivity'

  render: ->
    user = new User @model().get('user')
    followed_user = new User @model().get('followed_user')

    ReactGenericActivity {
        model: user,
        time: @model().get('created_at')
        href: followed_user.link()
        activity_header_action: [
            _span ["feed-activity-description"],
              Factlink.Global.t.followed
            " "
            _a ["feed-activity-username", href: followed_user.link(), rel:"backbone"],
              _img ["avatar-image feed-activity-followed-avatar", src: followed_user.avatar_url(32), style: {height: '32px', width: '32px'}]
              " "
              followed_user.get('name')
          ]
      }
{'fraction_non_alphanumeric': 0.13394495412844037, 'fraction_numerical': 0.0023745277927684836, 'mean_word_length': 3.0269448066058238, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 37, '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': '4621896', 'n_tokens_mistral': 2732, 'n_tokens_neox': 2730, 'n_words': 517}