Skip to content

Commit c17f200

Browse files
committed
Merge pull request #550 from Martii/Issue-468
Remove legacy GH batch import route Auto-merge
2 parents 223e0ed + 96ef151 commit c17f200

4 files changed

Lines changed: 0 additions & 182 deletions

File tree

controllers/user.js

Lines changed: 0 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ var categories = require('../controllers/discussion').categories;
2222

2323
var userRoles = require('../models/userRoles.json');
2424
var scriptStorage = require('./scriptStorage');
25-
var RepoManager = require('../libs/repoManager');
2625
var modelParser = require('../libs/modelParser');
2726
var modelQuery = require('../libs/modelQuery');
2827
var flagLib = require('../libs/flag');
@@ -1030,129 +1029,6 @@ var parseJavascriptBlob = function (aJavascriptBlob) {
10301029
return aJavascriptBlob;
10311030
};
10321031

1033-
// Sloppy code to let a user add scripts to their acount
1034-
exports.userManageGitHubPage = function (aReq, aRes, aNext) {
1035-
var authedUser = aReq.session.user;
1036-
1037-
//
1038-
var options = {};
1039-
var tasks = [];
1040-
1041-
// Session
1042-
authedUser = options.authedUser = modelParser.parseUser(authedUser);
1043-
options.isMod = authedUser && authedUser.isMod;
1044-
options.isAdmin = authedUser && authedUser.isAdmin;
1045-
1046-
// Page metadata
1047-
pageMetadata(options, ['Manage', 'GitHub']);
1048-
1049-
//
1050-
tasks.push(function (aCallback) {
1051-
var githubUserName = aReq.query.user || authedUser.ghUsername;
1052-
1053-
async.waterfall([
1054-
// authedUser.ghUsername
1055-
function (aCallback) {
1056-
if (githubUserName || authedUser.ghUsername) {
1057-
aCallback(null);
1058-
} else {
1059-
async.waterfall([
1060-
function (aCallback) {
1061-
var githubUserId = authedUser.githubUserId();
1062-
github.user.getFrom({
1063-
user: encodeURIComponent(githubUserId)
1064-
}, aCallback);
1065-
},
1066-
function (aGithubUser, aCallback) {
1067-
options.githubUser = aGithubUser;
1068-
console.log(aGithubUser);
1069-
User.findOne({
1070-
_id: authedUser._id
1071-
}, aCallback);
1072-
},
1073-
function (aUserData, aCallback) {
1074-
console.log(aUserData);
1075-
aUserData.ghUsername = options.githubUser.login;
1076-
aUserData.save(aCallback);
1077-
},
1078-
function (aCallback) {
1079-
console.log(util.format('Updated User(%s).ghUsername', aUserData.name));
1080-
aCallback(null);
1081-
},
1082-
], aCallback);
1083-
}
1084-
},
1085-
// Fetch repos and format for template.
1086-
function (aCallback) {
1087-
console.log(githubUserName);
1088-
var repoManager = RepoManager.getManager(githubUserName, authedUser);
1089-
repoManager.fetchRecentRepos(function () {
1090-
// convert the repos object to something mustache can use
1091-
options.repos = repoManager.makeRepoArray();
1092-
1093-
var repos = repoManager.repos;
1094-
aCallback(null, repos);
1095-
});
1096-
},
1097-
// Import repos.
1098-
function (aRepos, aCallback) {
1099-
var loadable = {};
1100-
var scriptname = null;
1101-
1102-
console.log(aReq.body);
1103-
_.each(aReq.body, function (aRepo, aReponame) {
1104-
// Load all scripts in the repo
1105-
if (typeof aRepo === 'string' && aReponame.substr(-4) === '_all') {
1106-
aReponame = aRepo;
1107-
aRepo = aRepos[aReponame];
1108-
1109-
if (aRepo) {
1110-
for (scriptname in aRepo) {
1111-
if (!loadable[aReponame]) { loadable[aReponame] = nil(); }
1112-
loadable[aReponame][scriptname] = aRepo[scriptname];
1113-
}
1114-
}
1115-
} else if (typeof aRepo === 'object') { // load individual scripts
1116-
for (scriptname in aRepo) {
1117-
if (aRepos[aReponame][scriptname]) {
1118-
if (!loadable[aReponame]) { loadable[aReponame] = nil(); }
1119-
loadable[aReponame][scriptname] = aRepos[aReponame][scriptname];
1120-
}
1121-
}
1122-
}
1123-
});
1124-
1125-
// Load the scripts onto the site
1126-
if (_.size(loadable) > 0) {
1127-
console.log('loadScripts');
1128-
var githubUserName = authedUser.ghUsername;
1129-
RepoManager.getManager(githubUserName, authedUser, loadable).loadScripts(function () {
1130-
console.log('preredirect');
1131-
aRes.redirect(authedUser.userScriptListPageUrl);
1132-
console.log('redirect');
1133-
aCallback(null);
1134-
});
1135-
} else {
1136-
aCallback(null);
1137-
}
1138-
},
1139-
], aCallback);
1140-
});
1141-
1142-
1143-
//---
1144-
async.parallel(tasks, function (aErr) {
1145-
if (aErr) {
1146-
return statusCodePage(aReq, aRes, aNext, {
1147-
statusMessage: aErr
1148-
});
1149-
}
1150-
1151-
console.log('render');
1152-
aRes.render('pages/userManageGitHub', options);
1153-
});
1154-
};
1155-
11561032
exports.uploadScript = function (aReq, aRes, aNext) {
11571033
var authedUser = aReq.session.user;
11581034
var isLib = aReq.params.isLib;

libs/modelParser.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,6 @@ var parseUser = function (aUserData) {
247247
user.userPageUrl = '/users/' + user.name;
248248
user.userCommentListPageUrl = user.userPageUrl + '/comments';
249249
user.userScriptListPageUrl = user.userPageUrl + '/scripts';
250-
user.userManageGitHubPageUrl = user.userPageUrl + '/github';
251250
user.userGitHubRepoListPageUrl = user.userPageUrl + '/github/repos';
252251
user.userGitHubRepoPageUrl = user.userPageUrl + '/github/repo';
253252
user.userGitHubImportPageUrl = user.userPageUrl + '/github/import';

routes.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ module.exports = function (aApp) {
3838
aApp.route('/users/:username').get(user.view);
3939
aApp.route('/users/:username/comments').get(user.userCommentListPage);
4040
aApp.route('/users/:username/scripts').get(user.userScriptListPage);
41-
aApp.route('/users/:username/github').get(authentication.validateUser, user.userManageGitHubPage).post(authentication.validateUser, user.userManageGitHubPage);
4241
aApp.route('/users/:username/github/repos').get(authentication.validateUser, user.userGitHubRepoListPage);
4342
aApp.route('/users/:username/github/repo').get(authentication.validateUser, user.userGitHubRepoPage);
4443
aApp.route('/users/:username/github/import').post(authentication.validateUser, user.userGitHubImportScriptPage);

views/pages/userManageGitHub.html

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)