diff --git a/app/controllers/activity_streams/photos_controller.rb b/app/controllers/activity_streams/photos_controller.rb index 1a7a72662..be0d6c07f 100644 --- a/app/controllers/activity_streams/photos_controller.rb +++ b/app/controllers/activity_streams/photos_controller.rb @@ -3,7 +3,8 @@ # the COPYRIGHT file. class ActivityStreams::PhotosController < ApplicationController - before_filter :authenticate_user! + authenticate_with_oauth + before_filter :set_user_from_oauth skip_before_filter :verify_authenticity_token, :only => :create respond_to :json @@ -38,4 +39,10 @@ class ActivityStreams::PhotosController < ApplicationController end respond_with @photo end + def current_user + @user + end + def set_user_from_oauth + @user = request.env['oauth2'].resource_owner + end end diff --git a/app/controllers/apis_controller.rb b/app/controllers/apis_controller.rb index 5ed3ed5df..b43da81fa 100644 --- a/app/controllers/apis_controller.rb +++ b/app/controllers/apis_controller.rb @@ -5,7 +5,11 @@ class ApisController < ApplicationController def me @person = @user.person - render :json => {:birthday => @person.profile.birthday, :name => @person.name} + render :json => { + :birthday => @person.profile.birthday, + :name => @person.name, + :uid => @user.username + } end private diff --git a/app/controllers/authorizations_controller.rb b/app/controllers/authorizations_controller.rb index 3dc991744..c6537953a 100644 --- a/app/controllers/authorizations_controller.rb +++ b/app/controllers/authorizations_controller.rb @@ -6,7 +6,9 @@ class AuthorizationsController < ApplicationController skip_before_filter :verify_authenticity_token, :only => :token def new + @requested_scopes = params["scope"].split(',') @client = oauth2_authorization_request.client + render :layout => "popup" if params[:popup] end def create diff --git a/app/views/authorizations/new.html.haml b/app/views/authorizations/new.html.haml index 4a31aed9b..9023c487b 100644 --- a/app/views/authorizations/new.html.haml +++ b/app/views/authorizations/new.html.haml @@ -1,27 +1,45 @@ +#popup-contents + %h4 + = "#{@client.name} is requesting access to your account" -%br -%br + #popup-content-left + %ul#requested-scopes + - @requested_scopes.each do |scope| + - if scope == "name" + %li + .scope-photo + = owner_image_tag -.prepend-4 - .floating.span-15 - .span-3.append-1 - = image_tag(@client.icon_url, :id => 'client-application-image') + %strong + Basic Info + %br + Cubbies will be able to see your name, profile photo, and other basic profile information. - .span-10 - = form_for :authorization, - :url => oauth_authorize_path(params.slice(:redirect_uri, :client_id, :client_secret)) do |form| + - elsif scope = "AS_photo:post" + %li + .scope-photo + = image_tag('/images/icons/photo.svg') - %h1 - = "Authorize #{@client.name}?" + %strong + Your Photos + %br + Cubbies will be able to post photos on your behalf - .description - = @client.description - %p - = "You are currently logged in as #{current_user.name}(#{current_user.diaspora_handle})." - = link_to("Not You?", destroy_user_session_path) - %br - %p - = form.submit "Fuck Yeah!", :value => "Yes" - = form.submit "Hell No.", :value => "No" + + = form_for :authorization, + :url => oauth_authorize_path(params.slice(:redirect_uri, :client_id, :client_secret)) do |form| + %br + %p + = form.submit "Fuck Yeah!", :value => "Authorize", :class => 'button' + = form.submit "Hell No.", :value => "No", :class => 'button' + + + #popup-content-right + = image_tag(@client.icon_url, :id => 'client-application-image') + %br + %strong + = @client.name + .description + = @client.description diff --git a/app/views/layouts/popup.html.haml b/app/views/layouts/popup.html.haml new file mode 100644 index 000000000..aa207839c --- /dev/null +++ b/app/views/layouts/popup.html.haml @@ -0,0 +1,73 @@ +-# Copyright (c) 2010, Diaspora Inc. This file is +-# licensed under the Affero General Public License version 3 or later. See +-# the COPYRIGHT file. + +!!! +%html{:lang => I18n.locale.to_s, :dir => (rtl?) ? 'rtl' : 'ltr'} + %head + %meta{:charset => 'utf-8'} + + %title + = page_title yield(:page_title) + + %meta{'http-equiv' => 'X-UA-Compatible', :content => 'IE=edge,chrome=1'} + + %meta{"http-equiv"=>"Content-Type", :content=>"text/html; charset=utf-8"}/ + + %link{:rel => 'shortcut icon', :href => '/favicon.png'} + %link{:rel => 'apple-touch-icon', :href => '/apple-touch-icon.png'} + + / Social Media Icons are by Paul Robert Lloyd @ http://paulrobertlloyd.com/2009/06/social_media_icons + = stylesheet_link_tag "login", :media => 'screen' + + = stylesheet_link_tag "blueprint/screen", :media => 'screen' + = stylesheet_link_tag "blueprint/print", :media => 'print' + = include_stylesheets :popup, :media => 'all' + + - if rtl? + = include_stylesheets :rtl, :media => 'all' + + + + = include_javascripts :jquery + :javascript + !window.jQuery && document.write(unescape('%3Cscript src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"%3E%3C/script%3E')) + + = csrf_meta_tag + + -if AppConfig[:google_a_site] + :javascript + var _gaq = _gaq || []; + _gaq.push(['_setAccount', '#{AppConfig[:google_a_site]}']); + _gaq.push(['_trackPageview']); + + (function() { + var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; + ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; + var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); + })(); + + -if AppConfig[:piwik_id] + :javascript + var pkBaseURL = (("https:" == document.location.protocol) ? "https://#{AppConfig[:piwik_url]}/" : "http://#{AppConfig[:piwik_url]}/"); + document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E")); + :javascript + try { + var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", #{AppConfig[:piwik_id]}); + piwikTracker.trackPageView(); + piwikTracker.enableLinkTracking(); + } catch( err ) {} + + + %body{:class => "#{yield(:body_class)}"} + %header + = image_tag('asterisk_white.png', :height => 25, :width => 25, :id => 'asterisk') + Grant Account Access + + = yield + + %footer + = "logged in as #{current_user.name}" + diff --git a/config/assets.yml b/config/assets.yml index e18c138ec..d97e78959 100644 --- a/config/assets.yml +++ b/config/assets.yml @@ -86,6 +86,12 @@ stylesheets: - public/stylesheets/vendor/fileuploader.css - public/stylesheets/vendor/tipsy.css - public/stylesheets/vendor/autoSuggest.css + + popup: + - public/stylesheets/application.css + - public/stylesheets/popup.css + - public/stylesheets/ui.css + rtl: - public/stylesheets/rtl.css diff --git a/public/images/asterisk.png b/public/images/asterisk.png index 9e181f5f3..140ede770 100644 Binary files a/public/images/asterisk.png and b/public/images/asterisk.png differ diff --git a/public/images/asterisk_white.png b/public/images/asterisk_white.png new file mode 100644 index 000000000..308299ecf Binary files /dev/null and b/public/images/asterisk_white.png differ diff --git a/public/images/icons/photo.svg b/public/images/icons/photo.svg new file mode 100644 index 000000000..554f63217 --- /dev/null +++ b/public/images/icons/photo.svg @@ -0,0 +1,14 @@ + + + + + + + + diff --git a/public/stylesheets/sass/popup.scss b/public/stylesheets/sass/popup.scss new file mode 100644 index 000000000..86c84da0b --- /dev/null +++ b/public/stylesheets/sass/popup.scss @@ -0,0 +1,85 @@ +// Copyright (c) 2010, Diaspora Inc. This file is +// licensed under the Affero General Public License version 3 or later. See +// the COPYRIGHT file. + +@import "mixins"; + + +body, html, header, footer, ul{ + padding: 0; + margin: 0; +} + +header, +footer{ + width: 100%; +} + +header{ + position: relative; + font-size: 14px; + font-weight: bold; + color: #fff; + vertical-align: top; + margin-bottom: 20px; + + #asterisk{ + margin-right: 3px; + } +} + +footer{ + position: absolute; + background-color: #eee; + border-top: 1px solid #ccc; + bottom: 0; + left: 0; +} + +#popup-contents{ + width: 700px; + text-align:center; +} + +#popup-content-left, +#popup-content-right{ + text-align: left; + display: inline-block; + vertical-align: top; + padding: 20px; +} + +#popup-content-left{ + width: 400px; +} + +#popup-content-right{ + width: 200px; + border-left: 3px solid #555; + text-align: center; +} + +ul#requested-scopes{ + padding-left: 20px; + margin-top: 5px; + + li{ + position: relative; + padding: 5px; + padding-left: 50px; + min-height: 40px; + margin-bottom: 15px; + } + + .scope-photo{ + height: 35px; + width: 35px; + left: 0; + position: absolute; + + *{ + max-height: 100%; + max-width: 100%; + } + } +}