Pull search logic out of the controller
Don't render the fragments partial if there are no line or body fragments for the entry
Move location of the call to html_safe
DRY up the index page a bit