/dev/templates/type/edition/view.tmpl
Type: /type/template
body: value: $def with (page)

$ lang = i18n.get_locale() or 'en'
$ _t = i18n.get_namespace('/type/edition')
$ _ = i18n.get_namespace('/mode/view')

$ title = page.title_prefix + ' ' + page.title

$var title: $title

$add_javascript('/static/js/jquery/jquery.js')
$add_javascript('/static/js/jquery/thickbox.js')

$add_stylesheet("/css/thickbox.css?format=raw")
$add_stylesheet("/css/doc-styles.css?format=raw")

<script type="text/javascript">
// <!--
function gbs_callback(d) {
    for (var k in d) {
        // process just the first resut
        document.getElementById('gbs_placeholder').innerHTML = '<a href="' + d[k]['info_url'] + '" class="datalink">$_t.gbs</a> (' + d[k]['preview']+')';
        break;
    }
}
// -->
</script>


<style type="text/css">
<!--
#book-art { width: 175px; height: 300px; text-align: center; float: left; padding-top: 21px; padding-left: 13px; padding-right: 14px; clear: both; }

/*background: transparent url(/static/logos/logo-${lang}.png) top center no-repeat; } */

td.toc { border-bottom: 2px dotted #ccc; }
td.toc-ellipsis { border-bottom: 2px dotted #ccc; padding-bottom: 0px;}
td.toc-number { font-style: bold; padding-bottom: 0px;}
td.toc-link-end { font-style: bold; padding-bottom: 0px;}

-->
</style>	

$ lccn = page["lccn"] and page["lccn"][0] and ("http://lccn.loc.gov/" + page["lccn"][0])
$ oclc = page["oclc_numbers"] and page["oclc_numbers"][0] and ("http://www.worldcat.org/oclc/" + page["oclc_numbers"][0] + "?tab=details")



<table border="0" cellpadding="0" cellspacing="0" width="100%" style="clear:both"><tr><td valign="top" width="100%">
<blockquote class="text">
    <div id="header">               
        <div id="title" class="title-pad">$title</div>
            $if page.get('subtitle'): <div class="subtitle" style="margin-top: -4px;">$page.subtitle<br /></div>

        <div id="statement">
            $if page.authors: by <span class="datalink">$:thingrepr(page.authors)</span><br />
            <span class="book-details-italic">
            $if page.get('publish_date'): $_.published_in $page.publish_date, 
            $if page.get('publishers'): $:thingrepr(page.publishers)
            $if page.get('publish_places'): ($:thingrepr(page.publish_places).strip())

            <br /></span> 

        </div>

        <div id="book-art" class="datalink" style="clear: both">
            $:macros.CoverImage(page)
            <div class="editbutton" style="margin-bottom: 6px; margin-top: 6px; width: 163px;">
                <a href="$:changequery(m='change_cover')" style="text-decoration: none">Change Cover</a>
            </div>

            $if page.ocaid:
                <div class="editbutton" style="width: 163px; margin-bottom: 10px;">
                    <a href="http://openlibrary.org/details/$page.ocaid" style="text-decoration:none">$_.full_text</a>
                </div>
                <!-- scod enabled = $("scod" in get_plugins()) -->
                $if 'scod' in get_plugins():
    		        $ scan_status = get_scan_status(page.key)
                        <!-- scan_status = $scan_status -->
    		        $if scan_status == "NOT_SCANNED":
    		            <div class="editbutton" style="width: 163px;"><a href="$page.key?m=scan_review" title="Open Library Scan On Demand">Scan This Book</a></div><br/>
    		        $elif (scan_status == "SCAN_IN_PROGRESS") or (scan_status == "WAITING_FOR_BOOK"):
    		            <div style="margin-top: 10px;"><span class="book-details-italic">Scan Progress <a href="/scan_record/b/$olid">(details)</a></span></div>
        </div>
    </div>

    <div>


            <table border="0" cellpadding="0" cellspacing="0">

                $ s1 = ["contributions", "other_titles", "work_titles", "works", "by_statement", "series", "copyright_date", "languages", "edition_name", "physical_format", "physical_dimensions", "pagination", "weight"]
                $ s2 = ["isbn_10", "isbn_13", "lccn", "dewey_decimal_class", "lc_classifications", "oclc_numbers"]
                $ s3 = ["genres", "subjects"]
                $ s4 = ["download_url", "purchase_url"]
                $ sections = [s1, s2, s3, s4]


                $ rule = "-top"

                $for s in sections:
                    $for name in s:
                        $if page[name]:
                            <tr>
                                <td class="formheader$rule">$_t[name]:</td>
                                $if name.endswith("_url"):
                                    $ links = []
                                    $for n in page[name]:
                                        $links.append('<a href="' + n + '">' + n + '</a>')
                                    $ links = NEWLINE.join(links)
                                    <td class="formfield$rule" width="100%">$:links</a></td>
                                $elif name == "lccn":
                                    $if lccn: <td class="formfield$rule" width="100%"><a href="$lccn">$:thingrepr(page[name])</a></td>
                                $elif name == "oclc_numbers":
                                    $if oclc: <td class="formfield$rule" width="100%"><a href="$oclc">$:thingrepr(page[name])</a></td>
                                $elif name == "subjects":
                                    <td class="formfield$rule" width="100%">
                                    $for subject in page[name]:
                                        <a href="/search?ftokens=$:utf8(facet_token('subjects', thingrepr(subject).strip()))">$:utf8(thingrepr(subject)).replace('--', '&mdash;')</a><br />
                                    </td>
                                $else:
                                    <td class="formfield$rule" width="100%">$:thingrepr(page[name])</td>
                            </tr>
                            $ rule = ""
                     $ rule = "-rule"

            </table>
    </blockquote>
    </td><td valign="top">
      $:macros.OptionsEdition(page)
</td></tr></table>


<blockquote class="text">

            <div class="toc-header" style="border-bottom: 1px solid #ccc">
                <b>$_.description</b>

$:macros.FlourishButton("edit", changequery(m='edit'), "right", "edition")

            </div>


<br />
$if page.notes: <b>Notes:</b> $page.notes<br /><br />

$if page.first_sentence: <b>First sentence:</b> $page.first_sentence<br /><br />
            
$if page.description: $:format(page.description)<br /><br />

$if page.uris:
    <div class="toc-header" style="border-bottom: 1px solid #ccc">
        <b>External links</b>
    </div>

    <table>
        $for num in range(len(page['uris'])):
            $if num < len(page['uri_descriptions']):
                $ desc = page.uri_descriptions[num]
            $else:
                $ desc = page.uris[num]
            <tr>
                <td class="path" valign="top">$desc</td>
                <td class="path" valign="top"><a href="$page.uris[num]">$page.uris[num]</a></td>
            </tr>
    </table>


<div class="toc-header" style="padding-top: 35px;">
    <b>$_t.table_of_contents</b>

$:macros.FlourishButton("edit", changequery(m='edit'), "right", "edition")

</div>

        $if page.table_of_contents:
            <div style="padding-top: 10px;">
                <table border="0" cellpadding="0" cellspacing="0" width="100%">
                    $ first = "first"
                    $ table_of_contents = page.table_of_contents
                    $if isinstance(table_of_contents[0], (str, unicode)):
                        $ table_of_contents = [{'class': 'section', 'label': '', 'title': x, 'pagenum': ''} for x in table_of_contents]
                    $for i, toc in enumerate(table_of_contents):
                        <tr class="toc-$toc['class']">
                            <td class="toc-number rule $first"><b>$toc['label']</b>&nbsp;&nbsp;</td>
                            <td class="toc rule $first" style="white-space: nowrap">$toc['title']</td>
                            <td class="toc-ellipsis rule $first" style="width: 100%"></td>
                            <td class="toc-link-end rule $first" align="center">$toc['pagenum']&nbsp;&nbsp;</td>
                        </tr>
                        $ first = ""
                </table>
            </div>
        $else:
            <p><em><span class="copyright">No table of contents available</span> <img src="/static/images/arrow.red.png" alt="Disclosure Arrow" /> <a href="$changequery(m='edit')"  style="text-decoration: underline">Add it!</a></em></p>


    </div>
</div>
</blockquote>

<br /><br />


$ keys = []
$for isbn in page.get('isbn_10', []) + page.get("isbn_13", []):
    $ keys.append("ISBN:" + isbn)
$for lccn in page.get('lccn', []):
    $ keys.append("LCCN:" + lccn)
$for oclc in page.get('oclc', []):
    $ keys.append("OCLC:" + oclc)

$if keys:
    <script src="http://books.google.com/books?bibkeys=$(",".join(keys))&amp;jscmd=viewapi&amp;callback=gbs_callback" type="text/javascript"></script>
title: Edition view template