From 76addeb815ab555a57596ef5b3eb0429c18f25d8 Mon Sep 17 00:00:00 2001
From: Derek Lieu
Date: Mon, 16 May 2016 16:23:57 -0400
Subject: [PATCH 1/2] Use authenticated endpoint for orgs if possible
---
app/collections/orgs.js | 16 ++++++++++++++--
app/cookie.js | 2 +-
test/index.js | 1 +
test/spec/collections/orgs.js | 32 ++++++++++++++++++++++++++++++++
4 files changed, 48 insertions(+), 3 deletions(-)
create mode 100644 test/spec/collections/orgs.js
diff --git a/app/collections/orgs.js b/app/collections/orgs.js
index 81de1e37f..69a3dda00 100644
--- a/app/collections/orgs.js
+++ b/app/collections/orgs.js
@@ -2,6 +2,7 @@ var _ = require('underscore');
var Backbone = require('backbone');
var Org = require('../models/org');
var config = require('../config');
+var cookie = require('../cookie');
module.exports = Backbone.Collection.extend({
model: Org,
@@ -14,7 +15,18 @@ module.exports = Backbone.Collection.extend({
},
url: function() {
- return this.user ? config.api + '/users/' + this.user.get('login') + '/orgs' :
- '/user/orgs';
+ var token = cookie.get('oauth-token');
+
+ // If not authenticated, show public repos for user in path.
+ // https://developer.github.com/v3/orgs/#list-user-organizations
+ if (!token) {
+ return config.api + '/users/' + this.user.get('login') + '/orgs';
+ }
+
+ // Authenticated users see all repos they have access to.
+ // https://developer.github.com/v3/orgs/#list-your-organizations
+ else {
+ return config.api + '/user/orgs';
+ }
}
});
diff --git a/app/cookie.js b/app/cookie.js
index 01e170ca2..8657a119a 100644
--- a/app/cookie.js
+++ b/app/cookie.js
@@ -64,7 +64,7 @@ cookie.unset = function(name) {
cookie.clear = function() {
var obj = cookie.getObject();
for(var key in obj) cookie.unset(key);
- return object;
+ return obj;
};
module.exports = cookie;
diff --git a/test/index.js b/test/index.js
index 878a69ec7..0464f8d99 100644
--- a/test/index.js
+++ b/test/index.js
@@ -17,3 +17,4 @@ require('./spec/views/metadata');
require('./spec/views/meta-forms');
require('./spec/views/header');
require('./spec/collections/files');
+require('./spec/collections/orgs');
diff --git a/test/spec/collections/orgs.js b/test/spec/collections/orgs.js
new file mode 100644
index 000000000..ed6a98930
--- /dev/null
+++ b/test/spec/collections/orgs.js
@@ -0,0 +1,32 @@
+var Orgs = require('../../../app/collections/orgs');
+var User = require('../../../app/models/user');
+var cookie = require('../../../app/cookie');
+
+describe('orgs collection', function () {
+
+ var token;
+ before(function () {
+ token = cookie.get('oauth-token');
+ if (!token) {
+ cookie.set('oauth-token', '12345');
+ }
+ });
+
+ after(function () {
+ if (token) {
+ cookie.set('oauth-token', token);
+ }
+ else {
+ cookie.unset('oauth-token');
+ }
+ });
+
+ // https://github.com/prose/prose/issues/826#issuecomment-219456842
+ // https://developer.github.com/v3/orgs/#list-your-organizations
+ // https://developer.github.com/v3/orgs/#list-user-organizations
+ it('does not use /users/:username/orgs when authenticated', function () {
+ var user = new User({login: 'tom'});
+ var orgs = new Orgs([], {user: user});
+ expect(/tom/.test(orgs.url())).not.ok;
+ });
+});
From 5746dd0f6ba9b1b98cf191596872e137883c02da Mon Sep 17 00:00:00 2001
From: Derek Lieu
Date: Mon, 16 May 2016 16:40:43 -0400
Subject: [PATCH 2/2] Prevent body from overflowing into sidebar
---
style/_main.scss | 3 +-
style/_responsive.scss | 148 +++++++++++++++++++++++------------------
2 files changed, 83 insertions(+), 68 deletions(-)
diff --git a/style/_main.scss b/style/_main.scss
index 100371ea9..7f885acfe 100644
--- a/style/_main.scss
+++ b/style/_main.scss
@@ -138,8 +138,7 @@
.containment,
.limiter {
position:relative;
- min-width:680px;
- max-width:1000px;
+ width: 680px;
margin:0 auto;
}
diff --git a/style/_responsive.scss b/style/_responsive.scss
index 2330b8a5d..a1f7ad935 100644
--- a/style/_responsive.scss
+++ b/style/_responsive.scss
@@ -2,11 +2,22 @@
Media Queries
---------------------------------------------*/
+/* Screen sizes > 1241px --------------------- */
+@media all and (min-width:1401px) {
+ .containment,
+ .limiter {
+ width: 100%;
+ min-width: 680px;
+ max-width: 840px;
+ }
+}
+
/* Screen sizes < 1200px --------------------- */
-@media all and (max-width:1240px) {
+@media all and (max-width:1400px) {
+
.icon.branding {
background-position:0 -115px;
- }
+ }
.loading {
background:rgb(255,255,255);
background:rgba(255,255,255,0.9);
@@ -20,86 +31,91 @@
font-size:16px;
line-height:30px;
box-shadow:0 1px 0 rgba(255, 255, 255, 0),
- 0 0 10px rgba(0, 0, 0, 0.1);
- }
- .loading .loading-icon {
- background-image:url('../img/loader@55x55.gif');
- margin:0 auto 5px;
- width:55px;
- height:55px;
- }
+ 0 0 10px rgba(0, 0, 0, 0.1);
+ }
+ .loading .loading-icon {
+ background-image:url('../img/loader@55x55.gif');
+ margin:0 auto 5px;
+ width:55px;
+ height:55px;
+ }
/* Display the Prose Menu in the footer */
.dropdown-menu.prose-menu {
width:100%;
position:static;
border-top:1px solid #d4d7d9;
- }
- .prose-menu:hover {
- background-color:transparent;
- }
- .prose-menu .branding {
- float:left;
- }
- .prose-menu .dropdown {
- background:transparent;
- display:block;
- position:static;
- width:auto;
- float:left;
- padding:0 0 8px;
- }
- .authenticated .prose-menu .dropdown .divider,
- .prose-menu .dropdown .divider {
- display:none;
- }
- .dropdown-menu .dropdown a {
- color:inherit;
- padding:0 0 0 8px;
- }
- .dropdown-menu .dropdown a:hover {
- background:transparent;
- }
+ }
+ .prose-menu:hover {
+ background-color:transparent;
+ }
+ .prose-menu .branding {
+ float:left;
+ }
+ .prose-menu .dropdown {
+ background:transparent;
+ display:block;
+ position:static;
+ width:auto;
+ float:left;
+ padding:0 0 8px;
+ }
+ .authenticated .prose-menu .dropdown .divider,
+ .prose-menu .dropdown .divider {
+ display:none;
+ }
+ .dropdown-menu .dropdown a {
+ color:inherit;
+ padding:0 0 0 8px;
+ }
+ .dropdown-menu .dropdown a:hover {
+ background:transparent;
+ }
.heading {
padding:20px 15px;
- }
+ }
.content-search {
margin:8px 15px 15px;
- }
- .containment,
+ }
+
+ .containment {
+ width: 100%;
+ margin: 0;
+ }
+
.limiter {
- width:100%;
+ width: 70%;
+ margin: 0;
+ }
+
+ .fixed .containment {
+ padding-right:60px;
+ }
+ .open .fixed .containment,
+ .open .limiter {
+ width:70%;
margin:0;
- }
- .fixed .containment,
- .limiter {
- padding-right:60px;
- }
- .open .fixed .containment,
- .open .limiter {
- width:70%;
- margin:0;
- padding:0;
- }
- .sidebar {
- width:30%;
- }
+ padding:0;
+ }
+ .sidebar {
+ width:30%;
+ }
.meta .finish {
-webkit-border-radius:4px;
- border-radius:4px;
- }
+ border-radius:4px;
+ }
- /* Some right alignment adjustments
- * to account for the fixed vertical menu */
- .fixed .col-last {
- padding-right:60px;
- }
- .post .view {
- padding:15px;
- }
+ /* Some right alignment adjustments
+ * to account for the fixed vertical menu */
+ .fixed .col-last {
+ padding-right:60px;
+ }
+ .post .view {
+ padding:15px;
}
+}
/* Screen sizes < 800px --------------------- */
@media all and (max-width:800px) {
@@ -148,10 +164,10 @@ and (orientation:portrait) {
.open .fixed .containment,
.open .limiter {
width:60%;
- }
+ }
.sidebar {
width:40%;
- }
+ }
}
/* Smartphone (portrait and landscape) ----------- */