Add basic html/rss support for book lists
This commit is contained in:
parent
c0a70a18e1
commit
46762ea17b
11 changed files with 254 additions and 78 deletions
|
@ -76,4 +76,31 @@ function delBook(){
|
|||
</div>
|
||||
</div>
|
||||
|
||||
{{if .Lists}}
|
||||
<br />
|
||||
<div class="span10 offset1">
|
||||
<h4>Book in lists:</h4>
|
||||
<ul>
|
||||
{{range .Lists}}
|
||||
<li><a href="/list/{{.ListID}}">{{.Title}}</a> ({{len .Books}})</li>
|
||||
{{end}}
|
||||
</ul>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
{{if .S.User}}
|
||||
<br />
|
||||
<form class="span6 offset3 form-inline" method="POST" action="/list/">
|
||||
<input type="hidden" id="book_id" name="book_id" value="{{.Book.ID}}">
|
||||
<input type="text" data-provide="typeahead" id="list" name="list">
|
||||
<button type="submit" class="btn btn-primary">Add to list</button>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
$(window).load(function() {
|
||||
$('.typeahead').typeahead(source={{.UserLists}})
|
||||
})
|
||||
</script>
|
||||
{{end}}
|
||||
|
||||
{{template "footer.html"}}
|
||||
|
|
25
templates/book_list.html
Normal file
25
templates/book_list.html
Normal file
|
@ -0,0 +1,25 @@
|
|||
{{range .}}
|
||||
<div class="row">
|
||||
<div class="span1">
|
||||
<p class="pull-right"><a href="/book/{{.ID}}">{{if .Cover}}<img class="img-rounded" src="/cover/{{.ID}}/small/{{.Title}}.jpg" alt="{{.Title}}" />{{end}}</a></p>
|
||||
</div>
|
||||
<div class="span10 well">
|
||||
<div class="row">
|
||||
<div class="span7">
|
||||
<p>
|
||||
<span class="muted">[{{if .Lang}}{{.Lang}}{{end}}]</span>
|
||||
<a href="/book/{{.ID}}"><strong>{{.Title}}</strong></a>
|
||||
<span class="muted">{{if .Publisher}}{{.Publisher}}{{end}}</span><br />
|
||||
{{range .Authors}}{{.}}, {{end}}
|
||||
</p>
|
||||
</div>
|
||||
<div class="span3">
|
||||
<div class="btn-group pull-right">
|
||||
<a href="/download/{{.ID}}/{{.Title}}.epub" class="btn btn-inverse"><i class="icon-download-alt icon-white"></i> download</a>
|
||||
<a href="/read/{{.ID}}" class="btn btn-warning"><i class="icon-eye-open icon-white"></i> read it!</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
17
templates/book_list.rss
Normal file
17
templates/book_list.rss
Normal file
|
@ -0,0 +1,17 @@
|
|||
{{$baseURL := .BaseURL}}
|
||||
{{range .Books}}
|
||||
<item>
|
||||
<title>{{.Title}} - {{index .Authors 0}}</title>
|
||||
<description>{{.Description}}</description>
|
||||
<link>{{$baseURL}}/book/{{.ID}}</link>
|
||||
{{if .Isbn}}
|
||||
<guid isPermaLink="false">ISBN: {{.Isbn}}</guid>
|
||||
{{end}}
|
||||
<enclosure url="{{$baseURL}}/download/{{.ID}}/{{.Title}}.epub" length="{{.FileSize}}" type="application/epub+zip" />
|
||||
{{range .Authors}}
|
||||
{{if .}}
|
||||
<category>{{.}}</category>
|
||||
{{end}}
|
||||
{{end}}
|
||||
</item>
|
||||
{{end}}
|
16
templates/list.html
Normal file
16
templates/list.html
Normal file
|
@ -0,0 +1,16 @@
|
|||
{{template "header.html" .S}}
|
||||
|
||||
<div class="row">
|
||||
<h4 class="span10">{{.List.Title}} <a href="/list/{{.List.ListID}}?fmt=rss"><img src="/img/feed.png"/></a></h4>
|
||||
<p class="span2 pull-right">By {{.List.User.Username}}</p>
|
||||
</div>
|
||||
<br />
|
||||
|
||||
{{range .List.Description}}
|
||||
<p>{{.}}</p>
|
||||
{{end}}
|
||||
|
||||
|
||||
{{template "book_list.html" .List.Books}}
|
||||
|
||||
{{template "footer.html"}}
|
14
templates/list.rss
Normal file
14
templates/list.rss
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<rss version="2.0">
|
||||
<channel>
|
||||
<title>{{.S.Title}}</title>
|
||||
<description>{{range .List.Description}}
|
||||
{{.}}
|
||||
{{end}}</description>
|
||||
<link>{{.S.BaseURL}}/list/{{.List.ListID}}</link>
|
||||
<managingEditor>{{.List.User.Username}}</managingEditor>
|
||||
|
||||
{{template "book_list.rss" book_list .List.Books .S.BaseURL}}
|
||||
|
||||
</channel>
|
||||
</rss>
|
|
@ -17,33 +17,7 @@
|
|||
{{end}}
|
||||
</ul>
|
||||
|
||||
{{with .Books}}
|
||||
{{range .}}
|
||||
<div class="row">
|
||||
<div class="span1">
|
||||
<p class="pull-right"><a href="/book/{{.ID}}">{{if .Cover}}<img class="img-rounded" src="/cover/{{.ID}}/small/{{.Title}}.jpg" alt="{{.Title}}" />{{end}}</a></p>
|
||||
</div>
|
||||
<div class="span10 well">
|
||||
<div class="row">
|
||||
<div class="span7">
|
||||
<p>
|
||||
<span class="muted">[{{if .Lang}}{{.Lang}}{{end}}]</span>
|
||||
<a href="/book/{{.ID}}"><strong>{{.Title}}</strong></a>
|
||||
<span class="muted">{{if .Publisher}}{{.Publisher}}{{end}}</span><br />
|
||||
{{range .Authors}}{{.}}, {{end}}
|
||||
</p>
|
||||
</div>
|
||||
<div class="span3">
|
||||
<div class="btn-group pull-right">
|
||||
<a href="/download/{{.ID}}/{{.Title}}.epub" class="btn btn-inverse"><i class="icon-download-alt icon-white"></i> download</a>
|
||||
<a href="/read/{{.ID}}" class="btn btn-warning"><i class="icon-eye-open icon-white"></i> read it!</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{template "book_list.html" .Books}}
|
||||
|
||||
<ul class="pager">
|
||||
{{if .Prev}}
|
||||
|
|
|
@ -11,23 +11,7 @@
|
|||
<link>{{.BaseURL}}</link>
|
||||
{{end}}
|
||||
|
||||
{{$baseURL := .S.BaseURL}}
|
||||
{{range .Books}}
|
||||
<item>
|
||||
<title>{{.Title}} - {{index .Authors 0}}</title>
|
||||
<description>{{.Description}}</description>
|
||||
<link>{{$baseURL}}/book/{{.ID}}</link>
|
||||
{{if .Isbn}}
|
||||
<guid isPermaLink="false">ISBN: {{.Isbn}}</guid>
|
||||
{{end}}
|
||||
<enclosure url="{{$baseURL}}/download/{{.ID}}/{{.Title}}.epub" length="{{.FileSize}}" type="application/epub+zip" />
|
||||
{{range .Authors}}
|
||||
{{if .}}
|
||||
<category>{{.}}</category>
|
||||
{{end}}
|
||||
{{end}}
|
||||
</item>
|
||||
{{end}}
|
||||
{{template "book_list.rss" book_list .Books .S.BaseURL}}
|
||||
|
||||
</channel>
|
||||
</rss>
|
||||
|
|
Reference in a new issue