#
# Alexander Barkov <bar@mnogosearch.org>
#
# Sample fo HTDB virtual scheme usage
#
# I tested this to search through our web-board 
# at http://search.mnogo.ru/board/board.php?board=1 
# wich is  stored in MySQL database. Messages
# are available under URLs like this:
# http://search.mnogo.ru/board/message.php?id=XXX
# where XXX is message PRIMARY KEY value.
#

DBAddr mysql://foo:bar@localhost/udm/

# Add standard HTML sections 
Section body  1 256
Section title 2 128
# Add CachedCopy for smart excerpts
Section CachedCopy 100 128000

# List which will be gererated for "htdb:/" URL

HTDBList "SELECT concat('http://search.mnogo.ru/board/message.php?id=',id) \
FROM udm.messages"


# Documents which will be generated for each "htdb:/XXX"  documents
# where XXX is 'messages' table PRIMARY KEY value.

HTDBDoc "\
SELECT concat( \
'HTTP/1.0 200 OK\\r\\n',\
'Content-type: text/html\\r\\n',\
'Last-Modified: ',Date_format(posted,'%a, %d %b %Y %T'),' GMT\\r\\n',\
'\\r\\n',\
'<HTML><HEAD>',\
'<TITLE>',subject,'</TITLE>',\
'<META NAME=''Description" Content=''',author,' ',urlname,' ',url,'''>',\
'</HEAD>\\n',\
'<BODY>\\n',msg,'\\n</BODY></HTML>'\
) \
FROM udm.messages \
WHERE id='$1'"



# Add HTDBList to generate a list of messages:
Server htdb:/

# Add messages:
Realm  http://search.mnogo.ru/board/message.php?id=*

# Add messages URL translation:
# http://search.mnogo.ru/board/message.php?id=XXX -> htdb:/XXX

Alias  http://search.mnogo.ru/board/message.php?id=  htdb:/

