/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')

$if page.title_prefix:
    $ title = page.title_prefix + ' ' + page.title
$else:
    $ title = 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="$:page.cover_url()" style="text-decoration: none">Change Cover</a>
            </div>

            $if page.ocaid:
                <div class="editbutton" style="width: 163px;">
                    <a href="http://www.archive.org/stream/$page.ocaid" style="text-decoration:none">$_.full_text</a>
                </div>
        </div>
    </div>

    <div>


            <table border="0" cellpadding="0" cellspacing="0">

                $ s1 = ["contributions", "other_titles", "work_titles", "works", "by_statement", "series", "copyright_date", "source_records", "languages", "translated_from", "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 == 'source_records':
                                    <td class="formfield$rule" width="100%">
                                    $for src in page[name]:
                                        $if src.startswith('marc:'):
                                            <a href="http://openlibrary.org/show-marc/$src[5:]">Library MARC record</a><br>
                                        $elif src.startswith('amazon:'):
                                            <a href="http://amazon.com/dp/$src[7:17]">Amazon.com</a><br>
                                        $elif src.startswith('ia:'):
                                            Internet Archive: <a href="http://www.archive.org/details/$src[3:]">$src[3:]</a><br>
                                        $else:
                                            $:thingrepr(src)<br>
                                    </td>
                                $elif name == "subjects":
                                    <td class="formfield$rule" width="100%">
                                    $for subject in page[name]:
                                        <a href="/search?ftokens=$:utf8(facet_token('subjects', 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>


$if page.ocaid: <blockquote class="text" style="margin-left: 32px; margin-top: 60px;">
$if not page.ocaid: <blockquote class="text" style="margin-left: 32px; margin-right: 20px;">


            <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>
    $for line in page.notes.split('\n'):
        $line<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], basestring):
                        $ 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 />

<!-- source_records: $page.get('source_records', []) -->