Safe Haskell | None |
---|
Synopsis
- data LHead = LHead {}
- data PDFInfo = PDFInfo {}
- titleDesc :: [String] -> LHead
- hempty :: LHead
- _PDFTABLE :: Query
- embed :: Text -> Text
- td_ :: Text -> Text -> Text
- trT :: Text -> Text
- styleT :: [Text] -> Text
- tableACT :: Text -> Text -> Text
- tableAA :: [[[Text]]] -> Text
- href_ :: Text -> Text -> Text
- tableA_ :: [[(Text, Text, Text)]] -> Text
- tableA2_ :: [[(Text, Text, Text)]] -> Text
- insertTexToTable :: Connection -> [String] -> IO ()
- dropTableSqlite :: Connection -> Query -> IO ()
- doesTableExistSqlite :: Connection -> Query -> IO Bool
- createNewTable :: Connection -> Query -> IO ()
- insertPDFToTable :: Connection -> [String] -> IO ()
- queryDBToHtml :: Connection -> Query -> String -> IO ByteString
- pdfMain :: Connection -> String -> IO ByteString
- getPDFPath :: String -> IO String
- getPDFPath_t :: String -> IO String
Documentation
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
Instances
Instances
Eq PDFInfo Source # | |
Read PDFInfo Source # | |
Defined in GenePDFHtmlLib | |
Show PDFInfo Source # | |
FromRow PDFInfo Source # | Sqlite toRow and fromRowclass 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] |
Defined in GenePDFHtmlLib | |
ToRow PDFInfo Source # | |
Defined in GenePDFHtmlLib |
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.
embed :: Text -> Text Source #
let link = "http://xfido.com" let imglink = "/a.png" href link (img imglink styleTag_ [("width", "100px"), ("height", "100px")])
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 #
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"
- Connection - db connection
- Query - table name
- String - absolute path location to pdf files
- 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 #