forked from codefirst/AsakusaSatellite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor desktop notification plugin refs codefirst#140
- Loading branch information
1 parent
e067632
commit da7ccaf
Showing
2 changed files
with
6 additions
and
54 deletions.
There are no files selected for viewing
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
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 | ||
|
25 changes: 0 additions & 25 deletions
25
plugins/as_desktopnotification/spec/lib/desktopnotification_spec.rb
This file was deleted.
Oops, something went wrong.