Fixed stash heart not highlighted in search results.

This commit is contained in:
DebaucheryLibrarian 2024-05-01 03:57:12 +02:00
parent ef2c832605
commit dd111a6c3b
5 changed files with 64 additions and 4 deletions

View File

@ -1,5 +1,22 @@
<template> <template>
<div class="page"> <div class="page">
<form
class="search-container"
@submit.prevent="search"
>
<input
v-model="query"
type="search"
placeholder="Search channel"
class="search input"
>
<Icon
icon="search"
@click="search"
/>
</form>
<div <div
v-for="(section, index) in sections" v-for="(section, index) in sections"
:key="`section-${index}`" :key="`section-${index}`"
@ -32,7 +49,10 @@
</template> </template>
<script setup> <script setup>
import { inject } from 'vue'; import { ref, inject } from 'vue';
import { get } from '#/src/api.js';
import navigate from '#/src/navigate.js';
const pageContext = inject('pageContext'); const pageContext = inject('pageContext');
@ -84,14 +104,42 @@ const sections = [
networks, networks,
}, },
]; ];
const query = ref(pageContext.urlParsed.search.q || null);
async function search() {
await get('/entities', { query: query.value });
navigate('/channels', { q: query.value });
}
</script> </script>
<style scoped> <style scoped>
.search-container {
display: flex;
align-items: stretch;
padding: 1rem 1rem 0 1rem;
.icon {
padding: 0 1rem;
height: auto;
fill: var(--shadow);
&:hover {
cursor: pointer;
fill: var(--primary);
}
}
}
.search {
font-size: 1.1rem;
}
.networks { .networks {
display: grid; display: grid;
grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
gap: .5rem; gap: .5rem;
padding: .5rem; padding: .5rem 1rem;
} }
.section-label { .section-label {

View File

@ -79,7 +79,7 @@
> >
by by
<Link <Link
:href="`/${scene.network.type}/thumbs/${scene.network.slug}`" :href="`/${scene.network.type}/${scene.network.slug}`"
class="network-link entity-link" class="network-link entity-link"
> >
<img <img

View File

@ -10,7 +10,7 @@ export async function onBeforeRender(pageContext) {
}), { }), {
page: Number(pageContext.routeParams.page) || 1, page: Number(pageContext.routeParams.page) || 1,
limit: Number(pageContext.urlParsed.search.limit) || 30, limit: Number(pageContext.urlParsed.search.limit) || 30,
}); }, pageContext.user);
const { const {
scenes, scenes,

View File

@ -26,6 +26,14 @@ export function curateEntity(entity, context) {
export async function fetchEntities(options) { export async function fetchEntities(options) {
const entities = await knex('entities') const entities = await knex('entities')
.modify((builder) => { .modify((builder) => {
if (options.query) {
builder.where((whereBuilder) => {
whereBuilder
.whereLike('name', options.query)
.orWhereLike('slug', options.query);
});
}
if (options.type === 'primary') { if (options.type === 'primary') {
builder builder
.where('type', 'network') .where('type', 'network')

View File

@ -17,6 +17,7 @@ import errorHandler from './error.js';
import { fetchScenesApi } from './scenes.js'; import { fetchScenesApi } from './scenes.js';
import { fetchActorsApi } from './actors.js'; import { fetchActorsApi } from './actors.js';
import { fetchMoviesApi } from './movies.js'; import { fetchMoviesApi } from './movies.js';
import { fetchEntitiesApi } from './entities.js';
import { import {
setUserApi, setUserApi,
@ -139,6 +140,9 @@ export default async function initServer() {
// MOVIES // MOVIES
router.get('/api/movies', fetchMoviesApi); router.get('/api/movies', fetchMoviesApi);
// ENTITIES
router.get('/api/entities', fetchEntitiesApi);
router.get('*', async (req, res, next) => { router.get('*', async (req, res, next) => {
const pageContextInit = { const pageContextInit = {
urlOriginal: req.originalUrl, urlOriginal: req.originalUrl,