Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/calavera/atompub-server
add atomPub server capabilities to you rails application
https://github.com/calavera/atompub-server
Last synced: about 2 months ago
JSON representation
add atomPub server capabilities to you rails application
- Host: GitHub
- URL: https://github.com/calavera/atompub-server
- Owner: calavera
- License: mit
- Created: 2008-06-15T16:26:37.000Z (over 16 years ago)
- Default Branch: master
- Last Pushed: 2013-06-06T16:49:52.000Z (over 11 years ago)
- Last Synced: 2024-04-14T09:15:54.928Z (9 months ago)
- Language: Ruby
- Homepage: http://github.com/calavera/atom_pub_server
- Size: 128 KB
- Stars: 10
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README
- License: MIT-LICENSE
Awesome Lists containing this project
README
AtomPubServer
=============
WARNING : This plugin just probably works with rails edge version(2.0RC)This plugin allows your app to create an atomPub service document from its controllers.
Example
=========First you must add the term "acts_as_collection" to the controllers that manage your resorces.
Mandatory options:
:title => the collection's title
:workspace => the collection's workspace
:href => collection's IRI
:accept => array with MimeType objects that the post and put method accept
Other available options:
:categories => array of hashes. Within each hash:
:href => mandatory if the categories are not fixed
:fixed => 'yes' or 'no' (DEFAULT 'no')
:scheme => if the categories are fixed they can inherit from this scheme
:category => array of hashes. Mandatory if the categories are fixed. Within each hash:
:term
:schemeExample:
class PostsController < ApplicationController
acts_as_collection :title => 'posts', :workspace => 'my blog', :href => 'http://myblog/posts',
:accept => Mime::ATOM_ENTRY,
:categories => [{
:fixed => 'yes', :scheme => 'http://myblog/tags',
:category => [{:term => 'rails'}, {:term => 'plugins'}]
},
{:href => 'http://myblog/mysections'}
]
end==Then you must add the term "acts_as_service_document" to a controller. This controller will have a method called "document_service"
that generates a valid atomPub service document xml.Example:
class ServicesController < ApplicationController
acts_as_service_document
def index
render :xml => service_document
end
endWritting 'http://localhost:3000/services' in your browser you lii get:
my blog
posts
application/atom+xml;type=entry
==In addition, when you declares a controller with the term 'acts_as_collection' this plugin adds a 'before_filter' declaration.
This filter must be created too, and must be called 'filter_content_type'. It will be only executed before the create and update methods.
The name of create and update methods can be initialized as two environment varible called ENV['COLLECTION_POST_METHOD'] and ENV['ENTRY_PUT_METHOD'].
Default names are :create and :update.
Please visit http://ryandaigle.com/articles/2007/10/22/what-s-new-in-edge-rails-filters-get-tweaked for more info about the rails 2.0 filters sintax.==Moreover, this plugin add some MimeType objects specifics for atomPub server implementation:
Mime::ATOM_ENTRY => 'application/atom+xml;type=entry'
Mime::ATOM_SVC => 'application/atomsvc+xml'
Mime::ATOM_CAT => 'application/atomcat+xml'==Finally, the atomPubServer plugins override the new AtomFeedHelper class in order to allow the developer could include new namespaces to an atom feed.
The rails 2.0 helper sintax:atom_feed do |feed|
...
endThe atomPubServer sintax:
atom_feed({'xmlns:app' => 'http://www.w3.org/2007/app',
'xmlns:georss' => 'http://www.georss.org/georss/10'}) do |feed|
...
endCopyright (c) 2007 David Calavera, released under the MIT license