comparison views/index.jade @ 0:b73191efc65b

Initial import of pumpbridge (bloody bloody alpha)
author Mathias Gebbe <mgebbe@intevation.de>
date Thu, 05 Jun 2014 10:35:15 +0200
parents
children 98a070c98982
comparison
equal deleted inserted replaced
-1:000000000000 0:b73191efc65b
1 doctype html
2 html(lang="en")
3 head
4 title= pageTitle
5
6 link(rel='stylesheet', href='/stylesheets/style.css')
7 link(rel='icon', href='/images/favicon.ico',type='image/x-icon')
8 link(rel='stylesheet', href='/stylesheets/bootstrap.min.css')
9
10 // load jquery
11 script(src='https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js')
12
13 // load googleplus api
14 script(type='text/javascript').
15 (function() {
16 var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
17 po.src = 'https://apis.google.com/js/client:plusone.js';
18 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
19 })();
20
21
22 // load googleplus api sign in
23
24 script(type='text/javascript').
25 (function() {
26 var po = document.createElement('script');
27 po.type = 'text/javascript'; po.async = true;
28 po.src = 'https://apis.google.com/js/client:plusone.js?onload=render';
29 var s = document.getElementsByTagName('script')[0];
30 s.parentNode.insertBefore(po, s);
31 })();
32
33 /* Executed when the APIs finish loading */
34 function render() {
35
36 gapi.signin.render('gp-root', {
37 'callback': 'signinCallback',
38 'clientid': '460404084439-rgb5r2vh7hh8hvf2na65c7n1ofhmomek.apps.googleusercontent.com',
39 'redirecturi': 'postmessage',
40 'response_type' : 'code',
41 'accesstype': 'offline',
42 'approvalprompt': 'force',
43 'cookiepolicy': "https://do.blessuren.de:3000",
44 'requestvisibleactions': 'http://schemas.google.com/AddActivity',
45 'scope': 'https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/userinfo.email'
46 });
47 }
48
49 // handle googleplus callback
50
51 script(type='text/javascript').
52 function signinCallback(authResult) {
53 if (authResult['status']['signed_in']) {
54 // Update the app to reflect a signed in user
55 // Hide the sign-in button now that the user is authorized, for example:
56 //document.getElementById('signinButton').setAttribute('style', 'display: none');
57 //alert('googleplus is ready for bridging');
58
59 gapi.client.load('plus', 'v1', function() {
60 var request = gapi.client.plus.people.get({
61 'userId': 'me'
62 });
63 request.execute(function(resp) {
64 //alert(JSON.stringify(resp));
65 $('#gpstatus').html('<a href=' + resp.url + '> ' + resp.displayName + '</a>');
66 var token = gapi.auth.getToken();
67 //alert(JSON.stringify(token));
68 $('#gpid').val(resp.id+'@google');
69 $('#gptoken').val(token.access_token + ';' + token.code);
70 });
71 });
72
73
74 } else {
75 // Update the app to reflect a signed out user
76 // Possible error values:
77 // "user_signed_out" - User is signed-out
78 // "access_denied" - User denied access to your app
79 // "immediate_failed" - Could not automatically log in the user
80 //alert('you cancelled login or did not fully authorize: ' + authResult['error']);
81 }
82 }
83
84
85 // load facebook api
86 script.
87 $(document).ready(function () {
88
89 $.ajaxSetup({
90 cache: true
91 });
92
93 $.getScript('//connect.facebook.net/en_UK/all.js', function () {
94 FB.init({
95 appId: '771281529571170',
96 status : true
97 });
98
99 FB.getLoginStatus(function(response) {
100 if (response.status === 'connected') {
101 // the user is logged in and has authenticated your
102 // app, and response.authResponse supplies
103 // the user's ID, a valid access token, a signed
104 // request, and the time the access token
105 // and signed request each expire
106 var uid = response.authResponse.userID;
107 var accessToken = response.authResponse.accessToken;
108 $('#fbtoken').val(accessToken);
109 FB.api('/me', function(response) {
110 $('#fbstatus').html('<a href=//facebook.com/' + response.id + '> ' + response.name + '</a>');
111 $('#fbid').val(response.id+'@facebook');
112 });
113 } else if (response.status === 'not_authorized') {
114 // the user is logged in to Facebook,
115 // but has not authenticated your app
116 $('#fbstatus').html('not authorized');
117 } else {
118 // the user isn't logged in to Facebook.
119 $('#fbstatus').html('not logged in');
120 }
121 });
122
123
124 });
125
126
127 $('.fbloginbutton').on('click', function(e){
128 FB.login(function(response) {
129 if (response.authResponse) {
130 FB.api('/me', function(response) {
131 //document.getElementById("logoutbutton").disabled = false;
132 });
133 } else {
134 //Not logged in
135 //alert('you cancelled login or did not fully authorize.');
136 }
137 }, {scope: 'publish_actions,publish_stream,read_stream,read_friendlists,user_likes,read_insights,user_activities'});
138 })
139
140 //$('.logoutbutton').on('click', function(e){
141 // FB.logout();
142 // })
143 $('#pumpobj').val(JSON.stringify(!{JSON.stringify(user)}));
144 });
145
146 body
147 block content
148 .main
149 h1(class='headline') pumpbridge.<br>connecting social networks
150 #fb-root.fb-root
151 input(id='fbloginbutton',type='image',class='fbloginbutton',value='fbLogin',src='images/fb.svg',width='100px',height='100px')
152 #gp-root.gp-root
153 input(id='gploginbutton',type='image',class='gploginbutton',value='gpLogin',src='images/gp.svg',width='100px',height='100px')
154 //span.g-signin(data-scope='https://www.googleapis.com/auth/plus.login', data-clientid='460404084439-rgb5r2vh7hh8hvf2na65c7n1ofhmomek.apps.googleusercontent.com', data-redirecturi='postmessage', data-accesstype='offline', data-cookiepolicy='single_host_origin', data-callback='signInCallback', approval_prompt='force')
155 #pump-root.pump-root
156 a(href='/login')
157 input(id='pumploginbutton',type='image',class='pumploginbutton',value='pumpLogin',src='images/pumpiologo.svg',width='100px',height='100px')
158 br
159 form(class='',action='/bridge',method='post')
160 #connect.connect
161 ul
162 li Facebook:
163 i(id='fbstatus') not logged in
164 br
165 input(id='fbid',name='fbid',hidden='true')
166 input(id='fbtoken',name='fbtoken',hidden='true')
167 li GooglePlus:
168 i(id='gpstatus') not logged in
169 br
170 input(id='gpid',name='gpid',hidden='true')
171 input(id='gptoken',name='gptoken',hidden='true',size=100)
172 li pump.io:
173 a(id='pumpstatus',class='pumpstatus',href=user.homepage)= user.id
174 br
175 input(id='pumpid',name='pumpid',hidden='true',value=user.id)
176 input(id='pumptoken',name='pumptoken',hidden='true', value=user.token)
177 input(id='pumpsecret',name='pumpsecret',hidden='true', value=user.secret)
178 input(id='pumpobj',name='pumpobj', hidden='true' value='')
179 br
180 input(type='submit',class='btn btn-default',value='save tokens')
181 .footer
182 #logout.logout
183 //input(id='logoutbutton',type='button',class='logoutbutton',value='Logout',disabled)
184 form(class='',action='/logout',method='post')
185 input(type='submit',class='btn btn-default',value='logout')
186 br
187 p.
188 here our bridge will be.
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)