mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-13 17:05:50 +01:00
Merge branch 'master' of https://github.com/takezoe/gitbucket into css_bootstrap3
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
GitBucket [](https://gitter.im/gitbucket/gitbucket) [](https://travis-ci.org/gitbucket/gitbucket)
|
||||
=========
|
||||
|
||||
GitBucket is the easily installable GitHub clone powered by Scala.
|
||||
|
||||
GitBucket is a GitHub clone powered by Scala which has easy installation and high extensibility.
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
@@ -49,7 +49,7 @@ object MyBuild extends Build {
|
||||
"org.scalatra" %% "scalatra-specs2" % ScalatraVersion % "test",
|
||||
"org.scalatra" %% "scalatra-json" % ScalatraVersion,
|
||||
"org.json4s" %% "json4s-jackson" % "3.2.11",
|
||||
"jp.sf.amateras" %% "scalatra-forms" % "0.1.0",
|
||||
"jp.sf.amateras" %% "scalatra-forms" % "0.2.0",
|
||||
"commons-io" % "commons-io" % "2.4",
|
||||
"io.github.gitbucket" % "markedj" % "1.0.5-SNAPSHOT",
|
||||
"org.apache.commons" % "commons-compress" % "1.9",
|
||||
|
||||
@@ -47,7 +47,7 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
||||
case class WebHookForm(url: String, events: Set[WebHook.Event])
|
||||
|
||||
def webHookForm(update:Boolean) = mapping(
|
||||
"url" -> trim(label("url", text(required, webHook(update)))),
|
||||
"url" -> trim(label("url", text(required, webHook(update)))),
|
||||
"events" -> webhookEvents
|
||||
)(WebHookForm.apply)
|
||||
|
||||
@@ -149,7 +149,7 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
||||
*/
|
||||
get("/:owner/:repository/settings/hooks/new")(ownerOnly { repository =>
|
||||
val webhook = WebHook(repository.owner, repository.name, "")
|
||||
html.editHooks(webhook, Set(WebHook.Push), repository, flash.get("info"), true)
|
||||
html.edithooks(webhook, Set(WebHook.Push), repository, flash.get("info"), true)
|
||||
})
|
||||
|
||||
/**
|
||||
@@ -226,7 +226,7 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
||||
*/
|
||||
get("/:owner/:repository/settings/hooks/edit/:url")(ownerOnly { repository =>
|
||||
getWebHook(repository.owner, repository.name, params("url")).map{ case (webhook, events) =>
|
||||
html.editHooks(webhook, events, repository, flash.get("info"), false)
|
||||
html.edithooks(webhook, events, repository, flash.get("info"), false)
|
||||
} getOrElse NotFound
|
||||
})
|
||||
|
||||
@@ -290,7 +290,7 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
||||
if(getWebHook(params("owner"), params("repository"), value).isDefined != needExists){
|
||||
Some(if(needExists){
|
||||
"URL had not been registered yet."
|
||||
}else{
|
||||
} else {
|
||||
"URL had been registered already."
|
||||
})
|
||||
} else {
|
||||
@@ -299,12 +299,14 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
||||
}
|
||||
|
||||
private def webhookEvents = new ValueType[Set[WebHook.Event]]{
|
||||
def convert(name: String, params: Map[String, String], messages: Messages): Set[WebHook.Event] = WebHook.Event.values.flatMap{ t =>
|
||||
params.get(name+"."+t.name).map(_ => t)
|
||||
}.toSet
|
||||
def convert(name: String, params: Map[String, String], messages: Messages): Set[WebHook.Event] = {
|
||||
WebHook.Event.values.flatMap { t =>
|
||||
params.get(name + "." + t.name).map(_ => t)
|
||||
}.toSet
|
||||
}
|
||||
def validate(name: String, params: Map[String, String], messages: Messages): Seq[(String, String)] = if(convert(name,params,messages).isEmpty){
|
||||
Seq(name -> messages("error.required").format(name))
|
||||
}else{
|
||||
} else {
|
||||
Nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ trait RepositoryService { self: AccountService =>
|
||||
Repositories insert repository.copy(userName = newUserName, repositoryName = newRepositoryName)
|
||||
|
||||
val webHooks = WebHooks .filter(_.byRepository(oldUserName, oldRepositoryName)).list
|
||||
val webHookEvents = WebHookEvents .filter(_.byRepository(oldUserName, oldRepositoryName)).list
|
||||
val milestones = Milestones .filter(_.byRepository(oldUserName, oldRepositoryName)).list
|
||||
val issueId = IssueId .filter(_.byRepository(oldUserName, oldRepositoryName)).list
|
||||
val issues = Issues .filter(_.byRepository(oldUserName, oldRepositoryName)).list
|
||||
@@ -75,9 +76,10 @@ trait RepositoryService { self: AccountService =>
|
||||
|
||||
deleteRepository(oldUserName, oldRepositoryName)
|
||||
|
||||
WebHooks .insertAll(webHooks .map(_.copy(userName = newUserName, repositoryName = newRepositoryName)) :_*)
|
||||
Milestones.insertAll(milestones .map(_.copy(userName = newUserName, repositoryName = newRepositoryName)) :_*)
|
||||
IssueId .insertAll(issueId .map(_.copy(_1 = newUserName, _2 = newRepositoryName)) :_*)
|
||||
WebHooks .insertAll(webHooks .map(_.copy(userName = newUserName, repositoryName = newRepositoryName)) :_*)
|
||||
WebHookEvents.insertAll(webHookEvents .map(_.copy(userName = newUserName, repositoryName = newRepositoryName)) :_*)
|
||||
Milestones .insertAll(milestones .map(_.copy(userName = newUserName, repositoryName = newRepositoryName)) :_*)
|
||||
IssueId .insertAll(issueId .map(_.copy(_1 = newUserName, _2 = newRepositoryName)) :_*)
|
||||
|
||||
val newMilestones = Milestones.filter(_.byRepository(newUserName, newRepositoryName)).list
|
||||
Issues.insertAll(issues.map { x => x.copy(
|
||||
@@ -146,6 +148,7 @@ trait RepositoryService { self: AccountService =>
|
||||
IssueId .filter(_.byRepository(userName, repositoryName)).delete
|
||||
Milestones .filter(_.byRepository(userName, repositoryName)).delete
|
||||
WebHooks .filter(_.byRepository(userName, repositoryName)).delete
|
||||
WebHookEvents .filter(_.byRepository(userName, repositoryName)).delete
|
||||
Repositories .filter(_.byRepository(userName, repositoryName)).delete
|
||||
|
||||
// Update ORIGIN_USER_NAME and ORIGIN_REPOSITORY_NAME
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
@if(content.viewType == "text"){
|
||||
@defining(isRenderable(pathList.reverse.head)){ isRrenderable =>
|
||||
@if(!isBlame && isRrenderable) {
|
||||
<div class="box-content-bottom markdown-body" style="padding-left: 16px; padding-right: 16px;">
|
||||
<div class="box-content-bottom markdown-body" style="padding-left: 20px; padding-right: 20px;">
|
||||
@renderMarkup(pathList, content.content.get, branch, repository, false, false, true)
|
||||
</div>
|
||||
} else {
|
||||
|
||||
@@ -130,7 +130,7 @@ $(function(){
|
||||
enableTaskList : false
|
||||
}, function(data){
|
||||
$('#preview').empty().append(
|
||||
$('<div class="markdown-body" style="padding-left: 16px; padding-right: 16px;">').html(data));
|
||||
$('<div class="markdown-body" style="padding-left: 20px; padding-right: 20px;">').html(data));
|
||||
prettyPrint();
|
||||
});
|
||||
} else {
|
||||
|
||||
@@ -127,7 +127,7 @@
|
||||
@readme.map { case(filePath, content) =>
|
||||
<div id="readme">
|
||||
<div class="box-header">@filePath.reverse.head</div>
|
||||
<div class="box-content-bottom markdown-body" style="padding-left: 16px; padding-right: 16px;">@renderMarkup(filePath, content, branch, repository, false, false, true)</div>
|
||||
<div class="box-content-bottom markdown-body" style="padding-left: 20px; padding-right: 20px;">@renderMarkup(filePath, content, branch, repository, false, false, true)</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
@menu("danger", repository){
|
||||
<div class="box">
|
||||
<div class="box-header">Danger Zone</div>
|
||||
<div class="box-content">
|
||||
<div class="box-content-bottom">
|
||||
<form id="transfer-form" method="post" action="@url(repository)/settings/transfer" validate="true" autocomplete="off">
|
||||
<fieldset>
|
||||
<label class="strong">Transfer Ownership</label>
|
||||
|
||||
@@ -1,165 +0,0 @@
|
||||
@(webHook: gitbucket.core.model.WebHook,
|
||||
events: Set[gitbucket.core.model.WebHook.Event],
|
||||
repository: gitbucket.core.service.RepositoryService.RepositoryInfo,
|
||||
info: Option[Any],
|
||||
create: Boolean)(implicit context: gitbucket.core.controller.Context)
|
||||
@import context._
|
||||
@import gitbucket.core.view.helpers._
|
||||
@import gitbucket.core.model.WebHook._
|
||||
@check(name: String, event: Event)={
|
||||
name="@(name).@event.name" value="on" @if(events(event)){checked}
|
||||
}
|
||||
@html.main("Settings", Some(repository)){
|
||||
@html.menu("settings", repository){
|
||||
@menu("hooks", repository){
|
||||
@helper.html.information(info)
|
||||
|
||||
<div class="box">
|
||||
<div class="box-header">
|
||||
Webhook / Manage webhook
|
||||
</div>
|
||||
<div class="box-content">
|
||||
<form method="POST" validate="true">
|
||||
<div>
|
||||
<span class="error" id="error-url"></span>
|
||||
</div>
|
||||
<label class="strong">Payload URL</label>
|
||||
@if(create){
|
||||
<input type="text" name="url" id="url" value="@webHook.url" class="input-xxlarge" style="margin-bottom: 0px;" required />
|
||||
}else{
|
||||
<input type="text" value="@webHook.url" style="margin-bottom: 0px;" class="input-xxlarge" disabled />
|
||||
<input type="hidden" value="@webHook.url" name="url" />
|
||||
}
|
||||
<button class="btn" id="test">Test Hook</button>
|
||||
|
||||
<hr />
|
||||
<div>
|
||||
<span class="error" id="error-events"></span>
|
||||
</div>
|
||||
<label class="strong">Which events would you like to trigger this webhook?</label>
|
||||
<!--
|
||||
<label class="checkbox"><input type="checkbox" @check("events",CommitComment) />Commit comment <small class="help-block">Commit or diff commented on. </small> </label>
|
||||
<label class="checkbox"><input type="checkbox" @check("events",Create) />Create <small class="help-block">Branch, or tag created. </small> </label>
|
||||
<label class="checkbox"><input type="checkbox" @check("events",Delete) />Delete <small class="help-block">Branch, or tag deleted. </small> </label>
|
||||
<label class="checkbox"><input type="checkbox" @check("events",Deployment) />Deployment <small class="help-block">Repository deployed. </small> </label>
|
||||
<label class="checkbox"><input type="checkbox" @check("events",DeploymentStatus) />Deployment status <small class="help-block">Deployment status updated from the API. </small> </label>
|
||||
<label class="checkbox"><input type="checkbox" @check("events",Fork) />Fork <small class="help-block">Repository forked. </small> </label>
|
||||
<label class="checkbox"><input type="checkbox" @check("events",Gollum) />Gollum <small class="help-block">Wiki page updated. </small> </label>
|
||||
<label class="checkbox"><input type="checkbox" @check("events",PullRequestReviewComment) />Pull Request review comment <small class="help-block">Pull Request diff commented on. </small> </label>
|
||||
<label class="checkbox"><input type="checkbox" @check("events",Member) />Member <small class="help-block">Collaborator added to a non-organization repository. </small> </label>
|
||||
<label class="checkbox"><input type="checkbox" @check("events",PageBuild) />Page build <small class="help-block">Pages site built. </small> </label>
|
||||
<label class="checkbox"><input type="checkbox" @check("events",Public) />Public <small class="help-block">Repository changes from private to public. </small> </label>
|
||||
<label class="checkbox"><input type="checkbox" @check("events",Release) />Release <small class="help-block">Release published in a repository. </small> </label>
|
||||
<label class="checkbox"><input type="checkbox" @check("events",TeamAdd) />Team add <small class="help-block">Team added or modified on a repository. </small> </label>
|
||||
<label class="checkbox"><input type="checkbox" @check("events",Watch) />Watch <small class="help-block">User stars a repository.</small></label>
|
||||
<label class="checkbox"><input type="checkbox" @check("events",Status) />Status <small class="help-block">Commit status updated from the API. </small> </label>
|
||||
-->
|
||||
<label class="checkbox"><input type="checkbox" @check("events",IssueComment) />Issue comment <small class="help-block">Issue commented on. </small> </label>
|
||||
<label class="checkbox"><input type="checkbox" @check("events",Issues) />Issues <small class="help-block">Issue opened, closed<!-- , assigned, or labeled -->. </small> </label>
|
||||
<label class="checkbox"><input type="checkbox" @check("events",PullRequest) />Pull Request <small class="help-block">Pull Request opened, closed<!-- , assigned, labeled -->, or synchronized. </small> </label>
|
||||
<label class="checkbox"><input type="checkbox" @check("events",Push) />Push <small class="help-block">Git push to a repository. </small> </label>
|
||||
<hr />
|
||||
@if(!create){
|
||||
<input type="submit" class="btn btn-success" value="Update webhook" formaction="@url(repository)/settings/hooks/edit/@urlEncode(webHook.url)" />
|
||||
<a href="@url(repository)/settings/hooks/delete?url=@urlEncode(webHook.url)" class="btn text-error" onclick="return confirm('delete webhook for @webHook.url ?')">
|
||||
Delete webhook
|
||||
</a>
|
||||
}else{
|
||||
<input type="submit" class="btn" value="Add webhook" formaction="@url(repository)/settings/hooks/new" />
|
||||
}
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal hide" id="test-report-modal">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3>WebHook Test</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>request to <span id="test-modal-url" style="word-break: break-all; word-wrap: break-word; white-space: pre; white-space: pre-wrap;"></span></p>
|
||||
<div id="test-report" style="display:none">
|
||||
<ul class="nav nav-tabs" id="test-report-tab">
|
||||
<li class="active"><a href="#REQUEST">REQUEST</a></li>
|
||||
<li><a href="#RESPONCE">RESPONCE <span class="badge badge-success" id="res-status"></span></a></li>
|
||||
</ul>
|
||||
<div class="tab-content" style="max-height: 300px;">
|
||||
<div class="tab-pane active" id="REQUEST">
|
||||
<div id="req-errors" class="alert alert-error">
|
||||
ERROR<span id="req-errors-body"></span>
|
||||
</div>
|
||||
<div id="req-success" style="display:none">
|
||||
Headers
|
||||
<pre id="req-headers"></pre>
|
||||
Payload
|
||||
<pre id="req-payload"></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane" id="RESPONCE">
|
||||
<div id="res-errors" class="alert alert-error">
|
||||
ERROR<span id="res-errors-body"></span>
|
||||
</div>
|
||||
<div id="res-success" style="display:none">
|
||||
Headers
|
||||
<pre id="res-headers"></pre>
|
||||
Body
|
||||
<pre id="res-body"></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$(function(){
|
||||
$('#test-report-tab a').click(function (e) {
|
||||
e.preventDefault();
|
||||
$(this).tab('show');
|
||||
});
|
||||
$('#test').click(function(e){
|
||||
e.stopPropagation();
|
||||
e.stopImmediatePropagation();
|
||||
e.preventDefault();
|
||||
var url = this.form.url.value;
|
||||
if(!/^https?:\/\/.+/.test(url)){
|
||||
alert("invalid url");
|
||||
return;
|
||||
}
|
||||
$("#test-modal-url").text(url)
|
||||
$("#test-report-modal").modal('show')
|
||||
$("#test-report").hide();
|
||||
$.ajax({
|
||||
method:'POST',
|
||||
url:'@url(repository)/settings/hooks/test?url='+encodeURIComponent(url),
|
||||
success:function(e){
|
||||
console.log(e);
|
||||
$('#test-report-tab a:first').tab('show');
|
||||
$("#test-report").show();
|
||||
$("#req-success").toggle(e.request&&!e.request.error);
|
||||
$("#req-errors").toggle(e.request&&!!e.request.error);
|
||||
$("#req-errors-body").text(e.request.error);
|
||||
function headers(h){
|
||||
h = h["headers"];
|
||||
return h ? $.map(h,function(h){
|
||||
return $("<div>").append($('<b>').text(h[0]+":"),$('<span>').text(" "+h[1]))
|
||||
}):"";
|
||||
}
|
||||
$("#req-headers").html(headers(e.request));
|
||||
$("#req-payload").text(e.request && e.request.payload ? JSON.stringify(JSON.parse(e.request.payload),undefined,4) : "");
|
||||
$("#res-success").toggle(e.responce&&!e.responce.error);
|
||||
$("#res-errors").toggle(e.responce&&!!e.responce.error);
|
||||
$("#res-errors-body").text(e.responce.error);
|
||||
var success = !!(e.responce && e.responce.status && /^2\d\d$/.test(e.responce.status.statusCode));
|
||||
$("#res-status").text((e.responce && e.responce.status && e.responce.status.statusCode) || "ERROR");
|
||||
$("#res-status").toggleClass("badge-success", success).toggleClass("badge-important", !success);
|
||||
$("#res-headers").html(headers(e.responce));
|
||||
$("#res-body").text(e.responce && e.responce.body ? e.responce.body : "");
|
||||
},
|
||||
});
|
||||
return false;
|
||||
});
|
||||
})
|
||||
</script>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
164
src/main/twirl/gitbucket/core/settings/edithooks.scala.html
Normal file
164
src/main/twirl/gitbucket/core/settings/edithooks.scala.html
Normal file
@@ -0,0 +1,164 @@
|
||||
@(webHook: gitbucket.core.model.WebHook,
|
||||
events: Set[gitbucket.core.model.WebHook.Event],
|
||||
repository: gitbucket.core.service.RepositoryService.RepositoryInfo,
|
||||
info: Option[Any],
|
||||
create: Boolean)(implicit context: gitbucket.core.controller.Context)
|
||||
@import context._
|
||||
@import gitbucket.core.view.helpers._
|
||||
@import gitbucket.core.model.WebHook._
|
||||
@check(name: String, event: Event)={
|
||||
name="@(name).@event.name" value="on" @if(events(event)){checked}
|
||||
}
|
||||
@html.main("Settings", Some(repository)){
|
||||
@html.menu("settings", repository){
|
||||
@menu("hooks", repository){
|
||||
@helper.html.information(info)
|
||||
|
||||
<div class="box">
|
||||
<div class="box-header">
|
||||
Webhook / Manage webhook
|
||||
</div>
|
||||
<div class="box-content-bottom">
|
||||
<form method="POST" validate="true">
|
||||
<div>
|
||||
<span class="error" id="error-url"></span>
|
||||
</div>
|
||||
<label class="strong">Payload URL</label>
|
||||
@if(create){
|
||||
<input type="text" name="url" id="url" value="@webHook.url" class="input-xxlarge" style="margin-bottom: 0px;" required />
|
||||
} else {
|
||||
<input type="text" value="@webHook.url" style="margin-bottom: 0px;" class="input-xxlarge" disabled />
|
||||
<input type="hidden" value="@webHook.url" name="url" />
|
||||
}
|
||||
<button class="btn" id="test">Test Hook</button>
|
||||
|
||||
<hr />
|
||||
<div>
|
||||
<span class="error" id="error-events"></span>
|
||||
</div>
|
||||
<label class="strong">Which events would you like to trigger this webhook?</label>
|
||||
<!--
|
||||
<label class="checkbox"><input type="checkbox" @check("events",CommitComment) />Commit comment <small class="help-block">Commit or diff commented on. </small> </label>
|
||||
<label class="checkbox"><input type="checkbox" @check("events",Create) />Create <small class="help-block">Branch, or tag created. </small> </label>
|
||||
<label class="checkbox"><input type="checkbox" @check("events",Delete) />Delete <small class="help-block">Branch, or tag deleted. </small> </label>
|
||||
<label class="checkbox"><input type="checkbox" @check("events",Deployment) />Deployment <small class="help-block">Repository deployed. </small> </label>
|
||||
<label class="checkbox"><input type="checkbox" @check("events",DeploymentStatus) />Deployment status <small class="help-block">Deployment status updated from the API. </small> </label>
|
||||
<label class="checkbox"><input type="checkbox" @check("events",Fork) />Fork <small class="help-block">Repository forked. </small> </label>
|
||||
<label class="checkbox"><input type="checkbox" @check("events",Gollum) />Gollum <small class="help-block">Wiki page updated. </small> </label>
|
||||
<label class="checkbox"><input type="checkbox" @check("events",PullRequestReviewComment) />Pull Request review comment <small class="help-block">Pull Request diff commented on. </small> </label>
|
||||
<label class="checkbox"><input type="checkbox" @check("events",Member) />Member <small class="help-block">Collaborator added to a non-organization repository. </small> </label>
|
||||
<label class="checkbox"><input type="checkbox" @check("events",PageBuild) />Page build <small class="help-block">Pages site built. </small> </label>
|
||||
<label class="checkbox"><input type="checkbox" @check("events",Public) />Public <small class="help-block">Repository changes from private to public. </small> </label>
|
||||
<label class="checkbox"><input type="checkbox" @check("events",Release) />Release <small class="help-block">Release published in a repository. </small> </label>
|
||||
<label class="checkbox"><input type="checkbox" @check("events",TeamAdd) />Team add <small class="help-block">Team added or modified on a repository. </small> </label>
|
||||
<label class="checkbox"><input type="checkbox" @check("events",Watch) />Watch <small class="help-block">User stars a repository.</small></label>
|
||||
<label class="checkbox"><input type="checkbox" @check("events",Status) />Status <small class="help-block">Commit status updated from the API. </small> </label>
|
||||
-->
|
||||
<label class="checkbox"><input type="checkbox" @check("events",IssueComment) />Issue comment <small class="help-block">Issue commented on. </small> </label>
|
||||
<label class="checkbox"><input type="checkbox" @check("events",Issues) />Issues <small class="help-block">Issue opened, closed<!-- , assigned, or labeled -->. </small> </label>
|
||||
<label class="checkbox"><input type="checkbox" @check("events",PullRequest) />Pull Request <small class="help-block">Pull Request opened, closed<!-- , assigned, labeled -->, or synchronized. </small> </label>
|
||||
<label class="checkbox"><input type="checkbox" @check("events",Push) />Push <small class="help-block">Git push to a repository. </small> </label>
|
||||
<hr />
|
||||
@if(!create){
|
||||
<input type="submit" class="btn btn-success" value="Update webhook" formaction="@url(repository)/settings/hooks/edit/@urlEncode(webHook.url)" />
|
||||
<a href="@url(repository)/settings/hooks/delete?url=@urlEncode(webHook.url)" class="btn text-error" onclick="return confirm('delete webhook for @webHook.url ?')">
|
||||
Delete webhook
|
||||
</a>
|
||||
} else {
|
||||
<input type="submit" class="btn" value="Add webhook" formaction="@url(repository)/settings/hooks/new" />
|
||||
}
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal hide" id="test-report-modal">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3>WebHook Test</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>request to <span id="test-modal-url" style="word-break: break-all; word-wrap: break-word; white-space: pre; white-space: pre-wrap;"></span></p>
|
||||
<div id="test-report" style="display:none">
|
||||
<ul class="nav nav-tabs" id="test-report-tab">
|
||||
<li class="active"><a href="#REQUEST">REQUEST</a></li>
|
||||
<li><a href="#RESPONCE">RESPONCE <span class="badge badge-success" id="res-status"></span></a></li>
|
||||
</ul>
|
||||
<div class="tab-content" style="max-height: 300px;">
|
||||
<div class="tab-pane active" id="REQUEST">
|
||||
<div id="req-errors" class="alert alert-error">
|
||||
ERROR<span id="req-errors-body"></span>
|
||||
</div>
|
||||
<div id="req-success" style="display:none">
|
||||
Headers
|
||||
<pre id="req-headers"></pre>
|
||||
Payload
|
||||
<pre id="req-payload"></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane" id="RESPONCE">
|
||||
<div id="res-errors" class="alert alert-error">
|
||||
ERROR<span id="res-errors-body"></span>
|
||||
</div>
|
||||
<div id="res-success" style="display:none">
|
||||
Headers
|
||||
<pre id="res-headers"></pre>
|
||||
Body
|
||||
<pre id="res-body"></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$(function(){
|
||||
$('#test-report-tab a').click(function (e) {
|
||||
e.preventDefault();
|
||||
$(this).tab('show');
|
||||
});
|
||||
$('#test').click(function(e){
|
||||
e.stopPropagation();
|
||||
e.stopImmediatePropagation();
|
||||
e.preventDefault();
|
||||
var url = this.form.url.value;
|
||||
if(!/^https?:\/\/.+/.test(url)){
|
||||
alert("invalid url");
|
||||
return;
|
||||
}
|
||||
$("#test-modal-url").text(url)
|
||||
$("#test-report-modal").modal('show')
|
||||
$("#test-report").hide();
|
||||
$.ajax({
|
||||
method:'POST',
|
||||
url:'@url(repository)/settings/hooks/test?url=' + encodeURIComponent(url),
|
||||
success: function(e){
|
||||
//console.log(e);
|
||||
$('#test-report-tab a:first').tab('show');
|
||||
$("#test-report").show();
|
||||
$("#req-success").toggle(e.request&&!e.request.error);
|
||||
$("#req-errors").toggle(e.request&&!!e.request.error);
|
||||
$("#req-errors-body").text(e.request.error);
|
||||
function headers(h){
|
||||
h = h["headers"];
|
||||
return h ? $.map(h, function(h){
|
||||
return $("<div>").append($('<b>').text(h[0] + ":"),$('<span>').text(" " + h[1]))
|
||||
}):"";
|
||||
}
|
||||
$("#req-headers").html(headers(e.request));
|
||||
$("#req-payload").text(e.request && e.request.payload ? JSON.stringify(JSON.parse(e.request.payload),undefined,4) : "");
|
||||
$("#res-success").toggle(e.responce && !e.responce.error);
|
||||
$("#res-errors").toggle(e.responce && !!e.responce.error);
|
||||
$("#res-errors-body").text(e.responce.error);
|
||||
var success = !!(e.responce && e.responce.status && /^2\d\d$/.test(e.responce.status.statusCode));
|
||||
$("#res-status").text((e.responce && e.responce.status && e.responce.status.statusCode) || "ERROR");
|
||||
$("#res-status").toggleClass("badge-success", success).toggleClass("badge-important", !success);
|
||||
$("#res-headers").html(headers(e.responce));
|
||||
$("#res-body").text(e.responce && e.responce.body ? e.responce.body : "");
|
||||
},
|
||||
});
|
||||
return false;
|
||||
});
|
||||
})
|
||||
</script>
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,10 +10,10 @@
|
||||
|
||||
<div class="box">
|
||||
<div class="box-header">
|
||||
<a href="@url(repository)/settings/hooks/new" class="btn btn-small pull-right">Add webhook</a>
|
||||
<a href="@url(repository)/settings/hooks/new" class="btn btn-mini pull-right">Add webhook</a>
|
||||
Webhooks
|
||||
</div>
|
||||
<div class="box-content">
|
||||
<div class="box-content-bottom">
|
||||
<p>
|
||||
Webhooks allow external services to be notified when certain events happen within your repository.
|
||||
When the specified events happen, we’ll send a POST request to each of the URLs you provide.
|
||||
@@ -28,7 +28,7 @@
|
||||
</a>
|
||||
<em class="css-truncate" style="max-width: 225px;">(<span class="css-truncate-target">@events.map(_.name).mkString(", ")</span>)</em>
|
||||
</td><td>
|
||||
<div class="btn-group">
|
||||
<div class="btn-group pull-right">
|
||||
<a href="@url(repository)/settings/hooks/edit/@urlEncode(webHook.url)" class="btn btn-small">
|
||||
<span class="octicon octicon-pencil"></span>
|
||||
</a>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<form id="form" method="post" action="@url(repository)/settings/options" validate="true">
|
||||
<div class="box">
|
||||
<div class="box-header">Settings</div>
|
||||
<div class="box-content">
|
||||
<div class="box-content-bottom">
|
||||
<fieldset>
|
||||
<label for="repositoryName" class="strong">Repository Name:</label>
|
||||
<input type="text" name="repositoryName" id="repositoryName" value="@repository.name"/>
|
||||
|
||||
@@ -1715,15 +1715,13 @@ div.markdown-body table colgroup + tbody tr:first-child td:last-child {
|
||||
}
|
||||
|
||||
.markdown-head {
|
||||
left: -18px;
|
||||
padding-left: 18px;
|
||||
position: relative;
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
a.markdown-anchor-link {
|
||||
position: absolute;
|
||||
left: 0px;
|
||||
left: -18px;
|
||||
display: none;
|
||||
color: #999;
|
||||
/* From octicon style */
|
||||
|
||||
Reference in New Issue
Block a user