Commit 9c599ec54eb953ada3586a32e882b793d2dda5bd

Authored by Evandro Junior
1 parent b341c320

fixed to switch easily between api local or from production

Showing 3 changed files with 39 additions and 21 deletions   Show diff stats
@@ -25,6 +25,7 @@ gulp.task('watch', function () { @@ -25,6 +25,7 @@ gulp.task('watch', function () {
25 gulp.watch('./sass/**/*.sass', ['sass']); 25 gulp.watch('./sass/**/*.sass', ['sass']);
26 }); 26 });
27 27
  28 +
28 gulp.task('connect', function() { 29 gulp.task('connect', function() {
29 connect.server({ 30 connect.server({
30 port: 8080, 31 port: 8080,
@@ -33,4 +34,21 @@ gulp.task('connect', function() { @@ -33,4 +34,21 @@ gulp.task('connect', function() {
33 }); 34 });
34 }); 35 });
35 36
  37 +
  38 +gulp.task('connect_api_prod', function(){
  39 + connect.server({
  40 + port: 3001,
  41 + root: [__dirname],
  42 + livereload: true
  43 + });
  44 +});
  45 +
  46 +gulp.task('connect_api_local', function(){
  47 + connect.server({
  48 + port: 3002,
  49 + root: [__dirname],
  50 + livereload: true
  51 + });
  52 +});
  53 +
36 gulp.task('default', ['sass','connect','watch']); 54 gulp.task('default', ['sass','connect','watch']);
@@ -8,9 +8,9 @@ @@ -8,9 +8,9 @@
8 <meta name="viewport" content="width=device-width, initial-scale=1"> 8 <meta name="viewport" content="width=device-width, initial-scale=1">
9 <meta property="og:title" content="Dialoga Brasil" /> 9 <meta property="og:title" content="Dialoga Brasil" />
10 10
11 - <link rel="icon" type="image/x-icon" href="data:image/png;base64,iVBORw0KGgo=">  
12 -  
13 - <link rel="stylesheet" href="style.css"> 11 + <link rel="icon" type="image/x-icon" href="data:image/png;base64,iVBORw0KGgo=" />
  12 +
  13 + <link rel="stylesheet" href="style.css" />
14 14
15 <script type="text/javascript"> 15 <script type="text/javascript">
16 /** 16 /**
@@ -40,6 +40,15 @@ @@ -40,6 +40,15 @@
40 40
41 })(); 41 })();
42 42
  43 + function makeCSSLink(filename){
  44 + var fileref=document.createElement('link');
  45 + fileref.setAttribute('rel', 'stylesheet');
  46 + fileref.setAttribute('type', 'text/css');
  47 + fileref.setAttribute('href', Url.addBaseUrl(filename));
  48 + return fileref;
  49 + }
  50 +
  51 +
43 function makeJSURL(filename){ 52 function makeJSURL(filename){
44 var url = Url.addBaseUrl(filename); 53 var url = Url.addBaseUrl(filename);
45 54
@@ -36,8 +36,9 @@ define([&#39;jquery&#39;, &#39;handlebars&#39;, &#39;fastclick&#39;, &#39;proposal_app&#39;, &#39;handlebars_helpers @@ -36,8 +36,9 @@ define([&#39;jquery&#39;, &#39;handlebars&#39;, &#39;fastclick&#39;, &#39;proposal_app&#39;, &#39;handlebars_helpers
36 // 1: Remote API 36 // 1: Remote API
37 // 2: Local API with proposal database 37 // 2: Local API with proposal database
38 // For (1) use port 3000 -> rails s 38 // For (1) use port 3000 -> rails s
39 - // For (2) use port 3001 -> rails s -p 3001  
40 // 39 //
  40 + // gulp connect_api_prod for access api from production - localhost:3001
  41 + // gulp connect_api_local for access api from local noosfero - localhost:3002
41 // For (2) set at /etc/hosts: 42 // For (2) set at /etc/hosts:
42 // 43 //
43 //127.0.0.1 participa.br 44 //127.0.0.1 participa.br
@@ -45,28 +46,18 @@ define([&#39;jquery&#39;, &#39;handlebars&#39;, &#39;fastclick&#39;, &#39;proposal_app&#39;, &#39;handlebars_helpers @@ -45,28 +46,18 @@ define([&#39;jquery&#39;, &#39;handlebars&#39;, &#39;fastclick&#39;, &#39;proposal_app&#39;, &#39;handlebars_helpers
45 //127.0.0.1 login.dialoga.gov.br 46 //127.0.0.1 login.dialoga.gov.br
46 //127.0.0.1 noosfero.com 47 //127.0.0.1 noosfero.com
47 //Detects for localhost settings 48 //Detects for localhost settings
48 - var patt = new RegExp(':300[0-2]/'); 49 + var patt = new RegExp(':300[1-2]/');
49 var localDevelopment = false; 50 var localDevelopment = false;
50 51
51 if(patt.test(window.location.href)){ 52 if(patt.test(window.location.href)){
52 localDevelopment = true; 53 localDevelopment = true;
53 - patt = new RegExp(':3000/'); 54 + patt = new RegExp(':3001/');
54 55
55 if(patt.test(window.location.href)){ 56 if(patt.test(window.location.href)){
56 host = 'http://login.dialoga.gov.br'; 57 host = 'http://login.dialoga.gov.br';
57 - }else if (new RegExp(':3001/').test(window.location.href)){  
58 - host = 'http://noosfero.com:3001';  
59 - // dialoga_community = 104;  
60 - // proposal_discussion = '413'; //Eugênio  
61 - // proposal_discussion = '392'; //Evandro  
62 - // cat_saude = 23; 58 + }else if (new RegExp(':3002/').test(window.location.href)){
  59 + host = 'http://noosfero.com:3000';
63 recaptchaSiteKey = '6LdsWAcTAAAAAChTUUD6yu9fCDhdIZzNd7F53zf-'; //http://noosfero.com/ 60 recaptchaSiteKey = '6LdsWAcTAAAAAChTUUD6yu9fCDhdIZzNd7F53zf-'; //http://noosfero.com/
64 - } else { //ABNER  
65 - host = 'http://local.abner.com:3002';  
66 - dialoga_community = 105;  
67 - proposal_discussion = '392'; //Evandro  
68 - recaptchaSiteKey = '6LdsWAcTAAAAAChTUUD6yu9fCDhdIZzNd7F53zf-'; //http://noosfero.com/  
69 - cat_saude = 23;  
70 } 61 }
71 } 62 }
72 63
@@ -671,7 +662,7 @@ define([&#39;jquery&#39;, &#39;handlebars&#39;, &#39;fastclick&#39;, &#39;proposal_app&#39;, &#39;handlebars_helpers @@ -671,7 +662,7 @@ define([&#39;jquery&#39;, &#39;handlebars&#39;, &#39;fastclick&#39;, &#39;proposal_app&#39;, &#39;handlebars_helpers
671 if(proposalOffset){ 662 if(proposalOffset){
672 scrollTop = proposalOffset.top; 663 scrollTop = proposalOffset.top;
673 } 664 }
674 - 665 +
675 } 666 }
676 } 667 }
677 668
@@ -1301,7 +1292,7 @@ define([&#39;jquery&#39;, &#39;handlebars&#39;, &#39;fastclick&#39;, &#39;proposal_app&#39;, &#39;handlebars_helpers @@ -1301,7 +1292,7 @@ define([&#39;jquery&#39;, &#39;handlebars&#39;, &#39;fastclick&#39;, &#39;proposal_app&#39;, &#39;handlebars_helpers
1301 var $form = $(this); 1292 var $form = $(this);
1302 var $description = $form.find('#article_abstract'); 1293 var $description = $form.find('#article_abstract');
1303 var $message = $form.find('.message'); 1294 var $message = $form.find('.message');
1304 - 1295 +
1305 // validation 1296 // validation
1306 if( $description.val().length === 0 ){ 1297 if( $description.val().length === 0 ){
1307 $message.text('O campo "descrição" é obrigatório.'); 1298 $message.text('O campo "descrição" é obrigatório.');
@@ -1316,7 +1307,7 @@ define([&#39;jquery&#39;, &#39;handlebars&#39;, &#39;fastclick&#39;, &#39;proposal_app&#39;, &#39;handlebars_helpers @@ -1316,7 +1307,7 @@ define([&#39;jquery&#39;, &#39;handlebars&#39;, &#39;fastclick&#39;, &#39;proposal_app&#39;, &#39;handlebars_helpers
1316 var $submitButton = $form.find('.make-proposal-button'); 1307 var $submitButton = $form.find('.make-proposal-button');
1317 $submitButton.hide(); 1308 $submitButton.hide();
1318 // $loading.show(); 1309 // $loading.show();
1319 - 1310 +
1320 $.ajax({ 1311 $.ajax({
1321 type: 'post', 1312 type: 'post',
1322 url: host + $form.attr('action'), 1313 url: host + $form.attr('action'),