From 7944a7f78e339d24f59db8abadcfd29de55ed8b4 Mon Sep 17 00:00:00 2001 From: usmannasir <01-134132-158@student.bahria.edu.pk> Date: Fri, 27 Jul 2018 04:13:10 +0500 Subject: [PATCH] GitLab integration to websites. --- .../templates/baseTemplate/index.html | 1 + plogical/applicationInstaller.py | 3 +- static/websiteFunctions/websiteFunctions.js | 11 +- .../websiteFunctions/websiteFunctions.js | 9 +- .../templates/websiteFunctions/setupGit.html | 121 +++++++++++++++++- websiteFunctions/views.py | 21 ++- 6 files changed, 156 insertions(+), 10 deletions(-) diff --git a/baseTemplate/templates/baseTemplate/index.html b/baseTemplate/templates/baseTemplate/index.html index 0b59ee3f8..e4c97e231 100755 --- a/baseTemplate/templates/baseTemplate/index.html +++ b/baseTemplate/templates/baseTemplate/index.html @@ -41,6 +41,7 @@ + diff --git a/plogical/applicationInstaller.py b/plogical/applicationInstaller.py index a56136cc9..c60d23f84 100644 --- a/plogical/applicationInstaller.py +++ b/plogical/applicationInstaller.py @@ -313,6 +313,7 @@ class ApplicationInstaller(multi.Thread): reponame = self.extraArgs['reponame'] branch = self.extraArgs['branch'] tempStatusPath = self.extraArgs['tempStatusPath'] + defaultProvider = self.extraArgs['defaultProvider'] statusFile = open(tempStatusPath, 'w') statusFile.writelines('Checking if GIT installed..,0') @@ -416,7 +417,7 @@ class ApplicationInstaller(multi.Thread): try: command = 'sudo GIT_SSH_COMMAND="ssh -i /root/.ssh/cyberpanel -o StrictHostKeyChecking=no" git clone ' \ - '--depth 1 --no-single-branch git@github.com:' + username + '/' + reponame + '.git -b ' + branch + ' ' + finalPath + '--depth 1 --no-single-branch git@' + defaultProvider +'.com:' + username + '/' + reponame + '.git -b ' + branch + ' ' + finalPath result = subprocess.check_output(shlex.split(command)) except subprocess.CalledProcessError, msg: diff --git a/static/websiteFunctions/websiteFunctions.js b/static/websiteFunctions/websiteFunctions.js index 58eb5d8d7..3bf3ce938 100644 --- a/static/websiteFunctions/websiteFunctions.js +++ b/static/websiteFunctions/websiteFunctions.js @@ -4247,6 +4247,12 @@ app.controller('setupGit', function($scope, $http, $timeout) { $scope.installProg = true; $scope.goBackDisable = true; + var defaultProvider = 'github'; + + $scope.setProvider = function (provider) { + defaultProvider = provider; + }; + var statusFile; var domain = $("#domainNamePage").text(); @@ -4284,7 +4290,7 @@ app.controller('setupGit', function($scope, $http, $timeout) { $scope.installationSuccessfull = false; $scope.couldNotConnect = true; $scope.gitLoading = true; - $scope.goBackDisable = false; + $scope.goBackDisable = true; $scope.installationURL = domain; @@ -4355,7 +4361,8 @@ app.controller('setupGit', function($scope, $http, $timeout) { domain: domain, username: $scope.githubUserName, reponame: $scope.githubRepo, - branch: $scope.githubBranch + branch: $scope.githubBranch, + defaultProvider: defaultProvider }; var config = { diff --git a/websiteFunctions/static/websiteFunctions/websiteFunctions.js b/websiteFunctions/static/websiteFunctions/websiteFunctions.js index f571456f0..3bf3ce938 100644 --- a/websiteFunctions/static/websiteFunctions/websiteFunctions.js +++ b/websiteFunctions/static/websiteFunctions/websiteFunctions.js @@ -4247,6 +4247,12 @@ app.controller('setupGit', function($scope, $http, $timeout) { $scope.installProg = true; $scope.goBackDisable = true; + var defaultProvider = 'github'; + + $scope.setProvider = function (provider) { + defaultProvider = provider; + }; + var statusFile; var domain = $("#domainNamePage").text(); @@ -4355,7 +4361,8 @@ app.controller('setupGit', function($scope, $http, $timeout) { domain: domain, username: $scope.githubUserName, reponame: $scope.githubRepo, - branch: $scope.githubBranch + branch: $scope.githubBranch, + defaultProvider: defaultProvider }; var config = { diff --git a/websiteFunctions/templates/websiteFunctions/setupGit.html b/websiteFunctions/templates/websiteFunctions/setupGit.html index 0b30fe638..2badea094 100644 --- a/websiteFunctions/templates/websiteFunctions/setupGit.html +++ b/websiteFunctions/templates/websiteFunctions/setupGit.html @@ -13,7 +13,9 @@
{% trans "Attach git to your website" %}
-
@@ -24,7 +26,7 @@
+ {% trans "Add this URL to Webhooks section of your Git respository, if you've used hostname SSL then replace IP with your hostname. Otherwise use IP and disable SSL check while configuring webhook. This will initiate a pull from your resposity as soon as you commit some changes."%} {{ webhookURL }}