bin/gitspotter in gitspotter-0.0.2 vs bin/gitspotter in gitspotter-0.0.3
- old
+ new
@@ -1,6 +1,72 @@
#!/usr/bin/env ruby
+# -*- coding: utf-8 -*-
+require "capillary/log_parser"
+require "capillary/commit"
+
require 'gitspotter'
+gitrepo_dotgit_path = "." #TODO use ARGV[0] if present and a directory
-puts "Nothing to see"
+# Steal logic from graphs_controller here...
+
+# TODO generate json based on git log in given repo dir
+data = `git --git-dir=./.git log --all --graph --pretty=format:"%H§%P§%ai§%ae§%d§%s§" --decorate=full -100 master`
+
+parser = Capillary::LogParser.new
+data.split("\n").each { |line| parser << line }
+git_json = parser.to_json
+
+html_visualization = git_json
+
+#puts html_visualization
+
+def html_body(git_json)
+ <<HTML_BODY
+<!DOCTYPE html>
+<html>
+<head>
+<title>Gitspotter generated graph</title>
+
+<script src="http://localhost:3000/javascripts/lib/jquery.js" type="text/javascript"></script>
+<script src="http://localhost:3000/javascripts/lib/raphael/raphael-min.js" type="text/javascript"></script>
+<script src="http://localhost:3000/javascripts/lib/buster-core/lib/buster-core.js" type="text/javascript"></script>
+<script src="http://localhost:3000/javascripts/lib/buster-core/lib/buster-event-emitter.js" type="text/javascript"></script>
+<script src="http://localhost:3000/javascripts/lib/capillary/lib/capillary.js" type="text/javascript"></script>
+<script src="http://localhost:3000/javascripts/lib/capillary/lib/capillary/branch.js" type="text/javascript"></script>
+<script src="http://localhost:3000/javascripts/lib/capillary/lib/capillary/graph.js" type="text/javascript"></script>
+<script src="http://localhost:3000/javascripts/lib/capillary/lib/capillary/formatters/scale.js" type="text/javascript"></script>
+<script src="http://localhost:3000/javascripts/lib/capillary/lib/capillary/formatters/svg-data.js" type="text/javascript"></script>
+<script src="http://localhost:3000/javascripts/lib/capillary/lib/capillary/formatters/raphael.js" type="text/javascript"></script>
+<script src="http://localhost:3000/javascripts/lib/capillary/lib/capillary/formatters/message-markup.js" type="text/javascript"></script>
+
+
+</head>
+<body id="graphs">
+ <div id="wrapper">
+
+<div id='graph-data' style="display:none">#{git_json}</div>
+
+ <div class="capillary" id="capillary-log"
+ data-id-url="/gitorious/gitorious/graph/{{id}}"
+ data-message-url="/gitorious/gitorious/commit/{{id}}"
+ data-capillary-url="/api/gitorious/gitorious/log/graph/master">
+ <h2>This page requires JavaScript</h2>
+ </div>
+
+<script src="http://localhost:3000/javascripts/gitorious/log-graph.js" type="text/javascript"></script>
+<script src="http://localhost:3000/javascripts/onload.js" type="text/javascript"></script>
+
+ </div>
+ </div>
+</body>
+</html>
+HTML_BODY
+
+end
+
+puts html_body(git_json)
+
+# TODO: handle param so i can point it to any git repo
+# TODO: embed javascripts/styling/other assets: copy the files I need into js_assets folder in gem, concat them, embed in markup
+# TODO: rewrite to enable non-flickering/reloading refreshes of the graph