/upstream/templates/search/editions.tmpl
Type: /type/template
body: value: $def with (get_results)

$ q = query_param('q')
$ results_per_page = 100
$ page = query_param('page')
$if page:
    $ page = int(page)
$else:
    $ page = 1
$ offset = (page - 1) * results_per_page

<div id="contentHead">
    <h1>
        $_("Edition Search")
    </h1>

$if q:
    $ results = get_results(q, offset=offset, limit=results_per_page)
    $if 'error' not in results:
        $ response = results['response']
        $ num_found = int(response['numFound'])
        <p class="sansserif darkgreen collapse"><strong>$commify(response['numFound']) hit$("s" if response['numFound'] != 1 else "")</strong></p>
$else:
    <p class="sansserif red collapse"><strong>No hits</strong></span></p>

</div>

<div id="contentBody">

    <div class="section">

    <form class="siteSearch olform" action="">
        <input type="text" class="larger" name="q" size="100" style="width: 505px;" value="$q"/>
        <input type="submit"  class="large" value="$_('Search')"/>
    </form>

    </div>

    $if q and 'error' in results:
        <strong>
            $for line in results['error'].splitlines():
                $line
                $if not loop.last:
                    <br>
        </strong>

    $if q and 'error' not in results:
        <div id="searchResults">
        <ul id="siteSearch">
        $for doc in response['docs']:
            $ authors = zip(doc.get('author_key', []), doc.get('author_name', []))
            <li>
            <span class="bookcover">
                $ cover = "http://covers.openlibrary.org/b/olid/%s-M.jpg?default=http://openlibrary.org/images/icons/avatar_book-sm.png" % doc['key']
                <a href="/books/$doc['key']"><img src="$cover" height="70" alt="$doc['title']" title="$doc['title']"/></a>
            </span>
            <span class="details">
                <span class="resultTitle">
                    <span class="booktitle sansserif">
                        $ title = doc['title']
                        $if doc.get('subtitle', None):
                            $ title = title + ': ' + doc['subtitle']
                        <b><a href="/books/$doc['key']" class="results">$title</a></b>
                    </span>
                
                    <span class="bookauthor">
                    $if authors:
                        by
                        $for k, n in authors:
                            <a href="http://upstream.openlibrary.org/authors/$k" class="results">$n</a>$(',' if not loop.last else '')
                    $else:
                        <em>no authors</em>
                    </span>
                    $if 'publisher' in doc:
                        <span class="resultPublisher">
                            Published $doc.get('publish_date', '') by $', '.join(doc['publisher'])
                        </span>
                </span>
            </span>
            </li>
            <!-- $:doc -->
        </ul>
        </div>

        $:macros.Pager(page, num_found, results_per_page)

</div>
plugin: worksearch
m: edit