<commit_before>import config from '../config/config';
import title from '../title/title';
import o from 'component-dom';
import bus from 'bus';
import debug from 'debug';
import page from 'page';
import request from '../request/request';
import user from '../user/user';
import Article from '../proposal-article/proposal-article';
import Options from '../proposal-options/proposal-options';
import Comments from '../comments-view/view';
import sidebar from '../sidebar/main';
import filter from '../topics-filter/topics-filter';
import locker from '../browser-lock/locker';
import { getForum } from '../forum-middlewares/forum-middlewares';
import forumRouter from '../forum-router/forum-router.js';

const log = debug('democracyos:topic:page');

page(forumRouter('/topic/:id'), user.optional, getForum, load, (ctx, next) => {
  bus.emit('page:render', ctx.topic);
  log(`rendering Topic ${ctx.params.id}`);

  if (!ctx.topic) {
    log('Topic %s not found', ctx.params.id);
    return next();
  }

  sidebar.forum(ctx.forum.name);

  // Render sidebar list
  sidebar.ready(() => {
    let select = () => {
      log('select sidebar topic %s', ctx.topic.id);
      return setTimeout(sidebar.select.bind(sidebar, ctx.topic.id), 0);<commit_msg>fix topic show on singleForum<commit_after>import config from '../config/config';
import title from '../title/title';
import o from 'component-dom';
import bus from 'bus';
import debug from 'debug';
import page from 'page';
import request from '../request/request';
import user from '../user/user';
import Article from '../proposal-article/proposal-article';
import Options from '../proposal-options/proposal-options';
import Comments from '../comments-view/view';
import sidebar from '../sidebar/main';
import filter from '../topics-filter/topics-filter';
import locker from '../browser-lock/locker';
import { getForum } from '../forum-middlewares/forum-middlewares';
import forumRouter from '../forum-router/forum-router.js';

const log = debug('democracyos:topic:page');

page(forumRouter('/topic/:id'), user.optional, getForum, load, (ctx, next) => {
  bus.emit('page:render', ctx.topic);
  log(`rendering Topic ${ctx.params.id}`);

  if (!ctx.topic) {
    log('Topic %s not found', ctx.params.id);
    return next();
  }

  if (ctx.forum) sidebar.forum(ctx.forum.name);

  // Render sidebar list
  sidebar.ready(() => {
    let select = () => {
      log('select sidebar topic %s', ctx.topic.id);
      return setTimeout(sidebar.select.bind(sidebar, ctx.topic.id), 0);
{'fraction_non_alphanumeric': 0.17614314115308152, 'fraction_numerical': 0.0007952286282306163, 'mean_word_length': 4.093117408906883, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '7615286', 'n_tokens_mistral': 778, 'n_tokens_neox': 748, 'n_words': 211}