... | ... |
@@ -3,6 +3,35 @@ |
3 | 3 |
my $op = param('op') // ''; |
4 | 4 |
my $book_id = param('book-id'); |
5 | 5 |
|
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 |
+ |
|
6 | 35 |
my $books = $dbi->model('book')->select(['id', 'short_name'])->all; |
7 | 36 |
|
8 | 37 |
my $content; |
... | ... |
@@ -24,28 +53,45 @@ |
24 | 53 |
</div> |
25 | 54 |
|
26 | 55 |
<div id="boxB"> |
27 |
- <div style="margin-bottom:5px"> |
|
56 |
+ <form style="margin-bottom:5px" action="<%= url_for('current') %>" method="get"> |
|
28 | 57 |
<%= text_field 'word' , style => "width:160px"%> |
29 |
- <button style="width:50px;padding:2px;">検索</button> |
|
30 |
- </div> |
|
58 |
+ <input type="submit" value="検索" style="width:50px;padding:2px;"> |
|
59 |
+ </form> |
|
31 | 60 |
<div style="margin-bottom:10px;"> |
32 | 61 |
<a href="<%= url_for('/') %>" style="color:blue">聖書</a> |
33 | 62 |
</div> |
34 | 63 |
<div style="border:1px solid gray;width:218px;height:400px;overflow:auto;padding:5px"> |
35 |
- <ul style="list-style-type:none"> |
|
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> |
|
36 | 75 |
% for my $book (@$books) { |
37 |
- <li><a class="book" id="<%= "book-$book->{id}" %>" href="<%= url_for->query('book-id' => $book->{id}) %>"><%= $book->{short_name} %></a></li> |
|
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> |
|
38 | 84 |
% } |
39 |
- </ul> |
|
85 |
+ </table> |
|
40 | 86 |
</div> |
41 | 87 |
</div> |
42 | 88 |
|
43 | 89 |
<div id="boxC"> |
44 |
- <p> |
|
45 |
- % if ($book_id) { |
|
46 |
- %== $content |
|
47 |
- % } |
|
48 |
- </p> |
|
90 |
+ <div style="height:500px;overflow:auto"> |
|
91 |
+ % if ($book_id) { |
|
92 |
+ %== $content |
|
93 |
+ % } |
|
94 |
+ </div> |
|
49 | 95 |
</div> |
50 | 96 |
|
51 | 97 |
|
... | ... |
@@ -0,0 +1,35 @@ |
1 |
+use strict; |
|
2 |
+use warnings; |
|
3 |
+use utf8; |
|
4 |
+use DBIx::Custom; |
|
5 |
+ |
|
6 |
+my $word ='主'; |
|
7 |
+my $word_length = length $word; |
|
8 |
+my $word_q = quotemeta($word); |
|
9 |
+ |
|
10 |
+my $dbi = DBIx::Custom->connect( |
|
11 |
+ dsn => "dbi:SQLite:dbname=../db/bible.db", |
|
12 |
+ option => {sqlite_unicode => 1} |
|
13 |
+); |
|
14 |
+ |
|
15 |
+for (my $i = 0; $i < 66; $i++) { |
|
16 |
+ my $num = sprintf "%02d", $i + 1; |
|
17 |
+ |
|
18 |
+ my $content = $dbi->select( |
|
19 |
+ 'content_no_tag', |
|
20 |
+ table => 'book', |
|
21 |
+ where => {id => $num} |
|
22 |
+ )->value; |
|
23 |
+ |
|
24 |
+ my $content_length = length $content; |
|
25 |
+ |
|
26 |
+ $content =~ s/$word//g; |
|
27 |
+ |
|
28 |
+ my $content_length_no_word = length $content; |
|
29 |
+ |
|
30 |
+ my $word_count = ($content_length - $content_length_no_word) / $word_length; |
|
31 |
+ |
|
32 |
+ print "$num:$word_count\n"; |
|
33 |
+} |
|
34 |
+ |
|
35 |
+1; |