Created
October 20, 2008 02:06
-
-
Save michaelklishin/17994 to your computer and use it in GitHub Desktop.
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
New entry posted to the journal: | |
= self.params[:entry].body |
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
def index(entry = {}) | |
@entry = Entry.new(entry) | |
@entries = Entry.all(:order => [:created_at.desc]) | |
JournalMessenger.dispatch(:index, self) | |
display @entries | |
end | |
def create(entry) | |
@entry = Entry.new(entry) | |
if @entry.save | |
run_later do | |
JournalMessenger.dispatch(:create, self, :entry => @entry) | |
end | |
redirect url(:entries) | |
else | |
@entries = Entry.all | |
render :index | |
end | |
end |
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
Merb::BootLoader.before_app_loads do | |
Merb::MessagingController.message_transport :local, :growl, { | |
:host => "localhost", | |
:application => "ruby-growl", | |
:notifications => ["journal notification", "presence notification"] | |
} | |
Merb::MessagingController.message_transport :remote, :xmpp4r, { | |
:jid => "merbpack@stormblast", | |
:password => "merbpack" | |
} | |
end | |
Merb::BootLoader.after_app_loads do | |
im = Merb::MessagingController.message_transport :local | |
im.deliver({ | |
:title => "MerbPack presence", | |
:body => "MerbPack agent is back online", | |
:notification => "presence notification" | |
}) | |
end | |
Merb::BootLoader.before_master_shutdown do | |
Merb.logger.info "Disconnecting XMPP notification agent..." | |
im = Merb::MessagingController.message_transport :local | |
im.deliver({ | |
:title => "MerbPack presence", | |
:body => "MerbPack agent is about to shut down", | |
:notification => "presence notification" | |
}) | |
im.disconnect | |
end | |
Merb::BootLoader.before_worker_shutdown do | |
Merb.logger.info "Shutting down worker..." | |
Merb::MessagingController.message_transport(:remote).disconnect | |
end |
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
class JournalMessenger < Merb::MessagingController | |
delivery_options :local, | |
:notification => "journal notification", | |
:title => "New MerbPack event" | |
delivery_options :remote, | |
:title => "Journal event", | |
:to => ["antares@stormblast"], | |
:message_type => :chat | |
def index(options) | |
body = render(:index) | |
deliver :remote, :body => body | |
deliver :local, :body => body | |
end | |
def create(options) | |
self.deliver :remote, :body => render(:create) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment