<% my $dbi = app->dbi; my $op = param('op') // ''; my $book_id = param('book-id'); my $show_word_count; my $word_count_h = {}; my $word = param('word'); my $word_length = length $word; my $word_q = quotemeta($word); if ($word_length) { $show_word_count = 1; for (my $i = 0; $i < 66; $i++) { my $num = sprintf "%02d", $i + 1; my $content = $dbi->select( 'content_no_tag', table => 'book', where => {id => $num} )->value; my $content_length = length $content; $content =~ s/$word_q//g; my $content_length_no_word = length $content; # 文字の個数 my $word_count = ($content_length - $content_length_no_word) / $word_length; $word_count_h->{$num} = $word_count; } } my $books = $dbi->model('book')->select(['id', 'short_name'])->all; my $content; my $max_search_pos; if ($book_id) { $content = $dbi->model('book')->select( 'content', where => {id => $book_id} )->value; # アンカーを追加 if ($word_length) { my $i = 1; my $replace_cb = sub { my $word = shift; my $after = qq|$word|; $i++; return $after; }; $content =~ s#($word_q)#$replace_cb->($1)#ge; $max_search_pos = $i; } } %> % layout 'common'; %= javascript begin $(document).ready(function () { $("#up-arrow").on('click', function () { var current_pos = $('#word-pos').text(); var prev_pos = current_pos - 1; $('#word-pos').text(prev_pos); location.href = '#word-' + prev_pos; }); $("#down-arrow").on('click', function () { var current_pos = $('#word-pos').text(); var next_pos = current_pos - 0 + 1; $('#word-pos').text(next_pos); location.href = '#word-' + next_pos; }); }); % end

口語訳聖書オンライン語句検索

<%= text_field 'word' , style => "width:160px"%>
聖書 % if ($word_length) {
<%= $book_id ? 1 : '-' %>
% }
% for my $book (@$books) { % if (!$word_length || $word_count_h->{$book->{id}} > 0) { % } % }
% if ($word_length) { 回数 % }
% my $book_url_query = {'book-id' => $book->{id}}; % $book_url_query->{word} = $word if $word_length; % my $book_url = url_for->query($book_url_query); % $book_url->fragment('#word-1') if $word_length; {id}" %>" href="<%= $book_url %>"> <%= $book->{short_name} %> <%= $word_count_h->{$book->{id}} %>
% if ($book_id) { %== $content % }
This site is create by Perl + Mojolicious. Auther is Yuki kimoto.