This commit is contained in:
Simon Cambier
2022-08-26 08:23:58 +02:00
parent d6455eafa7
commit b73c5a9391
23 changed files with 923 additions and 2188 deletions

View File

@@ -1,2 +1,9 @@
<script lang="ts"></script>
<span class="suggestion-flair" aria-label="Not created yet, select to create"><svg viewBox="0 0 100 100" class="add-note-glyph" width="16" height="16"><path fill="currentColor" stroke="currentColor" d="M23.3,6.7c-3.7,0-6.7,3-6.7,6.7v73.3c0,3.7,3,6.7,6.7,6.7h28.4c-3.2-4.8-5.1-10.5-5.1-16.7c0-16.6,13.4-30,30-30 c2.3,0,4.5,0.3,6.7,0.8V31.7c0-0.9-0.3-1.7-1-2.4L60.7,7.6c-0.6-0.6-1.5-1-2.4-1L23.3,6.7z M56.7,13L77,33.3H60 c-1.8,0-3.3-1.5-3.3-3.3L56.7,13z M76.7,53.3c-12.9,0-23.3,10.4-23.3,23.3S63.8,100,76.7,100S100,89.6,100,76.7 S89.6,53.3,76.7,53.3z M76.7,63.3c1.8,0,3.3,1.5,3.3,3.3v6.7h6.7c1.8,0,3.3,1.5,3.3,3.3c0,1.8-1.5,3.3-3.3,3.3H80v6.7 c0,1.8-1.5,3.3-3.3,3.3c-1.8,0-3.3-1.5-3.3-3.3V80h-6.7c-1.8,0-3.3-1.5-3.3-3.3s1.5-3.3,3.3-3.3h6.7v-6.7 C73.3,64.8,74.8,63.3,76.7,63.3L76.7,63.3z"></path></svg></span>
<span class="suggestion-flair" aria-label="Not created yet, select to create"
><svg viewBox="0 0 100 100" class="add-note-glyph" width="16" height="16"
><path
fill="currentColor"
stroke="currentColor"
d="M23.3,6.7c-3.7,0-6.7,3-6.7,6.7v73.3c0,3.7,3,6.7,6.7,6.7h28.4c-3.2-4.8-5.1-10.5-5.1-16.7c0-16.6,13.4-30,30-30 c2.3,0,4.5,0.3,6.7,0.8V31.7c0-0.9-0.3-1.7-1-2.4L60.7,7.6c-0.6-0.6-1.5-1-2.4-1L23.3,6.7z M56.7,13L77,33.3H60 c-1.8,0-3.3-1.5-3.3-3.3L56.7,13z M76.7,53.3c-12.9,0-23.3,10.4-23.3,23.3S63.8,100,76.7,100S100,89.6,100,76.7 S89.6,53.3,76.7,53.3z M76.7,63.3c1.8,0,3.3,1.5,3.3,3.3v6.7h6.7c1.8,0,3.3,1.5,3.3,3.3c0,1.8-1.5,3.3-3.3,3.3H80v6.7 c0,1.8-1.5,3.3-3.3,3.3c-1.8,0-3.3-1.5-3.3-3.3V80h-6.7c-1.8,0-3.3-1.5-3.3-3.3s1.5-3.3,3.3-3.3h6.7v-6.7 C73.3,64.8,74.8,63.3,76.7,63.3L76.7,63.3z" /></svg
></span>

View File

@@ -1,32 +1,31 @@
<script lang="ts">
import { debounce } from "obsidian"
import { toggleInputComposition } from "src/globals"
import { createEventDispatcher, onMount, tick } from "svelte"
import { debounce } from 'obsidian'
import { toggleInputComposition } from 'src/globals'
import { createEventDispatcher, onMount, tick } from 'svelte'
export let value = ""
const dispatch = createEventDispatcher()
export let value = ''
const dispatch = createEventDispatcher()
let elInput: HTMLInputElement
let elInput: HTMLInputElement
onMount(async () => {
await tick()
elInput.focus()
elInput.select()
})
onMount(async () => {
await tick()
elInput.focus()
elInput.select()
})
const debouncedOnInput = debounce(() => {
dispatch("input", value)
}, 100)
const debouncedOnInput = debounce(() => {
dispatch('input', value)
}, 100)
</script>
<input
bind:value
bind:this={elInput}
on:input={debouncedOnInput}
on:compositionstart={(_) => toggleInputComposition(true)}
on:compositionend={(_) => toggleInputComposition(false)}
on:compositionstart={_ => toggleInputComposition(true)}
on:compositionend={_ => toggleInputComposition(false)}
type="text"
class="prompt-input"
placeholder="Type to search through your notes"
spellcheck="false"
/>
spellcheck="false" />

View File

@@ -1,6 +1,6 @@
<script lang="ts">
</script>
<div class="prompt-results" on:mousedown={(e) => e.preventDefault()}>
<div class="prompt-results" on:mousedown={e => e.preventDefault()}>
<slot />
</div>

View File

@@ -1,145 +1,147 @@
<script lang="ts" context="module">
let lastSearch = ""
let lastSearch = ''
</script>
<script lang="ts">
import InputSearch from "./InputSearch.svelte"
import {
eventBus,
excerptAfter,
type ResultNote,
type SearchMatch,
} from "src/globals"
import { loopIndex } from "src/utils"
import { onDestroy, onMount, tick } from "svelte"
import { MarkdownView } from "obsidian"
import { getSuggestions } from "src/search"
import ModalContainer from "./ModalContainer.svelte"
import { OmnisearchInFileModal, OmnisearchVaultModal } from "src/modals"
import ResultItemInFile from "./ResultItemInFile.svelte"
import { Query } from "src/query"
import { openNote } from "src/notes";
import InputSearch from './InputSearch.svelte'
import {
eventBus,
excerptAfter,
type ResultNote,
type SearchMatch,
} from 'src/globals'
import { loopIndex } from 'src/utils'
import { onDestroy, onMount, tick } from 'svelte'
import { MarkdownView } from 'obsidian'
import { getSuggestions } from 'src/search'
import ModalContainer from './ModalContainer.svelte'
import { OmnisearchInFileModal, OmnisearchVaultModal } from 'src/modals'
import ResultItemInFile from './ResultItemInFile.svelte'
import { Query } from 'src/query'
import { openNote } from 'src/notes'
export let modal: OmnisearchInFileModal
export let parent: OmnisearchVaultModal | null = null
export let singleFilePath = ""
export let searchQuery: string
export let modal: OmnisearchInFileModal
export let parent: OmnisearchVaultModal | null = null
export let singleFilePath = ''
export let searchQuery: string
let groupedOffsets: number[] = []
let selectedIndex = 0
let note: ResultNote | null = null
let query: Query
let groupedOffsets: number[] = []
let selectedIndex = 0
let note: ResultNote | null = null
let query: Query
onMount(() => {
if (lastSearch && !searchQuery) {
searchQuery = lastSearch
}
eventBus.enable("infile")
eventBus.on("infile", "enter", openSelection)
eventBus.on("infile", "arrow-up", () => moveIndex(-1))
eventBus.on("infile", "arrow-down", () => moveIndex(1))
eventBus.on("infile", "tab", switchToVaultModal)
})
onDestroy(() => {
eventBus.disable("infile")
})
$: (async () => {
if (searchQuery) {
query = new Query(searchQuery)
note = (await getSuggestions(query, { singleFilePath }))[0] ?? null
lastSearch = searchQuery
}
selectedIndex = 0
scrollIntoView()
})()
$: {
if (note) {
const groups = getGroups(note.matches)
groupedOffsets = groups.map((group) =>
Math.round((group.first()!.offset + group.last()!.offset) / 2)
)
// console.log(groups)
// console.log(groupedOffsets)
}
}
/**
* Group together close matches to reduce the number of results
*/
function getGroups(matches: SearchMatch[]): SearchMatch[][] {
const groups: SearchMatch[][] = []
let lastOffset = -1
let count = 0 // TODO: FIXME: this is a hack to avoid infinite loops
while (true) {
const group = getGroupedMatches(matches, lastOffset, excerptAfter)
if (!group.length) break
lastOffset = group.last()!.offset
groups.push(group)
if (++count > 100) break
}
return groups
}
function getGroupedMatches(
matches: SearchMatch[],
offsetFrom: number,
maxLen: number
): SearchMatch[] {
const first = matches.find((m) => m.offset > offsetFrom)
if (!first) return []
return matches.filter(
(m) => m.offset > offsetFrom && m.offset <= first.offset + maxLen
)
}
function moveIndex(dir: 1 | -1): void {
selectedIndex = loopIndex(selectedIndex + dir, groupedOffsets.length)
scrollIntoView()
}
async function scrollIntoView(): Promise<void> {
await tick()
const elem = document.querySelector(`[data-result-id="${selectedIndex}"]`)
elem?.scrollIntoView({ behavior: "auto", block: "nearest" })
}
async function openSelection(evt?: MouseEvent | KeyboardEvent): Promise<void> {
if (note) {
modal.close()
if (parent) parent.close()
// Open (or switch focus to) the note
await openNote(note, evt?.ctrlKey)
// Move cursor to the match
const view = app.workspace.getActiveViewOfType(MarkdownView)
if (!view) {
throw new Error("OmniSearch - No active MarkdownView")
onMount(() => {
if (lastSearch && !searchQuery) {
searchQuery = lastSearch
}
eventBus.enable('infile')
const offset = groupedOffsets[selectedIndex] ?? 0
const pos = view.editor.offsetToPos(offset)
pos.ch = 0
view.editor.setCursor(pos)
view.editor.scrollIntoView({
from: { line: pos.line - 10, ch: 0 },
to: { line: pos.line + 10, ch: 0 },
})
eventBus.on('infile', 'enter', openSelection)
eventBus.on('infile', 'arrow-up', () => moveIndex(-1))
eventBus.on('infile', 'arrow-down', () => moveIndex(1))
eventBus.on('infile', 'tab', switchToVaultModal)
})
onDestroy(() => {
eventBus.disable('infile')
})
$: (async () => {
if (searchQuery) {
query = new Query(searchQuery)
note = (await getSuggestions(query, { singleFilePath }))[0] ?? null
lastSearch = searchQuery
}
selectedIndex = 0
scrollIntoView()
})()
$: {
if (note) {
const groups = getGroups(note.matches)
groupedOffsets = groups.map(group =>
Math.round((group.first()!.offset + group.last()!.offset) / 2)
)
// console.log(groups)
// console.log(groupedOffsets)
}
}
}
function switchToVaultModal(): void {
new OmnisearchVaultModal(app).open()
modal.close()
}
/**
* Group together close matches to reduce the number of results
*/
function getGroups(matches: SearchMatch[]): SearchMatch[][] {
const groups: SearchMatch[][] = []
let lastOffset = -1
let count = 0 // TODO: FIXME: this is a hack to avoid infinite loops
while (true) {
const group = getGroupedMatches(matches, lastOffset, excerptAfter)
if (!group.length) break
lastOffset = group.last()!.offset
groups.push(group)
if (++count > 100) break
}
return groups
}
function getGroupedMatches(
matches: SearchMatch[],
offsetFrom: number,
maxLen: number
): SearchMatch[] {
const first = matches.find(m => m.offset > offsetFrom)
if (!first) return []
return matches.filter(
m => m.offset > offsetFrom && m.offset <= first.offset + maxLen
)
}
function moveIndex(dir: 1 | -1): void {
selectedIndex = loopIndex(selectedIndex + dir, groupedOffsets.length)
scrollIntoView()
}
async function scrollIntoView(): Promise<void> {
await tick()
const elem = document.querySelector(`[data-result-id="${selectedIndex}"]`)
elem?.scrollIntoView({ behavior: 'auto', block: 'nearest' })
}
async function openSelection(
evt?: MouseEvent | KeyboardEvent
): Promise<void> {
if (note) {
modal.close()
if (parent) parent.close()
// Open (or switch focus to) the note
await openNote(note, evt?.ctrlKey)
// Move cursor to the match
const view = app.workspace.getActiveViewOfType(MarkdownView)
if (!view) {
throw new Error('OmniSearch - No active MarkdownView')
}
const offset = groupedOffsets[selectedIndex] ?? 0
const pos = view.editor.offsetToPos(offset)
pos.ch = 0
view.editor.setCursor(pos)
view.editor.scrollIntoView({
from: { line: pos.line - 10, ch: 0 },
to: { line: pos.line + 10, ch: 0 },
})
}
}
function switchToVaultModal(): void {
new OmnisearchVaultModal(app).open()
modal.close()
}
</script>
<div class="modal-title">Omnisearch - File</div>
<InputSearch value={searchQuery} on:input={(e) => (searchQuery = e.detail)} />
<InputSearch value={searchQuery} on:input={e => (searchQuery = e.detail)} />
<ModalContainer>
{#if groupedOffsets.length && note}
@@ -149,9 +151,8 @@ function switchToVaultModal(): void {
{note}
index={i}
selected={i === selectedIndex}
on:mousemove={(e) => (selectedIndex = i)}
on:click={openSelection}
/>
on:mousemove={e => (selectedIndex = i)}
on:click={openSelection} />
{/each}
{:else}
<center> We found 0 result for your search here. </center>

View File

@@ -1,159 +1,160 @@
<script lang="ts" context="module">
let lastSearch = ""
let lastSearch = ''
</script>
<script lang="ts">
import { MarkdownView, Notice, TFile } from "obsidian"
import { onMount, onDestroy, tick } from "svelte"
import InputSearch from "./InputSearch.svelte"
import ModalContainer from "./ModalContainer.svelte"
import { eventBus, type ResultNote } from "src/globals"
import { createNote, openNote } from "src/notes"
import { getSuggestions, reindexNotes } from "src/search"
import { getCtrlKeyLabel, loopIndex } from "src/utils"
import { OmnisearchInFileModal, type OmnisearchVaultModal } from "src/modals"
import ResultItemVault from "./ResultItemVault.svelte"
import { Query } from "src/query"
import { MarkdownView, Notice, TFile } from 'obsidian'
import { onMount, onDestroy, tick } from 'svelte'
import InputSearch from './InputSearch.svelte'
import ModalContainer from './ModalContainer.svelte'
import { eventBus, type ResultNote } from 'src/globals'
import { createNote, openNote } from 'src/notes'
import { getSuggestions, reindexNotes } from 'src/search'
import { getCtrlKeyLabel, loopIndex } from 'src/utils'
import { OmnisearchInFileModal, type OmnisearchVaultModal } from 'src/modals'
import ResultItemVault from './ResultItemVault.svelte'
import { Query } from 'src/query'
export let modal: OmnisearchVaultModal
let selectedIndex = 0
let searchQuery: string
let resultNotes: ResultNote[] = []
let query: Query
$: selectedNote = resultNotes[selectedIndex]
export let modal: OmnisearchVaultModal
let selectedIndex = 0
let searchQuery: string
let resultNotes: ResultNote[] = []
let query: Query
$: selectedNote = resultNotes[selectedIndex]
$: if (searchQuery) {
updateResults()
} else {
resultNotes = []
}
onMount(async () => {
await reindexNotes()
searchQuery = lastSearch
eventBus.enable("vault")
eventBus.on("vault", "enter", openNoteAndCloseModal)
eventBus.on("vault", "shift-enter", createNoteAndCloseModal)
eventBus.on("vault", "ctrl-enter", openNoteInNewPane)
eventBus.on("vault", "alt-enter", insertLink)
eventBus.on("vault", "tab", switchToInFileModal)
eventBus.on("vault", "arrow-up", () => moveIndex(-1))
eventBus.on("vault", "arrow-down", () => moveIndex(1))
})
onDestroy(() => {
eventBus.disable("vault")
})
async function updateResults() {
query = new Query(searchQuery)
resultNotes = (await getSuggestions(query)).sort((a, b) => b.score - a.score)
lastSearch = searchQuery
selectedIndex = 0
scrollIntoView()
}
function onClick(evt?: MouseEvent | KeyboardEvent) {
if (!selectedNote) return
openNote(selectedNote, evt?.ctrlKey) // Keep ctrl pressed to open in a new pane
modal.close()
}
function openNoteAndCloseModal(): void {
if (!selectedNote) return
openNote(selectedNote)
modal.close()
}
function openNoteInNewPane(): void {
if (!selectedNote) return
openNote(selectedNote, true)
modal.close()
}
async function createNoteAndCloseModal(): Promise<void> {
try {
await createNote(searchQuery)
} catch (e) {
new Notice((e as Error).message)
return
}
modal.close()
}
function insertLink(): void {
if (!selectedNote) return
const file = app.vault
.getMarkdownFiles()
.find((f) => f.path === selectedNote.path)
const active = app.workspace.getActiveFile()
const view = app.workspace.getActiveViewOfType(MarkdownView)
if (!view?.editor) {
new Notice("Omnisearch - Error - No active editor", 3000)
return
}
// Generate link
let link: string
if (file && active) {
link = app.fileManager.generateMarkdownLink(file, active.path)
$: if (searchQuery) {
updateResults()
} else {
link = `[[${selectedNote.basename}.md]]`
resultNotes = []
}
// Inject link
const cursor = view.editor.getCursor()
view.editor.replaceRange(link, cursor, cursor)
cursor.ch += link.length
view.editor.setCursor(cursor)
onMount(async () => {
await reindexNotes()
searchQuery = lastSearch
eventBus.enable('vault')
eventBus.on('vault', 'enter', openNoteAndCloseModal)
eventBus.on('vault', 'shift-enter', createNoteAndCloseModal)
eventBus.on('vault', 'ctrl-enter', openNoteInNewPane)
eventBus.on('vault', 'alt-enter', insertLink)
eventBus.on('vault', 'tab', switchToInFileModal)
eventBus.on('vault', 'arrow-up', () => moveIndex(-1))
eventBus.on('vault', 'arrow-down', () => moveIndex(1))
})
modal.close()
}
onDestroy(() => {
eventBus.disable('vault')
})
function switchToInFileModal(): void {
modal.close()
if (selectedNote) {
// Open in-file modal for selected search result
const file = app.vault.getAbstractFileByPath(selectedNote.path)
if (file && file instanceof TFile) {
new OmnisearchInFileModal(app, file, searchQuery).open()
}
} else {
// Open in-file modal for active file
const view = app.workspace.getActiveViewOfType(MarkdownView)
if (view) {
new OmnisearchInFileModal(app, view.file, searchQuery).open()
}
}
}
function moveIndex(dir: 1 | -1): void {
selectedIndex = loopIndex(selectedIndex + dir, resultNotes.length)
scrollIntoView()
}
async function scrollIntoView(): Promise<void> {
await tick()
if (selectedNote) {
const elem = document.querySelector(
`[data-result-id="${selectedNote.path}"]`
async function updateResults() {
query = new Query(searchQuery)
resultNotes = (await getSuggestions(query)).sort(
(a, b) => b.score - a.score
)
elem?.scrollIntoView({ behavior: "auto", block: "nearest" })
lastSearch = searchQuery
selectedIndex = 0
scrollIntoView()
}
function onClick(evt?: MouseEvent | KeyboardEvent) {
if (!selectedNote) return
openNote(selectedNote, evt?.ctrlKey) // Keep ctrl pressed to open in a new pane
modal.close()
}
function openNoteAndCloseModal(): void {
if (!selectedNote) return
openNote(selectedNote)
modal.close()
}
function openNoteInNewPane(): void {
if (!selectedNote) return
openNote(selectedNote, true)
modal.close()
}
async function createNoteAndCloseModal(): Promise<void> {
try {
await createNote(searchQuery)
} catch (e) {
new Notice((e as Error).message)
return
}
modal.close()
}
function insertLink(): void {
if (!selectedNote) return
const file = app.vault
.getMarkdownFiles()
.find(f => f.path === selectedNote.path)
const active = app.workspace.getActiveFile()
const view = app.workspace.getActiveViewOfType(MarkdownView)
if (!view?.editor) {
new Notice('Omnisearch - Error - No active editor', 3000)
return
}
// Generate link
let link: string
if (file && active) {
link = app.fileManager.generateMarkdownLink(file, active.path)
} else {
link = `[[${selectedNote.basename}.md]]`
}
// Inject link
const cursor = view.editor.getCursor()
view.editor.replaceRange(link, cursor, cursor)
cursor.ch += link.length
view.editor.setCursor(cursor)
modal.close()
}
function switchToInFileModal(): void {
modal.close()
if (selectedNote) {
// Open in-file modal for selected search result
const file = app.vault.getAbstractFileByPath(selectedNote.path)
if (file && file instanceof TFile) {
new OmnisearchInFileModal(app, file, searchQuery).open()
}
} else {
// Open in-file modal for active file
const view = app.workspace.getActiveViewOfType(MarkdownView)
if (view) {
new OmnisearchInFileModal(app, view.file, searchQuery).open()
}
}
}
function moveIndex(dir: 1 | -1): void {
selectedIndex = loopIndex(selectedIndex + dir, resultNotes.length)
scrollIntoView()
}
async function scrollIntoView(): Promise<void> {
await tick()
if (selectedNote) {
const elem = document.querySelector(
`[data-result-id="${selectedNote.path}"]`
)
elem?.scrollIntoView({ behavior: 'auto', block: 'nearest' })
}
}
}
</script>
<div class="modal-title">Omnisearch - Vault</div>
<InputSearch value={lastSearch} on:input={(e) => (searchQuery = e.detail)} />
<InputSearch value={lastSearch} on:input={e => (searchQuery = e.detail)} />
<ModalContainer>
{#each resultNotes as result, i}
<ResultItemVault
selected={i === selectedIndex}
note={result}
on:mousemove={(e) => (selectedIndex = i)}
on:click={onClick}
/>
on:mousemove={e => (selectedIndex = i)}
on:click={onClick} />
{/each}
{#if !resultNotes.length && searchQuery}
<center> We found 0 result for your search here. </center>

View File

@@ -1,9 +1,9 @@
<script lang="ts">
import GlyphAddNote from "./GlyphAddNote.svelte"
import GlyphAddNote from './GlyphAddNote.svelte'
export let id: string
export let selected = false
export let glyph = false
export let id: string
export let selected = false
export let glyph = false
</script>
<div
@@ -12,8 +12,7 @@ export let glyph = false
class:is-selected={selected}
on:mousemove
on:click
on:auxclick
>
on:auxclick>
{#if glyph}
<GlyphAddNote />
{/if}

View File

@@ -1,15 +1,15 @@
<script lang="ts">
import type { ResultNote } from "../globals"
import { highlighter, makeExcerpt, stringsToRegex } from "../utils"
import ResultItemContainer from "./ResultItemContainer.svelte"
import type { ResultNote } from '../globals'
import { highlighter, makeExcerpt, stringsToRegex } from '../utils'
import ResultItemContainer from './ResultItemContainer.svelte'
export let offset: number
export let note: ResultNote
export let index = 0
export let selected = false
export let offset: number
export let note: ResultNote
export let index = 0
export let selected = false
$: reg = stringsToRegex(note.foundWords)
$: cleanedContent = makeExcerpt(note?.content ?? "", offset)
$: reg = stringsToRegex(note.foundWords)
$: cleanedContent = makeExcerpt(note?.content ?? '', offset)
</script>
<ResultItemContainer id={index.toString()} {selected} on:mousemove on:click>

View File

@@ -1,19 +1,19 @@
<script lang="ts">
import { getNoteFromCache } from "src/notes"
import { settings } from "src/settings"
import type { ResultNote } from "../globals"
import { getMatches } from "../search"
import { highlighter, makeExcerpt, stringsToRegex } from "../utils"
import ResultItemContainer from "./ResultItemContainer.svelte"
import { getNoteFromCache } from 'src/notes'
import { settings } from 'src/settings'
import type { ResultNote } from '../globals'
import { getMatches } from '../search'
import { highlighter, makeExcerpt, stringsToRegex } from '../utils'
import ResultItemContainer from './ResultItemContainer.svelte'
export let selected = false
export let note: ResultNote
export let selected = false
export let note: ResultNote
$: reg = stringsToRegex(note.foundWords)
$: matches = getMatches(note.content, reg)
$: cleanedContent = makeExcerpt(note.content, note.matches[0]?.offset ?? -1)
$: glyph = getNoteFromCache(note.path)?.doesNotExist
$: title = settings.showShortName ? note.basename : note.path
$: reg = stringsToRegex(note.foundWords)
$: matches = getMatches(note.content, reg)
$: cleanedContent = makeExcerpt(note.content, note.matches[0]?.offset ?? -1)
$: glyph = getNoteFromCache(note.path)?.doesNotExist
$: title = settings.showShortName ? note.basename : note.path
</script>
<ResultItemContainer id={note.path} {selected} on:mousemove on:click {glyph}>
@@ -24,7 +24,7 @@ $: title = settings.showShortName ? note.basename : note.path
{#if matches.length > 0}
<span class="omnisearch-result__counter">
{matches.length}&nbsp;{matches.length > 1 ? "matches" : "match"}
{matches.length}&nbsp;{matches.length > 1 ? 'matches' : 'match'}
</span>
{/if}
</div>