From 3d4aab4d673fde1afd11926bd63cee0dfd763d49 Mon Sep 17 00:00:00 2001 From: Benjamin ter Kuile Date: Tue, 30 Sep 2014 08:40:28 +0200 Subject: [PATCH] Ember initialize hooks --- app/assets/javascripts/user/app/app.js.coffee | 11 ++++------- app/views/layouts/user/foundation.html.slim | 3 +++ bin/user_asset_corrections | 12 +++++++++++- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/user/app/app.js.coffee b/app/assets/javascripts/user/app/app.js.coffee index 6d55463c..21ff0768 100644 --- a/app/assets/javascripts/user/app/app.js.coffee +++ b/app/assets/javascripts/user/app/app.js.coffee @@ -12,19 +12,16 @@ rootElement: '#ember-app-container' obtain_token: (message)-> message ||= '' - # frame = $('').addClass('obtain-token-frame').attr 'src', $obtain_token_url - # frame.css width: $('body').outerWidth(), height: $('body').outerHeight() - # $('body').append frame - # window.location = "#{$obtain_token_url}" auth_win = window.open $obtain_token_url, "_blank", "location=no" auth_win.addEventListener "loadstart", (event)-> if event.url.match 'close_window' user_id = event.url.match(/user_id=([\w+-]+)/)[1] - auth_token = event.url.match(/auth_token=([\w-]+)/)[1] + auth_token = event.url.match(/authentication_token=([\w-]+)/)[1] Qstorage.setItem 'user_id', user_id - Qstorage.setItem 'auth_token', token + Qstorage.setItem 'auth_token', auth_token auth_win.close() - + true +App.deferReadiness() Ember.$.ajaxPrefilter (options) -> if options.type.toUpperCase() == 'GET' if auth_token = Qstorage.getItem('auth_token') diff --git a/app/views/layouts/user/foundation.html.slim b/app/views/layouts/user/foundation.html.slim index 513b4c6c..09039fa1 100644 --- a/app/views/layouts/user/foundation.html.slim +++ b/app/views/layouts/user/foundation.html.slim @@ -31,5 +31,8 @@ html lang="en" var $platform = 'web' var $log = function(params){console.log('App log:'); console.log(params);console.log('=======================================')}; = javascript_include_tag "user/flat/application" + - unless Rails.env.user_app? + javascript: + App.advanceReadiness() body #ember-app-container diff --git a/bin/user_asset_corrections b/bin/user_asset_corrections index 378bc2b8..5ce3b1ab 100755 --- a/bin/user_asset_corrections +++ b/bin/user_asset_corrections @@ -1,6 +1,7 @@ #!/usr/bin/env ruby require 'active_support/all' require 'uglifier' +require 'fileutils' def replace_files(files, &block) Array.wrap(files).each do |file| @@ -29,7 +30,16 @@ def gsub_all_scripts(find, replace) end end +def remove(*files) + files = files.first if files.first.is_a? Array + files.each do |file| + FileUtils.rm_rf(File.join('public/assets', file)) + end +end + +remove 'user/app/application.js' # embedded in flat/application + gsub_file 'user/foundation/application.css', /url\(("?)\/assets/, 'url(\1../..' gsub_all_scripts 'src="/assets', 'src="./assets' -compress_js 'user/flat/application.js', 'user/app/application.js' +compress_js 'user/flat/application.js'