Небольшие доработки opds

This commit is contained in:
Book Pauk
2022-12-07 20:55:30 +07:00
parent 8ed52f62b8
commit 307b78f60d
3 changed files with 72 additions and 1 deletions

View File

@@ -0,0 +1,59 @@
const he = require('he');
const BasePage = require('./BasePage');
class SearchHelpPage extends BasePage {
constructor(config) {
super(config);
this.id = 'search_help';
this.title = 'Памятка по поиску';
}
async body(req) {
const result = {};
result.link = this.baseLinks(req, true);
const content = `
Формат поискового значения:
<ul>
<li>
без префикса: значение трактуется, как "начинается с"
</li>
<li>
префикс "=": поиск по точному совпадению
</li>
<li>
префикс "*": поиск подстроки в строке
</li>
<li>
префикс "#": поиск подстроки в строке, но только среди значений, начинающихся не с латинского или кириллического символа
</li>
<li>
префикс "?": поиск пустых значений или тех, что начинаются с этого символа
</li>
</ul>
`;
const entry = [
this.makeEntry({
id: 'help',
title: this.title,
content: {
'*ATTRS': {type: 'text/html'},
'*TEXT': he.escape(content),
},
link: [
this.downLink({href: '/book/fake-link', type: `application/fb2+zip`})
],
})
];
result.entry = entry;
return this.makeBody(result, req);
}
}
module.exports = SearchHelpPage;

View File

@@ -38,7 +38,7 @@ class SearchPage extends BasePage {
entry.push(
this.makeEntry({
id: row.id,
title: `${(from === 'series' ? 'Серия: ': '')}${row[from]}`,
title: `${(from === 'series' ? 'Серия: ': '')}${from === 'author' ? this.bookAuthor(row[from]) : row[from]}`,
link: this.navLink({href: `/${from}?${from}==${encodeURIComponent(row[from])}`}),
content: {
'*ATTRS': {type: 'text'},
@@ -88,6 +88,15 @@ class SearchPage extends BasePage {
'*TEXT': `Искать по названиям книг`,
},
}),
this.makeEntry({
id: 'search_help',
title: '[Памятка по поиску]',
link: this.acqLink({href: `/search-help`}),
content: {
'*ATTRS': {type: 'text'},
'*TEXT': `Описание формата поискового значения`,
},
}),
]
}

View File

@@ -9,6 +9,7 @@ const BookPage = require('./BookPage');
const OpensearchPage = require('./OpensearchPage');
const SearchPage = require('./SearchPage');
const SearchHelpPage = require('./SearchHelpPage');
module.exports = function(app, config) {
if (!config.opds || !config.opds.enabled)
@@ -26,6 +27,7 @@ module.exports = function(app, config) {
const opensearch = new OpensearchPage(config);
const search = new SearchPage(config);
const searchHelp = new SearchHelpPage(config);
const routes = [
['', root],
@@ -38,6 +40,7 @@ module.exports = function(app, config) {
['/opensearch', opensearch],
['/search', search],
['/search-help', searchHelp],
];
const pages = new Map();