Last active
December 17, 2015 22:09
-
-
Save UladzKha/5679498 to your computer and use it in GitHub Desktop.
Atom
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
####Conroller | |
ActiveAdmin.register Post do | |
controller do | |
def feed | |
@posts = Post.all(:select => "title, created_at", :limit => 20) | |
respond_to do |format| | |
format.html | |
format.rss { render :layout => false } #index.rss.builder | |
end | |
end | |
end | |
index do | |
column :title | |
column :description, :sortable => false do |t| | |
truncate(t.description, :length => 300) | |
end | |
column "Created" , :created_at | |
default_actions | |
end | |
form :html => { :multipart => true } do |f| | |
f.inputs :new_post do | |
f.input :title | |
f.input :description | |
f.input :photo, :as => :file | |
f.input :content, as: :html_editor | |
end | |
f.buttons | |
end | |
show do |ad| | |
attributes_table do | |
row :title | |
row :description | |
row :image do | |
link_to image_tag(ad.photo.url(:small)), ad.photo.url(:norm) | |
end | |
end | |
active_admin_comments | |
end | |
end | |
####################################### | |
index.atom.builder | |
atom_feed do |feed| | |
feed.title "Fitu News" | |
@posts.each do |post| | |
feed.entry post do |entry| | |
entry.title post.title | |
entry.description post.description | |
end | |
end | |
end | |
######################################## | |
index.rss.builder | |
xml.instruct! :xml, version: "1.0" | |
xml.rss version: "2.0" do | |
xml.channel do | |
xml.title "Fitu News" | |
xml.description "From BSUIR" | |
xml.link posts_url | |
@posts.each do |post| | |
xml.item do | |
xml.title post.title | |
xml.description post.description | |
xml.link post_url(post) | |
xml.guid post_url(post) | |
end | |
end | |
end | |
end | |
################# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment