<commit_before>React = require 'react'
PromiseRenderer = require '../components/promise-renderer'
parseSection = require './lib/parse-section'
talkConfig = require './config'

PAGE_SIZE = talkConfig.discussionPageSize

module?.exports = React.createClass
  displayName: 'TalkCommentLink'

  propTypes:
    comment: React.PropTypes.object  # Comment resource
    pageSize: React.PropTypes.number # Optional: pass this in to override default PAGE_SIZE

  getDefaultProps: ->
    pageSize: PAGE_SIZE

  projectComment: ->
    @props.comment.section isnt 'zooniverse'

  pathname: ->
    if process.env.NON_ROOT == 'true' then window.location.pathname else ''

  projectCommentUrl: ->
    {comment} = @props
    [ownerName, projectName] = comment.project_slug.split('/')
    href= "projects/#{ownerName}/#{projectName}/talk/#{comment.board_id}/#{comment.discussion_id}?comment=#{comment.id}"
    window.location.origin + @pathname() + href

  mainTalkCommentUrl: ->
    {comment} = @props
    window.location.origin + @pathname() +
    "/talk/#{comment.board_id}/#{comment.discussion_id}?comment=#{comment.id}"

  render: ->
    <div className="talk-comment-link">
      {if @projectComment()
        <a href={@projectCommentUrl()}>
          {@props.children ? @projectCommentUrl()}
        </a>

      else
        <a href={@mainTalkCommentUrl()}>
          {@props.children ? @mainTalkCommentUrl()}
        </a>}
    </div><commit_msg>Fixes links from comment notifications.  Closes #2004<commit_after>React = require 'react'
PromiseRenderer = require '../components/promise-renderer'
parseSection = require './lib/parse-section'
talkConfig = require './config'

PAGE_SIZE = talkConfig.discussionPageSize

module?.exports = React.createClass
  displayName: 'TalkCommentLink'

  propTypes:
    comment: React.PropTypes.object  # Comment resource
    pageSize: React.PropTypes.number # Optional: pass this in to override default PAGE_SIZE

  getDefaultProps: ->
    pageSize: PAGE_SIZE

  projectComment: ->
    @props.comment.section isnt 'zooniverse'

  pathname: ->
    if process.env.NON_ROOT == 'true' then window.location.pathname else ''

  projectCommentUrl: ->
    {comment} = @props
    [ownerName, projectName] = comment.project_slug.split('/')
    href = "/projects/#{ownerName}/#{projectName}/talk/#{comment.board_id}/#{comment.discussion_id}?comment=#{comment.id}"
    window.location.origin + @pathname() + href

  mainTalkCommentUrl: ->
    {comment} = @props
    window.location.origin + @pathname() +
    "/talk/#{comment.board_id}/#{comment.discussion_id}?comment=#{comment.id}"

  render: ->
    <div className="talk-comment-link">
      {if @projectComment()
        <a href={@projectCommentUrl()}>
          {@props.children ? @projectCommentUrl()}
        </a>

      else
        <a href={@mainTalkCommentUrl()}>
          {@props.children ? @mainTalkCommentUrl()}
        </a>}
    </div>
{'fraction_non_alphanumeric': 0.14673539518900344, 'fraction_numerical': 0.0013745704467353953, 'mean_word_length': 3.613312202852615, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 27, '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': '6856222', 'n_tokens_mistral': 891, 'n_tokens_neox': 872, 'n_words': 167}