Commit 8683d8dafcc3199ed8390fc015712e230b06436b

Authored by Evandro Junior
1 parent e946ea53

Refactor to improve development setup

Showing 1 changed file with 30 additions and 9 deletions   Show diff stats
js/main.js
... ... @@ -23,6 +23,7 @@ define(['jquery', 'handlebars', 'fastclick', 'proposal_app', 'handlebars_helpers
23 23 var lastHash = window.location.hash;
24 24  
25 25 var host = 'http://login.dialoga.gov.br';
  26 + var serpro_captcha_clienteId = 'fdbcdc7a0b754ee7ae9d865fda740f17';
26 27 var dialoga_community = 19195;
27 28 var proposal_discussion = '103358'; //participa
28 29 var cat_saude = 180;
... ... @@ -31,16 +32,35 @@ define(['jquery', 'handlebars', 'fastclick', 'proposal_app', 'handlebars_helpers
31 32 // var cat_reducao_da_pobreza = 183;
32 33 var recaptchaSiteKey = '6LcLPAcTAAAAAKsd0bxY_TArhD_A7OL19SRCW7_i';
33 34  
  35 + // There are two modes for development
  36 + // 1: Remote API
  37 + // 2: Local API
  38 + // For (1) use port 3000 -> rails s
  39 + // For (2) use port 3001 -> rails s -p 3001
  40 + //
  41 + // For (2) set at /etc/hosts:
  42 + //
  43 + //127.0.0.1 participa.br
  44 + //127.0.0.1 dialoga.gov.br
  45 + //127.0.0.1 login.dialoga.gov.br
  46 + //127.0.0.1 noosfero.com
34 47  
35 48 //Detects for localhost settings
36   - var patt = new RegExp(':3001/');
  49 + var patt = new RegExp(':300[0-1]/');
  50 + var localDevelopment = false;
37 51 if(patt.test(window.location.href)){
38   - host = 'http://noosfero.com:3001';
39   - dialoga_community = 104;
  52 + localDevelopment = true;
  53 + patt = new RegExp(':3000/');
  54 + if(patt.test(window.location.href)){
  55 + host = 'http://noosfero.com:3000';
  56 + }else{
  57 + host = 'http://noosfero.com:3001';
  58 + dialoga_community = 104;
40 59 // proposal_discussion = '413'; //Eugênio
41   - proposal_discussion = '392'; //Evandro
42   - recaptchaSiteKey = '6LdsWAcTAAAAAChTUUD6yu9fCDhdIZzNd7F53zf-'; //http://noosfero.com/
43   - cat_saude = 23;
  60 + proposal_discussion = '392'; //Evandro
  61 + recaptchaSiteKey = '6LdsWAcTAAAAAChTUUD6yu9fCDhdIZzNd7F53zf-'; //http://noosfero.com/
  62 + cat_saude = 23;
  63 + }
44 64 }
45 65  
46 66 var BARRA_ADDED = false;
... ... @@ -52,7 +72,6 @@ define(['jquery', 'handlebars', 'fastclick', 'proposal_app', 'handlebars_helpers
52 72 var API = {
53 73 articles: '',
54 74 proposals: '/api/v1/articles/{topic_id}/children',
55   -
56 75 };
57 76  
58 77 API.getProposalsURL = function (topicId){
... ... @@ -1295,8 +1314,10 @@ define(['jquery', 'handlebars', 'fastclick', 'proposal_app', 'handlebars_helpers
1295 1314 var oCaptcha_serpro_gov_br;
1296 1315 oCaptcha_serpro_gov_br = new captcha_serpro_gov_br();
1297 1316 window.lastCaptcha = oCaptcha_serpro_gov_br;
1298   - oCaptcha_serpro_gov_br.clienteId = 'fdbcdc7a0b754ee7ae9d865fda740f17';
1299   - oCaptcha_serpro_gov_br.url = "/captchaserpro"
  1317 + oCaptcha_serpro_gov_br.clienteId = serpro_captcha_clienteId;
  1318 + if(!localDevelopment) {
  1319 + oCaptcha_serpro_gov_br.url = "/captchaserpro"
  1320 + }
1300 1321 oCaptcha_serpro_gov_br.criarUI(signupForm.find('#serpro_captcha')[0], 'css', 'serpro_captcha_component_');
1301 1322  
1302 1323 e.preventDefault();
... ...