|
|
@ -6,6 +6,7 @@ import 'jquery.are-you-sure'; |
|
|
|
import './publicPath.js'; |
|
|
|
import './publicPath.js'; |
|
|
|
import './polyfills.js'; |
|
|
|
import './polyfills.js'; |
|
|
|
import './vendor/semanticDropdown.js'; |
|
|
|
import './vendor/semanticDropdown.js'; |
|
|
|
|
|
|
|
import { svg } from './utils.js'; |
|
|
|
|
|
|
|
|
|
|
|
import initContextPopups from './features/contextPopup.js'; |
|
|
|
import initContextPopups from './features/contextPopup.js'; |
|
|
|
import initHighlight from './features/highlight.js'; |
|
|
|
import initHighlight from './features/highlight.js'; |
|
|
@ -14,17 +15,13 @@ import initClipboard from './features/clipboard.js'; |
|
|
|
|
|
|
|
|
|
|
|
import ActivityTopAuthors from './components/ActivityTopAuthors.vue'; |
|
|
|
import ActivityTopAuthors from './components/ActivityTopAuthors.vue'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { AppSubUrl, StaticUrlPrefix } = window.config; |
|
|
|
|
|
|
|
|
|
|
|
function htmlEncode(text) { |
|
|
|
function htmlEncode(text) { |
|
|
|
return jQuery('<div />').text(text).html(); |
|
|
|
return jQuery('<div />').text(text).html(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function svg(name, size) { |
|
|
|
|
|
|
|
return `<svg class="svg ${name}" width="${size}" height="${size}" aria-hidden="true"><use xlink:href="${staticPrefix}/img/svg/icons.svg#${name}"/></svg>`; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let csrf; |
|
|
|
let csrf; |
|
|
|
let suburl; |
|
|
|
|
|
|
|
let staticPrefix; |
|
|
|
|
|
|
|
let previewFileModes; |
|
|
|
let previewFileModes; |
|
|
|
let simpleMDEditor; |
|
|
|
let simpleMDEditor; |
|
|
|
const commentMDEditors = {}; |
|
|
|
const commentMDEditors = {}; |
|
|
@ -157,7 +154,7 @@ function initRepoStatusChecker() { |
|
|
|
} |
|
|
|
} |
|
|
|
$.ajax({ |
|
|
|
$.ajax({ |
|
|
|
type: 'GET', |
|
|
|
type: 'GET', |
|
|
|
url: `${suburl}/${repo_name}/status`, |
|
|
|
url: `${AppSubUrl}/${repo_name}/status`, |
|
|
|
data: { |
|
|
|
data: { |
|
|
|
_csrf: csrf, |
|
|
|
_csrf: csrf, |
|
|
|
}, |
|
|
|
}, |
|
|
@ -293,7 +290,7 @@ function uploadFile(file, callback) { |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
xhr.open('post', `${suburl}/attachments`, true); |
|
|
|
xhr.open('post', `${AppSubUrl}/attachments`, true); |
|
|
|
xhr.setRequestHeader('X-Csrf-Token', csrf); |
|
|
|
xhr.setRequestHeader('X-Csrf-Token', csrf); |
|
|
|
const formData = new FormData(); |
|
|
|
const formData = new FormData(); |
|
|
|
formData.append('file', file, file.name); |
|
|
|
formData.append('file', file, file.name); |
|
|
@ -313,7 +310,7 @@ function initImagePaste(target) { |
|
|
|
insertAtCursor(field, `![${name}]()`); |
|
|
|
insertAtCursor(field, `![${name}]()`); |
|
|
|
uploadFile(img, (res) => { |
|
|
|
uploadFile(img, (res) => { |
|
|
|
const data = JSON.parse(res); |
|
|
|
const data = JSON.parse(res); |
|
|
|
replaceAndKeepCursor(field, `![${name}]()`, `![${name}](${suburl}/attachments/${data.uuid})`); |
|
|
|
replaceAndKeepCursor(field, `![${name}]()`, `![${name}](${AppSubUrl}/attachments/${data.uuid})`); |
|
|
|
const input = $(`<input id="${data.uuid}" name="files" type="hidden">`).val(data.uuid); |
|
|
|
const input = $(`<input id="${data.uuid}" name="files" type="hidden">`).val(data.uuid); |
|
|
|
$('.files').append(input); |
|
|
|
$('.files').append(input); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -329,7 +326,7 @@ function initSimpleMDEImagePaste(simplemde, files) { |
|
|
|
uploadFile(img, (res) => { |
|
|
|
uploadFile(img, (res) => { |
|
|
|
const data = JSON.parse(res); |
|
|
|
const data = JSON.parse(res); |
|
|
|
const pos = simplemde.codemirror.getCursor(); |
|
|
|
const pos = simplemde.codemirror.getCursor(); |
|
|
|
simplemde.codemirror.replaceRange(`![${name}](${suburl}/attachments/${data.uuid})`, pos); |
|
|
|
simplemde.codemirror.replaceRange(`![${name}](${AppSubUrl}/attachments/${data.uuid})`, pos); |
|
|
|
const input = $(`<input id="${data.uuid}" name="files" type="hidden">`).val(data.uuid); |
|
|
|
const input = $(`<input id="${data.uuid}" name="files" type="hidden">`).val(data.uuid); |
|
|
|
files.append(input); |
|
|
|
files.append(input); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -2059,7 +2056,7 @@ function searchUsers() { |
|
|
|
$searchUserBox.search({ |
|
|
|
$searchUserBox.search({ |
|
|
|
minCharacters: 2, |
|
|
|
minCharacters: 2, |
|
|
|
apiSettings: { |
|
|
|
apiSettings: { |
|
|
|
url: `${suburl}/api/v1/users/search?q={query}`, |
|
|
|
url: `${AppSubUrl}/api/v1/users/search?q={query}`, |
|
|
|
onResponse(response) { |
|
|
|
onResponse(response) { |
|
|
|
const items = []; |
|
|
|
const items = []; |
|
|
|
$.each(response.data, (_i, item) => { |
|
|
|
$.each(response.data, (_i, item) => { |
|
|
@ -2086,7 +2083,7 @@ function searchTeams() { |
|
|
|
$searchTeamBox.search({ |
|
|
|
$searchTeamBox.search({ |
|
|
|
minCharacters: 2, |
|
|
|
minCharacters: 2, |
|
|
|
apiSettings: { |
|
|
|
apiSettings: { |
|
|
|
url: `${suburl}/api/v1/orgs/${$searchTeamBox.data('org')}/teams/search?q={query}`, |
|
|
|
url: `${AppSubUrl}/api/v1/orgs/${$searchTeamBox.data('org')}/teams/search?q={query}`, |
|
|
|
headers: { 'X-Csrf-Token': csrf }, |
|
|
|
headers: { 'X-Csrf-Token': csrf }, |
|
|
|
onResponse(response) { |
|
|
|
onResponse(response) { |
|
|
|
const items = []; |
|
|
|
const items = []; |
|
|
@ -2110,7 +2107,7 @@ function searchRepositories() { |
|
|
|
$searchRepoBox.search({ |
|
|
|
$searchRepoBox.search({ |
|
|
|
minCharacters: 2, |
|
|
|
minCharacters: 2, |
|
|
|
apiSettings: { |
|
|
|
apiSettings: { |
|
|
|
url: `${suburl}/api/v1/repos/search?q={query}&uid=${$searchRepoBox.data('uid')}`, |
|
|
|
url: `${AppSubUrl}/api/v1/repos/search?q={query}&uid=${$searchRepoBox.data('uid')}`, |
|
|
|
onResponse(response) { |
|
|
|
onResponse(response) { |
|
|
|
const items = []; |
|
|
|
const items = []; |
|
|
|
$.each(response.data, (_i, item) => { |
|
|
|
$.each(response.data, (_i, item) => { |
|
|
@ -2180,7 +2177,7 @@ function initU2FAuth() { |
|
|
|
} |
|
|
|
} |
|
|
|
u2fApi.ensureSupport() |
|
|
|
u2fApi.ensureSupport() |
|
|
|
.then(() => { |
|
|
|
.then(() => { |
|
|
|
$.getJSON(`${suburl}/user/u2f/challenge`).success((req) => { |
|
|
|
$.getJSON(`${AppSubUrl}/user/u2f/challenge`).success((req) => { |
|
|
|
u2fApi.sign(req.appId, req.challenge, req.registeredKeys, 30) |
|
|
|
u2fApi.sign(req.appId, req.challenge, req.registeredKeys, 30) |
|
|
|
.then(u2fSigned) |
|
|
|
.then(u2fSigned) |
|
|
|
.catch((err) => { |
|
|
|
.catch((err) => { |
|
|
@ -2193,12 +2190,12 @@ function initU2FAuth() { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}).catch(() => { |
|
|
|
}).catch(() => { |
|
|
|
// Fallback in case browser do not support U2F
|
|
|
|
// Fallback in case browser do not support U2F
|
|
|
|
window.location.href = `${suburl}/user/two_factor`; |
|
|
|
window.location.href = `${AppSubUrl}/user/two_factor`; |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
function u2fSigned(resp) { |
|
|
|
function u2fSigned(resp) { |
|
|
|
$.ajax({ |
|
|
|
$.ajax({ |
|
|
|
url: `${suburl}/user/u2f/sign`, |
|
|
|
url: `${AppSubUrl}/user/u2f/sign`, |
|
|
|
type: 'POST', |
|
|
|
type: 'POST', |
|
|
|
headers: { 'X-Csrf-Token': csrf }, |
|
|
|
headers: { 'X-Csrf-Token': csrf }, |
|
|
|
data: JSON.stringify(resp), |
|
|
|
data: JSON.stringify(resp), |
|
|
@ -2215,7 +2212,7 @@ function u2fRegistered(resp) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
$.ajax({ |
|
|
|
$.ajax({ |
|
|
|
url: `${suburl}/user/settings/security/u2f/register`, |
|
|
|
url: `${AppSubUrl}/user/settings/security/u2f/register`, |
|
|
|
type: 'POST', |
|
|
|
type: 'POST', |
|
|
|
headers: { 'X-Csrf-Token': csrf }, |
|
|
|
headers: { 'X-Csrf-Token': csrf }, |
|
|
|
data: JSON.stringify(resp), |
|
|
|
data: JSON.stringify(resp), |
|
|
@ -2274,7 +2271,7 @@ function initU2FRegister() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function u2fRegisterRequest() { |
|
|
|
function u2fRegisterRequest() { |
|
|
|
$.post(`${suburl}/user/settings/security/u2f/request_register`, { |
|
|
|
$.post(`${AppSubUrl}/user/settings/security/u2f/request_register`, { |
|
|
|
_csrf: csrf, |
|
|
|
_csrf: csrf, |
|
|
|
name: $('#nickname').val() |
|
|
|
name: $('#nickname').val() |
|
|
|
}).success((req) => { |
|
|
|
}).success((req) => { |
|
|
@ -2337,7 +2334,7 @@ function initTemplateSearch() { |
|
|
|
$('#repo_template_search') |
|
|
|
$('#repo_template_search') |
|
|
|
.dropdown({ |
|
|
|
.dropdown({ |
|
|
|
apiSettings: { |
|
|
|
apiSettings: { |
|
|
|
url: `${suburl}/api/v1/repos/search?q={query}&template=true&priority_owner_id=${$('#uid').val()}`, |
|
|
|
url: `${AppSubUrl}/api/v1/repos/search?q={query}&template=true&priority_owner_id=${$('#uid').val()}`, |
|
|
|
onResponse(response) { |
|
|
|
onResponse(response) { |
|
|
|
const filteredResponse = { success: true, results: [] }; |
|
|
|
const filteredResponse = { success: true, results: [] }; |
|
|
|
filteredResponse.results.push({ |
|
|
|
filteredResponse.results.push({ |
|
|
@ -2365,8 +2362,6 @@ function initTemplateSearch() { |
|
|
|
|
|
|
|
|
|
|
|
$(document).ready(async () => { |
|
|
|
$(document).ready(async () => { |
|
|
|
csrf = $('meta[name=_csrf]').attr('content'); |
|
|
|
csrf = $('meta[name=_csrf]').attr('content'); |
|
|
|
suburl = $('meta[name=_suburl]').attr('content'); |
|
|
|
|
|
|
|
staticPrefix = $('meta[name=_staticprefix]').attr('content'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Show exact time
|
|
|
|
// Show exact time
|
|
|
|
$('.time-since').each(function () { |
|
|
|
$('.time-since').each(function () { |
|
|
@ -2455,7 +2450,7 @@ $(document).ready(async () => { |
|
|
|
|
|
|
|
|
|
|
|
// Emojify
|
|
|
|
// Emojify
|
|
|
|
emojify.setConfig({ |
|
|
|
emojify.setConfig({ |
|
|
|
img_dir: `${suburl}/vendor/plugins/emojify/images`, |
|
|
|
img_dir: `${AppSubUrl}/vendor/plugins/emojify/images`, |
|
|
|
ignore_emoticons: true |
|
|
|
ignore_emoticons: true |
|
|
|
}); |
|
|
|
}); |
|
|
|
const hasEmoji = document.getElementsByClassName('has-emoji'); |
|
|
|
const hasEmoji = document.getElementsByClassName('has-emoji'); |
|
|
@ -2575,7 +2570,7 @@ $(document).ready(async () => { |
|
|
|
initPullRequestReview(); |
|
|
|
initPullRequestReview(); |
|
|
|
initRepoStatusChecker(); |
|
|
|
initRepoStatusChecker(); |
|
|
|
initTemplateSearch(); |
|
|
|
initTemplateSearch(); |
|
|
|
initContextPopups(suburl); |
|
|
|
initContextPopups(); |
|
|
|
|
|
|
|
|
|
|
|
// Repo clone url.
|
|
|
|
// Repo clone url.
|
|
|
|
if ($('#repo-clone-url').length > 0) { |
|
|
|
if ($('#repo-clone-url').length > 0) { |
|
|
@ -2785,7 +2780,7 @@ function initVueComponents() { |
|
|
|
reposFilter: 'all', |
|
|
|
reposFilter: 'all', |
|
|
|
searchQuery: '', |
|
|
|
searchQuery: '', |
|
|
|
isLoading: false, |
|
|
|
isLoading: false, |
|
|
|
staticPrefix, |
|
|
|
staticPrefix: StaticUrlPrefix, |
|
|
|
repoTypes: { |
|
|
|
repoTypes: { |
|
|
|
all: { |
|
|
|
all: { |
|
|
|
count: 0, |
|
|
|
count: 0, |
|
|
@ -2891,6 +2886,8 @@ function initVueComponents() { |
|
|
|
return 'octicon-repo-forked'; |
|
|
|
return 'octicon-repo-forked'; |
|
|
|
} if (repo.mirror) { |
|
|
|
} if (repo.mirror) { |
|
|
|
return 'octicon-repo-clone'; |
|
|
|
return 'octicon-repo-clone'; |
|
|
|
|
|
|
|
} if (repo.template) { |
|
|
|
|
|
|
|
return `octicon-repo-template${repo.private ? '-private' : ''}`; |
|
|
|
} if (repo.private) { |
|
|
|
} if (repo.private) { |
|
|
|
return 'octicon-lock'; |
|
|
|
return 'octicon-lock'; |
|
|
|
} |
|
|
|
} |
|
|
@ -2921,7 +2918,7 @@ function initVueApp() { |
|
|
|
el, |
|
|
|
el, |
|
|
|
data: { |
|
|
|
data: { |
|
|
|
searchLimit: (document.querySelector('meta[name=_search_limit]') || {}).content, |
|
|
|
searchLimit: (document.querySelector('meta[name=_search_limit]') || {}).content, |
|
|
|
suburl: document.querySelector('meta[name=_suburl]').content, |
|
|
|
suburl: AppSubUrl, |
|
|
|
uid: Number((document.querySelector('meta[name=_context_uid]') || {}).content), |
|
|
|
uid: Number((document.querySelector('meta[name=_context_uid]') || {}).content), |
|
|
|
activityTopAuthors: window.ActivityTopAuthors || [], |
|
|
|
activityTopAuthors: window.ActivityTopAuthors || [], |
|
|
|
}, |
|
|
|
}, |
|
|
@ -3037,7 +3034,7 @@ window.initHeatmap = function (appElementId, heatmapUser, locale) { |
|
|
|
el, |
|
|
|
el, |
|
|
|
|
|
|
|
|
|
|
|
data: { |
|
|
|
data: { |
|
|
|
suburl: document.querySelector('meta[name=_suburl]').content, |
|
|
|
suburl: AppSubUrl, |
|
|
|
heatmapUser, |
|
|
|
heatmapUser, |
|
|
|
locale |
|
|
|
locale |
|
|
|
}, |
|
|
|
}, |
|
|
@ -3283,7 +3280,7 @@ function initTopicbar() { |
|
|
|
const last = viewDiv.children('a').last(); |
|
|
|
const last = viewDiv.children('a').last(); |
|
|
|
for (let i = 0; i < topicArray.length; i++) { |
|
|
|
for (let i = 0; i < topicArray.length; i++) { |
|
|
|
const link = $('<a class="ui repo-topic small label topic"></a>'); |
|
|
|
const link = $('<a class="ui repo-topic small label topic"></a>'); |
|
|
|
link.attr('href', `${suburl}/explore/repos?q=${encodeURIComponent(topicArray[i])}&topic=1`); |
|
|
|
link.attr('href', `${AppSubUrl}/explore/repos?q=${encodeURIComponent(topicArray[i])}&topic=1`); |
|
|
|
link.text(topicArray[i]); |
|
|
|
link.text(topicArray[i]); |
|
|
|
link.insertBefore(last); |
|
|
|
link.insertBefore(last); |
|
|
|
} |
|
|
|
} |
|
|
@ -3331,7 +3328,7 @@ function initTopicbar() { |
|
|
|
label: 'ui small label' |
|
|
|
label: 'ui small label' |
|
|
|
}, |
|
|
|
}, |
|
|
|
apiSettings: { |
|
|
|
apiSettings: { |
|
|
|
url: `${suburl}/api/v1/topics/search?q={query}`, |
|
|
|
url: `${AppSubUrl}/api/v1/topics/search?q={query}`, |
|
|
|
throttle: 500, |
|
|
|
throttle: 500, |
|
|
|
cache: false, |
|
|
|
cache: false, |
|
|
|
onResponse(res) { |
|
|
|
onResponse(res) { |
|
|
@ -3488,9 +3485,9 @@ function initIssueList() { |
|
|
|
const repoId = $('#repoId').val(); |
|
|
|
const repoId = $('#repoId').val(); |
|
|
|
const crossRepoSearch = $('#crossRepoSearch').val(); |
|
|
|
const crossRepoSearch = $('#crossRepoSearch').val(); |
|
|
|
const tp = $('#type').val(); |
|
|
|
const tp = $('#type').val(); |
|
|
|
let issueSearchUrl = `${suburl}/api/v1/repos/${repolink}/issues?q={query}&type=${tp}`; |
|
|
|
let issueSearchUrl = `${AppSubUrl}/api/v1/repos/${repolink}/issues?q={query}&type=${tp}`; |
|
|
|
if (crossRepoSearch === 'true') { |
|
|
|
if (crossRepoSearch === 'true') { |
|
|
|
issueSearchUrl = `${suburl}/api/v1/repos/issues/search?q={query}&priority_repo_id=${repoId}&type=${tp}`; |
|
|
|
issueSearchUrl = `${AppSubUrl}/api/v1/repos/issues/search?q={query}&priority_repo_id=${repoId}&type=${tp}`; |
|
|
|
} |
|
|
|
} |
|
|
|
$('#new-dependency-drop-list') |
|
|
|
$('#new-dependency-drop-list') |
|
|
|
.dropdown({ |
|
|
|
.dropdown({ |
|
|
|