styling for doorkeeper and api functional

This commit is contained in:
Connor Turland 2016-03-24 17:16:27 -07:00
parent 5317711b57
commit 14dfe3c926
26 changed files with 571 additions and 42 deletions

View file

@ -43,7 +43,7 @@ Metamaps.Active = {
Metamaps.Maps = {};
$(document).ready(function () {
function init() {
for (var prop in Metamaps) {
// this runs the init function within each sub-object on the Metamaps one
@ -55,11 +55,13 @@ $(document).ready(function () {
Metamaps[prop].init();
}
}
}
// initialize the famous ui
var callFamous = function(){
if (Metamaps.Famous) {
Metamaps.Famous.build();
init();
}
else {
setTimeout(callFamous, 100);

View file

@ -0,0 +1,131 @@
.centerContent {
position: relative;
margin: 92px auto 0 auto;
padding: 20px 0 60px 20px;
width: 760px;
overflow: hidden;
box-shadow: 0 1px 3px rgba(0,0,0,.12),0 1px 2px rgba(0,0,0,.24);
background: #fff;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
border: 1px solid #dcdcdc;
margin-bottom: 10px;
padding: 15px;
}
.centerContent .page-header {
margin-bottom: 20px;
padding-bottom: 8px;
border-bottom: 1px solid #DCDCDC;
}
.centerContent .form-group {
margin-bottom: 20px;
}
.centerContent .inline-button {
display: inline-block;
}
.centerContent.showApp p {
margin-bottom: 20px;
}
.centerContent a {
color: #4fb5c0;
}
.centerContent a:hover {
text-decoration: underline;
}
.centerContent a.button {
color: #FFFFFF;
}
.centerContent a.button:hover {
text-decoration: none;
}
.centerContent th {
text-align: left;
}
.centerContent td {
padding-right: 20px;
padding-bottom: 20px;
}
.centerContent .link-button {
line-height: 32px;
color: #FFFFFF;
}
.centerContent .button-margin {
margin-bottom: 20px;
}
.centerContent .button-margin-top {
margin-top: 20px;
}
.centerContent a.red-button, .centerContent button.red-button,
.centerContent input[type="submit"].red-button {
color: #c04f4f;
background: transparent;
text-transform: none;
}
.centerContent .red-button:hover {
background: transparent;
color: #9A3E3E !important;
}
.centerContent input[type="text"] {
font-family: 'din-medium', helvetica, sans-serif;
width: 400px;
height: 32px;
font-size: 14px;
direction: ltr;
-webkit-appearance: none;
appearance: none;
display: inline-block;
margin: 0;
padding: 0 8px;
background: #fff;
border: 1px solid #d9d9d9;
border-top: 1px solid #c0c0c0;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
-webkit-border-radius: 1px;
-moz-border-radius: 1px;
border-radius: 2px;
color: #424242;
letter-spacing: normal;
word-spacing: normal;
text-transform: none;
text-indent: 0px;
text-shadow: none;
display: inline-block;
text-align: start;
}
.centerContent textarea {
color: #424242;
padding: 8px;
border: 1px solid #d9d9d9;
border-top: 1px solid #c0c0c0;
resize: none;
letter-spacing: normal;
word-spacing: normal;
text-transform: none;
text-indent: 0px;
text-shadow: none;
text-align: start;
font-family: 'din-medium', helvetica, sans-serif;
font-size: 14px;
line-height: 17px;
width: 400px;
box-sizing: border-box;
border-radius: 2px;
}

View file

@ -30,18 +30,23 @@ class API::RestfulController < ActionController::Base
end
def current_user
super || token_user || nil
super || token_user || doorkeeper_user || nil
end
def token_user
authenticate_with_http_token do |token, options|
access_token = Token.find_by_token(token)
if access_token
@token_user ||= access_token.user
end
token = params[:access_token]
access_token = Token.find_by_token(token)
if access_token
@token_user ||= access_token.user
end
end
def doorkeeper_user
return unless doorkeeper_token.present?
doorkeeper_render_error unless valid_doorkeeper_token?
@doorkeeper_user ||= User.find(doorkeeper_token.resource_owner_id)
end
def permitted_params
@permitted_params ||= PermittedParams.new(params)
end

View file

@ -0,0 +1,5 @@
<%- submit_btn_css ||= 'button red-button' %>
<%= form_tag oauth_application_path(application) do %>
<input type="hidden" name="_method" value="delete">
<%= submit_tag t('doorkeeper.applications.buttons.destroy'), onclick: "return confirm('#{ t('doorkeeper.applications.confirmations.destroy') }')", class: submit_btn_css %>
<% end %>

View file

@ -0,0 +1,36 @@
<%= form_for application, url: doorkeeper_submit_path(application), html: {class: 'form-horizontal', role: 'form'} do |f| %>
<% if application.errors.any? %>
<div class="alert alert-danger" data-alert><p><%= t('doorkeeper.applications.form.error') %></p></div>
<% end %>
<%= content_tag :div, class: "form-group#{' has-error' if application.errors[:name].present?}" do %>
<%= f.label :name, class: 'col-sm-2 control-label' %>
<div class="col-sm-10">
<%= f.text_field :name, class: 'form-control' %>
<%= doorkeeper_errors_for application, :name %>
</div>
<% end %>
<%= content_tag :div, class: "form-group#{' has-error' if application.errors[:redirect_uri].present?}" do %>
<%= f.label :redirect_uri, class: 'col-sm-2 control-label' %>
<div class="col-sm-10">
<%= f.text_area :redirect_uri, class: 'form-control' %>
<%= doorkeeper_errors_for application, :redirect_uri %>
<span class="help-block">
<%= t('doorkeeper.applications.help.redirect_uri') %>.
</span>
<% if Doorkeeper.configuration.native_redirect_uri %>
<span class="help-block">
<%= raw t('doorkeeper.applications.help.native_redirect_uri', native_redirect_uri: "<code>#{ Doorkeeper.configuration.native_redirect_uri }</code>") %>
</span>
<% end %>
</div>
<% end %>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<%= f.submit t('doorkeeper.applications.buttons.submit'), class: "btn btn-primary" %>
<%= link_to t('doorkeeper.applications.buttons.cancel'), oauth_applications_path, :class => "button link-button red-button", :data => { :bypass => 'true' } %>
</div>
</div>
<% end %>

View file

@ -0,0 +1,10 @@
<script type="text/javascript">
Metamaps.Apps = {
init: function () {
Metamaps.Famous.explore.setApps('registered');
Metamaps.Famous.explore.show();
Metamaps.GlobalUI.Search.open();
Metamaps.GlobalUI.Search.lock();
}
};
</script>

View file

@ -0,0 +1,10 @@
<div id="yield">
<div class="centerContent">
<div class="page-header">
<h2><%= t('.title') %></h2>
</div>
<%= render 'form', application: @application %>
</div>
</div>
<%= render 'script' %>

View file

@ -0,0 +1,28 @@
<div id="yield">
<div class="centerContent">
<div class="page-header">
<h2><%= t('.title') %></h2>
</div>
<table class="table table-striped">
<thead>
<tr>
<th><%= t('.name') %></th>
<th><%= t('.callback_url') %></th>
<th></th>
</tr>
</thead>
<tbody>
<% @applications.each do |application| %>
<tr id="application_<%= application.id %>">
<td><%= link_to application.name, oauth_application_path(application), :data => { :bypass => 'true' } %></td>
<td><%= application.redirect_uri %></td>
<td><%= render 'delete_form', application: application %></td>
</tr>
<% end %>
</tbody>
</table>
<%= link_to t('.new'), new_oauth_application_path, class: 'button link-button', :data => { :bypass => 'true' } %>
</div>
</div>
<%= render 'script' %>

View file

@ -0,0 +1,11 @@
<div id="yield">
<div class="centerContent">
<%= link_to t('doorkeeper.applications.buttons.back'), oauth_applications_path(), class: 'button link-button button-margin', :data => { :bypass => 'true' } %>
<div class="page-header">
<h2><%= t('.title') %></h2>
</div>
<%= render 'form', application: @application %>
</div>
</div>
<%= render 'script' %>

View file

@ -0,0 +1,37 @@
<div id="yield">
<div class="centerContent showApp">
<%= link_to t('doorkeeper.applications.buttons.back'), oauth_applications_path(), class: 'button link-button button-margin', :data => { :bypass => 'true' } %>
<div class="page-header">
<h2><%= t('.title', name: @application.name) %></h2>
</div>
<h4><%= t('.application_id') %>:</h4>
<p><code id="application_id"><%= @application.uid %></code></p>
<h4><%= t('.secret') %>:</h4>
<p><code id="secret"><%= @application.secret %></code></p>
<h4><%= t('.callback_urls') %>:</h4>
<table>
<% @application.redirect_uri.split.each do |uri| %>
<tr>
<td>
<code><%= uri %></code>
</td>
<td>
<%= link_to t('doorkeeper.applications.buttons.authorize'), oauth_authorization_path(client_id: @application.uid, redirect_uri: uri, response_type: 'code'), class: 'button link-button', target: '_blank', :data => { :bypass => 'true' } %>
</td>
</tr>
<% end %>
</table>
<div class="inline-button"><%= link_to t('doorkeeper.applications.buttons.edit'), edit_oauth_application_path(@application), class: 'button link-button', :data => { :bypass => 'true' } %></div>
<div class="inline-button"><%= render 'delete_form', application: @application, submit_btn_css: 'button red-button' %></div>
</div>
</div>
<%= render 'script' %>

View file

@ -0,0 +1,11 @@
<div id="yield">
<div class="centerContent">
<div class="page-header">
<h2><%= t('doorkeeper.authorizations.error.title') %></h2>
</div>
<main role="main">
<div><%= @pre_auth.error_response.body[:error_description] %></div>
</main>
</div>
</div>

View file

@ -0,0 +1,48 @@
<div id="yield">
<div class="centerContent">
<header class="page-header" role="banner">
<h1><%= t('.title') %></h1>
</header>
<main role="main">
<p class="h4">
<%= raw t('.prompt', client_name: "<strong class=\"text-info\">#{ @pre_auth.client.name }</strong>") %>
</p>
<% if @pre_auth.scopes.count > 0 %>
<div id="oauth-permissions">
<p><%= t('.able_to') %>:</p>
<ul class="text-info">
<% @pre_auth.scopes.each do |scope| %>
<li><%= t scope, scope: [:doorkeeper, :scopes] %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="actions">
<div class="inline-button button-margin-top">
<%= form_tag oauth_authorization_path, method: :post do %>
<%= hidden_field_tag :client_id, @pre_auth.client.uid %>
<%= hidden_field_tag :redirect_uri, @pre_auth.redirect_uri %>
<%= hidden_field_tag :state, @pre_auth.state %>
<%= hidden_field_tag :response_type, @pre_auth.response_type %>
<%= hidden_field_tag :scope, @pre_auth.scope %>
<%= submit_tag t('doorkeeper.authorizations.buttons.authorize'), class: "button" %>
<% end %>
</div>
<div class="inline-button button-margin-top">
<%= form_tag oauth_authorization_path, method: :delete do %>
<%= hidden_field_tag :client_id, @pre_auth.client.uid %>
<%= hidden_field_tag :redirect_uri, @pre_auth.redirect_uri %>
<%= hidden_field_tag :state, @pre_auth.state %>
<%= hidden_field_tag :response_type, @pre_auth.response_type %>
<%= hidden_field_tag :scope, @pre_auth.scope %>
<%= submit_tag t('doorkeeper.authorizations.buttons.deny'), class: "button red-button" %>
<% end %>
</div>
</div>
</main>
</div>
</div>

View file

@ -0,0 +1,11 @@
<div id="yield">
<div class="centerContent">
<header class="page-header">
<h2><%= t('.title') %></h2>
</header>
<main role="main">
<code id="authorization_code"><%= params[:code] %></code>
</main>
</div>
</div>

View file

@ -0,0 +1,5 @@
<%- submit_btn_css ||= 'button red-button' %>
<%= form_tag oauth_authorized_application_path(application) do %>
<input type="hidden" name="_method" value="delete">
<%= submit_tag t('doorkeeper.authorized_applications.buttons.revoke'), onclick: "return confirm('#{ t('doorkeeper.authorized_applications.confirmations.revoke') }')", class: submit_btn_css %>
<% end %>

View file

@ -0,0 +1,10 @@
<script type="text/javascript">
Metamaps.Apps = {
init: function () {
Metamaps.Famous.explore.setApps('authorized');
Metamaps.Famous.explore.show();
Metamaps.GlobalUI.Search.open();
Metamaps.GlobalUI.Search.lock();
}
};
</script>

View file

@ -0,0 +1,30 @@
<div id="yield">
<div class="centerContent">
<header class="page-header">
<h2><%= t('doorkeeper.authorized_applications.index.title') %></h2>
</header>
<main role="main">
<table class="table table-striped">
<thead>
<tr>
<th><%= t('doorkeeper.authorized_applications.index.application') %></th>
<th><%= t('doorkeeper.authorized_applications.index.created_at') %></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<% @applications.each do |application| %>
<tr>
<td><%= application.name %></td>
<td><%= application.created_at.strftime(t('doorkeeper.authorized_applications.index.date_format')) %></td>
<td><%= render 'delete_form', application: application %></td>
</tr>
<% end %>
</tbody>
</table>
</main>
</div>
</div>
<%= render 'script' %>

View file

@ -3,9 +3,9 @@
# The inner HTML of the account box that comes up in the bottom left
#%>
<% if authenticated? %>
<% if current_user %>
<% account = current_user %>
<%= image_tag user.image.url(:sixtyfour), :size => "48x48", :class => "sidebarAccountImage" %>
<%= image_tag account.image.url(:sixtyfour), :size => "48x48", :class => "sidebarAccountImage" %>
<h3 class="accountHeader"><%= account.name.split[0...1][0] %></h3>
<ul>
<li class="accountListItem accountSettings">

View file

@ -222,7 +222,7 @@
<%= render :partial => 'shared/cheatsheet' %>
</div>
<% if authenticated? %>
<% if current_user %>
<div class="lightboxContent" id="invite">
<h3>SHARE INVITE</h3>

View file

@ -4,7 +4,7 @@
<div class="upperLeftUI">
<!-- home button -->
<div class="homeButton">
<a href="<%= root_url %>" <% if !authenticated? %><%= 'data-bypass=true' %><% end %>></a>
<a href="<%= root_url %>" <% if !current_user || appsPage %><%= 'data-bypass=true' %><% end %>></a>
</div> <!-- end homeButton -->
<!-- search box -->
@ -28,7 +28,7 @@
</div>
</div> <!-- end sidebarFilter -->
<% if authenticated? %>
<% if current_user %>
<!-- fork map -->
<div class="sidebarFork upperRightEl">
<div class="sidebarForkIcon upperRightIcon"><div class="tooltipsUnder">Save To New Map</div></div>
@ -38,7 +38,7 @@
<div class="clearfloat"></div>
</div> <!-- end mapElement -->
<% if authenticated? %>
<% if current_user %>
<!-- create new map -->
<div class="addMap openLightbox upperRightEl upperRightIcon" data-open="newmap"><div class="tooltipsUnder">Create New Map</div>
</div><!-- end addMap -->
@ -48,9 +48,9 @@
<% if !(controller_name == "sessions" && action_name == "new") %>
<div class="sidebarAccount upperRightEl">
<div class="sidebarAccountIcon"><div class="tooltipsUnder">Account</div>
<% if user && user.image %>
<%= image_tag user.image.url(:thirtytwo), :size => "32x32" %>
<% elsif !authenticated? %>
<% if current_user && current_user.image %>
<%= image_tag current_user.image.url(:thirtytwo), :size => "32x32" %>
<% elsif !current_user %>
SIGN IN
<div class="accountInnerArrow"></div>
<% end %>

View file

@ -104,7 +104,7 @@
<div class="wrapper <%= classes %>" id="wrapper">
<%= render :partial => 'layouts/upperelements' %>
<%= render :partial => 'layouts/upperelements', :locals => { :appsPage => false } %>
<%= yield %>

View file

@ -0,0 +1,125 @@
<%#
# @file
# Main application file. Holds scaffolding present on every page.
# Then a certain non-partial view (no _ preceding filename) will be
# displayed within, based on URL
#%>
<!--
Do you want to learn more about web development using Ruby or Javascript?
Metamaps.cc is an open source project, and we are always looking for new
developers to help contribute to our codebase! To get involved, send an
email to team@metamaps.cc or find us on Github at
https://github.com/metamaps/metamaps_gen002.
-->
<!DOCTYPE html>
<html>
<head>
<title><%=h yield(:title) %></title>
<%= csrf_meta_tags %>
<meta name="viewport" content="width=device-width, user-scalable=no">
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<!-- typekit for vinyl font -->
<script type="text/javascript" src="https://use.typekit.net/tki2nyo.js"></script>
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
<!-- app code -->
<script type="text/javascript">
require.config({baseUrl: '<%= "#{ asset_path '/famous/main.js' }".chomp('main.js') %>'});
require(['main']);
</script>
<!--[if (IE)]>
<style type="text/css">
#lightbox_overlay {
display: block;
}
#lightbox_main {
top: 50%;
margin-top: -281px;
}
#lightbox_screen {
height: 100%;
opacity: 0.42;
}
.lightboxContent {
display: none;
}
#noIE {
display: block;
}
#lightbox_close {
display: none;
}
</style>
<script type="text/javascript">
$(document).ready(function(){
$("#lightbox_screen").unbind().click(function(event){
event.preventDefault();
event.stopPropagation();
return false;
});
});
</script>
<![endif]-->
</head>
<body class="<%= current_user ? 'authenticated' : 'unauthenticated' %>">
<% if devise_error_messages? %>
<p id="toast"><%= devise_error_messages! %></p>
<% elsif notice %>
<p id="toast"><%= notice %></p>
<% end %>
<%= content_tag :div, class: "main" do %>
<div class="wrapper" id="wrapper">
<%= render :partial => 'layouts/upperelements', :locals => {:appsPage => true } %>
<%= yield %>
<div id="famousOverlay"></div>
<div id="loading"></div>
</div>
<% end %>
<%= render :partial => 'layouts/lightboxes' %>
<%= render :partial => 'layouts/templates' %>
<%= render :partial => 'shared/metacodeBgColors' %>
<script type="text/javascript" charset="utf-8">
Metamaps.Loading = {
loader: new CanvasLoader('loading'),
hide: function () {
$('#loading').hide();
},
show: function () {
$('#loading').show();
}
};
Metamaps.Loading.loader.setColor('#4fb5c0'); // default is '#000000'
Metamaps.Loading.loader.setDiameter(28); // default is 40
Metamaps.Loading.loader.setDensity(41); // default is 40
Metamaps.Loading.loader.setRange(0.9); // default is 1.3
Metamaps.Loading.loader.show(); // Hidden by default
</script>
<%= render :partial => 'layouts/googleanalytics' if Rails.env.production? %>
</body>
</html>

View file

@ -37,6 +37,13 @@ module Metamaps
# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"
config.to_prepare do
Doorkeeper::ApplicationsController.layout "doorkeeper"
Doorkeeper::AuthorizationsController.layout "doorkeeper"
Doorkeeper::AuthorizedApplicationsController.layout "doorkeeper"
Doorkeeper::ApplicationController.helper ApplicationHelper
end
# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password]

View file

@ -8,18 +8,16 @@ Doorkeeper.configure do
end
# If you want to restrict access to the web interface for adding oauth authorized applications, you need to declare the block below.
# admin_authenticator do
# # Put your admin authentication logic here.
# # Example implementation:
# Admin.find_by_id(session[:admin_id]) || redirect_to(new_admin_session_url)
# end
admin_authenticator do
current_user || redirect_to(new_user_session_url)
end
# Authorization Code expiration time (default 10 minutes).
# authorization_code_expires_in 10.minutes
# Access token expiration time (default 2 hours).
# If you want to disable expiration, set this to nil.
# access_token_expires_in 2.hours
access_token_expires_in nil
# Assign a custom TTL for implicit grants.
# custom_access_token_expires_in do |oauth_client|

View file

@ -3,7 +3,7 @@ en:
attributes:
doorkeeper/application:
name: 'Name'
redirect_uri: 'Redirect URI'
redirect_uri: 'Redirect URIs'
errors:
models:
doorkeeper/application:
@ -19,8 +19,9 @@ en:
confirmations:
destroy: 'Are you sure?'
buttons:
back: 'Back'
edit: 'Edit'
destroy: 'Destroy'
destroy: 'remove'
submit: 'Submit'
cancel: 'Cancel'
authorize: 'Authorize'
@ -33,26 +34,24 @@ en:
edit:
title: 'Edit application'
index:
title: 'Your applications'
new: 'New Application'
title: 'Registered Apps'
new: 'New App'
name: 'Name'
callback_url: 'Callback URL'
callback_url: 'Redirect URIs'
new:
title: 'New Application'
title: 'New App'
show:
title: 'Application: %{name}'
application_id: 'Application Id'
secret: 'Secret'
scopes: 'Scopes'
callback_urls: 'Callback urls'
actions: 'Actions'
title: '%{name}'
application_id: 'App ID'
secret: 'App Secret'
callback_urls: 'Redirect URIs'
authorizations:
buttons:
authorize: 'Authorize'
deny: 'Deny'
error:
title: 'An error has occurred'
title: 'Invalid Authorization Request'
new:
title: 'Authorization required'
prompt: 'Authorize %{client_name} to use your account?'
@ -66,10 +65,10 @@ en:
buttons:
revoke: 'Revoke'
index:
title: 'Your authorized applications'
application: 'Application'
created_at: 'Created At'
date_format: '%Y-%m-%d %H:%M:%S'
title: 'Authorized Apps'
application: 'App'
created_at: 'Date Authorized'
date_format: '%Y-%m-%d'
errors:
messages:
@ -117,7 +116,7 @@ en:
layouts:
admin:
nav:
oauth2_provider: 'OAuth2 Provider'
app: 'METAMAPS'
applications: 'Applications'
application:
title: 'OAuth authorization required'

View file

@ -296,6 +296,9 @@ Metamaps.Famous.build = function () {
{ duration: 300, curve: 'easeIn' }
);
};
f.explore.setApps = function (section) {
f.explore.surf.setContent(templates[section + 'AppsContent']);
};
f.explore.set = function (section, mapperId) {
var loggedIn = Metamaps.Active.Mapper ? 'Auth' : '';
@ -402,4 +405,4 @@ Metamaps.Famous.build = function () {
f.logo.show();
}// build
});
});

View file

@ -30,5 +30,12 @@ t.logoContent += '</ul>';
t.featuredAuthContent += '<a href="/" class="activeMaps exploreMapsButton"><div class="exploreMapsIcon"></div>Recently Active</a>';
t.featuredAuthContent += '<a href="/explore/featured" class="active featuredMaps exploreMapsButton"><div class="exploreMapsIcon"></div>Featured</a>';
/* apps bars */
t.registeredAppsContent = '<a href="/oauth/applications" class="active activeMaps exploreMapsButton" data-bypass="true"><div class="exploreMapsIcon"></div>Registered Apps</a>';
t.registeredAppsContent += '<a href="/oauth/authorized_applications" class="featuredMaps exploreMapsButton" data-bypass="true"><div class="exploreMapsIcon"></div>Authorized Apps</a>';
t.authorizedAppsContent = '<a href="/oauth/applications" class="activeMaps exploreMapsButton" data-bypass="true"><div class="exploreMapsIcon"></div>Registered Apps</a>';
t.authorizedAppsContent += '<a href="/oauth/authorized_applications" class="active featuredMaps exploreMapsButton" data-bypass="true"><div class="exploreMapsIcon"></div>Authorized Apps</a>';
module.exports = t;
});