Add rss feed

This commit is contained in:
Las Zenow 2013-08-31 00:38:32 +02:00
parent c3529c3a8e
commit 56964ec45f
7 changed files with 58 additions and 3 deletions

View file

@ -6,6 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="/css/bootstrap-responsive.min.css" rel="stylesheet">
<link href="/css/custom.css" rel="stylesheet">
<link rel="alternate" type="application/rss+xml" title="Imperial Library of Trantor" href="/search/?fmt=rss&q={{.Search}}" />
<title>Imperial Library of Trantor</title>
<script src="/js/jquery.js"></script>
</head>

View file

@ -8,7 +8,7 @@
<div class="row">
<div class="span8">
<h4>Last books added:</h4>
<h4>Last books added: <a href="/search/?fmt=rss&q="><img src="/img/feed.png"/></a></h4>
</div>
<div class="span4">
<p class="pull-right">{{.Count}} books</p>

View file

@ -1,6 +1,6 @@
{{template "header.html" .S}}
<p class="centered">Found {{.Found}} books. Page {{.Page}}</p>
<p class="centered">Found {{.Found}} books. Page {{.Page}} <a href="/search/?fmt=rss&q={{.S.Search}}"><img src="/img/feed.png"/></a></p>
<ul class="pager">
{{if .Prev}}

32
templates/search_rss.xml Normal file
View file

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
{{with .S}}
<title>Imperial Library of Trantor</title>
{{if .Search}}
<description>Book search: {{.Search}}</description>
{{else}}
<description>Last books added</description>
{{end}}
<link>{{.BaseURL}}</link>
{{end}}
{{$baseURL := .S.BaseURL}}
{{range .Books}}
<item>
<title>{{.Title}} - {{index .Author 0}}</title>
<description>{{.Description}}</description>
<link>{{$baseURL}}/book/{{.Id}}</link>
{{if .Isbn}}
<guid isPermaLink="false">ISBN: {{.Isbn}}</guid>
{{end}}
{{range .Subject}}
{{if .}}
<category>{{.}}</category>
{{end}}
{{end}}
</item>
{{end}}
</channel>
</rss>