RootPage.js 938 B

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