Permalink
Browse files

Adding rss and atom to the application

  • Loading branch information...
1 parent f6cc379 commit 4ab1ebe65edbbfc98b5324cb81f64fac8338fef7 @mirouhh committed Mar 1, 2012
@@ -1,6 +1,6 @@
PadrinoSampleBlog.controllers :posts do
- get :index do
+ get :index, :provides => [:html, :rss, :atom] do
@posts = Post.all(:order => 'created_at desc')
render 'posts/index'
end
@@ -0,0 +1,19 @@
+xml.instruct!
+xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do
+ xml.title "Padrino Sample Blog"
+ xml.link "rel" => "self", "href" => url_for(:posts, :index)
+ xml.id url_for(:posts, :index)
+ xml.updated @posts.first.updated_at.strftime "%Y-%m-%dT%H:%M:%SZ" if @posts.any?
+ xml.author { xml.name "Padrino Team" }
+
+ @posts.each do |post|
+ xml.entry do
+ xml.title post.title
+ xml.link "rel" => "alternate", "href" => url_for(:posts, :show, :id => post)
+ xml.id url_for(:posts, :show, :id => post)
+ xml.updated post.updated_at.strftime "%Y-%m-%dT%H:%M:%SZ"
+ xml.author { xml.name post.account.email }
+ xml.summary post.body
+ end
+ end
+end
@@ -1,3 +1,7 @@
- @title = "Welcome"
+- content_for :include do
+ = feed_tag(:rss, url(:posts, :index, :format => :rss),:title => "RSS")
+ = feed_tag(:atom, url(:posts, :index, :format => :atom),:title => "ATOM")
+
#posts= partial 'posts/post', :collection => @posts
@@ -0,0 +1,17 @@
+xml.instruct!
+xml.rss "version" => "2.0", "xmlns:dc" => "http://purl.org/dc/elements/1.1/" do
+ xml.channel do
+ xml.title "Padrino Blog"
+ xml.description "The fantastic padrino sample blog"
+ xml.link url_for(:posts, :index)
+
+ for post in @posts
+ xml.item do
+ xml.title post.title
+ xml.description post.body
+ xml.pubDate post.created_at.to_s(:rfc822)
+ xml.link url_for(:posts, :show, :id => post)
+ end
+ end
+ end
+end
@@ -0,0 +1,123 @@
+body {
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
+ font-size: 14px;
+ background-color: #e6e0d9; }
+ body a {
+ color: #336699; }
+ body h2 {
+ padding-bottom: 12px;
+ font-weight: bold; }
+ body h3 {
+ padding-bottom: 10px; }
+ body pre {
+ display: block;
+ background-color: #f8f8ff;
+ border: 1px solid #dedede;
+ color: #444444;
+ line-height: 1.5em;
+ margin-bottom: 10px;
+ padding: 0.5em; }
+ body ul.bulleted {
+ margin-left: 20px;
+ margin-bottom: 10px; }
+ body ul.bulleted li {
+ list-style-type: square; }
+ body ul.bulleted li span {
+ font-weight: bold; }
+
+#container {
+ width: 80%;
+ margin: 20px auto;
+ overflow: hidden; }
+
+#header {
+ background-color: #900209;
+ padding: 30px 10px 20px 10px;
+ border-bottom: 2px solid #ec9a94;
+ overflow: hidden; }
+ #header h1 {
+ float: left;
+ color: #ecebc3;
+ font-size: 2.3em;
+ font-weight: bold; }
+ #header ul.menu {
+ margin-left: 80px;
+ margin-top: 10px;
+ float: left;
+ overflow: hidden; }
+ #header ul.menu li {
+ float: left;
+ margin-right: 20px;
+ padding-bottom: 5px; }
+ #header ul.menu li a {
+ font-size: 1.2em;
+ color: #dff6fc;
+ text-decoration: none; }
+ #header ul.menu li a:hover {
+ text-decoration: underline; }
+
+#main {
+ float: left;
+ width: 600px;
+ padding-top: 20px; }
+ #main h2 {
+ font-size: 2.1em; }
+ #main .post {
+ margin-bottom: 20px; }
+ #main .post p {
+ padding-bottom: 10px; }
+ #main .post .title {
+ font-family: "Georgia,Times New Roman,serif";
+ font-size: 2em;
+ color: #752a26; }
+ #main .post .title a {
+ color: #752a26;
+ text-decoration: none; }
+ #main .post .title a:hover {
+ text-decoration: underline; }
+ #main .post .date {
+ font-size: 1.1em;
+ color: #999999;
+ display: block;
+ margin-bottom: 15px;
+ margin-top: 2px; }
+ #main .post .body {
+ padding-bottom: 10px; }
+ #main .post .details {
+ border-top: 1px solid #cccccc;
+ margin-bottom: 0.25em;
+ padding: 5px 0;
+ overflow: hidden; }
+ #main .post .details .author {
+ float: left;
+ padding-right: 5px;
+ border-right: 1px solid #cccccc; }
+ #main #show .author {
+ border-right: none; }
+
+#sidebar {
+ padding: 20px;
+ margin-left: 20px;
+ float: left;
+ height: 650px;
+ width: 320px;
+ border: 1px dotted black; }
+ #sidebar p {
+ font-weight: bold;
+ padding-top: 10px;
+ padding-bottom: 12px; }
+
+#about h2 {
+ font-family: "Georgia,Times New Roman,serif";
+ font-size: 2em;
+ color: #752a26; }
+#about h3 {
+ font-family: "Georgia,Times New Roman,serif";
+ font-size: 1.5em;
+ color: #752a26;
+ padding-bottom: 6px; }
+#about p {
+ padding-bottom: 12px; }
+
+#footer {
+ padding: 30px 10px 10px 10px; }

0 comments on commit 4ab1ebe

Please sign in to comment.