aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Spiers <git@adamspiers.org>2015-01-12 23:10:58 +0000
committerAdam Spiers <git@adamspiers.org>2015-01-12 23:10:58 +0000
commit80d531898b434ade5f8f942025cb409b445922d1 (patch)
tree31f9be356b144e6595d0b40b6b73a4ff6a6c3eed
parent149f5253f8d0f92aaf93922e17b5c86df3f92178 (diff)
downloadgit-deps-80d531898b434ade5f8f942025cb409b445922d1.tar.gz
add hyperlinks with gitfile:// URLs (#29)
Closes #29.
-rw-r--r--README.md19
-rwxr-xr-xgit-deps4
-rwxr-xr-xgitfile-handler34
-rw-r--r--gitfile-handler.desktop7
-rw-r--r--html/js/git-deps-graph.coffee5
5 files changed, 67 insertions, 2 deletions
diff --git a/README.md b/README.md
index a093540..53fc85c 100644
--- a/README.md
+++ b/README.md
@@ -112,6 +112,25 @@ If you run with the `--serve` option then it will start a lightweight
webserver and output a URL you can connect to for dynamically
visualizing and navigating the dependency graph.
+### Setting up a `gitfile://` URL handler
+
+If you double-click any commit node on the dependency graph, your
+browser will be asked to launch a handler for a `gitfile://...` URL
+which points to that commit within the repository path on your local
+filesystem. So if you configure your browser desktop environment,
+you can have a program such as [`gitk`](http://git-scm.com/docs/gitk)
+launch for viewing further details of that commit. Obviously this
+only makes sense when viewing the graph via http://localhost.
+
+On most Linux machines, this can be set up via something like the
+following:
+
+ # First cd to the top of this git-deps repo.
+ repo="`pwd`"
+ ln -sf $repo/gitfile-handler ~/bin
+ ln -sf $repo/gitfile-handler.desktop ~/.local/share/applications
+ xdg-mime default gitfile-handler.desktop x-scheme-handler/gitfile
+
Development / support / feedback
--------------------------------
diff --git a/git-deps b/git-deps
index 410a475..0d3e2dd 100755
--- a/git-deps
+++ b/git-deps
@@ -726,7 +726,9 @@ def serve(options):
@webserver.route('/options')
def send_options():
- return jsonify(options.__dict__)
+ client_options = options.__dict__
+ client_options['repo_path'] = os.getcwd()
+ return jsonify(client_options)
@webserver.route('/deps.json/<commitish>')
def deps(commitish):
diff --git a/gitfile-handler b/gitfile-handler
new file mode 100755
index 0000000..5fc5d3e
--- /dev/null
+++ b/gitfile-handler
@@ -0,0 +1,34 @@
+#!/usr/bin/python
+
+from __future__ import print_function
+
+import os
+import re
+import subprocess
+import sys
+from urlparse import urlparse, urljoin
+
+def abort(msg, exitcode=1):
+ print(msg, file=sys.stderr)
+ sys.exit(exitcode)
+
+def usage():
+ abort("usage: git-handler URL")
+
+def main():
+ if len(sys.argv) != 2:
+ usage()
+
+ url = urlparse(sys.argv[1])
+
+ if url.scheme != 'gitfile':
+ abort("URL must use gitfile:// scheme")
+
+ repo = os.path.join(url.netloc, url.path)
+ rev = url.fragment
+ os.chdir(repo)
+
+ subprocess.Popen(['gitk', '--all', '--select-commit=%s' % rev])
+
+if __name__ == "__main__":
+ main()
diff --git a/gitfile-handler.desktop b/gitfile-handler.desktop
new file mode 100644
index 0000000..dfef2d5
--- /dev/null
+++ b/gitfile-handler.desktop
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Name=gitk launcher
+Exec=gitfile-handler %u
+# Icon=emacs-icon
+Type=Application
+Terminal=false
+MimeType=x-scheme-handler/gitfile;
diff --git a/html/js/git-deps-graph.coffee b/html/js/git-deps-graph.coffee
index 6157a42..1148109 100644
--- a/html/js/git-deps-graph.coffee
+++ b/html/js/git-deps-graph.coffee
@@ -284,7 +284,7 @@ draw_new_nodes = (fg, g_enter) ->
rects = g_enter.append('rect')
.attr('rx', 5)
.attr('ry', 5)
- .on('dblclick', (d) -> explore_node d)
+ .on('dblclick', (d) -> launch_viewer d)
labels = g_enter.append('text').text((d) ->
d.name
@@ -310,6 +310,9 @@ explore_node = (d) ->
else
add_commitish d.sha1
+launch_viewer = (d) ->
+ window.location.assign "gitfile://#{options.repo_path}##{d.sha1}"
+
new_data_notification = (new_data) ->
new_nodes = new_data[0]
new_deps = new_data[1]