Skip to content

Commit

Permalink
refactor desktop notification plugin refs codefirst#140
Browse files Browse the repository at this point in the history
  • Loading branch information
shimomura1004 committed Sep 28, 2013
1 parent e067632 commit da7ccaf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 54 deletions.
35 changes: 6 additions & 29 deletions plugins/as_desktopnotification/lib/desktopnotification.rb
Original file line number Diff line number Diff line change
@@ -1,32 +1,9 @@
class DesktopnotificationListener < AsakusaSatellite::Hook::Listener
def read_js(filename)
js_path = Rails.root.join 'plugins/as_desktopnotification/app/assets/javascripts'
File.read(js_path.join filename)
end
js_path = plugin_root + "app/assets/javascripts/"

render_on :account_setting_item, :partial => "desktopnotification_setting"

def global_footer(context)
controller = context[:request][:controller]
action = context[:request][:action]

case {:controller => controller, :action => action}
when {:controller => "account", :action => "index"}
<<-JS
<script>#{read_js 'desktopnotification.js'}</script>
<script>#{read_js 'desktopnotification_setting.js'}</script>
JS
when {:controller => "chat", :action => "room"}
<<-JS
<script>#{read_js 'desktopnotification.js'}</script>
<script>#{read_js 'desktopnotification_notify.js'}</script>
JS
end
end

private
def render(context, options)
context[:controller].send(:render_to_string, {:locals => context}.merge(options))
end
render_on :account_setting_item, :partial => "desktopnotification_setting"
render_on :script_in_account_setting, :jsfile => js_path + "desktopnotification.js"
render_on :script_in_account_setting, :jsfile => js_path + "desktopnotification_setting.js"
render_on :script_in_chat_room, :jsfile => js_path + "desktopnotification.js"
render_on :script_in_chat_room, :jsfile => js_path + "desktopnotification_notify.js"
end

This file was deleted.

0 comments on commit da7ccaf

Please sign in to comment.