Commit 25e3c3de5ef9a2539de31c8fec647777d1051952
Exists in
master
and in
6 other branches
Merge private_token refactory conflicts in main.js
Showing
6 changed files
with
85 additions
and
31 deletions
Show diff stats
Gemfile
Gemfile.lock
index.html
| 1 | +<!DOCTYPE html> | |
| 1 | 2 | <html lang="pt-br"> |
| 2 | 3 | <head> |
| 3 | 4 | <meta charset="utf-8" /> |
| ... | ... | @@ -5,6 +6,7 @@ |
| 5 | 6 | |
| 6 | 7 | <meta http-equiv="X-UA-Compatible" content="IE=edge"> |
| 7 | 8 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 9 | + <meta property="og:title" content="Dialoga Brasil" /> | |
| 8 | 10 | |
| 9 | 11 | <script type="text/javascript"> |
| 10 | 12 | /** |
| ... | ... | @@ -74,6 +76,16 @@ |
| 74 | 76 | |
| 75 | 77 | </head> |
| 76 | 78 | <body> |
| 79 | + <div id="fb-root"></div> | |
| 80 | + <script>(function(d, s, id) { | |
| 81 | + var js, fjs = d.getElementsByTagName(s)[0]; | |
| 82 | + if (d.getElementById(id)) return; | |
| 83 | + js = d.createElement(s); js.id = id; | |
| 84 | + js.src = "//connect.facebook.net/pt_BR/sdk.js#xfbml=1&version=v2.3&appId=1449495475361394"; | |
| 85 | + fjs.parentNode.insertBefore(js, fjs); | |
| 86 | + }(document, 'script', 'facebook-jssdk'));</script> | |
| 87 | + | |
| 88 | + | |
| 77 | 89 | <div class="container"> |
| 78 | 90 | <div id="proposal-result"></div> |
| 79 | 91 | </div> |
| ... | ... | @@ -83,6 +95,9 @@ |
| 83 | 95 | <header> |
| 84 | 96 | <h1><a href="#">{{article.title}}</a></h1> |
| 85 | 97 | <a id="display-contrast" href="#">Alto Contraste</a> |
| 98 | + <div class="social"> | |
| 99 | + <a href="#" class="fb-share" data-description="Aqui suas ideias viram propostas e você ajuda a melhorar as ações do governo">Compartilhar</a> | |
| 100 | + </div> | |
| 86 | 101 | </header> |
| 87 | 102 | |
| 88 | 103 | <div id="content"> |
| ... | ... | @@ -153,6 +168,9 @@ |
| 153 | 168 | {{/each}} |
| 154 | 169 | </ul> |
| 155 | 170 | |
| 171 | + <div class="social"> | |
| 172 | + <a href="#" class="fb-share" data-caption="{{title}}" data-description="{{stripTags abstract}}">Compartilhar</a> | |
| 173 | + </div> | |
| 156 | 174 | <div class="proposal-header"> |
| 157 | 175 | <div class="abstract"> |
| 158 | 176 | <img src="{{../host}}{{image.url}}" alt="Imagem de apresentação do programa."/> |
| ... | ... | @@ -188,7 +206,7 @@ |
| 188 | 206 | <div class="info">Esta consulta termina em julho de 2015. Até lá, todas as propostas serão lidas e as cinco mais pontuadas em cada programa receberão resposta oficial do governo.</div> |
| 189 | 207 | <div class="send-proposal-button send-button"><a href="#"><span>Envie Sua Proposta</span></a></div> |
| 190 | 208 | <div class="login-container hide">Login</div> |
| 191 | - <form class="make-proposal-form save-article-form hide" id="make-proposal-form-{{id}}" action="{{proposal_action ../article . }}" method="post"> | |
| 209 | + <form class="make-proposal-form save-article-form require-login hide" id="make-proposal-form-{{id}}" action="{{proposal_action ../article . }}" method="post"> | |
| 192 | 210 | <div class="message hide"></div> |
| 193 | 211 | <div> |
| 194 | 212 | <div><label for="article_abstract">Descrição</label></div> |
| ... | ... | @@ -209,9 +227,13 @@ |
| 209 | 227 | <div class="support-proposal-container"> |
| 210 | 228 | <div class="support-proposal"> |
| 211 | 229 | <div class="container-title"> Apoie outras propostas</div> |
| 212 | - <div class="random-proposal"></div> | |
| 213 | - <div class="loading">Carregando...</div> | |
| 214 | - <div class="no-proposals">Ainda não existe nenhuma proposta para este programa.</div> | |
| 230 | + <div class="support-proposal-content require-login"> | |
| 231 | + <div class="random-proposal"></div> | |
| 232 | + <div class="loading">Carregando...</div> | |
| 233 | + <div class="no-proposals">Ainda não existe nenhuma proposta para este programa.</div> | |
| 234 | + </div> | |
| 235 | + <div class="login-container hide">Login</div> | |
| 236 | + <div class="send-button"><a href="#"><span>Login</span></a></div> | |
| 215 | 237 | </div> |
| 216 | 238 | </div> |
| 217 | 239 | |
| ... | ... | @@ -263,6 +285,9 @@ |
| 263 | 285 | <a href="#" class="skip">Pular</a> |
| 264 | 286 | <a href="#" class="vote-result">Resultados</a> |
| 265 | 287 | </div> |
| 288 | + <div class="social"> | |
| 289 | + <a href="#/programas/{{parent.id}}/propostas/{{id}}" class="fb-share" data-caption="{{parent.title}}" data-description="{{stripTags abstract}}">Compartilhar</a> | |
| 290 | + </div> | |
| 266 | 291 | </script> |
| 267 | 292 | |
| 268 | 293 | <script id="results" type="text/x-handlebars-template"> | ... | ... |
js/main.js
| ... | ... | @@ -20,14 +20,10 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F |
| 20 | 20 | var participa = true; |
| 21 | 21 | if(participa){ |
| 22 | 22 | var host = 'http://www.participa.br'; |
| 23 | - var private_token = '375bee7e17d0021af7160ce664874618'; //participa | |
| 24 | 23 | var proposal_discussion = '92856'; //participa |
| 25 | 24 | }else{ |
| 26 | 25 | var host = 'http://noosfero.com:3000'; |
| 27 | - //var private_token = 'bd8996155f5ea4354e42fee50b4b6891'; //casa | |
| 28 | - var private_token = 'aae32bf5031e895b00a20a529d763b31'; //local serpro | |
| 29 | 26 | var proposal_discussion = '632'; //local serpro |
| 30 | - //var proposal_discussion = '401'; //casa | |
| 31 | 27 | } |
| 32 | 28 | |
| 33 | 29 | var BARRA_ADDED = false; |
| ... | ... | @@ -36,7 +32,8 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F |
| 36 | 32 | Main = (function(){ |
| 37 | 33 | |
| 38 | 34 | return { |
| 39 | - getProposalId: function(){ | |
| 35 | + private_token: '375bee7e17d0021af7160ce664874618', | |
| 36 | + getProposalId: function() { | |
| 40 | 37 | var regexProposals = /\d.*\/propostas\/\d.*/; |
| 41 | 38 | var proposalId = 0; |
| 42 | 39 | |
| ... | ... | @@ -49,8 +46,8 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F |
| 49 | 46 | |
| 50 | 47 | return proposalId; |
| 51 | 48 | }, |
| 52 | - | |
| 53 | - loadRandomProposal: function (topic_id, private_token) { | |
| 49 | + loadRandomProposal: function (topic_id) { | |
| 50 | + var private_token = Main.private_token; | |
| 54 | 51 | var $noProposals = $('.no-proposals'); |
| 55 | 52 | var $loading = $('.loading'); |
| 56 | 53 | var $randomProposal = $('.random-proposal'); |
| ... | ... | @@ -68,7 +65,7 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F |
| 68 | 65 | if(childId != 0){ |
| 69 | 66 | url += '/'+childId; |
| 70 | 67 | } |
| 71 | - url += '?private_token=' + private_token + '&limit=1&order=random()&_='+new Date().getTime()+'&fields=id,name,abstract,created_by&content_type=ProposalsDiscussionPlugin::Proposal'; | |
| 68 | + url += '?private_token=' + Main.private_token + '&limit=1&order=random()&_='+new Date().getTime()+'&fields=id,name,abstract,created_by&content_type=ProposalsDiscussionPlugin::Proposal'; | |
| 72 | 69 | |
| 73 | 70 | $.getJSON(url).done(function( data ) { |
| 74 | 71 | $loading.hide(); |
| ... | ... | @@ -80,10 +77,12 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F |
| 80 | 77 | } |
| 81 | 78 | |
| 82 | 79 | var article = data.articles[0]; |
| 80 | + var parentTitle = $('#proposal-item-'+topic_id).find('.proposal-header .title').text(); | |
| 81 | + article.parent = {id: topic_id, title: parentTitle}; | |
| 83 | 82 | $randomProposal.html(supportProposalTemplate(article)); |
| 84 | 83 | $body.off('click', '.vote-actions .skip'); |
| 85 | 84 | $body.on('click', '.vote-actions .skip', function(e) { |
| 86 | - contextMain.loadRandomProposal(topic_id, private_token); | |
| 85 | + contextMain.loadRandomProposal(topic_id); | |
| 87 | 86 | e.preventDefault(); |
| 88 | 87 | }); |
| 89 | 88 | $body.off('click', '.vote-actions .like'); |
| ... | ... | @@ -91,20 +90,27 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F |
| 91 | 90 | //Helps to prevent more than one vote per proposal |
| 92 | 91 | if(ProposalApp.hasProposalbeenVoted(article.id)){ |
| 93 | 92 | console.log("Proposta " + article.id + " já havia sido votada"); |
| 94 | - contextMain.loadRandomProposal(topic_id, private_token); | |
| 93 | + contextMain.loadRandomProposal(topic_id); | |
| 94 | + e.preventDefault(); | |
| 95 | + return; | |
| 96 | + } | |
| 97 | + | |
| 98 | + if(!logged_in) { | |
| 99 | + $(this).closest('.support-proposal').find('.send-button a').click(); | |
| 95 | 100 | e.preventDefault(); |
| 96 | 101 | return; |
| 97 | 102 | } |
| 103 | + | |
| 98 | 104 | $.ajax({ |
| 99 | 105 | type: 'post', |
| 100 | 106 | url: host + '/api/v1/articles/' + article.id + '/vote', |
| 101 | 107 | data: { |
| 102 | 108 | value: $(this).data('vote-value'), |
| 103 | - private_token: private_token | |
| 109 | + private_token: Main.private_token | |
| 104 | 110 | } |
| 105 | 111 | }).done(function( /*data*/ ) { |
| 106 | 112 | ProposalApp.addVotedProposal(article.id); |
| 107 | - contextMain.loadRandomProposal(topic_id, private_token); | |
| 113 | + contextMain.loadRandomProposal(topic_id); | |
| 108 | 114 | }); |
| 109 | 115 | e.preventDefault(); |
| 110 | 116 | }); |
| ... | ... | @@ -132,7 +138,7 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F |
| 132 | 138 | $resultsContainer.find('.results-content').hide(); |
| 133 | 139 | |
| 134 | 140 | var per_page = 10; |
| 135 | - var url = host + '/api/v1/proposals_discussion_plugin/' + topic_id + '/ranking' + '?private_token=' + private_token + '&per_page='+per_page+'&page='+page; | |
| 141 | + var url = host + '/api/v1/proposals_discussion_plugin/' + topic_id + '/ranking' + '?private_token=' + Main.private_token + '&per_page='+per_page+'&page='+page; | |
| 136 | 142 | $.getJSON(url).done(function( data, stats, xhr ) { |
| 137 | 143 | data.pagination = { |
| 138 | 144 | total: parseInt(xhr.getResponseHeader('Total')), |
| ... | ... | @@ -176,14 +182,14 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F |
| 176 | 182 | |
| 177 | 183 | if(logged_in) { |
| 178 | 184 | if(token){ |
| 179 | - private_token = token; | |
| 185 | + Main.private_token = token; | |
| 180 | 186 | } |
| 181 | - loginButton.siblings('.save-article-form').show(); | |
| 182 | - loginButton.siblings('.save-article-form .message').show(); | |
| 187 | + loginButton.siblings('.require-login').show(); | |
| 188 | + loginButton.siblings('.require-login .message').show(); | |
| 183 | 189 | loginButton.siblings('.login-container').hide(); |
| 184 | - $.cookie('_dialoga_session', private_token); | |
| 190 | + $.cookie('_dialoga_session', Main.private_token); | |
| 185 | 191 | } else { |
| 186 | - loginButton.siblings('.save-article-form').hide(); | |
| 192 | + loginButton.siblings('.require-login').hide(); | |
| 187 | 193 | loginButton.siblings('.login-container').show(); |
| 188 | 194 | } |
| 189 | 195 | }, |
| ... | ... | @@ -238,7 +244,7 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F |
| 238 | 244 | $proposal.find('.calendar').slick(); |
| 239 | 245 | |
| 240 | 246 | var topic_id = proposal_id.split('-').pop(); |
| 241 | - this.loadRandomProposal(topic_id, private_token); | |
| 247 | + this.loadRandomProposal(topic_id); | |
| 242 | 248 | }, |
| 243 | 249 | display_proposal_detail: function(proposal_id){ |
| 244 | 250 | $('#proposal-categories').hide(); |
| ... | ... | @@ -256,7 +262,7 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F |
| 256 | 262 | $proposal.find('.body').show(); |
| 257 | 263 | $proposal.show(); |
| 258 | 264 | |
| 259 | - var url = host + '/api/v1/articles/' + proposal_id + '?private_token=' + private_token + '&fields=id,body&content_type=ProposalsDiscussionPlugin::Topic'; | |
| 265 | + var url = host + '/api/v1/articles/' + proposal_id + '?private_token=' + Main.private_token + '&fields=id,body&content_type=ProposalsDiscussionPlugin::Topic'; | |
| 260 | 266 | $.getJSON(url).done(function( data ) { |
| 261 | 267 | $('#proposal-item-' + proposal_id + ' .body-content').replaceWith(data.article.body); |
| 262 | 268 | }) |
| ... | ... | @@ -455,12 +461,12 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F |
| 455 | 461 | })(); |
| 456 | 462 | |
| 457 | 463 | // Load data from localhost when it is dev env. |
| 458 | - var noosferoAPI = host + '/api/v1/articles/' + proposal_discussion + '?private_token=' + private_token + '&fields=id,children,categories,abstract,title,image,url,setting,position'; | |
| 464 | + var noosferoAPI = host + '/api/v1/articles/' + proposal_discussion + '?private_token=' + Main.private_token + '&fields=id,children,categories,abstract,title,image,url,setting,position'; | |
| 459 | 465 | |
| 460 | 466 | $.getJSON(noosferoAPI) |
| 461 | 467 | .done(function( data ) { |
| 462 | 468 | data.host = host; |
| 463 | - data.private_token = private_token; | |
| 469 | + data.private_token = Main.private_token; | |
| 464 | 470 | resultsPlaceholder.innerHTML = template(data); |
| 465 | 471 | $('.login-container').html(loginTemplate()); |
| 466 | 472 | $('.countdown').maxlength({text: '%left caracteres restantes'}); |
| ... | ... | @@ -603,7 +609,7 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F |
| 603 | 609 | $.ajax({ |
| 604 | 610 | type: 'post', |
| 605 | 611 | url: host + $form.attr('action'), |
| 606 | - data: $('#'+this.id).serialize() + '&private_token=' + private_token + '&fields=id&article[name]=article_' + Main.guid() | |
| 612 | + data: $('#'+this.id).serialize() + '&private_token=' + Main.private_token + '&fields=id&article[name]=article_' + Main.guid() | |
| 607 | 613 | }) |
| 608 | 614 | .done(function( /*data*/ ) { |
| 609 | 615 | form.reset(); |
| ... | ... | @@ -639,7 +645,7 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F |
| 639 | 645 | var url = host + '/api/v1/users/me?private_token=' + $.cookie('_dialoga_session'); |
| 640 | 646 | $.getJSON(url).done(function( /*data*/ ) { |
| 641 | 647 | logged_in = true; |
| 642 | - private_token = $.cookie('_dialoga_session'); | |
| 648 | + Main.private_token = $.cookie('_dialoga_session'); | |
| 643 | 649 | }); |
| 644 | 650 | } |
| 645 | 651 | |
| ... | ... | @@ -663,6 +669,23 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F |
| 663 | 669 | e.preventDefault(); |
| 664 | 670 | }); |
| 665 | 671 | |
| 672 | + $(document).on('click', '.social .fb-share', function(e) { | |
| 673 | + var link = $(this).attr('href'); | |
| 674 | + if(link==='#' || link ==='') { | |
| 675 | + link = window.location.href; | |
| 676 | + } else { | |
| 677 | + link = 'http:'+Url.addBaseUrl(link); | |
| 678 | + } | |
| 679 | + FB.ui({ | |
| 680 | + method: 'feed', | |
| 681 | + link: link, | |
| 682 | + name: $(this).data('name') || 'Dialoga Brasil', | |
| 683 | + caption: $(this).data('caption') || 'dialoga.gov.br', | |
| 684 | + description: $(this).data('description'), | |
| 685 | + }, function(response){}); | |
| 686 | + e.preventDefault(); | |
| 687 | + }); | |
| 688 | + | |
| 666 | 689 | $(document).on('click', '.new-user', function(e) { |
| 667 | 690 | var loginForm = $(this).parents('#login-form'); |
| 668 | 691 | loginForm.hide(); | ... | ... |
sass/_header.scss