精通 Grails: 文件上传和 Atom 联合
2009-10-26 00:00:00 来源:WEB开发网最后需要做的是向未经认证的用户开放 Atom feed。调整 EntryController.groovy 中的 beforeInterceptor,如清单 20 所示:
清单 20. 向未经认证的用户开放 Atom feed
class EntryController {
def beforeInterceptor = [action:this.&auth, except:["index", "list", "show", "atom"]]
//SNIP
}
重新启动 Grails,当访问 http://localhost:9090/blogito/entry/atom 时,应该产生一个格式良好的 Atom feed,如清单 21 所示:
清单 21. 格式良好的 Atom feed
<feed xmlns="http://www.w3.org/2005/Atom">
<title type="text">News from Blogito.org</title>
<link rel="alternate" type="text/html" href="http://blogito.org/"/>
<link rel="self" type="application/atom+xml" href="http://blogito.org/entry/atom" />
<updated>2009-04-20T00:03:34-07:00</updated>
<author><name>Blogito.org</name></author>
<id>tag:blogito.org,2009-01-01:entry/atom</id>
<generator uri="http://blogito.org" version="0.1">Hand-rolled Grails code</generator>
<entry xmlns='http://www.w3.org/2005/Atom'>
<author>
<name>Jane Smith</name>
</author>
<published>2009-04-20T00:03:34-07:00</published>
<updated>2009-04-20T00:03:34-07:00</updated>
<link href="http://blogito.org/blog/jsmith/Testing_with_Groovy" rel="alternate"
title="Testing with Groovy" type="text/html" />
<id>tag:blogito.org,2009:/blog/jsmith/Testing_with_Groovy</id>
<title type="text">Testing with Groovy</title>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
See Practically Groovy
</div>
</content>
<!-- SNIP -->
</entry>
</feed>
更多精彩
赞助商链接