Safe HaskellNone

GenePDFHtmlLib

Synopsis

Documentation

data LHead Source #

end_fold ,}}}

KEY:

15-02-2021

  • Too many open files error when inserting Latex files to database
  • See $bdatabasehaskellwebapp2_sqlite3.db
  • Open db file
   sqlite3 $bdatabasehaskellwebapp2_sqlite3.db

   -- Show all table
   -- .table
   -- table name => pdftable
   

Constructors

LHead 

Fields

Instances

Instances details
Eq LHead Source # 
Instance details

Defined in GenePDFHtmlLib

Methods

(==) :: LHead -> LHead -> Bool

(/=) :: LHead -> LHead -> Bool

Show LHead Source # 
Instance details

Defined in GenePDFHtmlLib

Methods

showsPrec :: Int -> LHead -> ShowS

show :: LHead -> String

showList :: [LHead] -> ShowS

Default LHead Source # 
Instance details

Defined in GenePDFHtmlLib

Methods

def :: LHead

data PDFInfo Source #

Constructors

PDFInfo 

Fields

Instances

Instances details
Eq PDFInfo Source # 
Instance details

Defined in GenePDFHtmlLib

Methods

(==) :: PDFInfo -> PDFInfo -> Bool

(/=) :: PDFInfo -> PDFInfo -> Bool

Read PDFInfo Source # 
Instance details

Defined in GenePDFHtmlLib

Methods

readsPrec :: Int -> ReadS PDFInfo

readList :: ReadS [PDFInfo]

readPrec :: ReadPrec PDFInfo

readListPrec :: ReadPrec [PDFInfo]

Show PDFInfo Source # 
Instance details

Defined in GenePDFHtmlLib

Methods

showsPrec :: Int -> PDFInfo -> ShowS

show :: PDFInfo -> String

showList :: [PDFInfo] -> ShowS

FromRow PDFInfo Source #

Sqlite toRow and fromRow

Sqlite toRow and fromRow

SQLData

fromRow

   class ToRow where
       toRow:: a -> [SQLData]

   class FromRow where
       fromRow:: RowParser a

   class Functor f where
       fmap (a -> b) -> f a -> f b
   <$> = fmap 

   (+1) <$> Just [1, 2] => Just [2, 3]

   class Functor f => Applicative f where
       <*> :: f (a -> b) -> f a -> f b

   Just (+1) <*> Just [1, 2] => Just [2, 3]
   
Instance details

Defined in GenePDFHtmlLib

Methods

fromRow :: RowParser PDFInfo

ToRow PDFInfo Source # 
Instance details

Defined in GenePDFHtmlLib

Methods

toRow :: PDFInfo -> [SQLData]

titleDesc :: [String] -> LHead Source #

Parse first two lines inside .tex file

  • If title and desc are found, return an titleDesc with the title and desc
  • Otherwise return an default titleDesc which is empty title and empty desc.
  • Example inside latex file.
   % title : This is an awesome.
   % desc  : The document is doing some fantastic thing. 
   

_PDFTABLE :: Query Source #

embed :: Text -> Text Source #

  let link = "http://xfido.com"
  let imglink = "/a.png"
  href link (img imglink  styleTag_ [("width", "100px"), ("height", "100px")]) 
 

td_ :: Text -> Text -> Text Source #

trT :: Text -> Text Source #

styleT :: [Text] -> Text Source #

tableACT :: Text -> Text -> Text Source #

tableAA :: [[[Text]]] -> Text Source #

href_ :: Text -> Text -> Text Source #

tableA_ :: [[(Text, Text, Text)]] -> Text Source #

Generate html table "genepdf.html"

 style=''
   trtdhref='pdf/f.pdf'src='pdfimage/f-0.png'/td
   /tr
 /table
 

(title, baseNameT or pdesc, path to PDF file)

XXX

tableA2_ :: [[(Text, Text, Text)]] -> Text Source #

KEY: Generate png file format from pdf file

   -- first page of pdf file
   pdffile.pdf => pdffile-0.png
 

insertTexToTable :: Connection -> [String] -> IO () Source #

Insert tex file PDFInfo to database

  • read file with readFileLatin1ToList
  • read the first two lines from a tex file
  • create PDFInfo record
  • insert into database
  • texPath = $HOME / "myfilebitbucketmath"

dropTableSqlite :: Connection -> Query -> IO () Source #

Create new table _PDFTABLE

doesTableExistSqlite :: Connection -> Query -> IO Bool Source #

Check whether a table exist in Sqlite3

  • sqlite_master schema
   CREATE TABLE sqlite_master(
     type text,
     name text,
     tbl_name text,
     rootpage integer,
     sql text
   );
   

createNewTable :: Connection -> Query -> IO () Source #

Create new table _PDFTABLE IF NOT EXISTS

_PDFTABLE = "pdftable"

insertPDFToTable :: Connection -> [String] -> IO () Source #

Insert PDF file to database

_PDFTABLE = "pdftable"

queryDBToHtml :: Connection -> Query -> String -> IO ByteString Source #

KEY: Query PDF files name from table:[_PDFfile = pdffile] and create html page genepdf.html => send html page to client

⇒ read PDF file name from table _PDFfile = pdffile ⇒ create html page, (html table) → * use tableA_

⇒ send page to client

_PDFTABLE = "pdftable"
  1. Connection - db connection
  2. Query - table name
  3. String - absolute path location to pdf files
  4. return - Html page in BS.Bytestring
   data PDFInfo = PDFInfo 
     { pdfId :: Int64
     , title :: Text
     , pdesc :: Text
     , path  :: Text
     } deriving (Eq,Read,Show)
  

pdfMain :: Connection -> String -> IO ByteString Source #

Currently, the table need to be deleted manually in order to get new pdf files from $www/pdf

See config.txt

   sqlite3 $bdatabasehaskellwebapp_sqlite3.db

   .table
   .schema pdftable
   SELECT path FROM pdftable WHERE path LIKE '%haskell%';

   $bdatabasehaskellwebapp_sqlite3_test.db
   $bdatabasehaskellwebapp_sqlite3.db

   _PDFTABLE = "pdftable"

   * Rename table:
   ALERT TABLE old_table RENAME TO new_table

   * Restart the service
     ps aux | grep haskellwebapp2 | awk '{print $2}' | line 'x -> kill -9 x'
     haskellwebapp2.sh

   
  • TODO:
  • Better approach is to insert pdf file to database externally
  • Create a monitor to the pdf folder and run the code to insert pdf file to table(pdftable)
   dropTableSqlite conn _PDFTABLE 
   foundTable <- doesTableExistSqlite conn _PDFTABLE 
   createNewTable conn _PDFTABLE 
   insertTexToTable conn utexFile 
   insertPDFToTable conn updfFile 
   
  • USED: WaiLib.hs => PDF.pdfMain
  • Currently, use all the PDF under $b/math
   haskellwebapp2pdf -> LibraryWebServerDocumentsxfidopdf
   

getPDFPath :: String -> IO String Source #

getPDFPath_t :: String -> IO String Source #

test only, use getPDFPath