This repository has been archived on 2025-03-01. You can view files and clone it, but cannot push or open issues or pull requests.
trantor/templates/book.html

180 lines
5.3 KiB
HTML
Raw Normal View History

2012-08-18 02:06:43 +02:00
{{template "header.html" .S}}
2012-08-15 12:00:44 +02:00
2016-10-16 20:05:45 -04:00
{{$role := .S.Role}}
{{$downloadCounter := .DownloadCounter}}
2012-08-18 02:06:43 +02:00
{{with .Book}}
<script>
function delBook(){
const div = document.getElementById('delete');
div.classList.remove("visually-hidden");
}
function closeAlert() {
const div = document.getElementById('delete');
div.classList.add("visually-hidden");
2012-08-18 02:06:43 +02:00
}
</script>
<div id="delete" class="alert alert-danger fade visually-hidden show" role="alert">
<div class="row">
<div class="col-11">
<h4 class="alert-heading">Do you really want to delete it?</h4>
<p>Remove a book is permanent, you won't be able to get it back</p>
<a class="btn btn-danger" href="/delete/{{.ID}}/">Remove it</a>
<a class="btn" href="#" onClick="closeAlert();">Cancel</a>
</div>
<div class="col-1 justify-content-end">
<button type="button" class="btn-close" onClick="closeAlert();"></button>
</div>
</div>
</div>
2012-08-18 02:06:43 +02:00
<header class="row justify-content-end">
<h1>{{.Title}}
{{if not .Active}}
<span class="badge label-warning text-dark">waiting for moderation</span>
{{end}}
</h1>
2012-08-18 02:06:43 +02:00
</header>
2012-08-17 08:25:44 +02:00
<div class="row">
{{if .Cover}}
<div class="col-sm-4 text-center">
<img src="/cover/{{.ID}}/big/{{.Title}}.jpg" alt="{{.Title}}" class="float-sm-end img-fluid" />
2012-08-17 08:25:44 +02:00
</div>
{{end}}
2012-07-31 00:42:02 +02:00
<div class="col-sm-8">
<div class="row">
<div class="col-md-8">
<dl class="row">
{{if .Authors}}
<dt class="col-sm-3 text-sm-end">Authors</dt>
<dd class="col-sm-9 text-start">
{{range $i, $author := .Authors}}
{{if $i}}&amp;{{end}}
<a href="/search/?q=author:{{$author}}">{{$author}}</a>
{{end}}
</dd>
{{end}}
{{if .Publisher}}
<dt class="col-sm-3 text-sm-end">Publisher</dt>
<dd class="col-sm-9 text-start"><a href="/search/?q=publisher:{{.Publisher}}">{{.Publisher}}</a></dd>
{{end}}
{{if .Tags}}
<dt class="col-sm-3 text-sm-end">Tags</dt>
<dd class="col-sm-9 text-start">
{{range $i, $tag := .Tags}}
{{if $i}},{{end}}
<a href="/search/?q=tag:{{$tag}}">{{$tag}}</a>
{{end}}
</dd>
{{end}}
{{if .Isbn}}
<dt class="col-sm-3 text-sm-end">ISBN</dt>
<dd class="col-sm-9 text-start">{{.Isbn}}</dd>
{{end}}
{{if .Date}}
<dt class="col-sm-3 text-sm-end">Date</dt>
<dd class="col-sm-9 text-start">{{.Date}}</dd>
{{end}}
{{if .FileSize}}
<dt class="col-sm-3 text-sm-end">Size</dt>
<dd class="col-sm-9 text-start">{{printf "%.2f" (size2mb .FileSize)}} MB</dd>
{{end}}
{{if .Lang}}
<dt class="col-sm-3 text-sm-end">Lang</dt>
<dd class="col-sm-9 text-start"><a href="/search/?q=lang:{{.Lang}}">{{.Lang}}</a> </dd>
{{end}}
</dl>
</div>
<div class="col-md-4">
<div class="btn-group d-flex justify-content-end">
<a href="{{download_url .}}" class="btn btn-dark btn-sm">
<svg class="bi" width="1em" height="1em" fill="currentColor">
<use xlink:href="/img/bootstrap-icons.svg#file-earmark-arrow-down"/>
</svg>
download
</a>
<a href="/read/{{.ID}}" class="btn btn-warning btn-sm">
<svg class="bi" width="1em" height="1em" fill="currentColor">
<use xlink:href="/img/bootstrap-icons.svg#eyeglasses"/>
</svg>
read it!
</a>
2014-09-07 20:22:24 -05:00
</div>
<div class="text-end">
<small>Downloaded: {{$downloadCounter}} times</small>
</div>
{{if eq $role "admin" "moderator"}}
<div class="row"><p></p></div>
<div class="btn-group d-flex justify-content-end">
<a href="/edit/{{.ID}}" class="btn btn-primary btn-sm">
<svg class="bi" width="1em" height="1em" fill="currentColor">
<use xlink:href="/img/bootstrap-icons.svg#pencil"/>
</svg>
edit
</a>
<a href="#" onClick="delBook();" class="btn btn-danger btn-sm">
<svg class="bi" width="1em" height="1em" fill="currentColor">
<use xlink:href="/img/bootstrap-icons.svg#trash"/>
</svg>
delete
</a>
</div>
{{end}}
</div>
</div>
2013-05-31 00:34:11 +02:00
{{end}}
2012-08-17 08:25:44 +02:00
<div class="row">
2013-05-31 00:34:11 +02:00
{{range .Description}}
<p>{{.}}</p>
2012-09-09 13:16:51 +02:00
{{end}}
2012-08-17 08:25:44 +02:00
</div>
</div>
2012-08-17 08:25:44 +02:00
</div>
2012-08-15 12:00:44 +02:00
{{if .Lists}}
<br />
<div class="row justify-content-center">
<div class="col-10">
<h4>Book in lists:</h4>
<ul class="nav flex-column">
{{range .Lists}}
<li class="nav-item">
<a class="nav-link" href="/list/{{.ListID}}">
<div class="row">
<div class="col">{{.Title}} ({{len .Books}})</div>
<div class="col text-end">By {{.User.Username}}</div>
</div>
</a>
</li>
{{end}}
</ul>
</div>
</div>
{{else}}
<br />
{{end}}
<br />
{{if .S.User}}
<form method="POST" action="/list/">
<div class="row g-3 align-items-start">
<h6 class="col-sm-2 text-sm-end col-form-label">Add book to a list:</h6>
<input type="hidden" id="book_id" name="book_id" value="{{.Book.ID}}">
<div class="col-sm-5">
<div class="input-group">
<input class="form-control" list="bookListOptions" id="list" name="list" placeholder="Write a name of a list to create or add">
<datalist id="bookListOptions">
{{range .UserLists}}
<option value="{{.}}">
{{end}}
</datalist>
<button type="submit" class="btn btn-primary">Add</button>
</div>
</div>
</div>
</form>
{{end}}
2020-03-23 19:13:58 +00:00
{{template "footer.html" .S}}