add files
|
1 |
<% |
2 |
my $dbi = app->dbi; |
|
3 |
my $op = param('op') // ''; |
|
4 |
my $book_id = param('book-id'); |
|
5 |
|
|
improve design
|
6 |
my $show_word_count; |
7 |
my $word_count_h = {}; |
|
8 |
my $word = param('word'); |
|
9 |
my $word_length = length $word; |
|
10 |
if ($word_length) { |
|
11 |
$show_word_count = 1; |
|
12 |
for (my $i = 0; $i < 66; $i++) { |
|
13 |
my $num = sprintf "%02d", $i + 1; |
|
14 |
|
|
15 |
my $content = $dbi->select( |
|
16 |
'content_no_tag', |
|
17 |
table => 'book', |
|
18 |
where => {id => $num} |
|
19 |
)->value; |
|
20 | ||
21 |
my $content_length = length $content; |
|
22 | ||
23 |
$content =~ s/$word//g; |
|
24 | ||
25 |
my $content_length_no_word = length $content; |
|
26 | ||
27 |
my $word_count = ($content_length - $content_length_no_word) / $word_length; |
|
28 | ||
29 |
$word_count_h->{$num} = $word_count; |
|
30 |
} |
|
31 |
} |
|
32 |
|
|
33 |
warn dumper $word_count_h; |
|
34 |
|
|
improve design
|
35 |
my $books = $dbi->model('book')->select(['id', 'short_name'])->all; |
add files
|
36 |
|
improve design
|
37 |
my $content; |
38 |
if ($book_id) { |
|
39 |
$content = $dbi->model('book')->select( |
|
40 |
'content', |
|
41 |
where => {id => $book_id} |
|
42 |
)->value; |
|
43 |
} |
|
add files
|
44 |
%> |
45 | ||
46 | ||
47 |
% layout 'common'; |
|
48 | ||
49 |
<div id="container"> |
|
50 | ||
51 |
<div id="boxA"> |
|
52 |
<h1>口語訳聖書オンライン語句検索</h1> |
|
53 |
</div> |
|
54 | ||
55 |
<div id="boxB"> |
|
improve design
|
56 |
<form style="margin-bottom:5px" action="<%= url_for('current') %>" method="get"> |
add files
|
57 |
<%= text_field 'word' , style => "width:160px"%> |
improve design
|
58 |
<input type="submit" value="検索" style="width:50px;padding:2px;"> |
59 |
</form> |
|
add files
|
60 |
<div style="margin-bottom:10px;"> |
improve design
|
61 |
<a href="<%= url_for('/') %>" style="color:blue">聖書</a> |
add files
|
62 |
</div> |
63 |
<div style="border:1px solid gray;width:218px;height:400px;overflow:auto;padding:5px"> |
|
improve design
|
64 |
<table style="border-collapse: collapse;width:100%;color:#333333"> |
65 |
<tr style="border-bottom:1px solid #EEEEEE"> |
|
66 |
<td> |
|
67 |
書 |
|
68 |
</td> |
|
69 |
<td style="text-align:right"> |
|
70 |
% if ($word_length) { |
|
71 |
回数 |
|
72 |
% } |
|
73 |
</td> |
|
74 |
</tr> |
|
add files
|
75 |
% for my $book (@$books) { |
improve design
|
76 |
<tr> |
77 |
<td> |
|
78 |
<a class="book" id="<%= "book-$book->{id}" %>" href="<%= url_for->query('book-id' => $book->{id}) %>"><%= $book->{short_name} %></a> |
|
79 |
</td> |
|
80 |
<td style="text-align:right"> |
|
81 |
<%= $word_count_h->{$book->{id}} %> |
|
82 |
</td> |
|
83 |
</tr> |
|
add files
|
84 |
% } |
improve design
|
85 |
</table> |
add files
|
86 |
</div> |
87 |
</div> |
|
88 | ||
89 |
<div id="boxC"> |
|
improve design
|
90 |
<div style="height:500px;overflow:auto"> |
91 |
% if ($book_id) { |
|
92 |
%== $content |
|
93 |
% } |
|
94 |
</div> |
|
add files
|
95 |
</div> |
96 | ||
97 | ||
98 |
<div id="boxD"> |
|
improve design
|
99 |
<div style="border-top:1px solid #AAAAAA;padding-top:10px;"> |
100 |
This site is create by |
|
101 |
<a href="http://d.hatena.ne.jp/perlcodesample">Perl</a> + |
|
102 |
<a href="http://d.hatena.ne.jp/perlcodesample/20140319/1395203665">Mojolicious</a>. |
|
103 |
Auther is <a href="https://twitter.com/yukikimoto2">Yuki kimoto</a>. |
|
104 |
</div> |
|
add files
|
105 |
</div> |
106 |
</div> |