<commit_before>import domify from 'domify';

import Page from '../base/page';
import View from '../base/view';
import Event from '../models/event';
import Place from '../models/place';
import Feeder from '../components/feeder';

import template from '../../templates/pages/search.ejs';
import eventTemplate from '../../templates/search-event.ejs';
import placeTemplate from '../../templates/search-place.ejs';


export default class SearchPage extends Page {
  constructor({app, location, query, feed}) {
    super({app});

    this.location = location;
    this.query = query;
    this.feed = feed;
  }

  getHTML() {
    return this.app.renderTemplate(template, {
      query: this.query,
    });
  }

  getTitle() {
    return `Поиск «${this.query}»`;
  }

  mount(element) {
    const feeder = new Feeder(
      element.querySelector('.search-feed'),
      this.feed,
      data => this.buildItemElement(data)
    )
    feeder.loadNewFeed();
  }

  buildItemElement(data) {
    if (data.type == 'place') {
      const place = new Place(data);
      return domify(this.app.renderTemplate(placeTemplate, {place}));
    } else if (data.type == 'event') {
      const event = new Event(data);
      return domify(this.app.renderTemplate(eventTemplate, {event}));
    } else {
      throw new Error(`Unknown item type: ${data.type}`);
    }
  }
}<commit_msg>Allow transitioning between search pages<commit_after>import domify from 'domify';

import Page from '../base/page';
import View from '../base/view';
import Event from '../models/event';
import Place from '../models/place';
import Feeder from '../components/feeder';

import template from '../../templates/pages/search.ejs';
import eventTemplate from '../../templates/search-event.ejs';
import placeTemplate from '../../templates/search-place.ejs';


export default class SearchPage extends Page {
  constructor({app, location, query, feed}) {
    super({app});

    this.location = location;
    this.query = query;
    this.feed = feed;
  }

  getHTML() {
    return this.app.renderTemplate(template, {
      query: this.query,
    });
  }

  getTitle() {
    return `Поиск «${this.query}»`;
  }

  mount(element) {
    const feeder = new Feeder(
      element.querySelector('.search-feed'),
      this.feed,
      data => this.buildItemElement(data)
    )
    feeder.loadNewFeed();
  }

  buildItemElement(data) {
    if (data.type == 'place') {
      const place = new Place(data);
      return domify(this.app.renderTemplate(placeTemplate, {place}));
    } else if (data.type == 'event') {
      const event = new Event(data);
      return domify(this.app.renderTemplate(eventTemplate, {event}));
    } else {
      throw new Error(`Unknown item type: ${data.type}`);
    }
  }

  canTransitionFrom(other) {
    return other instanceof SearchPage;
  }
}
{'fraction_non_alphanumeric': 0.1566607460035524, 'fraction_numerical': 0.0, 'mean_word_length': 3.0634920634920637, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6244666', 'n_tokens_mistral': 853, 'n_tokens_neox': 848, 'n_words': 215}