$pdfpath = $dbh2->{'id'};
$jumplink =
"htmlserver.pl?title=$title_uri&mode=$mode&width=$width&height=$height&pagenum=";
+$searchlink =
+"pdfsearch.pl?mode=$mode&width=$width&height=$height&search_text=";
$bpage = $pagenum - 1;
$blink =
"htmlserver.pl?title=$title_uri&mode=$mode&width=$width&height=$height&pagenum=$bpage";
$template->param( nlink => $nlink );
$template->param( jpegpath => $jpeglink );
$template->param( jumplink => $jumplink );
+ $template->param( searchlink => $searchlink );
$template->param( nowpage => $pagenum );
$template->param( maxpage => $multi_maxpage );
$template->param( homelink => $homelink );
+ #$template->param( title_id => $title_group );
}
else {
$blink = "$blink";
$template->param( n10link => $n10link );
$template->param( jpegpath => $jpeglink );
$template->param( jumplink => $jumplink );
+ $template->param( searchlink => $searchlink );
$template->param( nowpage => $pagenum );
$template->param( maxpage => $multi_maxpage );
$template->param( homelink => $homelink );
+ $template->param( title_id => $title_group );
}
print $cgi->header( -charset => 'utf-8' ), $template->output;
import commands
import sys
import os
+import os.path
import subprocess
import codecs
import time
import solr
import yaml
import sqlite3
-
confstr="/etc/libre10.conf"
+if os.path.exists("./libre10.conf"):
+ confstr="./libre10.conf"
+elif os.path.exists("../libre10.conf"):
+ confstr="../libre10.conf"
conf_dic=yaml.load(open(confstr).read())
sqlpath=conf_dic['dburl']
dbcon=sqlite3.connect(sqlpath,isolation_level=None)
$height = $q->param("height");
$start = $q->param("start");
$rows = $q->param("rows");
+$fq_title_row = $q->param("fq_title");
+$fq_genre_row = $q->param("fq_genre");
+$fq_title = uri_unescape($fq_title_row);
+#$fq_title = decode('utf-8',$fq_title);
+$fq_genre = decode('utf-8',uri_unescape($fq_genre_row));
if ( $start eq "" ) { $start = "0"; }
if ( $rows eq "" ) { $rows = "10"; }
$bstart = 0;
}
$blink =
-"pdfsearch.pl?mode=$mode&search_text=$search_text&width=$width&height=$height&start=$bstart&rows=$rows";
+"pdfsearch.pl?mode=$mode&search_text=$search_text&width=$width&height=$height&start=$bstart&rows=$rows&fq_title=$fq_title_row&fq_genre=$fq_genre_row";
$nlink =
-"pdfsearch.pl?mode=$mode&search_text=$search_text&width=$width&height=$height&start=$nstart&rows=$rows";
+"pdfsearch.pl?mode=$mode&search_text=$search_text&width=$width&height=$height&start=$nstart&rows=$rows&fq_title=$fq_title_row&fq_genre=$fq_genre_row";
$template->param( blink => $blink );
$template->param( nlink => $nlink );
$template->param( search_top => "0" );
my $query = WebService::Solr::Query->new(
{ text => decode( 'utf-8', $search_text ) } );
+ my %response_query = (
+ 'rows' => $rows,
+ 'start' => $start,
+ 'group.limit' => '30',
+ 'group.field' => 'title_group',
+ 'group' => true,
+ 'hl' => true,
+ 'hl.fl' => 'text',
+ 'hl.simple.pre' => "<font color=red><em>",
+ 'hl.simple.post' => "</em></font>",
+ 'hl.fragsize' => '300',
+ 'hl.fragmenter' => 'gap',
+ 'hl.alternateField' => 'text',
+ 'hl.maxAlternateFieldLength' => '300',
+ 'hl.useFastVectorHighlighter' => true,
+ );
+ my $fq_title_solr="";
+ if ((length $fq_title > 0) or (length $fq_genre > 0)){
+ $sql = "SELECT title
+ FROM pdffile
+ WHERE title_id = '$fq_title'
+ ORDER BY part DESC LIMIT 1";
+ $dbs = $sqldbi->prepare($sql);
+ $dbs->execute();
+ $dbh = $dbs->fetchrow_hashref;
+ $fq_title_solr = decode('utf-8',$dbh->{'title'});
+ #print Dumper $dbh;
+ }
+ #if ((length $fq_title > 0) and (length $fq_genre > 0)){
+ # $response_query{'facet'} = "true";
+ # @fqs = ('title_group:$fq_title_solr','genre:$fq_genre');
+ # $response_query{'fq'} = [@fqs];
+ if (length $fq_title > 0){
+ $response_query{'fq'}="title_group:\"$fq_title_solr\"";
+ }
+ if (length $fq_genre > 0){
+ $response_query{'facet'} = "true";
+ @fqs = ('genre:' . $fq_genre,);
+ $response_query{'fq'} = [@fqs];
+ }
+ #print Dumper %response_query;
my $response = $solr->search(
- $query,
- {
- 'rows' => $rows,
- 'start' => $start,
- 'group.limit' => '30',
- 'group.field' => 'title_group',
- 'group' => true,
- 'hl' => true,
- 'hl.fl' => 'text',
- 'hl.simple.pre' => "<font color=red><em>",
- 'hl.simple.post' => "</em></font>",
- 'hl.fragsize' => '300',
- 'hl.fragmenter' => 'gap',
- 'hl.alternateField' => 'text',
- 'hl.maxAlternateFieldLength' => '300',
- 'hl.useFastVectorHighlighter' => true,
- }
+ $query,\%response_query
);
+ #print Dumper $response;
my $hits = $response->content;
my %hits = %$hits;
.click(function(){
window.location.href="<TMPL_VAR NAME="nlink">";
});
- $("#blink_footer").button({
+ $("#blinkF").button({
label:"back",
icons:{
primary:"ui-icon-circle-triangle-w"
.click(function(){
window.location.href="<TMPL_VAR NAME="blink">";
});
- $("#settings_footer").button({
+ $("#settingsF").button({
label:"Settings",
icons:{
primary:"ui-icon-gear"
})
.click(function(){
});
- $("#login_footer").button({
+ $("#loginF").button({
label:"Login",
icons:{
primary:"ui-icon-key"
})
.click(function(){
});
- $("#nlink_footer").button({
+ $("#nlinkF").button({
label:"next",
icons:{
primary:"ui-icon-circle-triangle-e"
</TMPL_LOOP>
<div align="center">
<div id="toolbar" class="ui-corner-all">
- <button id="blink_footer"></button>
- <button id="settings_footer" disabled></button>
- <button id="login_footer" disabled></button>
- <button id="nlink_footer"></button>
+ <button type="button" id="blinkF"></button>
+ <button type="button" id="settingsF" disabled></button>
+ <button type="button" id="loginF" disabled></button>
+ <button type="button" id="nlinkF"></button>
</div>
</div>
</TMPL_IF>
modal:true,
title:"Search"
});
+ $("#search").button({
+ label:"検索",
+ icons:{
+ primary:"ui-icon-search"
+ }
+ })
+ .click(function(){
+ $("#search_dialog").dialog('open');
+ });
+ $("#search_button").button({
+ label:"検索",
+ icons:{
+ primary:"ui-icon-search"
+ }
+ })
+ .click(function(){
+ var selected = $("#search_radio :radio:checked").attr('id');
+ if (selected == 'search_all'){
+ var search_link="<TMPL_VAR NAME="homelink">"+"&search_text="+$("#search_text").val();
+ window.location.href=search_link;
+ }else{
+ var search_link="<TMPL_VAR NAME="homelink">"+"&search_text="+$("#search_text").val()+"&fq_title=<TMPL_VAR NAME="title_id">";
+ window.location.href=search_link;
+ }
+ });
+ $("#search_text").bind('keypress',function(e){
+ if(e.keyCode == 13){
+ var selected = $("#search_radio :radio:checked").attr('id');
+ if (selected == 'search_all'){
+ var search_link="<TMPL_VAR NAME="homelink">"+"&search_text="+$("#search_text").val();
+ window.location.href=search_link;
+ }else{
+ var search_link="<TMPL_VAR NAME="homelink">"+"&search_text="+$("#search_text").val()+"&fq_title=<TMPL_VAR NAME="title_id">";
+ window.location.href=search_link;
+ }
+ }
+ });
$("#jump_dialog").dialog({
autoOpen:false,
//height:140,
modal:true,
title:"移動 (<TMPL_VAR NAME="nowpage">/<TMPL_VAR NAME="maxpage">)"
});
+ $("#jump").button({
+ label:"移動",
+ icons:{
+ primary:"ui-icon-arrowreturnthick-1-n"
+ }
+ })
+ .click(function(){
+ $("#jump_dialog").dialog('open');
+ });
+ $("#jump_button").button({
+ label:"移動",
+ icons:{
+ primary:"ui-icon-arrowreturnthick-1-n"
+ }
+ })
+ .click(function(){
+ var jump_link="<TMPL_VAR NAME="jumplink">"+$("#jump_num").val();
+ window.location.href=jump_link;
+ });
+ $("#jump_num").bind('keypress',function(e){
+ if(e.keyCode == 13){
+ if ($('#jump_num').val().length > 0){
+ var jump_link="<TMPL_VAR NAME="jumplink">"+$("#jump_num").val();
+ window.location.href=jump_link;
+ }
+ }
+ });
$("#b10link").button({
label:"-10頁",
icons:{
.click(function(){
window.location.href="<TMPL_VAR NAME="blink">";
});
- $("#search").button({
- label:"検索",
- icons:{
- primary:"ui-icon-search"
- }
- })
- .click(function(){
- $("#search_dialog").dialog('open');
- });
- $("#search_button").button({
- label:"検索",
- icons:{
- primary:"ui-icon-search"
- }
- })
- .click(function(){
- var selected = $("#search_radio :radio:checked").attr('id');
- if (selected == 'search_all'){
- var search_link="<TMPL_VAR NAME="homelink">"+"&search_text="+$("#search_text").val();
- window.location.href=search_link;
- }
- //alert($("#search_radio :radio:checked").attr('id'));
- });
- $("#jump").button({
- label:"移動",
- icons:{
- primary:"ui-icon-arrowreturnthick-1-n"
- }
- })
- .click(function(){
- $("#jump_dialog").dialog('open');
- });
- $("#jump_button").button({
- label:"移動",
- icons:{
- primary:"ui-icon-arrowreturnthick-1-n"
- }
- })
- .click(function(){
- var jump_link="<TMPL_VAR NAME="jumplink">"+$("#jump_num").val();
- window.location.href=jump_link;
- //alert($("#search_radio :radio:checked").attr('id'));
- });
+
+
$("#index").button({
label:"目次",
icons:{
<div id="search_radio">
<input type="radio" id="search_all" checked="checked" name="radio"/>
<label for="search_all">全体から</label>
- <input type="radio" id="search_this" name="radio" disabled/>
+ <input type="radio" id="search_this" name="radio" />
<label for="search_this">本書から</label>
</div>
<br>
</div>
</div>
<div data-role="content" id='top'>
- <input type='search' name='search_text' id='search-text' value='' />
+ <input type='search' name='search_text' id='search-text' value='<TMPL_VAR NAME="text">' />
<label><button type="submit" data-theme="b" id="submit" name="submit">検索</button></label>
<TMPL_IF NAME="show_result">
<div data-role="collapsible-set" data-theme="c" data-content-theme="d">
//$.mobile.changePage('<TMPL_VAR NAME="blink">',{transition:'slide'});
});
$('div.ui-input-search').bind('keypress',function(e){
+ //console.log("test");
if(e.keyCode == 13){
+ //console.log("test");
if ($('#search-text').val().length > 0){
- $.mobile.changePage("pdfsearch.pl?mode=&width=&height=&search_text=\"" + $('#search-text').val() + "\"",{transition:'slide'});
+ var txt=$('#search-text').val();
+ $('#search-text').val("");
+ $.mobile.changePage("<TMPL_VAR NAME="searchlink">" + txt ,{transition:'slide'});
}
}
});
+ $('#jumpPagenum').bind('keypress',function(e){
+ if(e.keyCode == 13){
+ if($('#jumpPagenum').val().length > 0){
+ var jnum=$('#jumpPagenum').val();
+ $('#jumpPagenum').val("");
+ $.mobile.changePage("<TMPL_VAR NAME="jumplink">"+jnum,{transition:'slidedown'});
+
+ }
+ }
+ });
$('#jumpPage').bind("click",function(e,ui){
- $.mobile.changePage("<TMPL_VAR NAME="jumplink">"+$('#jumpPagenum').val(),{transition:'slidedown'});
+ if($('#jumpPagenum').val().length > 0){
+ var jnum=$('#jumpPagenum').val();
+ $('#jumpPagenum').val("");
+ $.mobile.changePage("<TMPL_VAR NAME="jumplink">"+jnum,{transition:'slidedown'});
+
+ }
});
$.mobile.loadPage("<TMPL_VAR NAME="nlink">",{showLoadMsg: false});
$.mobile.loadPage("<TMPL_VAR NAME="blink">",{showLoadMsg: false});
<h1>page move dialog</h1>
</div>
<div data-role='content'>
+ <TMPL_VAR NAME="nowpage"> / <TMPL_VAR NAME="maxpage">
<p><input type='number' id='jumpPagenum' value='' />
<div data-role='button' id='jumpPage'>移動</div>
</p>