diff --git a/ConfJuvApp/www/html/_proposal.html b/ConfJuvApp/www/html/_proposal.html index 79c8bc5..e4b1aae 100644 --- a/ConfJuvApp/www/html/_proposal.html +++ b/ConfJuvApp/www/html/_proposal.html @@ -2,21 +2,29 @@

- {{proposal.title}} + {{proposal.title}}
Autoria: {{proposal.author.name}}
Voltar

+ +

- + +

diff --git a/ConfJuvApp/www/index.html b/ConfJuvApp/www/index.html index c55d3b9..a294a51 100644 --- a/ConfJuvApp/www/index.html +++ b/ConfJuvApp/www/index.html @@ -3,6 +3,7 @@ + #3confjuv diff --git a/ConfJuvApp/www/js/config.js.example b/ConfJuvApp/www/js/config.js.example index 813c8d4..c5b9063 100644 --- a/ConfJuvApp/www/js/config.js.example +++ b/ConfJuvApp/www/js/config.js.example @@ -1,5 +1,6 @@ var ConfJuvAppConfig = { noosferoApiHost: 'http://juventude.gov.br', + noosferoApiPublicHost: 'http://app.juventude.gov.br', noosferoApiVersion: 'v1', noosferoDiscussion: 99895, noosferoStatutePath: 'articles/participatorio/0010/2309/Resolucao-01-2015-etapa-digital.pdf', diff --git a/ConfJuvApp/www/js/controllers.js b/ConfJuvApp/www/js/controllers.js index 2372313..db05249 100644 --- a/ConfJuvApp/www/js/controllers.js +++ b/ConfJuvApp/www/js/controllers.js @@ -25,6 +25,8 @@ angular.module('confjuvapp.controllers', []) $scope.loggedIn = true; $scope.loadMe(); $scope.loadTopics($scope.token); + + $scope.parseURLParams(); } else if ($scope.modal) { $scope.modal.show(); } else { @@ -39,6 +41,34 @@ angular.module('confjuvapp.controllers', []) } }; + $scope.parseURLParams = function() { + var params = document.location.search.replace(/^\?/, '').split('&'); + for (var i=0; i < params.length; i++) { + var pair = params[i].split('='); + + if (pair[0] == 'proposal') { + $scope.loadSingleProposal(pair[1]); + } + } + }; + + $scope.loadSingleProposal = function(pid) { + $scope.loading = true; + + var params = '?private_token=' + $scope.token + '&fields=title,image,body,abstract,id,tag_list,categories,created_by&content_type=ProposalsDiscussionPlugin::Proposal'; + + var path = 'articles/' + pid + params; + + $http.get(ConfJuvAppUtils.pathTo(path)) + .then(function(resp) { + $scope.openProposal(resp.data.article); + $scope.loading = false; + }, function(err) { + $ionicPopup.alert({ title: 'Proposta', template: 'Não foi possível carregar a proposta com id ' + pid }); + $scope.loading = false; + }); + }; + // Function to logout $scope.logout = function() { ConfJuvAppUtils.setPrivateToken(null); diff --git a/ConfJuvApp/www/js/utils.js b/ConfJuvApp/www/js/utils.js index 1792070..de40e51 100644 --- a/ConfJuvApp/www/js/utils.js +++ b/ConfJuvApp/www/js/utils.js @@ -21,6 +21,21 @@ var ConfJuvAppUtils = { getPrivateToken: function() { return window.localStorage['private_token']; - } + }, + shareOnTwitter: function() { + var title = document.getElementById('proposal-title').innerHTML, + id = document.getElementById('proposal-id').innerHTML, + text = 'Apoie a minha proposta para a #3ConfJuv: ' + title + ' ' + ConfJuvAppConfig.noosferoApiPublicHost + '/?proposal=' + id, + url = 'https://twitter.com/intent/tweet?text=' + encodeURIComponent(text); + return url; + }, + + shareOnFacebook: function() { + var title = document.getElementById('proposal-title').innerHTML, + id = document.getElementById('proposal-id').innerHTML, + link = ConfJuvAppConfig.noosferoApiPublicHost + '/?proposal=' + id, + url = 'https://www.facebook.com/sharer/sharer.php?u=' + encodeURIComponent(link); + return url; + } }; -- libgit2 0.21.2