diff --git a/backend/generator.js b/backend/generator.js index 51196a94..f209929a 100644 --- a/backend/generator.js +++ b/backend/generator.js @@ -9,41 +9,42 @@ exports.executeScript = function (socket, formData) { socket.emit('err-logs', "Failed to generated documentation due to an error in input fields"); return false; } - var email = formData.email; - var gitUrl = formData.gitUrl; - var docTheme = formData.docTheme; - var uniqueId = uuidV4(); - var webUI = "true" - - var donePercent = 0; - - const args = [ - "-g", gitUrl, - "-t", docTheme, - "-m", email, - "-u", uniqueId, - "-w", webUI - ]; - - var process = spawn("./generate.sh", args); - - process.stdout.on('data', function (data) { - console.log(data.toString()); - socket.emit('logs', {donePercent: (donePercent = donePercent + 4), data: data.toString()}); - }); - - process.stderr.on('data', function (data) { - console.log(data.toString()); - socket.emit('err-logs', data.toString()); - }); - - process.on('exit', function (code) { - console.log('child process exited with code ' + code); - if (code === 0) { - socket.emit('success', {email: email, uniqueId: uniqueId, gitUrl: gitUrl}); - } else { - socket.emit('failure', {errorCode: code}); - } - }); - return true; + var email = formData.email; + var gitUrl = formData.gitUrl[0]; + var docTheme = formData.docTheme; + var webUI = "true" + + var uniqueId = uuidV4(); + var donePercent = 0; + + const args = [ + "-g", gitUrl, + "-t", docTheme, + "-m", email, + "-u", uniqueId, + "-w", webUI + ]; + + var process = spawn("./generate.sh", args); + + process.stdout.on('data', function (data) { + console.log(data.toString()); + socket.emit('logs', {donePercent: (donePercent = donePercent + 4), data: data.toString()}); + }); + + process.stderr.on('data', function (data) { + console.log(data.toString()); + socket.emit('err-logs', data.toString()); + }); + + process.on('exit', function (code) { + console.log('child process exited with code ' + code); + if (code === 0) { + socket.emit('success', {email: email, uniqueId: uniqueId, gitUrl: gitUrl}); + } else { + socket.emit('failure', {errorCode: code}); + } + }); + return true; + } }; diff --git a/modules/scripts/genindex.py b/modules/scripts/genindex.py index 46ce4512..12ef4e96 100644 --- a/modules/scripts/genindex.py +++ b/modules/scripts/genindex.py @@ -19,7 +19,7 @@ def get_toctree(dirpath, filenames): toctree = ['.. toctree::', ' :maxdepth: 1'] caption_template = ' :caption: {caption}' content_template = ' {document}' - + caption = os.path.basename(dirpath).replace('_', ' ').title() if caption == os.curdir: caption = 'Contents' @@ -52,9 +52,9 @@ def get_index(root): index.append(get_include(root, 'README.rst')) elif 'README.md' in root_files: index.append(get_include(root, 'README.md')) - + # Add toctrees as per the directory structure - for (dirpath, dirnames, filenames) in os.walk(os.curdir): + for (dirpath, dirnames, filenames) in os.walk(root): if filenames: toctree = get_toctree(dirpath, filenames) if toctree: diff --git a/public/scripts/form.js b/public/scripts/form.js index 42ecfd9b..75da9f65 100644 --- a/public/scripts/form.js +++ b/public/scripts/form.js @@ -7,8 +7,8 @@ $(function () { $("#btnGenerate").click(function () { var formData = getData(); - if (validation.isValid(formData)) { - socket.emit('execute', formData); + if (validation.isValid(formData)) { + socket.emit('execute', formData); $(this).attr("disabled", "none"); } else { $('.notification').append($('
  • ')).text(validation.getMessages()); @@ -69,9 +69,18 @@ function getData() { var formData = $("form").serializeArray(); $.each(formData, function (i, field) { if (field.name === "email") { data.email = field.value.trim(); } - if (field.name === "git_url") { data.gitUrl = field.value.trim(); } + if (field.name === "git_url[]") { + if (data.git_url == undefined) { + data.git_url = [field.value] + } else { + data.git_url.push(field.value) + } + } if (field.name === "doc_theme") { data.docTheme = field.value.trim(); } }); - return data; } + +function add() { + $("#git_input").append(``) +} diff --git a/public/scripts/validation.js b/public/scripts/validation.js index 98aaffe1..3852e957 100644 --- a/public/scripts/validation.js +++ b/public/scripts/validation.js @@ -18,11 +18,14 @@ } } - if (formData.gitUrl !== "") { + if (formData.gitUrl.length > 0) { regex = /^(https?|ftp):\/\/([a-zA-Z0-9.-]+(:[a-zA-Z0-9.&%$-]+)*@)*((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}|([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(:[0-9]+)*(\/($|[a-zA-Z0-9.,?'\\+&%$#=~_-]+))*$/; - if(!regex.test(formData.gitUrl)) { - messages.push("Invalid URL"); - valid = false; + for (var i = 0; i < formData.gitUrl.length; i++) { + if(!regex.test(formData.gitUrl[i])) { + messages.push("Invalid URL"); + valid = false; + break; + } } } diff --git a/public/stylesheets/style.css b/public/stylesheets/style.css index e61a09e4..967ecea2 100644 --- a/public/stylesheets/style.css +++ b/public/stylesheets/style.css @@ -33,6 +33,11 @@ a { #btnGenerate { margin-bottom: 20px; } +#btnAdd { + width: -moz-fit-content; + margin-bottom: 20px; + margin-left: 10px; +} #btnDownload { display: none; @@ -52,6 +57,8 @@ a { margin-left: 10px; } + + #notification-container { position: absolute; text-align: center; @@ -95,4 +102,8 @@ a { font-size: .7em; opacity: 1; font-weight: 700; -} \ No newline at end of file +} + +#git_url { + margin-bottom: 10px; +} diff --git a/views/index.jade b/views/index.jade index 2d5a7182..f312d30b 100644 --- a/views/index.jade +++ b/views/index.jade @@ -12,9 +12,10 @@ block content .form-group label.control-label(for='email') Email: input#email.form-control(type='email', placeholder='Enter Email', name='email', required='') - .form-group - label.control-label(for='git_url') GITURL: - input#git_url.form-control(type='text', placeholder='Enter URL of Github Repository', name='git_url') + .div#git_input + .form-group + label.control-label(for='git_url') GITURL: + input#git_url.form-control(type='text', placeholder='Enter URL of Github Repository', name='git_url[]') .form-group label.control-label(for='doc_theme') Doc Theme: select#doc_theme.form-control(name='doc_theme') @@ -36,6 +37,7 @@ block content option(value='rtcat_sphinx_theme') rtcat_sphinx_theme .form-group#buttons button.btn.btn-default(type='button' id='btnGenerate') Generate Docs + button.btn.btn-default(type='button' id='btnAdd' onclick="add()") Add Repository .row a.btn.btn-default(type='button' id='btnDownload') Download a.btn.btn-default(type='button' id='btnPreview' target='_blank') Preview