final touchups on oauth

This commit is contained in:
Connor Turland 2016-03-24 21:26:07 -07:00
parent 540b35c757
commit 415c9b8ac3
7 changed files with 160 additions and 247 deletions

View file

@ -1,10 +1,10 @@
class ApplicationController < ActionController::Base class ApplicationController < ActionController::Base
include ApplicationHelper
include Pundit include Pundit
include PunditExtra include PunditExtra
rescue_from Pundit::NotAuthorizedError, with: :handle_unauthorized rescue_from Pundit::NotAuthorizedError, with: :handle_unauthorized
protect_from_forgery protect_from_forgery
before_action :get_invite_link
after_action :allow_embedding after_action :allow_embedding
def default_serializer_options def default_serializer_options
@ -69,10 +69,6 @@ private
authenticated? && current_user.admin authenticated? && current_user.admin
end end
def get_invite_link
@invite_link = "#{request.base_url}/join" + (current_user ? "?code=#{current_user.code}" : "")
end
def allow_embedding def allow_embedding
#allow all #allow all
response.headers.except! 'X-Frame-Options' response.headers.except! 'X-Frame-Options'

View file

@ -1,12 +1,12 @@
module ApplicationHelper module ApplicationHelper
def get_metacodeset def get_metacodeset
@m = user.settings.metacodes @m = current_user.settings.metacodes
set = @m[0].include?("metacodeset") ? MetacodeSet.find(@m[0].sub("metacodeset-","").to_i) : false set = @m[0].include?("metacodeset") ? MetacodeSet.find(@m[0].sub("metacodeset-","").to_i) : false
return set return set
end end
def user_metacodes def user_metacodes
@m = user.settings.metacodes @m = current_user.settings.metacodes
set = get_metacodeset set = get_metacodeset
if set if set
@metacodes = set.metacodes.to_a @metacodes = set.metacodes.to_a
@ -15,4 +15,8 @@ module ApplicationHelper
end end
@metacodes.sort! {|m1,m2| m2.name.downcase <=> m1.name.downcase }.rotate!(-1) @metacodes.sort! {|m1,m2| m2.name.downcase <=> m1.name.downcase }.rotate!(-1)
end end
def determine_invite_link
"#{request.base_url}/join" + (current_user ? "?code=#{current_user.code}" : "")
end
end end

View file

@ -0,0 +1,32 @@
<%= render :partial => 'layouts/lightboxes' %>
<%= render :partial => 'layouts/templates' %>
<%= render :partial => 'shared/metacodeBgColors' %>
<script type="text/javascript" charset="utf-8">
<% if current_user %>
Metamaps.Active.Mapper = <%= current_user.to_json.html_safe %>
<% else %>
Metamaps.Active.Mapper = null;
<% end %>
Metamaps.Metacodes = <%= Metacode.all.to_json.html_safe %>;
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
USERVOICE.load();
</script>
<%= render :partial => 'layouts/googleanalytics' if Rails.env.production? %>
</body>
</html>

View file

@ -0,0 +1,71 @@
<!--
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>

View file

@ -231,7 +231,7 @@
<p>As a valued beta tester, you have the ability to invite your peers, colleagues and collaborators onto the platform.</p> <p>As a valued beta tester, you have the ability to invite your peers, colleagues and collaborators onto the platform.</p>
<p>Below is a personal invite link containing your unique access code, which can be used multiple times.</p> <p>Below is a personal invite link containing your unique access code, which can be used multiple times.</p>
<div id="joinCodesBox"> <div id="joinCodesBox">
<p class="joinCodes"><%= @invite_link %> <p class="joinCodes"><%= determine_invite_link %>
<button class="button" onclick="Metamaps.GlobalUI.shareInvite('<%= @invite_link %>');">COPY INVITE LINK!</button> <button class="button" onclick="Metamaps.GlobalUI.shareInvite('<%= @invite_link %>');">COPY INVITE LINK!</button>
</div> </div>
@ -255,4 +255,3 @@
</div> </div>
<div id="lightbox_screen" style="height: 100%;"></div> <div id="lightbox_screen" style="height: 100%;"></div>
</div> </div>

View file

@ -5,77 +5,7 @@
# displayed within, based on URL # displayed within, based on URL
#%> #%>
<!-- <%= render :partial => 'layouts/head' %>
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="<%= authenticated? ? "authenticated" : "unauthenticated" %>"> <body class="<%= authenticated? ? "authenticated" : "unauthenticated" %>">
@ -124,40 +54,4 @@
<% end %> <% end %>
<%= render :partial => 'layouts/lightboxes' %> <%= render :partial => 'layouts/foot' %>
<%= render :partial => 'layouts/templates' %>
<%= render :partial => 'shared/metacodeBgColors' %>
<script type="text/javascript" charset="utf-8">
<% if authenticated? %>
Metamaps.Active.Mapper = <%= user.to_json.html_safe %>
<% else %>
Metamaps.Active.Mapper = null;
<% end %>
Metamaps.Metacodes = <%= Metacode.all.to_json.html_safe %>;
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
// set up uservoice with signed in user
<% if authenticated? && ENV['SSO_KEY'] %>
USERVOICE.load(Metamaps.Active.Mapper.name, Metamaps.Active.Mapper.id, "<%= user.email %>", "<%= current_sso_token %>");
<% else %>
USERVOICE.load();
<% end %>
</script>
<%= render :partial => 'layouts/googleanalytics' if Rails.env.production? %>
</body>
</html>

View file

@ -5,77 +5,7 @@
# displayed within, based on URL # displayed within, based on URL
#%> #%>
<!-- <%= render :partial => 'layouts/head' %>
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' %>"> <body class="<%= current_user ? 'authenticated' : 'unauthenticated' %>">
@ -93,33 +23,20 @@
<%= yield %> <%= yield %>
<div class="showcard mapElement mapElementHidden" id="showcard"></div> <!-- the topic card -->
<% if current_user %>
<% # for creating and pulling in topics and synapses %>
<%= render :partial => 'maps/newtopic' %>
<%= render :partial => 'maps/newsynapse' %>
<% # for populating the change metacode list on the topic card %>
<%= render :partial => 'shared/metacodeoptions' %>
<% end %>
<%= render :partial => 'layouts/lowermapelements' %>
<div id="famousOverlay"></div> <div id="famousOverlay"></div>
<div id="loading"></div> <div id="loading"></div>
</div> </div>
<% end %> <% end %>
<%= render :partial => 'layouts/lightboxes' %> <%= render :partial => 'layouts/foot' %>
<%= 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>