1 2 3 4 5 6 | def atom = { if(!params.max) params.max = 10 def list = Entry.list( params ) def lastUpdated = list[0].lastUpdated [ entryInstanceList:list, lastUpdated:lastUpdated ] } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <% response.setContentType("application/atom+xml") %><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><g:atomDate>${lastUpdated}</g:atomDate></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> <g:each in="${entryInstanceList}" status="i" var="entryInstance"> <g:render template="atomEntry" bean="${entryInstance}" var="entryInstance" /> </g:each> </feed> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | import java.text.SimpleDateFormat class DateTagLib { public static final String INCOMING_DATE_FORMAT = "yyyy-MM-dd hh:mm:ss" public static final String ATOM_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'-07:00'" def atomDate = {attrs, body -> def b = attrs.body ?: body() def d = new SimpleDateFormat(INCOMING_DATE_FORMAT).parse(b) out << new SimpleDateFormat(ATOM_DATE_FORMAT).format(d) } //SNIP } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | <entry xmlns='http://www.w3.org/2005/Atom'> <author> <name>${entryInstance.author.name}</name> </author> <published><g:atomDate>${entryInstance.dateCreated}</g:atomDate></published> <updated><g:atomDate>${entryInstance.lastUpdated}</g:atomDate></updated> <link href="http://blogito.org/blog/${entryInstance.author.login}/ ${entryInstance.title.encodeAsUnderscore()}" rel="alternate" title="${entryInstance.title}" type="text/html" /> <id>tag:blogito.org,2009:/blog/${entryInstance.author.login}/ ${entryInstance.title.encodeAsUnderscore()}</id> <title type="text">${entryInstance.title}</title> <content type="xhtml"> <div xmlns="http://www.w3.org/1999/xhtml"> ${entryInstance.summary} </div> </content> </entry> |
1 2 3 4 5 6 | class EntryController { def beforeInterceptor = [action:this.&auth, except:["index", "list", "show", "atom"]] //SNIP } |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |