diff --git a/Gemfile b/Gemfile index 8ec0cb82..49639640 100644 --- a/Gemfile +++ b/Gemfile @@ -74,6 +74,9 @@ gem 'iso_country_codes' # To use Jbuilder templates for JSON # gem 'jbuilder' # +group :user_app do + gem 'pry-rails' +end group :development, :test do gem 'rspec-rails' gem 'pry-rails' diff --git a/Procfile b/Procfile index 412a5d7e..d5c8cef3 100644 --- a/Procfile +++ b/Procfile @@ -3,4 +3,4 @@ faye: thin start -R faye/config.ru -p 9296 #faye: rackup faye.ru -s thin -E production counters: bin/drb_counter.rb run database: echo "BuenosAires" | sudo -S couchdb start | ~/bin/couch_output -server: rails s +#server: rails s diff --git a/app/assets/images/user/logo-small.png b/app/assets/images/user/logo-small.png new file mode 100644 index 00000000..a4730610 Binary files /dev/null and b/app/assets/images/user/logo-small.png differ diff --git a/app/assets/images/user/logo.png b/app/assets/images/user/logo.png new file mode 100644 index 00000000..34e11ae1 Binary files /dev/null and b/app/assets/images/user/logo.png differ diff --git a/app/assets/images/user/logo.svg b/app/assets/images/user/logo.svg new file mode 100644 index 00000000..089901ca --- /dev/null +++ b/app/assets/images/user/logo.svg @@ -0,0 +1,652 @@ + + + +image/svg+xml + + + + + + + + + + + + + + + + + + + + +Q + + + + + + + +WAITE + + + + + + + +R + + + + + + + + +QWAITER + + + + + + + +MOZO +.BAR +MOZO.BAR + diff --git a/app/assets/images/scan-logo.png b/app/assets/images/user/scan-logo.png similarity index 100% rename from app/assets/images/scan-logo.png rename to app/assets/images/user/scan-logo.png diff --git a/app/assets/images/scan-logo.svg b/app/assets/images/user/scan-logo.svg similarity index 100% rename from app/assets/images/scan-logo.svg rename to app/assets/images/user/scan-logo.svg diff --git a/app/assets/javascripts/shared-ember-helpers/image_tag.js.coffee b/app/assets/javascripts/shared-ember-helpers/image_tag.js.coffee index 41d7449c..67091552 100644 --- a/app/assets/javascripts/shared-ember-helpers/image_tag.js.coffee +++ b/app/assets/javascripts/shared-ember-helpers/image_tag.js.coffee @@ -1,6 +1,6 @@ Ember.Handlebars.helper 'image_tag', (path, options={})-> alt = options.hash.alt || '' - image_path = if path.substring(0,4) == 'http' then path else "/assets/#{path}" + image_path = if path.substring(0,4) == 'http' then path else "#{$assets_path}#{path}" extra_attributes = '' extra_attributes += " width=\"#{options.hash.width}\"" if options.hash.width extra_attributes += " height=\"#{options.hash.height}\"" if options.hash.height diff --git a/app/assets/javascripts/supplier/app/application.js.coffee b/app/assets/javascripts/supplier/app/application.js.coffee index 8c8f2d47..0e990841 100644 --- a/app/assets/javascripts/supplier/app/application.js.coffee +++ b/app/assets/javascripts/supplier/app/application.js.coffee @@ -5,4 +5,5 @@ #= require shared-ember-helpers/all #= require ./app #= require_tree . +@$assets_path = '/assets/'; @EmberENV = {FEATURES: {'query-params-new': true}} diff --git a/app/assets/javascripts/user/app/templates/application.emblem b/app/assets/javascripts/user/app/templates/application.emblem index 193c6eea..68e7bd78 100644 --- a/app/assets/javascripts/user/app/templates/application.emblem +++ b/app/assets/javascripts/user/app/templates/application.emblem @@ -4,7 +4,7 @@ header.top-menu .menu-content section.main-buttons link-to 'index' - = image_tag 'icons/logo-small.png' + = image_tag 'user/logo-small.png' if list.id App.MenuItemView route="active_list" App.MenuItemView route='table' route_param=list.table.id diff --git a/app/assets/javascripts/user/app/templates/index.emblem b/app/assets/javascripts/user/app/templates/index.emblem index 07a6a96e..745667a7 100644 --- a/app/assets/javascripts/user/app/templates/index.emblem +++ b/app/assets/javascripts/user/app/templates/index.emblem @@ -1,6 +1,6 @@ .home-panel - .home-header= image_tag 'logo.png' width=100 height=115 alt="Logo" + .home-header= image_tag 'user/logo.png' width=100 height=115 alt="Logo" .home-center - a{ action "scanQr" } href="#"= image_tag 'scan-logo.png' width=148 height=177 alt="Scan" + a{ action "scanQr" } href="#"= image_tag 'user/scan-logo.png' width=148 height=177 alt="Scan" .home-footer .home-footer-content diff --git a/app/assets/stylesheets/user/foundation/_qconstants.css.sass b/app/assets/stylesheets/user/foundation/_qconstants.css.sass index 2de5af3a..bccb91f5 100644 --- a/app/assets/stylesheets/user/foundation/_qconstants.css.sass +++ b/app/assets/stylesheets/user/foundation/_qconstants.css.sass @@ -3,6 +3,6 @@ $qbrown: #853d15 $qbrown-active: lighten($qbrown, 20%) $green: #7BB459 //Heineken //$wood: image-url('textures/wood001-vertical.jpg') -$wood: image-url('textures/theme1.jpg') +$wood: image-url('theme1/wall-bg.jpg') $background-brown: #57351f $active-link-color: #ff0 diff --git a/app/assets/stylesheets/user/foundation/_structure.css.sass b/app/assets/stylesheets/user/foundation/_structure.css.sass index 2382ad15..831daf8e 100644 --- a/app/assets/stylesheets/user/foundation/_structure.css.sass +++ b/app/assets/stylesheets/user/foundation/_structure.css.sass @@ -1,5 +1,5 @@ #ember-app-container - background-image: image-url('textures/theme1.jpg') + background-image: image-url('theme1/wall-bg.jpg') background-repeat: repeat main.main-section +panel($bg:rgba(200,200,200,0.8)) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 83aac28e..798efc43 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -14,6 +14,12 @@ class ApplicationController < ActionController::Base private + def allow_all_origins + headers['Access-Control-Allow-Origin'] = '*' + headers['Access-Control-Request-Method'] = '*' + headers['Access-Control-Allow-Headers'] = '*' + end + def authorize_cmtool redirect_to '/', alert: t('general.unauthorized') unless current_user.present? && current_user.admin? end diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 2f67e669..7fee3d79 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -1,16 +1,10 @@ class UserController < Users::ApplicationController - before_filter :allow_mobile + before_action :allow_all_origins layout 'user/foundation' #layout 'phone' alias :list :active_list - def allow_mobile - headers['Access-Control-Allow-Origin'] = '*' - headers['Access-Control-Request-Method'] = '*' - headers['Access-Control-Allow-Headers'] = '*' - end - def index handle_message_params end diff --git a/app/controllers/users/application_controller.rb b/app/controllers/users/application_controller.rb index b2aaee78..7660dd54 100644 --- a/app/controllers/users/application_controller.rb +++ b/app/controllers/users/application_controller.rb @@ -1,5 +1,6 @@ module Users class ApplicationController < ::ApplicationController + before_action :allow_all_origins before_action :user_authentication, :unless => ->(c){ %w(obtain_token).include?(c.action_name) || c.request.format.symbol == :html } # , except: [:obtain_token, :index] private diff --git a/app/controllers/users/lists_controller.rb b/app/controllers/users/lists_controller.rb index d31748f3..31447492 100644 --- a/app/controllers/users/lists_controller.rb +++ b/app/controllers/users/lists_controller.rb @@ -3,9 +3,9 @@ module Users def index #lists = current_user.lists.include_relation(:supplier, :table) - lists = List.for_user(current_user, page: params[:page], per_page: params[:per_page].presence || 25).include_relation(:supplier, :table) + lists = List.for_user(current_user, page: params[:page], per_page: params[:per_page].presence || 25) #lists.include_relation(:supplier) - lists.include_relation(:users, :orders) + lists.include_relation(:users, :orders, :supplier, :table) render json: lists, each_serializer: UserListSerializer, meta: {total_pages: lists.total_pages, page: lists.current_page} #, root: :lists end diff --git a/app/views/layouts/phone.html.slim b/app/views/layouts/phone.html.slim index 44743a3b..eb866b57 100644 --- a/app/views/layouts/phone.html.slim +++ b/app/views/layouts/phone.html.slim @@ -17,14 +17,14 @@ html lang="en" var QMobile, Qwaiter, Quser; var data_host = 'http://data.mozo.bar'; var event_host = '#{Qwaiter.event_host}'; - var $asset_path = '##assets_path##'; + var $asset_paths = '##assets_path##'; var Qstorage = localStorage; - else javascript: var QMobile, Qwaiter, Quser; var data_host = 'http://data.mozo.bar'; var event_host = '#{Qwaiter.event_host}'; - var $asset_path = '/assets/'; + var $assets_path = '/assets/'; var Qstorage = localStorage; #{user_dynamic_data_host} QMobile || (QMobile = { diff --git a/app/views/layouts/user/foundation.html.slim b/app/views/layouts/user/foundation.html.slim index a0ce68f7..85841acc 100644 --- a/app/views/layouts/user/foundation.html.slim +++ b/app/views/layouts/user/foundation.html.slim @@ -7,14 +7,13 @@ html lang="en" title= application_title = javascript_include_tag "vendor/modernizr" = stylesheet_link_tag "user/foundation/application" - / = javascript_include_tag 'http://connect.facebook.net/en_US/all.js' = javascript_include_tag "user/flat/application" - if ENV['QWAITER_MOBILE_EXPORT'] == 'yes' javascript: var QMobile, Qwaiter, Quser; var $data_host = 'http://data.mozo.bar'; var $event_host = '#{Qwaiter.event_host}'; - var $asset_path = '##assets_path##'; + var $assets_path = './assets/'; var Qstorage = window.localStorage; Qstorage.setItem('root_url', '##root_url##'); var $platform = '##platform##'; @@ -24,7 +23,7 @@ html lang="en" javascript: var QMobile, Qwaiter, Quser; var $event_host = '#{Qwaiter.event_host}'; - var $asset_path = '/assets/'; + var $assets_path = '/assets/'; var Qstorage = window.localStorage; #{user_dynamic_data_host}; #{user_dynamic_root_url}; diff --git a/app/views/user/index.html.slim b/app/views/user/index.html.slim index 088a4497..12c58798 100644 --- a/app/views/user/index.html.slim +++ b/app/views/user/index.html.slim @@ -1,7 +1,7 @@ .home-panel .home-header = image_tag 'logo.png' .home-center - a href="#" onClick="QMobile.scanQr()" = image_tag 'scan-logo.png' + a href="#" onClick="QMobile.scanQr()" = image_tag 'user/scan-logo.png' .home-footer .home-footer-content = link_to content_tag(:span, 'P'), user_list_products_path, class: ['home-link', 'home-menu-link'] diff --git a/bin/user_asset_corrections b/bin/user_asset_corrections new file mode 100755 index 00000000..8829a73b --- /dev/null +++ b/bin/user_asset_corrections @@ -0,0 +1,35 @@ +#!/usr/bin/env ruby +require 'active_support/all' +require 'uglifier' + +def replace_files(files, &block) + Array.wrap(files).each do |file| + file_path = File.join('public/assets', file) + contents = File.read(file_path) + block.call(contents) + File.open(file_path, 'w+'){|f| f.puts contents} + end +end + +def gsub_file(file, find, replace) + replace_files file do |contents| + contents.gsub! find, replace + end +end + +def compress_js(*files) + replace_files files do |contents| + contents.replace Uglifier.compile(contents, screw_ie8: true) + end +end + +def gsub_all_scripts(find, replace) + extensions = %w[js] + Dir.glob(File.join('public/assets/**', "*.{#{extensions.join(',')}}")).each do |asset_path| + end +end + +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' diff --git a/config/application.rb b/config/application.rb index 84bc43ab..01420739 100644 --- a/config/application.rb +++ b/config/application.rb @@ -15,8 +15,8 @@ require File.expand_path('./../../lib/couchbase-setting', __FILE__) if defined?(Bundler) # If you precompile assets before deploying to production, use this line - Bundler.require(*Rails.groups(assets: %w(development test))) - Bundler.require(:assets) if ENV['QWAITER_MOBILE_EXPORT']=='yes' || ENV['DEPLOY']=='yes' + Bundler.require(*Rails.groups(assets: %w(development test user_app))) + Bundler.require(:assets) if ENV['DEPLOY']=='yes' # If you want your assets lazily compiled in production, use this line # Bundler.require(:default, :assets, Rails.env) end diff --git a/config/couchbase.yml b/config/couchbase.yml index df1073e0..dd94c19b 100644 --- a/config/couchbase.yml +++ b/config/couchbase.yml @@ -13,3 +13,7 @@ test: production: <<: *defaults bucket: qwaiter + +user_app: + <<: *defaults + bucket: qwaiter_development diff --git a/config/couchdb.yml b/config/couchdb.yml index b7c58c71..451eb66a 100644 --- a/config/couchdb.yml +++ b/config/couchdb.yml @@ -7,3 +7,6 @@ test: production: validation_framework: :active_model #optional database: qwaiter +user_app: + validation_framework: :active_model #optional + database: qwaiter_development diff --git a/config/environments/production.rb b/config/environments/production.rb index c2d43b11..acfb9695 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -20,15 +20,16 @@ Qwaiter::Application.configure do config.static_cache_control = 'public, max-age=3600' # Compress JavaScripts and CSS - config.assets.compress = true + # config.assets.compress = true #DEPRICATED + config.assets.js_compressor = :uglifier - # Don't fallback to assets pipeline if a precompiled asset is missed - config.assets.compile = false config.ember.variant = :production if defined?(Ember::Rails) # Generate digests for assets URLs - config.assets.digest = false + config.assets.digest = true + # Don't fallback to assets pipeline if a precompiled asset is missed + config.assets.compile = false # Defaults to nil and saved in location specified by config.assets.prefix # config.assets.manifest = YOUR_PATH diff --git a/config/environments/user_app.rb b/config/environments/user_app.rb new file mode 100644 index 00000000..81c29a83 --- /dev/null +++ b/config/environments/user_app.rb @@ -0,0 +1,90 @@ +Qwaiter::Application.configure do + # Settings specified here will take precedence over those in config/application.rb + + # Code is not reloaded between requests + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both thread web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + config.action_controller.action_on_unpermitted_parameters = :log + + # Configure static asset server for tests with Cache-Control for performance. + config.serve_static_assets = true + config.static_cache_control = 'public, max-age=3600' + + # Compress JavaScripts and CSS + # config.assets.js_compressor = :uglifier # compress manual, since the rails 4 asset pipeline is non configurable + + config.ember.variant = :production if defined?(Ember::Rails) + + # Generate digests for assets URLs + config.assets.compile = true + config.assets.digest = false + + # Defaults to nil and saved in location specified by config.assets.prefix + # config.assets.manifest = YOUR_PATH + + # Specifies the header that your server uses for sending files + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # See everything in the log (default is :info) + # config.log_level = :debug + + # Prepend all log lines with the following tags + # config.log_tags = [ :subdomain, :uuid ] + + # Use a different logger for distributed setups + # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) + + # Use a different cache store in production + # config.cache_store = :mem_cache_store + + # Enable serving of images, stylesheets, and JavaScripts from an asset server + # config.action_controller.asset_host = "http://assets.example.com" + + # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) + # config.assets.precompile += %w( search.js ) + + # Disable delivery errors, bad email addresses will be ignored + config.action_mailer.raise_delivery_errors = false + config.action_mailer.default_url_options = { + host: 'www.mozo.bar' + } + config.action_mailer.smtp_settings = { + address: "smtp.gmail.com", + port: 587, + domain: "atool.nl", + authentication: :plain, + user_name: "bterkuile@companytools.nl", + password: "BjTKct22", + enable_starttls_auto: true + } + + # Enable threaded mode + # config.threadsafe! + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation can not be found) + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners + config.active_support.deprecation = :notify + + # Log the query plan for queries taking more than this (works + # with SQLite, MySQL, and PostgreSQL) + # config.active_record.auto_explain_threshold_in_seconds = 0.5 + # + # # Print deprecation notices to the stderr. + config.active_support.deprecation = :stder +end diff --git a/make_mobile b/make_mobile index a05f43d7..228f197b 100755 --- a/make_mobile +++ b/make_mobile @@ -1,15 +1,33 @@ #!/usr/bin/env bash -rm -rf public/assets; -QWAITER_MOBILE_EXPORT=yes RAILS_ENV=production bundle exec rake assets:precompile; +ANDROID_ROOT="$HOME/Documents/workspace/mozo/www/assets" +spring stop +rm -rf $ANDROID_ROOT +mkdir $ANDROID_ROOT +rm -rf public/assets +QWAITER_MOBILE_EXPORT=yes RAILS_ENV=user_app bundle exec rake assets:precompile +find public/assets -name "*.gz" -exec rm -f {} \; ./bin/dedigest_assets -rm -rf public/assets/cmtool; -rm -rf public/assets/jquery-ui; -rm -rf public/assets/admin; -rm -rf public/assets/waiter; -rm -rf public/assets/obtain_token; -rm -rf public/assets/qr_sheet; -rm -rf public/assets/supplier; -rm -rf public/assets/site; -rm -rf public/assets/cartoon; -rm -rf public/assets/frames; -QWAITER_MOBILE_EXPORT=yes RAILS_ENV=production TEST_HOST=$1 bundle exec rails runner bin/build_mobile_app.rb; + +# correct stuff +./bin/user_asset_corrections + +# now move stuff to a cleaned up cordova location +cp -r public/assets/user $ANDROID_ROOT/user +cp -r public/assets/theme1 $ANDROID_ROOT/theme1 +cp -r public/assets/vendor $ANDROID_ROOT/vendor +find $ANDROID_ROOT/theme1 -name "*.css" -exec rm -f {} \; +find $ANDROID_ROOT/theme1 -name "*.js" -exec rm -f {} \; +find public/assets -iname "font*" -depth 1 -exec cp {} $ANDROID_ROOT \; + +# rm -rf public/assets/cmtool; +# rm -rf public/assets/jquery-ui; +# rm -rf public/assets/admin; +# rm -rf public/assets/waiter; +# rm -rf public/assets/obtain_token; +# rm -rf public/assets/qr_sheet; +# rm -rf public/assets/supplier; +# rm -rf public/assets/site; +# rm -rf public/assets/cartoon; +# rm -rf public/assets/frames; +# QWAITER_MOBILE_EXPORT=yes RAILS_ENV=user_app TEST_HOST=$1 bundle exec rails runner bin/build_mobile_app.rb; +rm -rf public/assets