dolt 0.16.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,39 @@
1
+ /*global cull, dome*/
2
+ this.gts.blob = (function () {
3
+ function highlightLineOnFocus(element, start, end) {
4
+ var highlight = function () { dome.cn.add("focus", this); };
5
+ var dim = function () { dome.cn.rm("focus", this); };
6
+
7
+ cull.doall(function (li) {
8
+ dome.on(li, "mouseenter", highlight);
9
+ dome.on(li, "mouseleave", dim);
10
+ }, element.getElementsByTagName("li"));
11
+ }
12
+
13
+ function regionFromUrl(url) {
14
+ var matches = url.match(/\#l(\d+)(?:-(\d+))?/i);
15
+ if (!matches) { return; }
16
+ var start = Math.min(matches[2] || matches[1], matches[1]);
17
+ var end = Math.max(matches[2] || matches[1], matches[1]);
18
+ return [start, end];
19
+ }
20
+
21
+ function highlightRegion(element, region) {
22
+ // Line numbers are 1-based, but ElementLists are 0-indexed,
23
+ // offset region accordingly
24
+ var start = region[0] - 1;
25
+ var end = region[1] - 1;
26
+ var lines = element.getElementsByTagName("li");
27
+
28
+ cull.doall(function (li, num) {
29
+ var inRegion = start <= num && num <= end;
30
+ dome.cn[inRegion ? "add" : "rm"]("region", li);
31
+ }, element.getElementsByTagName("li"));
32
+ }
33
+
34
+ return {
35
+ highlightLineOnFocus: highlightLineOnFocus,
36
+ regionFromUrl: regionFromUrl,
37
+ highlightRegion: highlightRegion
38
+ };
39
+ }());
@@ -0,0 +1,20 @@
1
+ /*global cull, dome*/
2
+ this.gts.cloneUrlSelection = function cloneUrlSelection(element) {
3
+ var input = element.getElementsByTagName("input")[0];
4
+
5
+ if (input) {
6
+ dome.on(input, "focus", function (e) { this.select(); });
7
+ }
8
+
9
+ dome.delegate.bycn("gts-repo-url", element, "click", function (e) {
10
+ e.preventDefault();
11
+ var links = dome.byClass("gts-repo-url", element);
12
+ cull.doall(cull.partial(dome.cn.rm, "active"), links);
13
+ if (e.target) {
14
+ dome.cn.add("active", e.target);
15
+ var input = dome.byClass("gts-current-repo-url")[0];
16
+ input.value = e.target.href;
17
+ input.focus();
18
+ }
19
+ });
20
+ };
@@ -0,0 +1,71 @@
1
+ /*global dome*/
2
+ /**
3
+ * A simplified version of the Bootstrap dropdown jQuery plugin. Uses dome
4
+ * instead of jQuery and does not support most features in the original code,
5
+ * only toggling the dropdown.
6
+ *
7
+ * Original license follows.
8
+ *
9
+ * ============================================================
10
+ * bootstrap-dropdown.js v2.3.2
11
+ * http://twitter.github.com/bootstrap/javascript.html#dropdowns
12
+ * ============================================================
13
+ * Copyright 2012 Twitter, Inc.
14
+ *
15
+ * Licensed under the Apache License, Version 2.0 (the "License");
16
+ * you may not use this file except in compliance with the License.
17
+ * You may obtain a copy of the License at
18
+ *
19
+ * http://www.apache.org/licenses/LICENSE-2.0
20
+ *
21
+ * Unless required by applicable law or agreed to in writing, software
22
+ * distributed under the License is distributed on an "AS IS" BASIS,
23
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24
+ * See the License for the specific language governing permissions and
25
+ * limitations under the License.
26
+ * ===========================================================
27
+ */
28
+ this.gts.dropdown = (function (D) {
29
+ return function dropdown(element) {
30
+ var backdrop, active = false;
31
+
32
+ function close() {
33
+ if (backdrop) {
34
+ backdrop.parentNode.removeChild(backdrop);
35
+ backdrop = null;
36
+ }
37
+
38
+ D.cn.rm("open", element);
39
+ active = false;
40
+ }
41
+
42
+ function toggle(element) {
43
+ if (active) { return close(); }
44
+
45
+ if ("ontouchstart" in document.documentElement) {
46
+ // if mobile we we use a backdrop because click events don't delegate
47
+ backdrop = D.el("div", {
48
+ className: "dropdown-backdrop",
49
+ events: { click: close }
50
+ });
51
+ element.insertBefore(backdrop, element);
52
+ }
53
+ D.cn.add("open", element);
54
+ active = true;
55
+ }
56
+
57
+ D.on(element, "click", function (e) {
58
+ toggle(this);
59
+ e.preventDefault();
60
+ e.stopPropagation();
61
+ });
62
+
63
+ D.on(document.documentElement, "click", close);
64
+ D.on(document.documentElement, "keydown", function (e) {
65
+ if (e.keyCode !== 27) { return; }
66
+ close();
67
+ e.preventDefault();
68
+ e.stopPropagation();
69
+ });
70
+ };
71
+ }(dome));
@@ -0,0 +1,16 @@
1
+ // The global, shared Gitorious namespace
2
+ var gts = this.gts || {};
3
+
4
+ gts.googleAnalytics = function (account, domainName) {
5
+ window._gaq = window._gaq || [];
6
+ window._gaq.push(["_setAccount", account]);
7
+ if (domainName) {
8
+ window._gaq.push(["_setDomainName", domainName]);
9
+ }
10
+ window._gaq.push(["_trackPageview"]);
11
+ var ga = document.createElement("script");
12
+ ga.type = "text/javascript";
13
+ ga.async = true;
14
+ ga.src = ("https:" == document.location.protocol ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js";
15
+ (document.getElementsByTagName("head")[0] || document.getElementsByTagName("body")[0]).appendChild(ga);
16
+ };
@@ -0,0 +1,39 @@
1
+ /*global Showdown*/
2
+ this.gts.liveMarkdownPreview = function liveMarkdownPreview(textarea) {
3
+ var target = document.getElementById(textarea.getAttribute("data-gts-preview-target"));
4
+ if (!target || typeof Showdown === "undefined") { return; }
5
+ var converter = new Showdown.converter();
6
+ var previous, content;
7
+
8
+ var cageSeed = new Date().getTime();
9
+
10
+ function zeroPad(num) {
11
+ return num < 10 ? "0" + num : num;
12
+ }
13
+
14
+ function signature() {
15
+ var now = new Date();
16
+ return "<p>" +
17
+ "<img width=\"24\" height=\"24\" class=\"gts-avatar\" alt=\"avatar\" src=\"http://cageme.herokuapp.com/24/24?" +
18
+ cageSeed + "\">" +
19
+ "<a href=\"/~zmalltalker\">Marius Mathiesen</a>" +
20
+ zeroPad(now.getHours()) + ":" + zeroPad(now.getMinutes()) +
21
+ ". <a href=\"#\">Edit comment</a></p>";
22
+ }
23
+
24
+ function setPreview(preview) {
25
+ target.style.display = preview ? "block" : "none";
26
+ target.getElementsByTagName("div")[0].innerHTML = preview;
27
+ }
28
+
29
+ function updatePreview() {
30
+ content = textarea.value;
31
+ if (content !== previous) {
32
+ previous = content;
33
+ setPreview(converter.makeHtml(content));
34
+ }
35
+ setTimeout(updatePreview, 20);
36
+ }
37
+
38
+ updatePreview();
39
+ };
@@ -16,7 +16,7 @@ var gts = this.gts || {};
16
16
  if (!user) { return; }
17
17
  d.setContent([
18
18
  e.a({ className: "btn btn-inverse", href: user.dashboardPath },
19
- e.i({ className: "icon-user icon-white" }, user.login)),
19
+ [e.i({ className: "icon-user icon-white" }), user.login]),
20
20
  e.a({ className: "btn btn-inverse dropdown-toggle",
21
21
  href: "#",
22
22
  data: { toggle: "dropdown" }
@@ -1,4 +1,4 @@
1
- /*global cull*/
1
+ /*global cull, dome*/
2
2
  // The global, shared Gitorious namespace
3
3
  this.gts = this.gts || {};
4
4
 
@@ -96,9 +96,18 @@ this.gts.refSelector = (function (e) {
96
96
  concat(refItems("Tags", refs.tags || [], urlTemplate)));
97
97
  }
98
98
 
99
- return function (refs, current, urlTemplate) {
99
+ function build(refs, current, urlTemplate) {
100
100
  return e.div({
101
101
  className: "dropdown gts-branch-selector pull-right"
102
102
  }, [currentRefLink(refs, current), refsList(refs, urlTemplate)]);
103
- };
103
+ }
104
+
105
+ function refSelector(placeholder, refs, ref, refUrlTemplate) {
106
+ var selector = build(refs, ref, refUrlTemplate);
107
+ placeholder.appendChild(selector);
108
+ this.gts.dropdown(selector);
109
+ }
110
+
111
+ refSelector.build = build;
112
+ return refSelector;
104
113
  }(dome.el));
@@ -1,4 +1,4 @@
1
- /*global gts, cull, dome, Spinner*/
1
+ /*global gts, cull, dome, reqwest, Spinner*/
2
2
  // The global, shared Gitorious namespace
3
3
  this.gts = this.gts || {};
4
4
 
@@ -76,8 +76,9 @@ this.gts.treeHistory = (function (c, d) {
76
76
  left: "auto"
77
77
  }).spin(cell);
78
78
 
79
- $.ajax({
79
+ reqwest({
80
80
  url: url,
81
+ type: "json",
81
82
  success: function (tree) {
82
83
  spinner.stop();
83
84
  th.annotate(table, tree);
@@ -0,0 +1,4 @@
1
+ /*global reqwest*/
2
+ this.gts.userRepoViewState = function (path) {
3
+ return reqwest({ url: path, type: "json" });
4
+ };
@@ -1,149 +1,82 @@
1
- // $(".gts-select-onfocus").focus(function () {
2
- // this.select();
3
- // });
1
+ /*global gts, reqwest, cull*/
4
2
 
5
- $(".gts-repo-url").click(function (e) {
6
- e.preventDefault();
7
- var btn = $(this);
8
- var parent = btn.parent();
9
- parent.find(".gts-repo-url").removeClass("active");
10
- btn.addClass("active");
11
- parent.find(".gts-current-repo-url").val(btn.attr("href")).focus();
12
- });
13
-
14
- // $(".linenums li").mouseenter(function () {
15
- // $(this).addClass("focus");
16
- // });
17
-
18
- // $(".linenums li").mouseleave(function () {
19
- // $(this).removeClass("focus");
20
- // });
21
-
22
- // (function () {
23
- // var fileEl = document.getElementById("file");
24
- // var matches = window.location.href.match(/\#l(\d+)(?:-(\d+))?/);
25
- // if (!fileEl || !matches) { return; }
26
- // var lines = fileEl.getElementsByTagName("li");
27
- // var end = Math.max(matches[2] || matches[1], matches[1]);
28
-
29
- // for (var i = matches[1]; i <= end; ++i) {
30
- // $(lines[i - 1]).addClass("focus");
31
- // }
32
- // }());
33
-
34
- jQuery("[rel=tooltip]").tooltip();
35
-
36
- jQuery("[data-preview-target]").each(function () {
37
- var textarea = this;
38
- var target = document.getElementById(this.getAttribute("data-preview-target"));
39
- if (!target || !Showdown) { return; }
40
- var converter = new Showdown.converter();
41
- var previous, content;
42
-
43
- var cageSeed = new Date().getTime();
44
-
45
- function zeroPad(num) {
46
- return num < 10 ? "0" + num : num;
47
- }
48
-
49
- function signature() {
50
- var now = new Date();
51
- return "<p>" +
52
- "<img width=\"24\" height=\"24\" class=\"gts-avatar\" alt=\"avatar\" src=\"http://cageme.herokuapp.com/24/24?" +
53
- cageSeed + "\">" +
54
- "<a href=\"/~zmalltalker\">Marius Mathiesen</a>" +
55
- zeroPad(now.getHours()) + ":" + zeroPad(now.getMinutes()) +
56
- ". <a href=\"#\">Edit comment</a></p>";
57
- }
58
-
59
- function setPreview(preview) {
60
- target.style.display = preview ? "block" : "none";
61
- target.getElementsByTagName("div")[0].innerHTML = preview;
62
- }
63
-
64
- function updatePreview() {
65
- content = textarea.value;
66
- if (content !== previous) {
67
- previous = content;
68
- setPreview(converter.makeHtml(content));
69
- }
70
- setTimeout(updatePreview, 20);
71
- }
72
-
73
- updatePreview();
74
- });
75
-
76
- // Lest ye forget
77
- /*
78
- var _gaq = _gaq || [];
79
- _gaq.push(['_setAccount', 'UA-52238-3']);
80
- _gaq.push(['_setDomainName', '.gitorious.org']);
81
- _gaq.push(['_trackPageview']);
82
- (function() {
83
- var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
84
- ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
85
- (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
86
- })();
87
- */
88
-
89
- var gts = this.gts || {};
90
-
91
- // VERY TMP/TODO
92
-
93
- this.gts.loadRefs = function (repo, callback) {
94
- repo = repo ? "/" + repo : "";
95
-
96
- jQuery.ajax({
97
- url: repo + "/refs",
98
- success: function (refs) {
99
- callback(null, refs);
100
- }
101
- });
3
+ this.gts.loadRefs = function (url) {
4
+ return reqwest({ url: url, type: "json" });
102
5
  };
103
6
 
104
- gts.run = function (env) {
105
- var placeHolder = document.getElementById("gts-ref-selector-ph");
7
+ function refUrlTpl(url, ref) {
8
+ return gts.url.templatize(url, { ref: ref });
9
+ }
10
+
11
+ // Environment variables
12
+ gts.app.env("url", window.location.href);
13
+ gts.app.env("redirect", function (url) { window.location = url; });
14
+
15
+ if ("onpopstate" in window) {
16
+ window.onpopstate = function (event) {
17
+ gts.app.env("url", window.location.href);
18
+ };
19
+ }
20
+
21
+ // Data
22
+ gts.app.data("current-ref", gts.url.currentRef, { depends: ["url"] });
23
+ gts.app.data("ref-url-template", refUrlTpl, { depends: ["url", "current-ref"] });
24
+ gts.app.data("repository-refs", gts.loadRefs, { depends: ["repository-refs-url"] });
25
+ gts.app.data("user-repo-view-state", gts.userRepoViewState, { depends: ["user-repository-path"] });
26
+ gts.app.data("current-user", cull.prop("user"), { depends: ["user-repo-view-state"] });
27
+ gts.app.data("blob-region", gts.blob.regionFromUrl, { depends: ["url"] });
28
+
29
+ // Features
30
+ // NB! While it is possible to lean on the function name when registering
31
+ // features, e.g. gts.app.feature(gts.googleAnalytics, { ... }); we don't do
32
+ // that, because uglify will strip out the function names, and the app will
33
+ // crash.
34
+ gts.app.feature("google-analytics", gts.googleAnalytics, {
35
+ depends: ["analytics-account", "analytics-domain-name"]
36
+ });
106
37
 
107
- if (placeHolder) {
108
- gts.loadRefs(env.repository, function (err, refs) {
109
- var selector = gts.refSelector(refs, env.ref, env.refUrlTemplate);
110
- placeHolder.appendChild(selector);
111
- $(selector).find(".dropdown-toggle").dropdown();
112
- });
113
- }
38
+ gts.app.feature("ref-selector", gts.refSelector, {
39
+ elements: ["gts-ref-selector-ph"],
40
+ depends: ["repository-refs", "current-ref", "ref-url-template"]
41
+ });
114
42
 
115
- var treeBrowser = $("table[data-gts-tree-history]");
43
+ gts.app.feature("tree-history", gts.treeHistory, {
44
+ elements: ["gts-tree-explorer"],
45
+ depends: ["tree-history-url"]
46
+ });
116
47
 
117
- if (treeBrowser.length > 0) {
118
- gts.treeHistory(treeBrowser[0], treeBrowser.attr("data-gts-tree-history"));
119
- }
48
+ gts.app.feature("commit-linker", gts.commitLinker, {
49
+ elements: ["gts-body"],
50
+ depends: ["commit-url-template", "redirect"]
51
+ });
120
52
 
121
- var gtsBody = $(".gts-body");
53
+ gts.app.feature("profile-menu", gts.profileMenu, {
54
+ elements: ["login_button"],
55
+ depends: ["current-user"]
56
+ });
122
57
 
123
- if (gtsBody.length > 0) {
124
- gts.commitLinker(gtsBody[0], gts.commitUrlTemplate, function (url) {
125
- window.location = url;
126
- });
127
- }
58
+ gts.app.feature("clone-url-selection", gts.cloneUrlSelection, {
59
+ elements: ["gts-repo-urls"]
60
+ });
128
61
 
129
- var userRepositoryPath = $("[data-gts-user-repository-path]").data("gts-user-repository-path");
62
+ gts.app.feature("highlight-region", gts.blob.highlightRegion, {
63
+ elements: ["gts-lines"],
64
+ depends: ["blob-region"]
65
+ });
130
66
 
131
- if (userRepositoryPath) {
132
- jQuery.ajax({
133
- url: userRepositoryPath,
134
- success: function (data) {
135
- gts.profileMenu(document.getElementById("login_button"), data.user);
136
- }
137
- });
138
- }
139
- };
67
+ gts.app.feature("highlight-line-mouseover", gts.blob.highlightLineOnFocus, {
68
+ elements: ["gts-lines"]
69
+ });
140
70
 
141
- (function () {
142
- var ref = gts.url.currentRef(window.location.href);
71
+ gts.app.feature("live-markdown-preview", gts.liveMarkdownPreview, {
72
+ elements: ["gts-live-markdown-preview"]
73
+ });
143
74
 
144
- gts.run({
145
- repository: gts.repository || "",
146
- ref: ref,
147
- refUrlTemplate: gts.url.templatize(window.location.href, { ref: ref })
148
- });
149
- }());
75
+ // Spin off app asynchronously so subsequent scripts have a chance
76
+ // to register loggers etc before we roll
77
+ setTimeout(function () {
78
+ // Scan the document for data-gts-* attributes that set
79
+ // "environment variables"
80
+ gts.app.scanEnvAttrs(document.body, "data-gts-env-");
81
+ gts.app.load(document.body);
82
+ }, 10);