Skip to content

Commit

Permalink
Merge pull request #151 from matortheeternal/dev
Browse files Browse the repository at this point in the history
Public Beta Release v1.5.2
  • Loading branch information
matortheeternal authored Apr 27, 2017
2 parents ec7fa96 + ecd814a commit 31b080e
Show file tree
Hide file tree
Showing 52 changed files with 518 additions and 252 deletions.
6 changes: 5 additions & 1 deletion mod-picker/app/assets/javascripts/BackendAPI/modService.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ app.service('modService', function(backend, $q, pageUtils, objectUtils, contribu

this.sanitizeModOption = function(option) {
var sanitizedPlugins = service.sanitizePlugins(option.plugins);
return {
var sanitizedOption = {
id: option.id,
_destroy: option._destroy,
name: option.name,
Expand All @@ -314,6 +314,10 @@ app.service('modService', function(backend, $q, pageUtils, objectUtils, contribu
plugin_dumps: sanitizedPlugins,
asset_paths: option.assets
};
if (option.download_link) {
sanitizedOption.download_link = option.download_link;
}
return sanitizedOption;
};

this.buildDestroyedOldPlugins = function(newOption, mod) {
Expand Down
4 changes: 3 additions & 1 deletion mod-picker/app/assets/javascripts/BackendAPI/userService.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ app.service('userService', function(backend, $q, userSettingsService, userTitleS
permissions.isModerator = user.role === 'moderator';
permissions.isNewsWriter = user.role === 'writer';
permissions.isHelper = user.role === 'helper';
permissions.isBetaTester = user.role === 'beta_tester';
permissions.isRestricted = user.role === 'restricted';
permissions.isBanned = user.role === 'banned';
permissions.isSignedIn = true;
Expand All @@ -65,7 +66,8 @@ app.service('userService', function(backend, $q, userSettingsService, userTitleS
permissions.canSubmitMods = !permissions.isRestricted;
permissions.canContribute = !permissions.isRestricted;
permissions.canManageMods = permissions.canModerate || permissions.isHelper;
permissions.canUseCustomSources = permissions.canModerate;
permissions.canDownloadModList = permissions.canModerate || permissions.isHelper || permissions.isBetaTester;
permissions.canUseCustomSources = true;
permissions.canSetModMetadata = permissions.canModerate;
permissions.canChangeAvatar = (rep >= 10) || permissions.canModerate;
permissions.canChangeTitle = (rep >= 1280) || permissions.canModerate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,25 @@ app.directive('modAnalysisManager', function() {
}
});

app.controller('modAnalysisManagerController', function($scope, $rootScope, pluginService, objectUtils, assetUtils) {
app.controller('modAnalysisManagerController', function($scope, $rootScope, $timeout, pluginService, assetUtils, objectUtils, modOptionUtils) {
// inherited variables
$scope.currentGame = $rootScope.currentGame;

// set up old nested mod options
$scope.$watch('mod.mod_options', function() {
if (!$scope.mod.mod_options) return;
$scope.oldNestedOptions = modOptionUtils.getNestedModOptions($scope.mod.mod_options);
});

$scope.changeAnalysisFile = function(event) {
var input = event.target;
if (input.files && input.files[0]) {
$scope.loadAnalysisFile(input.files[0]);
input.value = "";
$scope.loadingAnalysis = true;
$scope.$digest();
$timeout(function() {
$scope.loadAnalysisFile(input.files[0]);
input.value = "";
}, 10);
}
};

Expand All @@ -26,6 +36,7 @@ app.controller('modAnalysisManagerController', function($scope, $rootScope, plug
$scope.clearAnalysis = function() {
if ($scope.mod.analysis) {
delete $scope.mod.analysis;
delete $scope.nestedOptions;
} else {
$scope.mod.mod_options.forEach(function(modOption) {
modOption._destroy = true;
Expand Down Expand Up @@ -141,7 +152,9 @@ app.controller('modAnalysisManagerController', function($scope, $rootScope, plug
$scope.prepareModOption = function(option) {
$scope.getBaseName(option);
option.display_name = angular.copy(option.base_name);
option.plugins_count = option.plugins.length;
if (option.assets && option.assets.length) {
option.asset_files_count = option.assets.length;
option.nestedAssets = assetUtils.getNestedAssets(option.assets);
}
$scope.loadExistingOption(option);
Expand All @@ -161,6 +174,8 @@ app.controller('modAnalysisManagerController', function($scope, $rootScope, plug
analysis.mod_options.forEach($scope.prepareModOption);
$scope.$applyAsync(function() {
$scope.mod.analysis = analysis;
$scope.nestedOptions = modOptionUtils.getNestedModOptions(analysis.mod_options);
$scope.loadingAnalysis = false;
$scope.getRequirementsFromAnalysis();
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ app.directive('modOption', function() {
templateUrl: '/resources/directives/editMod/modOption.html',
scope: {
option: '=',
oldOptions: '='
oldOptions: '=',
canSetDownloadLinks: '=?'
},
controller: 'modOptionController'
}
Expand All @@ -13,6 +14,18 @@ app.directive('modOption', function() {
app.controller('modOptionController', function($scope, formUtils) {
$scope.focusText = formUtils.focusText;

$scope.toggleExpansion = function() {
$scope.option.expanded = !$scope.option.expanded;
};

$scope.togglePluginsExpansion = function() {
$scope.option.pluginsExpanded = !$scope.option.pluginsExpanded;
};

$scope.toggleAssetsExpansion = function() {
$scope.option.assetsExpanded = !$scope.option.assetsExpanded;
};

$scope.removeModOption = function() {
if ($scope.option.id) {
$scope.option._destroy = true;
Expand Down
18 changes: 15 additions & 3 deletions mod-picker/app/assets/javascripts/Directives/editMod/modSources.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ app.controller('modSourcesController', function($scope, $rootScope, sitesFactory
var sourceUsed = $scope.mod.sources.find(function(item, index) {
return index != sourceIndex && item.label === source.label
});
var urlFormat = sitesFactory.getModUrlFormat(site, $rootScope.currentGame);
var currentGameName = $rootScope.currentGame.nexus_name;
var urlFormat = sitesFactory.getModUrlFormat(site, currentGameName);
var match = source.url.match(urlFormat);
source.valid = !sourceUsed && match != null;
};
Expand All @@ -47,7 +48,8 @@ app.controller('modSourcesController', function($scope, $rootScope, sitesFactory
$scope.scrapeSource = function(source) {
// exit if the source is invalid
var site = sitesFactory.getSite(source.label);
var urlFormat = sitesFactory.getModUrlFormat(site, $rootScope.currentGame);
var currentGameName = $rootScope.currentGame.nexus_name;
var urlFormat = sitesFactory.getModUrlFormat(site, currentGameName);
var match = source.url.match(urlFormat);
if (!match) {
return;
Expand Down Expand Up @@ -108,7 +110,17 @@ app.controller('modSourcesController', function($scope, $rootScope, sitesFactory
}
};

$scope.setCustomSourceLabel = function(source) {
var currentGameName = $rootScope.currentGame.nexus_name;
var matchingSite = sitesFactory.getSiteFromUrl(source.url, currentGameName);
if (matchingSite) {
source.label = matchingSite.label;
}
};

$scope.validateCustomSource = function(source) {
source.valid = (source.label.length > 3) && (source.url.length > 12);
source.labelToShort = source.label.length < 4;
source.isDirectLink = source.url.match(/\.(7z|rar|zip)$/i);
source.valid = !source.labelToShort && !source.isDirectLink;
};
});
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
app.directive('modOptionTree', function() {
return {
restrict: 'E',
templateUrl: '/resources/directives/shared/modOptionTree.html',
templateUrl: '/resources/directives/showMod/modOptionTree.html',
scope: {
modOptions: '='
},
Expand Down
3 changes: 3 additions & 0 deletions mod-picker/app/assets/javascripts/Factories/columnsFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,7 @@ app.service('columnsFactory', function() {
data: function(item) {
return item.tools_count + item.custom_tools_count;
},
sortData: "tools_count",
filter: "number"
},
{
Expand All @@ -802,6 +803,7 @@ app.service('columnsFactory', function() {
data: function(item) {
return item.mods_count + item.custom_mods_count;
},
sortData: "mods_count",
filter: "number"
},
{
Expand All @@ -811,6 +813,7 @@ app.service('columnsFactory', function() {
data: function(item) {
return item.plugins_count + item.custom_plugins_count;
},
sortData: "plugins_count",
filter: "number"
},
{
Expand Down
171 changes: 114 additions & 57 deletions mod-picker/app/assets/javascripts/Factories/sitesFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,58 +4,109 @@

// userIndex is the regex group to capture to get the user's username/id
app.service('sitesFactory', function() {
this.sites = function() {
return [
{
label: "Nexus Mods",
shortLabel: "Nexus",
dataLabel: "nexus",
includeGame: true,
modUrlFormat: "www\.nexusmods\.com\/\[game\]\/mods\/([0-9]+)(\/\?)?",
baseUserUrlFormat: "https://forums.nexusmods.com/index.php?showuser=",
userUrlFormat: /forums\.nexusmods\.com\/index\.php\?showuser=([0-9]+)(\/)?/i,
badUserUrlFormat: /forums\.nexusmods\.com\/index\.php\?\/user\/([A-Za-z0-9\-]+)(\/)?/i,
modUrlBase: "https://www.nexusmods.com/{game}/mods/{id}",
userIndex: 2,
loginUrl: "https://forums.nexusmods.com/",
logoPath: "/images/nexus_logo.png"
},
{
label: "Steam Workshop",
shortLabel: "Steam",
dataLabel: "workshop",
modUrlFormat: /steamcommunity\.com\/sharedfiles\/filedetails\/\?id=([0-9]+)(\&)?.*/i,
userUrlFormat: /steamcommunity\.com\/(id|profiles)\/([A-Za-z0-9\_]+)(\/)?/i,
modUrlBase: "https://steamcommunity.com/sharedfiles/filedetails/?id={id}",
userIndex: 3,
loginUrl: "https://steamcommunity.com/login/",
logoPath: "/images/workshop_logo.png"
},
{
label: "Lover's Lab",
shortLabel: "Lab",
dataLabel: "lab",
modUrlFormat: /www\.loverslab\.com\/files\/file\/([0-9]+)\-([0-9a-z\-]+)(\/)?/i,
userUrlFormat: /www\.loverslab\.com\/user\/([a-zA-Z0-9\-]+)(\/)?/i,
modUrlBase: "https://www.loverslab.com/files/file/{id}",
userIndex: 2,
loginUrl: "https://www.loverslab.com/",
logoPath: "/images/lab_logo.png"
},
{
hidden: true,
label: "Steam Store",
shortLabel: "Steam",
logoPath: "/images/workshop_logo.png"
},
{
hidden: true,
label: "GitHub",
shortLabel: "GitHub",
logoPath: "/images/github_logo.png"
}
];
};
var factory = this;

this.sites = [
{
label: "Nexus Mods",
shortLabel: "Nexus",
dataLabel: "nexus",
includeGame: true,
modUrlFormat: "www\.nexusmods\.com\/\[game\]\/mods\/([0-9]+)(\/\?)?",
baseUserUrlFormat: "https://forums.nexusmods.com/index.php?showuser=",
userUrlFormat: /forums\.nexusmods\.com\/index\.php\?showuser=([0-9]+)(\/)?/i,
badUserUrlFormat: /forums\.nexusmods\.com\/index\.php\?\/user\/([A-Za-z0-9\-]+)(\/)?/i,
modUrlBase: "https://www.nexusmods.com/{game}/mods/{id}",
userIndex: 1,
loginUrl: "https://forums.nexusmods.com/",
logoPath: "/images/nexus_logo.png"
},
{
label: "Steam Workshop",
shortLabel: "Steam",
dataLabel: "workshop",
modUrlFormat: /steamcommunity\.com\/sharedfiles\/filedetails\/\?id=([0-9]+)(\&)?.*/i,
userUrlFormat: /steamcommunity\.com\/(id|profiles)\/([A-Za-z0-9\_]+)(\/)?/i,
modUrlBase: "https://steamcommunity.com/sharedfiles/filedetails/?id={id}",
userIndex: 2,
loginUrl: "https://steamcommunity.com/login/",
logoPath: "/images/workshop_logo.png"
},
{
label: "Lover's Lab",
shortLabel: "Lab",
dataLabel: "lab",
modUrlFormat: /www\.loverslab\.com\/files\/file\/([0-9]+)\-([0-9a-z\-]+)(\/)?/i,
userUrlFormat: /www\.loverslab\.com\/user\/([a-zA-Z0-9\-]+)(\/)?/i,
modUrlBase: "https://www.loverslab.com/files/file/{id}",
userIndex: 1,
loginUrl: "https://www.loverslab.com/",
logoPath: "/images/lab_logo.png"
},
{
hidden: true,
label: "Steam Store",
shortLabel: "Steam",
modUrlFormat: /store\.steampowered\.com\/app\/([0-9]+)/i,
logoPath: "/images/workshop_logo.png"
},
{
hidden: true,
label: "GitHub",
shortLabel: "GitHub",
modUrlFormat: /github.com\/([a-zA-Z0-9]+)\/([a-zA-Z0-9]+)/i,
logoPath: "/images/github_logo.png"
},
{
hidden: true,
label: "Tumblr",
shortLabel: "Tumblr",
modUrlFormat: /([a-zA-Z0-9\-\_]+)\.tumblr\.com\/post\/([0-9]+)/i,
logoPath: "/images/tumblr_logo.png"
},
{
hidden: true,
label: "Blogspot",
shortLabel: "Blogspot",
modUrlFormat: /([a-zA-Z0-9\-\_]+)\.blogspot\.(com|ca)\/([0-9]+)\/([0-9]+)\/([a-zA-Z\-]+)/i,
logoPath: "/images/blogger_logo.png"
},
{
hidden: true,
label: "Imgur",
shortLabel: "Imgur",
modUrlFormat: /imgur\.com\/([0-9a-zA-Z]+)/i,
logoPath: "/images/imgur_logo.png"
},
{
hidden: true,
label: "Google Site",
shortLabel: "Google Site",
modUrlFormat: /sites\.google\.com\/site\/([0-9a-zA-Z\-]+)/i,
logoPath: "/images/google_logo.png"
},
{
hidden: true,
label: "Skyrim Modtype",
shortLabel: "Skyrim Modtype",
modUrlFormat: /modtype\.doorblog\.jp\/archives\/([0-9]+)\.html/i,
logoPath: "/images/skyrim_modtype_logo.png"
},
{
hidden: true,
label: "ModDB",
shortLabel: "ModDB",
modUrlFormat: /moddb\.com\/mods\/([a-zA-Z\-]+)/i,
logoPath: "/images/moddb_logo.png"
},
{
hidden: true,
label: "Curse",
shortLabel: "Curse",
modUrlFormat: /mods\.curse\.com\/mods\/([a-zA-Z0-9\-]+)\/([a-zA-Z0-9\-]+)/i,
logoPath: "/images/curse_logo.png"
}
];

this.customSite = function() {
return {
Expand All @@ -66,20 +117,26 @@ app.service('sitesFactory', function() {
};

this.getSite = function(label) {
var sites = this.sites();
return sites.find(function(site) {
return factory.sites.find(function(site) {
return site.label === label;
}) || this.customSite();
};

this.getSiteFromUrl = function(url, gameName) {
return factory.sites.find(function(site) {
var urlFormat = factory.getModUrlFormat(site, gameName);
return url.match(urlFormat);
});
};

this.getModUrl = function(label, id, gameName) {
var site = this.getSite(label);
var site = factory.getSite(label);
return site.modUrlBase.replace("{id}", id).replace("{game}", gameName);
};

this.getModUrlFormat = function(site, game) {
this.getModUrlFormat = function(site, gameName) {
if (site.dataLabel === "nexus") {
return new RegExp(site.modUrlFormat.replace("[game]", game.nexus_name), "i");
return new RegExp(site.modUrlFormat.replace("[game]", gameName), "i");
} else {
return site.modUrlFormat;
}
Expand Down
Loading

0 comments on commit 31b080e

Please sign in to comment.