OSDN Git Service

change GET option to use title_id(hash) instead of title(utf-8)
authorgn64_jp <gn64@rec10.org>
Tue, 23 Apr 2013 14:45:46 +0000 (23:45 +0900)
committergn64_jp <gn64@rec10.org>
Tue, 23 Apr 2013 14:45:46 +0000 (23:45 +0900)
htmlserver.pl
index/pdf2xml.py
pdfsearch.pl
template/mobile_viewjpeg.tmpl

index 1fcbe28..bb4d108 100755 (executable)
@@ -58,14 +58,14 @@ $dbi =
 $multi_maxpage = 0;
 
 $sql =
-"SELECT id,title,part,startpage,endpage FROM pdffile WHERE title = '$title_group' ORDER BY part DESC LIMIT 1";
+"SELECT id,title,part,startpage,endpage FROM pdffile WHERE title_id = '$title_group' ORDER BY part DESC LIMIT 1";
 $dbs = $dbi->prepare($sql);
 $dbs->execute();
 $dbh           = $dbs->fetchrow_hashref;
 $multi_maxpage = $dbh->{'endpage'};
 
 $sql2 =
-"SELECT id,startpage FROM pdffile WHERE title = '$title_group' AND startpage < $pagenum AND endpage > $pagenum";
+"SELECT id,startpage FROM pdffile WHERE title_id = '$title_group' AND startpage < $pagenum AND endpage > $pagenum";
 $dbs2 = $dbi->prepare($sql2);
 $dbs2->execute();
 $dbh2           = $dbs2->fetchrow_hashref;
index 0e0cad7..7863d97 100644 (file)
@@ -16,8 +16,8 @@ import yaml
 import sqlite3
 
 confstr="/etc/libre10.conf"
-sqlpath="/tmp/libre10.db"
 conf_dic=yaml.load(open(confstr).read())
+sqlpath=conf_dic['dburl']
 dbcon=sqlite3.connect(sqlpath,isolation_level=None)
 try:
     sql = u"""
@@ -26,6 +26,7 @@ create table pdffile (
     path varchar(100),
     page integer,
     title varchar(40),
+    title_id varchar(40),
     part integer,
     genre varchar(100),
     startpage integer,
@@ -79,11 +80,13 @@ def PDF2TEXT(pdfpath,dstpath,idnum):
             parttext=int(parttext)
     else:
         parttext=0
-        title_group=os.path.basename(pdfpath).split(".")[0]
+        title_group=os.path.basename(pdfpath).split(".pdf")[0]
     print title_group
     print "Part"
     print parttext
-
+    rd = hashlib.md5()
+    rd.update(title_group.encode('utf-8'))
+    rdl=rd.hexdigest()
     for i in xrange(1,pagenum+1):
         cmd=u"pdftotext -eol unix -enc UTF-8 -f "+str(i)+u" -l "+str(i)+" \""+pdfpath+u"\" page-"+str(i)+dstpath
         p=subprocess.Popen(cmd.encode("utf-8"),shell=True)
@@ -91,8 +94,8 @@ def PDF2TEXT(pdfpath,dstpath,idnum):
         time.sleep(1)
         TEXT2solr(s,os.path.splitext(os.path.basename(pdfpath))[0],"page-"+str(i)+dstpath,i,pagenum,pdfpath,idnum)
        os.system("rm -f page-"+str(i)+dstpath)
-    sql = u"insert into pdffile (id,path,page,title,part)values (?,?,?,?,?)"
-    dbcon.execute(sql,(idnum,pdfpath,pagenum,title_group,parttext))
+    sql = u"insert into pdffile (id,path,page,title,title_id,part)values (?,?,?,?,?,?)"
+    dbcon.execute(sql,(idnum,pdfpath,pagenum,title_group,rdl,parttext))
     s.commit()
 def TEXT2solr(solrcon,titletxt,textpath,pagenum,pagemax,pdfpath,idnum):
     f=codecs.open(textpath,"r","utf-8","ignore")
index 9eb7bc1..71083e8 100755 (executable)
@@ -39,6 +39,7 @@ else {
 $confdata = YAML::XS::LoadFile($confpath);
 
 my $sqlpath = "/tmp/libre10.db";
+$sqlpath = $confdata->{dburl};
 $sqldbi =
   DBI->connect( "dbi:SQLite:dbname=$sqlpath", "", "",
        { RaiseError => 1, AutoCommit => 1 } );
@@ -128,14 +129,16 @@ sub printGroupResults() {
        foreach $doc (@$hits) {
                ( $pagenum, $path, $linkpath ) =
                  ( $doc->{page}, $doc->{path_id}, $doc->{path_id} );
-               my $findPageSQL = "SELECT startpage from pdffile WHERE id = '$path';";
+               my $findPageSQL = "SELECT startpage,title_id from pdffile WHERE id = '$path';";
                my $sth         = $sqldbi->prepare($findPageSQL);
                $sth->execute;
-               $showpagenum = $pagenum + $sth->fetchrow_array;
+               $dbarray=$sth->fetchrow_arrayref;
+               $showpagenum = $pagenum + $dbarray->[0];
+               #print Dumper $dbarray;
                print "page " . $showpagenum . "<br>";
                print " " . $hits_hl->{ $doc->{id} }{text}[0] . "<br>";
                print "<a href=\"htmlserver.pl?title="
-                 . uri_escape( encode( 'utf-8', $title ) );
+                 . uri_escape( $dbarray->[1] );
                print "&pagenum=$showpagenum&mode=$mode&width=$width&height=$height\">";
                print "該当ページを見る";
                print "</a>";
index ac472d1..0ded5db 100644 (file)
@@ -8,6 +8,11 @@
   <script src='http://code.jquery.com/jquery-1.9.1.min.js'></script>
   <script src='http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js'></script>
   <script>
+       $(document).on("mobileinit",function(){
+               $(document).bind("mobileinit",function(event){
+                       $.extend($.mobile.zoom,{locked:false,enabled:true});
+               });
+       });
         $(document).on('pageinit',function(){
                 $.mobile.loadPage('<TMPL_VAR NAME="nlink">',{showLoadMsg:false});
                 $.mobile.loadPage('<TMPL_VAR NAME="blink">',{showLoadMsg:false});
                        $.mobile.metaViewportContent = 'width-device-width,user-scalable=yes';
                        }
                });
+               $(document).bind("mobileinit",function(){
+                       $.mobile.metaViewportContent = 'width=device-width,initial-scale=1';
+               });
                $('#jumpPage').bind("click",function(e,ui){
                        //console.log("<TMPL_VAR NAME="jumplink">");
                        //console.log($('#jumpPagenum').val());
-                       $.mobile.changePage("<TMPL_VAR NAME="jumplink">"+$('#jumpPagenum').val(),{transition:'slide'});
+                       $.mobile.changePage("<TMPL_VAR NAME="jumplink">"+$('#jumpPagenum').val(),{transition:'slidedown'});
                
                });
+               //$("#images").css('width',$("#image"),innerWidth()+"px");
+               
        });
   </script>
  </head>