RootPage.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. const BasePage = require('./BasePage');
  2. const AuthorPage = require('./AuthorPage');
  3. const SeriesPage = require('./SeriesPage');
  4. const TitlePage = require('./TitlePage');
  5. class RootPage extends BasePage {
  6. constructor(config) {
  7. super(config);
  8. this.id = 'root';
  9. this.title = '';
  10. this.authorPage = new AuthorPage(config);
  11. this.seriesPage = new SeriesPage(config);
  12. this.titlePage = new TitlePage(config);
  13. }
  14. async body(req) {
  15. const result = {};
  16. if (!this.title) {
  17. const dbConfig = await this.webWorker.dbConfig();
  18. const collection = dbConfig.inpxInfo.collection.split('\n');
  19. this.title = collection[0].trim();
  20. if (!this.title)
  21. this.title = 'Неизвестная коллекция';
  22. }
  23. result.entry = [
  24. this.authorPage.myEntry(),
  25. this.seriesPage.myEntry(),
  26. this.titlePage.myEntry(),
  27. ];
  28. return this.makeBody(result, req);
  29. }
  30. }
  31. module.exports = RootPage;