express = require 'express'
xmler = require 'node-xmler'
router = express.Router()

# GET: /explore
router.get '/', (req, res) ->
  # TODO: Show latest letters
  res.render 'explore/index',
    title: req.config.title

# GET: /explore/search
router.get '/search', (req, res) ->
  client = req.baseXClient

  query =
    text:
      'declare namespace tei="http://www.tei-c.org/ns/1.0"; ' +
      '//tei:title[. = "' + req.query.q + '"]'

  client.query query, (results) ->
    # TODO: Convert XML to JS object
    res.render 'explore/search',
      title: req.config.title
      query: req.query.q
      results: results

module.exports = router

express = require 'express'
xmler = require 'node-xmler'
router = express.Router()

# GET: /explore
router.get '/', (req, res) ->
  # TODO: Show latest letters
  res.render 'explore/index',
    title: req.config.title

# GET: /explore/search
router.get '/search', (req, res) ->
  client = req.baseXClient

  query =
    text:
      'declare namespace tei="http://www.tei-c.org/ns/1.0"; ' +
      '//tei:title[contains(text(), "' + req.query.q + '")]'

  client.query query, (results) ->
    # TODO: Convert XML to JS object
    res.render 'explore/search',
      title: req.config.title
      query: req.query.q
      results: results

module.exports = router

Update search query to check if contains string
Update search query to check if contains string

This overrides the original search method which required an exact
match to show results. The new contains approach will return any title
that contains the query string.
