Skip to content

Add option to allow write access to all connections #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/libexec/git-core/git-webui
Original file line number Diff line number Diff line change
@@ -142,6 +142,8 @@ class WebUiRequestHandler(SimpleHTTPRequestHandler):


def is_view_only(self):
if "*" in allowed_hosts:
return False
host = self.headers.get("Host", "").split(":")[0]
return host not in allowed_hosts

@@ -283,7 +285,7 @@ if __name__ == '__main__':
parser = argparse.ArgumentParser(description = "Simple HTTP server for git webui")
parser.add_argument("--port", type = int, help = "server port")
parser.add_argument("--repo-root", help = "repository root path. By default goes up a dir until a '.git' directory is found")
parser.add_argument("--allow-hosts", help = "what other host(s) are allowed to have write access")
parser.add_argument("--allow-hosts", help = "what other host(s) are allowed to have write access. Use '*' to allow acces from all hosts.")
parser.add_argument("--no-browser", dest = "nobrowser", action = 'store_const', const = True, help = "do not start web browser")
parser.add_argument("--host", help = "the host webui listens on (default is all)")

5 changes: 5 additions & 0 deletions src/share/git-webui/webui/css/git-webui.less
Original file line number Diff line number Diff line change
@@ -152,6 +152,10 @@ body {
content: url(/img/daemon.svg);
}

#sidebar-sync h4:before {
content: url(/img/mail-send-receive-symbolic.svg);
}

#sidebar-local-branches, #sidebar-remote-branches {
h4:before {
content: url(/img/branch.svg);
@@ -611,6 +615,7 @@ body {
}
}


#commit-explorer-view {
#commit-explorer-navigator-view {
.panel {
34 changes: 34 additions & 0 deletions src/share/git-webui/webui/img/folder-download-symbolic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions src/share/git-webui/webui/img/mail-send-receive-symbolic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions src/share/git-webui/webui/img/pull.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 54 additions & 0 deletions src/share/git-webui/webui/js/git-webui.js
Original file line number Diff line number Diff line change
@@ -309,6 +309,9 @@ webui.SideBarView = function(mainView) {
'<section id="sidebar-remote">' +
'<h4>Remote access</h4>' +
'</section>' +
'<section id="sidebar-sync">' +
'<h4>Remote sync</h4>' +
'</section>' +
'<section id="sidebar-local-branches">' +
'<h4>Local Branches</h4>' +
'</section>' +
@@ -323,13 +326,20 @@ webui.SideBarView = function(mainView) {

if (webui.viewonly) {
$("#sidebar-workspace", self.element).remove();
$("#sidebar-sync", self.element).remove();
} else {
var workspaceElement = $("#sidebar-workspace h4", self.element);
workspaceElement.click(function (event) {
$("*", self.element).removeClass("active");
workspaceElement.addClass("active");
self.mainView.workspaceView.update("stage");
});
var syncElement = $("#sidebar-sync h4", self.element);
syncElement.click(function (event) {
$("*", self.element).removeClass("active");
syncElement.addClass("active");
self.mainView.syncView.update();
});
}

var remoteElement = $("#sidebar-remote h4", self.element);
@@ -1710,6 +1720,49 @@ webui.RemoteView = function(mainView) {
$(".git-pull", self.element).text("git pull http://" + webui.hostname + ":" + document.location.port + "/");
};

/*
* == SyncView =======================================================
*/
webui.SyncView = function(mainView) {

var self = this;

self.show = function() {
mainView.switchTo(self.element);
};

self.update = function() {
self.show();
};

self.onPush = function() {
webui.git("push");
self.update();
}

self.onFetch = function() {
webui.git("fetch");
self.update();
}

self.onPull = function() {
webui.git("pull");
self.update();
}

self.element = $( '<div class="jumbotron">' +
'<h1>Sync between local and remote</h1>' +
'<div>' +
'<button type="button" class="btn btn-sm btn-default sync-pull"><img src="img/pull.svg" />Pull</button>' +
'<button type="button" class="btn btn-sm btn-default sync-push"><img src="img/pull.svg" style="transform: scaleY(-1);" />Push</button>' +
'<button type="button" class="btn btn-sm btn-default sync-fetch"><img src="img/folder-download-symbolic.svg" />Fetch</button>' +
'</div>' +
'</div>')[0];
$(".sync-pull", self.element).click(self.onPull);
$(".sync-push", self.element).click(self.onPush);
$(".sync-fetch", self.element).click(self.onFetch);
};

/*
* == Initialization =========================================================
*/
@@ -1744,6 +1797,7 @@ function MainUi() {
self.historyView = new webui.HistoryView(self);
self.remoteView = new webui.RemoteView(self);
if (!webui.viewonly) {
self.syncView = new webui.SyncView(self);
self.workspaceView = new webui.WorkspaceView(self);
}
});