Skip to content

Commit 03eec55

Browse files
authored
Allow multiple Regexp pattren in search (#643)
* add basic regex based Quran search * use linear regexp * allow multiple rexexp pattern in search
1 parent 52915cc commit 03eec55

4 files changed

Lines changed: 4 additions & 5 deletions

File tree

app/admin/audio/audio_recitation.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
:recitation_style_id,
1919
:qirat_type_id,
2020
:reciter_id,
21-
:gapped_recitation_id,
2221
:segment_locked
2322

2423
scope :all
@@ -333,9 +332,6 @@
333332
f.input :qirat_type_id,
334333
as: :searchable_select,
335334
ajax: { resource: QiratType }
336-
f.input :gapped_recitation_id,
337-
as: :searchable_select,
338-
ajax: { resource: Recitation }
339335
end
340336

341337
f.actions

app/services/search/pattern.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ def add_gap(token)
7777
@tokens << Token.new(:gap, '.*?', '%', false)
7878
else
7979
spec = token[1...token.index('}')]
80+
8081
@tokens << Token.new(:gap, "\\s+(?:\\S+\\s+)#{bound(spec)}", nil, true)
8182
end
8283
end

app/views/search/index.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<h1 class="text-2xl font-bold text-gray-900 mb-6">Search the Quran</h1>
55

66
<%= form_with url: search_path, method: :get, data: { turbo: false } do %>
7-
<%= render 'shared/search_input', name: 'q', value: @query, placeholder: 'Search Quran text…' %>
7+
<%= render 'shared/search_input', name: 'q', value: @query, placeholder: 'Search Quran text…', dir: 'auto' %>
88

99
<div class="flex items-center gap-6 mt-4 flex-wrap">
1010
<label class="flex items-center gap-2 text-sm text-gray-700">

app/views/shared/_search_input.html.erb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
input_value = local_assigns.fetch(:value, nil)
55
placeholder = local_assigns.fetch(:placeholder, 'Quick Search...')
66
input_data = local_assigns.fetch(:data, {})
7+
input_dir = local_assigns.fetch(:dir, nil)
78
%>
89
<div class="relative">
910
<%= tag.input(
@@ -14,6 +15,7 @@
1415
name: input_name,
1516
value: input_value,
1617
autocomplete: 'off',
18+
dir: input_dir,
1719
data: input_data
1820
) %>
1921
<div class="absolute <%= variant == 'large' ? 'start-6 top-[1.65rem]' : 'start-5 top-[1.15rem]' %>">

0 commit comments

Comments
 (0)