Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug report: The searching method is changed #166

Open
op06072 opened this issue Nov 12, 2024 · 0 comments
Open

Bug report: The searching method is changed #166

op06072 opened this issue Nov 12, 2024 · 0 comments

Comments

@op06072
Copy link

op06072 commented Nov 12, 2024

var get_suggestions_for_query = function(query, serial) {
        return new Promise((resolve, reject) => {
                query = query.replace(/_/g, ' ');
                
                let field = 'global', term = query, results = [];
                if (query.indexOf(':') > -1) {
                        const sides = query.split(/:/);
                        field = sides[0];
                        term = sides[1];
                }

                if (/^(?:sort|order)by(?:key|direction)?:/.test(query)) {
                        if (/^(?:sort|order)by:/.test(query)) {
                                results.push({ s: 'date',          t: undefined, u: '/', n: field });
                                results.push({ s: 'datepublished', t: undefined, u: '/date/published-all.html', n: field });
                                results.push({ s: 'popular',       t: undefined, u: '/popular/year-all.html', n: field });
                                results.push({ s: 'random',        t: undefined, u: '/search.html?orderbydirection:random', n: field });
                        } else if (/^(?:sort|order)bydirection:/.test(query)) {
                                results.push({ s: 'asc',           t: undefined, u: '/search.html?orderbydirection:asc', n: field });
                                results.push({ s: 'desc',          t: undefined, u: '/', n: field });
                                results.push({ s: 'random',        t: undefined, u: '/search.html?orderbydirection:random', n: field });
                        } else { //orderbykey
                                if (/\b(?:sort|order)by:popular/i.test($('#query-input').val())) {
                                        results.push({ s: 'today',      t: undefined, u: '/popular/today-all.html', n: field });
                                        results.push({ s: 'week',       t: undefined, u: '/popular/week-all.html',  n: field });
                                        results.push({ s: 'month',      t: undefined, u: '/popular/month-all.html', n: field });
                                        results.push({ s: 'year',       t: undefined, u: '/popular/year-all.html',  n: field });
                                } else {
                                        results.push({ s: 'added',      t: undefined, u: '/', n: field });
                                        results.push({ s: 'published',  t: undefined, u: '/date/published-all.html', n: field });
                                }
                        }
                        
                        resolve([results, serial]);
                        return;
                }
                
                const chars = term.split('').map(encode_search_query_for_url);
                let url = `//${tag_index_domain}/`+field;
                if (chars.length) {
                        url += '/'+chars.join('/');
                }
                url += '.json';

                const suggestions = fetch(url).then(response => response.json()).then(suggestions => {
                        for (const suggestion of suggestions) {
                                const ns = suggestion[2];
                
                                const tagname = sanitize(suggestion[0]);
                                let url = '/'+ns+'/'+tagname+separator+'all'+separator+'1'+extension;
                                if (ns === 'female' || ns === 'male') {
                                        url = '/tag/'+ns+':'+tagname+separator+'all'+separator+'1'+extension;
                                } else if (ns === 'language') {
                                        url = '/index-'+tagname+separator+'1'+extension;
                                }

                                results.push({ s: suggestion[0], t: suggestion[1], u: url, n: ns, });
                        }
                        resolve([results, serial]);
                }).catch(error => { resolve([[], serial]); });
                
//                 const key = hash_term(term);
//         
//                 get_node_at_address(field, 0, serial).then((node) => {
//                         if (!node) {
//                                 resolve([[], serial]);
//                                 return;
//                         }
//                         
//                         B_search(field, key, node, serial).then((data) => {
//                                 if (!data) {
//                                         resolve([[], serial]);
//                                         return;
//                                 }
//                                 
//                                 get_suggestions_from_data(field, data).then((results) => resolve([results, serial]));
//                         });
//                 });
        });
};

The search url is changed like https://tagindex.hitomi.la/global/s/o/l/e/_/f/e/m/a/l/e.json.
So tag searching feature is downed. So you need to rewrite the function.

PS. Can I use your code's logic for iOS app?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant