<commit_before>React               = require 'kd-react'
Router              = require 'app/components/router'
Location            = require 'react-router/lib/Location'
handlers            = require './routehandlers'
lazyrouter          = require 'app/lazyrouter'
isReactivityEnabled = require 'app/util/isReactivityEnabled'

module.exports = -> lazyrouter.bind 'activity', (type, info, state, path, ctx) ->

  handle = (name) -> handlers["handle#{name}"](info, ctx, path, state)

  reactivityRoutes = [
    'SingleChannel'
    'SinglePost'
    'SingleChannelWithSummary'
    'SinglePostWithSummary'
  ]

  if type in reactivityRoutes
    if isReactivityEnabled()
    then handleReactivity info, ctx
    # unless reactivity is enabled redirect reactivity routes to `Public`
    else ctx.handleRoute '/Activity/Public'
  else handle type


###*
 * Renders with reacth router.
###
handleReactivity = ({ query }, router) ->

  location = new Location router.currentPath, query
  routes = require './reactivityroutes'

  activityView (view) ->
    Router.run routes, location, (error, state) ->
      React.render(
        <Router {...state}>
          {routes}
        </Router>
        view.getElement()
      )


activityView = (callback) ->
  {appManager} = require('kd').singletons
  appManager.open 'Activity', (app) ->
    callback app.getView()

<commit_msg>activity: render Reactivity routes in reactivity container<commit_after>React               = require 'kd-react'
Router              = require 'app/components/router'
Location            = require 'react-router/lib/Location'
handlers            = require './routehandlers'
lazyrouter          = require 'app/lazyrouter'
isReactivityEnabled = require 'app/util/isReactivityEnabled'

module.exports = -> lazyrouter.bind 'activity', (type, info, state, path, ctx) ->

  handle = (name) -> handlers["handle#{name}"](info, ctx, path, state)

  reactivityRoutes = [
    'SingleChannel'
    'SinglePost'
    'SingleChannelWithSummary'
    'SinglePostWithSummary'
  ]

  if type in reactivityRoutes
    if isReactivityEnabled()
    then handleReactivity info, ctx
    # unless reactivity is enabled redirect reactivity routes to `Public`
    else ctx.handleRoute '/Activity/Public'
  else handle type


###*
 * Renders with reacth router.
###
handleReactivity = ({ query }, router) ->

  location = new Location router.currentPath, query
  routes = require './reactivityroutes'

  activityView (view) ->
    Router.run routes, location, (error, state) ->
      React.render(
        <Router {...state}>
          {routes}
        </Router>
        view.reactivityContainer.getElement()
      )


activityView = (callback) ->
  {appManager} = require('kd').singletons
  appManager.open 'Activity', (app) ->
    callback app.getView()


{'fraction_non_alphanumeric': 0.1198421241478292, 'fraction_numerical': 0.0, 'mean_word_length': 3.0057471264367814, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 23, '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': '5987215', 'n_tokens_mistral': 802, 'n_tokens_neox': 787, 'n_words': 204}