diff --git a/back-office/config.ru b/back-office/config.ru index bd83b25..2a18402 100644 --- a/back-office/config.ru +++ b/back-office/config.ru @@ -1,4 +1,8 @@ # This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) -run Rails.application +if Rails.env.production? + run Rack::URLMap.new("/backoffice" => Rails::application) +else + run Rails.application +end diff --git a/back-office/config/database.yml b/back-office/config/database.yml index 9c4b1d6..5f7007d 100644 --- a/back-office/config/database.yml +++ b/back-office/config/database.yml @@ -37,7 +37,7 @@ development: # Connect on a TCP socket. Omitted by default since the client uses a # domain socket that doesn't need configuration. Windows does not have # domain sockets, so uncomment these lines. - #host: localhost + host: localhost # The TCP port the server listens on. Defaults to 5432. # If your server runs on a different port number, change accordingly. @@ -80,6 +80,7 @@ test: # production: <<: *default - database: ribicabackoffice_production - username: ribicabackoffice - password: <%= ENV['RIBICABACKOFFICE_DATABASE_PASSWORD'] %> + database: ribica + username: postgres + password: testni_hamo2 + host: localhost diff --git a/back-office/config/environments/production.rb b/back-office/config/environments/production.rb index 5c1b32e..1ea5bc2 100644 --- a/back-office/config/environments/production.rb +++ b/back-office/config/environments/production.rb @@ -76,4 +76,6 @@ Rails.application.configure do # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false + + config.relative_url_root = "/backoffice" end diff --git a/back-office/config/secrets.yml b/back-office/config/secrets.yml index c7a8b5a..c2f15e3 100644 --- a/back-office/config/secrets.yml +++ b/back-office/config/secrets.yml @@ -19,4 +19,4 @@ test: # Do not keep production secrets in the repository, # instead read values from the environment. production: - secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> + secret_key_base: 747e8584786929d2b34d2b9fccb257dcc9f718fec7619baef4ec00aac60140b34e6396836222e3c18ba7b9bb08638c78fed39974c96ce147fc439c85f94302f6 diff --git a/front-api/config.ru b/front-api/config.ru index 76a6edf..5fb51ae 100644 --- a/front-api/config.ru +++ b/front-api/config.ru @@ -1,2 +1,6 @@ require './app' -run Sinatra::Application +if settings.environment == :production + run Rack::URLMap.new("/api" => Sinatra::Application.new) +else + run Sinatra::Application +end diff --git a/front-ui/Gruntfile.js b/front-ui/Gruntfile.js index a76e1a0..765d289 100644 --- a/front-ui/Gruntfile.js +++ b/front-ui/Gruntfile.js @@ -34,6 +34,35 @@ module.exports = function(grunt) { } } }, + config: { + dev: { + options: { + variables: { + apiEndpoint: 'http://localhost:4567' + } + } + }, + prod: { + options: { + variables: { + apiEndpoint: '/api' + } + } + } + }, + replace: { + dist: { + options: { + variables: { + 'apiEndpoint': '<%= grunt.config.get("apiEndpoint") %>' + }, + force: true + }, + files: [ + {expand: true, flatten: true, src: ['build/ribica.bundle.js'], dest: 'build/'} + ] + } +}, concat: { css: { src: [ @@ -56,7 +85,14 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-browserify'); grunt.loadNpmTasks('grunt-contrib-connect'); grunt.loadNpmTasks('grunt-contrib-uglify'); + grunt.loadNpmTasks('grunt-config'); + grunt.loadNpmTasks('grunt-replace'); + grunt.registerTask('default', []); - grunt.registerTask('dev', ['browserify', 'concat:css', 'concat:js', 'connect:server:keepalive']); + grunt.registerTask('config-dev', ['config:dev', 'replace']); + grunt.registerTask('config-prod', ['config:prod', 'replace']); + grunt.registerTask('dev', ['browserify', 'config-dev','concat:css', 'concat:js', 'connect:server:keepalive']); + grunt.registerTask('build', ['browserify', 'config-prod', 'concat:css', 'concat:js']); + }; diff --git a/front-ui/app/globals.js b/front-ui/app/globals.js index ba7875e..85764eb 100644 --- a/front-ui/app/globals.js +++ b/front-ui/app/globals.js @@ -1,5 +1,5 @@ module.exports = { - ApiUrl: 'http://localhost:4567', + ApiUrl: '@@apiEndpoint', DefaultPageSize: 18, FormatCurrency: function(amount_s) { var amount = parseFloat(amount_s); diff --git a/front-ui/app/models/itemWithDetails.js b/front-ui/app/models/itemWithDetails.js index 83de4dd..8840940 100644 --- a/front-ui/app/models/itemWithDetails.js +++ b/front-ui/app/models/itemWithDetails.js @@ -1,6 +1,6 @@ var Backbone = require('backbone'); var Globals = require('../globals'); -var Mutators = require('backbone.mutators'); +var Mutators = require('Backbone.Mutators'); var ItemWithDetails = Backbone.Model.extend({ @@ -19,4 +19,4 @@ var ItemWithDetails = Backbone.Model.extend({ }); -module.exports = ItemWithDetails; \ No newline at end of file +module.exports = ItemWithDetails; diff --git a/front-ui/package.json b/front-ui/package.json index a2dc1ec..2a05b2c 100644 --- a/front-ui/package.json +++ b/front-ui/package.json @@ -21,7 +21,9 @@ "grunt-contrib-watch": "~0.6.1", "reactify": "~0.17.1", "underscore": "^1.7.0", - "Backbone.Mutators": "~0.4.4" + "Backbone.Mutators": "~0.4.4", + "grunt-config": "~0.2.2", + "grunt-replace": "~0.8.0" }, "dependencies": { "react": "~0.12.2",