pact_broker 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.gitignore +0 -1
- data/.rspec +1 -0
- data/CHANGELOG.md +47 -0
- data/README.md +4 -2
- data/config.ru +3 -5
- data/db/migrations/09_add_timestamps.rb +12 -0
- data/db/migrations/10_populate_timestamps.rb +15 -0
- data/db/migrations/11_made_timestamps_mandatory.rb +20 -0
- data/db/migrations/12_create_webhooks_table.rb +21 -0
- data/db/migrations/13_add_columns_to_webhooks.rb +8 -0
- data/lib/pact_broker/api.rb +14 -0
- data/lib/pact_broker/api/decorators.rb +2 -2
- data/lib/pact_broker/api/decorators/base_decorator.rb +2 -1
- data/lib/pact_broker/api/decorators/basic_pacticipant_decorator.rb +21 -0
- data/lib/pact_broker/api/decorators/decorator_context.rb +20 -0
- data/lib/pact_broker/api/decorators/latest_pact_decorator.rb +2 -2
- data/lib/pact_broker/api/decorators/pact_decorator.rb +12 -5
- data/lib/pact_broker/api/decorators/pact_details_decorator.rb +22 -0
- data/lib/pact_broker/api/decorators/pacticipant_decorator.rb +6 -4
- data/lib/pact_broker/api/decorators/relationships_csv_decorator.rb +25 -3
- data/lib/pact_broker/api/decorators/representable_pact.rb +3 -1
- data/lib/pact_broker/api/decorators/tag_decorator.rb +3 -0
- data/lib/pact_broker/api/decorators/webhook_decorator.rb +52 -0
- data/lib/pact_broker/api/decorators/webhook_execution_result_decorator.rb +58 -0
- data/lib/pact_broker/api/decorators/webhook_request_decorator.rb +18 -0
- data/lib/pact_broker/api/decorators/webhooks_decorator.rb +37 -0
- data/lib/pact_broker/api/pact_broker_urls.rb +16 -0
- data/lib/pact_broker/api/renderers/html_pact_renderer.rb +2 -1
- data/lib/pact_broker/api/resources/base_resource.rb +12 -1
- data/lib/pact_broker/api/resources/group.rb +38 -0
- data/lib/pact_broker/api/resources/index.rb +30 -21
- data/lib/pact_broker/api/resources/latest_pact.rb +1 -1
- data/lib/pact_broker/api/resources/latest_pacts.rb +1 -1
- data/lib/pact_broker/api/resources/pact.rb +18 -2
- data/lib/pact_broker/api/resources/pact_webhooks.rb +87 -0
- data/lib/pact_broker/api/resources/pacticipant.rb +15 -6
- data/lib/pact_broker/api/resources/pacticipants.rb +1 -1
- data/lib/pact_broker/api/resources/tag.rb +2 -2
- data/lib/pact_broker/api/resources/webhook.rb +44 -0
- data/lib/pact_broker/api/resources/webhook_execution.rb +43 -0
- data/lib/pact_broker/api/resources/webhooks.rb +29 -0
- data/lib/pact_broker/app.rb +46 -8
- data/lib/pact_broker/db.rb +10 -0
- data/lib/pact_broker/doc/controllers/app.rb +32 -0
- data/lib/pact_broker/doc/views/latest-pacts.markdown +3 -0
- data/lib/pact_broker/doc/views/layouts/main.haml +5 -0
- data/lib/pact_broker/doc/views/pacticipants.markdown +10 -0
- data/lib/pact_broker/doc/views/self.markdown +8 -0
- data/lib/pact_broker/doc/views/webhooks.markdown +48 -0
- data/lib/pact_broker/functions/groupify.rb +39 -0
- data/lib/pact_broker/jobs/after_pact_save.rb +13 -0
- data/lib/pact_broker/json.rb +4 -0
- data/lib/pact_broker/locale/en.yml +23 -0
- data/lib/pact_broker/messages.rb +18 -0
- data/lib/pact_broker/models/group.rb +21 -0
- data/lib/pact_broker/models/pact.rb +4 -2
- data/lib/pact_broker/models/pacticipant.rb +3 -1
- data/lib/pact_broker/models/relationship.rb +34 -0
- data/lib/pact_broker/models/tag.rb +3 -1
- data/lib/pact_broker/models/version.rb +3 -1
- data/lib/pact_broker/models/webhook.rb +53 -0
- data/lib/pact_broker/models/webhook_execution_result.rb +26 -0
- data/lib/pact_broker/models/webhook_request.rb +107 -0
- data/lib/pact_broker/models/webhook_request_header.rb +13 -0
- data/lib/pact_broker/repositories.rb +6 -0
- data/lib/pact_broker/repositories/pact_repository.rb +25 -7
- data/lib/pact_broker/repositories/pacticipant_repository.rb +4 -0
- data/lib/pact_broker/repositories/webhook_repository.rb +134 -0
- data/lib/pact_broker/services.rb +10 -0
- data/lib/pact_broker/services/group_service.rb +24 -0
- data/lib/pact_broker/services/pact_service.rb +37 -7
- data/lib/pact_broker/services/pacticipant_service.rb +12 -1
- data/lib/pact_broker/services/webhook_service.rb +63 -0
- data/lib/pact_broker/tasks.rb +0 -1
- data/lib/pact_broker/ui/controllers/base_controller.rb +1 -0
- data/lib/pact_broker/ui/controllers/groups.rb +25 -0
- data/lib/pact_broker/ui/controllers/relationships.rb +0 -2
- data/lib/pact_broker/ui/helpers/url_helper.rb +17 -0
- data/lib/pact_broker/ui/view_models/relationship.rb +13 -4
- data/lib/pact_broker/ui/view_models/relationships.rb +1 -1
- data/lib/pact_broker/ui/views/groups/show.html.erb +409 -0
- data/lib/pact_broker/ui/views/relationships/show.haml +4 -2
- data/lib/pact_broker/version.rb +1 -1
- data/pact_broker.gemspec +7 -6
- data/public/{d3.v3.js.pagespeed.ce.dFNRrGTALe.js → javascripts/d3.v3.js.pagespeed.ce.dFNRrGTALe.js} +0 -0
- data/public/stylesheets/relationships.css +4 -0
- data/spec/integration/endpoints/group.rb +22 -0
- data/spec/lib/pact_broker/api/decorators/pact_decorator_spec.rb +49 -0
- data/spec/lib/pact_broker/api/decorators/pacticipant_decorator_spec.rb +25 -0
- data/spec/lib/pact_broker/api/decorators/relationships_csv_decorator_spec.rb +7 -4
- data/spec/lib/pact_broker/api/decorators/webhook_decorator_spec.rb +121 -0
- data/spec/lib/pact_broker/api/decorators/webhook_execution_result_decorator_spec.rb +69 -0
- data/spec/lib/pact_broker/api/decorators/webhook_request_decorator_spec.rb +78 -0
- data/spec/lib/pact_broker/api/decorators/webhooks_decorator_spec.rb +46 -0
- data/spec/lib/pact_broker/api/resources/group_spec.rb +80 -0
- data/spec/lib/pact_broker/api/resources/pact_spec.rb +41 -0
- data/spec/lib/pact_broker/api/resources/pact_webhooks_spec.rb +184 -0
- data/spec/lib/pact_broker/api/resources/pacticipant_spec.rb +71 -0
- data/spec/lib/pact_broker/api/resources/webhook_execution_spec.rb +77 -0
- data/spec/lib/pact_broker/api/resources/webhook_spec.rb +60 -0
- data/spec/lib/pact_broker/api/resources/webhooks_spec.rb +44 -0
- data/spec/lib/pact_broker/doc/controllers/app_spec.rb +51 -0
- data/spec/lib/pact_broker/functions/groupify_spec.rb +50 -0
- data/spec/lib/pact_broker/models/group_spec.rb +26 -0
- data/spec/lib/pact_broker/models/webhook_request_spec.rb +175 -0
- data/spec/lib/pact_broker/models/webhook_spec.rb +59 -0
- data/spec/lib/pact_broker/repositories/pact_repository_spec.rb +40 -0
- data/spec/lib/pact_broker/repositories/webhook_repository_spec.rb +257 -0
- data/spec/lib/pact_broker/services/group_service_spec.rb +52 -0
- data/spec/lib/pact_broker/services/pact_service_spec.rb +49 -0
- data/spec/lib/pact_broker/services/pacticipant_service_spec.rb +50 -0
- data/spec/lib/pact_broker/services/webhook_service_spec.rb +51 -0
- data/spec/lib/pact_broker/ui/view_models/relationship_spec.rb +20 -6
- data/spec/lib/pact_broker/ui/view_models/relationships_spec.rb +33 -0
- data/spec/service_consumers/provider_states_for_pact_broker_client.rb +1 -1
- data/spec/spec_helper.rb +11 -4
- data/spec/support/provider_state_builder.rb +11 -0
- data/spec/support/shared_examples_for_responses.rb +25 -0
- data/vendor/hal-browser/js/hal/views/embedded_resource.js +3 -3
- data/vendor/hal-browser/js/hal/views/resource.js +3 -3
- metadata +174 -80
- data/assets/d3.v3.js +0 -9263
- data/assets/force.csv +0 -29
- data/assets/index.html +0 -186
- data/assets/index2.html +0 -224
- data/assets/relationships +0 -4
- data/assets/stylesheets/github.css +0 -387
- data/lib/pact_broker/tasks/delete.rake +0 -20
- data/public/Network Graph REA.html +0 -48
- data/public/rea.csv +0 -10
data/assets/force.csv
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
source,target,value
|
2
|
-
Contract Transaction Service,MAS,1
|
3
|
-
Contract Transaction Service,Media Proposals,1
|
4
|
-
Sarah,Media Billee Orchestrator,1
|
5
|
-
Eveie,Media Billee Orchestrator,1
|
6
|
-
Peter,Media Billee Orchestrator,1
|
7
|
-
Media Proposals,Media Billee Orchestrator,1
|
8
|
-
James,Media Billee Orchestrator,1
|
9
|
-
Contract Transaction Service,Carol,1
|
10
|
-
Contract Transaction Service,Nicky,1
|
11
|
-
Media Proposal Sync,Frank,1
|
12
|
-
Media Billee Orchestrator,Media Proposals,1
|
13
|
-
Contract Transaction Service,Lynne,1
|
14
|
-
Sarah,James,1
|
15
|
-
Roger,James,1
|
16
|
-
Maddy,James,1
|
17
|
-
Sonny,Roger,1
|
18
|
-
James,Roger,1
|
19
|
-
Media Billee Orchestrator,Peter,1
|
20
|
-
Johan,Peter,1
|
21
|
-
Media Billee Orchestrator,Eveie,1
|
22
|
-
Contract Transaction Service,Eveie,1
|
23
|
-
Eveie,Contract Transaction Service,1
|
24
|
-
Henry,Mikey,1
|
25
|
-
Elric,Mikey,1
|
26
|
-
James,Sarah,1
|
27
|
-
Media Billee Orchestrator,Sarah,1
|
28
|
-
James,Maddy,1
|
29
|
-
Peter,Johan,1
|
data/assets/index.html
DELETED
@@ -1,186 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<meta charset="utf-8">
|
3
|
-
<script src="http://d3js.org/d3.v3.js"></script>
|
4
|
-
<style>
|
5
|
-
|
6
|
-
path.link {
|
7
|
-
fill: none;
|
8
|
-
stroke: #666;
|
9
|
-
stroke-width: 1.5px;
|
10
|
-
}
|
11
|
-
|
12
|
-
path.link.twofive {
|
13
|
-
opacity: 0.25;
|
14
|
-
}
|
15
|
-
|
16
|
-
path.link.fivezero {
|
17
|
-
opacity: 0.50;
|
18
|
-
}
|
19
|
-
|
20
|
-
path.link.sevenfive {
|
21
|
-
opacity: 0.75;
|
22
|
-
}
|
23
|
-
|
24
|
-
path.link.onezerozero {
|
25
|
-
opacity: 1.0;
|
26
|
-
}
|
27
|
-
|
28
|
-
circle {
|
29
|
-
fill: #ccc;
|
30
|
-
stroke: #fff;
|
31
|
-
stroke-width: 1.5px;
|
32
|
-
}
|
33
|
-
|
34
|
-
text {
|
35
|
-
fill: #000;
|
36
|
-
font: 10px sans-serif;
|
37
|
-
pointer-events: none;
|
38
|
-
}
|
39
|
-
|
40
|
-
</style>
|
41
|
-
<body>
|
42
|
-
<script>
|
43
|
-
|
44
|
-
// get the data
|
45
|
-
d3.csv("relationships", function(error, links) {
|
46
|
-
|
47
|
-
var nodes = {};
|
48
|
-
|
49
|
-
// Compute the distinct nodes from the links.
|
50
|
-
links.forEach(function(link) {
|
51
|
-
link.source = nodes[link.source] ||
|
52
|
-
(nodes[link.source] = {name: link.source});
|
53
|
-
link.target = nodes[link.target] ||
|
54
|
-
(nodes[link.target] = {name: link.target});
|
55
|
-
link.value = +link.value;
|
56
|
-
});
|
57
|
-
|
58
|
-
var width = 1500,
|
59
|
-
height = 1000;
|
60
|
-
|
61
|
-
var force = d3.layout.force()
|
62
|
-
.nodes(d3.values(nodes))
|
63
|
-
.links(links)
|
64
|
-
.size([width, height])
|
65
|
-
.linkDistance(150)
|
66
|
-
.charge(-1300)
|
67
|
-
.on("tick", tick)
|
68
|
-
.start();
|
69
|
-
|
70
|
-
// Set the range
|
71
|
-
var v = d3.scale.linear().range([0, 100]);
|
72
|
-
|
73
|
-
// Scale the range of the data
|
74
|
-
v.domain([0, d3.max(links, function(d) { return d.value; })]);
|
75
|
-
|
76
|
-
// asign a type per value to encode opacity
|
77
|
-
links.forEach(function(link) {
|
78
|
-
if (v(link.value) <= 25) {
|
79
|
-
link.type = "twofive";
|
80
|
-
} else if (v(link.value) <= 50 && v(link.value) > 25) {
|
81
|
-
link.type = "fivezero";
|
82
|
-
} else if (v(link.value) <= 75 && v(link.value) > 50) {
|
83
|
-
link.type = "sevenfive";
|
84
|
-
} else if (v(link.value) <= 100 && v(link.value) > 75) {
|
85
|
-
link.type = "onezerozero";
|
86
|
-
}
|
87
|
-
});
|
88
|
-
|
89
|
-
var svg = d3.select("body").append("svg")
|
90
|
-
.attr("width", width)
|
91
|
-
.attr("height", height);
|
92
|
-
|
93
|
-
// build the arrow.
|
94
|
-
svg.append("svg:defs").selectAll("marker")
|
95
|
-
.data(["end"]) // Different link/path types can be defined here
|
96
|
-
.enter().append("svg:marker") // This section adds in the arrows
|
97
|
-
.attr("id", String)
|
98
|
-
.attr("viewBox", "0 -5 10 10")
|
99
|
-
.attr("refX", 15)
|
100
|
-
.attr("refY", -1.5)
|
101
|
-
.attr("markerWidth", 6)
|
102
|
-
.attr("markerHeight", 6)
|
103
|
-
.attr("orient", "auto")
|
104
|
-
.append("svg:path")
|
105
|
-
.attr("d", "M0,-5L10,0L0,5");
|
106
|
-
|
107
|
-
// add the links and the arrows
|
108
|
-
var path = svg.append("svg:g").selectAll("path")
|
109
|
-
.data(force.links())
|
110
|
-
.enter().append("svg:path")
|
111
|
-
.attr("class", function(d) { return "link " + d.type; })
|
112
|
-
.attr("marker-end", "url(#end)");
|
113
|
-
|
114
|
-
// define the nodes
|
115
|
-
var node = svg.selectAll(".node")
|
116
|
-
.data(force.nodes())
|
117
|
-
.enter().append("g")
|
118
|
-
.attr("class", "node")
|
119
|
-
.on("click", click)
|
120
|
-
.on("dblclick", dblclick)
|
121
|
-
.call(force.drag);
|
122
|
-
|
123
|
-
// add the nodes
|
124
|
-
node.append("circle")
|
125
|
-
.attr("r", 5);
|
126
|
-
|
127
|
-
// add the text
|
128
|
-
node.append("text")
|
129
|
-
.attr("x", 12)
|
130
|
-
.attr("dy", ".35em")
|
131
|
-
.text(function(d) { return d.name; });
|
132
|
-
|
133
|
-
// add the curvy lines
|
134
|
-
function tick() {
|
135
|
-
path.attr("d", function(d) {
|
136
|
-
var dx = d.target.x - d.source.x,
|
137
|
-
dy = d.target.y - d.source.y,
|
138
|
-
dr = Math.sqrt(dx * dx + dy * dy);
|
139
|
-
return "M" +
|
140
|
-
d.source.x + "," +
|
141
|
-
d.source.y + "A" +
|
142
|
-
dr + "," + dr + " 0 0,1 " +
|
143
|
-
d.target.x + "," +
|
144
|
-
d.target.y;
|
145
|
-
});
|
146
|
-
|
147
|
-
node
|
148
|
-
.attr("transform", function(d) {
|
149
|
-
return "translate(" + d.x + "," + d.y + ")"; });
|
150
|
-
}
|
151
|
-
|
152
|
-
// action to take on mouse click
|
153
|
-
function click() {
|
154
|
-
d3.select(this).select("text").transition()
|
155
|
-
.duration(750)
|
156
|
-
.attr("x", 22)
|
157
|
-
.style("fill", "steelblue")
|
158
|
-
.style("stroke", "lightsteelblue")
|
159
|
-
.style("stroke-width", ".5px")
|
160
|
-
.style("font", "20px sans-serif");
|
161
|
-
d3.select(this).select("circle").transition()
|
162
|
-
.duration(750)
|
163
|
-
.attr("r", 16)
|
164
|
-
.style("fill", "lightsteelblue");
|
165
|
-
}
|
166
|
-
|
167
|
-
// action to take on mouse double click
|
168
|
-
function dblclick() {
|
169
|
-
d3.select(this).select("circle").transition()
|
170
|
-
.duration(750)
|
171
|
-
.attr("r", 6)
|
172
|
-
.style("fill", "#ccc");
|
173
|
-
d3.select(this).select("text").transition()
|
174
|
-
.duration(750)
|
175
|
-
.attr("x", 12)
|
176
|
-
.style("stroke", "none")
|
177
|
-
.style("fill", "black")
|
178
|
-
.style("stroke", "none")
|
179
|
-
.style("font", "10px sans-serif");
|
180
|
-
}
|
181
|
-
|
182
|
-
});
|
183
|
-
|
184
|
-
</script>
|
185
|
-
</body>
|
186
|
-
</html>
|
data/assets/index2.html
DELETED
@@ -1,224 +0,0 @@
|
|
1
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
2
|
-
<html lang="en">
|
3
|
-
<head>
|
4
|
-
<meta charset="utf-8">
|
5
|
-
<title>Force based label placement</title>
|
6
|
-
<!--
|
7
|
-
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?3.0.0"></script>
|
8
|
-
-->
|
9
|
-
<script src="http://d3js.org/d3.v3.js" charset="utf-8"></script>
|
10
|
-
</head>
|
11
|
-
<body>
|
12
|
-
<script type="text/javascript" charset="utf-8">
|
13
|
-
|
14
|
-
d3.csv("relationships", function(error, relationships) {
|
15
|
-
var w = 960, h = 500;
|
16
|
-
|
17
|
-
var labelDistance = 0;
|
18
|
-
|
19
|
-
var vis = d3.select("body").append("svg:svg").attr("width", w).attr("height", h);
|
20
|
-
|
21
|
-
var nodes = [];
|
22
|
-
var labelAnchors = [];
|
23
|
-
var labelAnchorLinks = [];
|
24
|
-
var links = [];
|
25
|
-
|
26
|
-
/* *
|
27
|
-
for(var i = 0; i < 4; i++) {
|
28
|
-
var node = {
|
29
|
-
label : "node " + i
|
30
|
-
};
|
31
|
-
nodes.push(node);
|
32
|
-
labelAnchors.push({
|
33
|
-
node : node
|
34
|
-
});
|
35
|
-
labelAnchors.push({
|
36
|
-
node : node
|
37
|
-
});
|
38
|
-
};
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
for(var i = 0; i < nodes.length; i++) {
|
43
|
-
for(var j = 0; j < i; j++) {
|
44
|
-
if(Math.random() > .5)
|
45
|
-
links.push({
|
46
|
-
source : i,
|
47
|
-
target : j,
|
48
|
-
weight : 1 //Math.random()
|
49
|
-
});
|
50
|
-
}
|
51
|
-
labelAnchorLinks.push({
|
52
|
-
source : i * 2,
|
53
|
-
target : i * 2 + 1,
|
54
|
-
weight : 1
|
55
|
-
});
|
56
|
-
};
|
57
|
-
|
58
|
-
links = [{
|
59
|
-
source : 0,
|
60
|
-
target : 1,
|
61
|
-
weight : 1 //Math.random()
|
62
|
-
},{
|
63
|
-
source : 0,
|
64
|
-
target : 2,
|
65
|
-
weight : 1 //Math.random()
|
66
|
-
},{
|
67
|
-
source : 0,
|
68
|
-
target : 3,
|
69
|
-
weight : 1 //Math.random()
|
70
|
-
}
|
71
|
-
|
72
|
-
];
|
73
|
-
/* */
|
74
|
-
|
75
|
-
/*
|
76
|
-
nodes
|
77
|
-
[{"label":"node 0"},{"label":"node 1"},{"label":"node 2"},{"label":"node 3"}]
|
78
|
-
links
|
79
|
-
[{"source":1,"target":0,"weight":0.5917420655023307},{"source":2,"target":0,"weight":0.8654833608306944},{"source":3,"target":0,"weight":0.0552730702329427},{"source":3,"target":2,"weight":0.2258284434210509}]
|
80
|
-
labelAnchorLinks
|
81
|
-
[{"source":0,"target":1,"weight":1},{"source":2,"target":3,"weight":1},{"source":4,"target":5,"weight":1},{"source":6,"target":7,"weight":1}]
|
82
|
-
labelAnchors
|
83
|
-
[{"node":{"label":"node 0"}},{"node":{"label":"node 0"}},{"node":{"label":"node 1"}},{"node":{"label":"node 1"}},{"node":{"label":"node 2"}},{"node":{"label":"node 2"}},{"node":{"label":"node 3"}},{"node":{"label":"node 3"}}]
|
84
|
-
|
85
|
-
|
86
|
-
nodes index2.html:136
|
87
|
-
[{"label":"Media Proposal Sync"},{"label":"Media Projects"},{"label":"Media Opportunity Events"},{"label":"Media Advertising"}] index2.html:137
|
88
|
-
links index2.html:138
|
89
|
-
[{"source":0,"target":1,"value":1},{"source":0,"target":2,"value":1},{"source":0,"target":3,"value":1}] index2.html:139
|
90
|
-
labelAnchorLinks index2.html:140
|
91
|
-
[{"source":0,"target":1,"weight":1},{"source":2,"target":3,"weight":1},{"source":4,"target":5,"weight":1},{"source":6,"target":7,"weight":1}] index2.html:141
|
92
|
-
labelAnchors index2.html:142
|
93
|
-
[{"node":{"label":"Media Proposal Sync"}},{"node":{"label":"Media Proposal Sync"}},{"node":{"label":"Media Projects"}},{"node":{"label":"Media Projects"}},{"node":{"label":"Media Opportunity Events"}},{"node":{"label":"Media Opportunity Events"}},{"node":{"label":"Media Advertising"}},{"node":{"label":"Media Advertising"}}]
|
94
|
-
|
95
|
-
JSON.stringify(nodes)
|
96
|
-
JSON.stringify(links)
|
97
|
-
JSON.stringify(labelAnchorLinks)
|
98
|
-
JSON.stringify(labelAnchors)
|
99
|
-
|
100
|
-
/* */
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
var allLabels = [];
|
105
|
-
|
106
|
-
relationships.forEach(function(relationship) {
|
107
|
-
allLabels.push(relationship.source);
|
108
|
-
allLabels.push(relationship.target);
|
109
|
-
});
|
110
|
-
|
111
|
-
var labels = d3.set(allLabels).values();
|
112
|
-
|
113
|
-
labels.forEach(function(label, i){
|
114
|
-
var node = {
|
115
|
-
label: label
|
116
|
-
};
|
117
|
-
nodes.push(node)
|
118
|
-
|
119
|
-
labelAnchors.push({
|
120
|
-
node : node
|
121
|
-
});
|
122
|
-
|
123
|
-
labelAnchors.push({
|
124
|
-
node : node
|
125
|
-
});
|
126
|
-
|
127
|
-
labelAnchorLinks.push({
|
128
|
-
source : i * 2,
|
129
|
-
target : i * 2 + 1,
|
130
|
-
weight : 1
|
131
|
-
});
|
132
|
-
});
|
133
|
-
|
134
|
-
links = relationships;
|
135
|
-
// Compute the distinct nodes from the links.
|
136
|
-
relationships.forEach(function(relationship, i) {
|
137
|
-
relationship.source = labels.indexOf(relationship.source);
|
138
|
-
relationship.target = labels.indexOf(relationship.target);;
|
139
|
-
relationship.value = +relationship.value;
|
140
|
-
});
|
141
|
-
|
142
|
-
|
143
|
-
var force = d3.layout.force().size([w, h]).nodes(nodes).links(links).gravity(1).linkDistance(100).charge(-3000).linkStrength(function(x) {
|
144
|
-
return x.weight * 10
|
145
|
-
});
|
146
|
-
|
147
|
-
|
148
|
-
force.start();
|
149
|
-
|
150
|
-
var force2 = d3.layout.force().nodes(labelAnchors).links(labelAnchorLinks).gravity(0).linkDistance(0).linkStrength(8).charge(-300).size([w, h]);
|
151
|
-
force2.start();
|
152
|
-
|
153
|
-
var link = vis.selectAll("line.link").data(links).enter().append("svg:line").attr("class", "link").style("stroke", "#CCC");
|
154
|
-
|
155
|
-
var node = vis.selectAll("g.node").data(force.nodes()).enter().append("svg:g").attr("class", "node");
|
156
|
-
node.append("svg:circle").attr("r", 5).style("fill", "#555").style("stroke", "#FFF").style("stroke-width", 3);
|
157
|
-
node.call(force.drag);
|
158
|
-
|
159
|
-
|
160
|
-
var anchorLink = vis.selectAll("line.anchorLink").data(labelAnchorLinks)//.enter().append("svg:line").attr("class", "anchorLink").style("stroke", "#999");
|
161
|
-
|
162
|
-
var anchorNode = vis.selectAll("g.anchorNode").data(force2.nodes()).enter().append("svg:g").attr("class", "anchorNode");
|
163
|
-
anchorNode.append("svg:circle").attr("r", 0).style("fill", "#FFF");
|
164
|
-
anchorNode.append("svg:text").text(function(d, i) {
|
165
|
-
return i % 2 == 0 ? "" : d.node.label
|
166
|
-
}).style("fill", "#555").style("font-family", "Arial").style("font-size", 12);
|
167
|
-
|
168
|
-
var updateLink = function() {
|
169
|
-
this.attr("x1", function(d) {
|
170
|
-
return d.source.x;
|
171
|
-
}).attr("y1", function(d) {
|
172
|
-
return d.source.y;
|
173
|
-
}).attr("x2", function(d) {
|
174
|
-
return d.target.x;
|
175
|
-
}).attr("y2", function(d) {
|
176
|
-
return d.target.y;
|
177
|
-
});
|
178
|
-
|
179
|
-
}
|
180
|
-
|
181
|
-
var updateNode = function() {
|
182
|
-
this.attr("transform", function(d) {
|
183
|
-
return "translate(" + d.x + "," + d.y + ")";
|
184
|
-
});
|
185
|
-
|
186
|
-
}
|
187
|
-
|
188
|
-
|
189
|
-
force.on("tick", function() {
|
190
|
-
|
191
|
-
force2.start();
|
192
|
-
|
193
|
-
node.call(updateNode);
|
194
|
-
|
195
|
-
anchorNode.each(function(d, i) {
|
196
|
-
if(i % 2 == 0) {
|
197
|
-
d.x = d.node.x;
|
198
|
-
d.y = d.node.y;
|
199
|
-
} else {
|
200
|
-
var b = this.childNodes[1].getBBox();
|
201
|
-
|
202
|
-
var diffX = d.x - d.node.x;
|
203
|
-
var diffY = d.y - d.node.y;
|
204
|
-
|
205
|
-
var dist = Math.sqrt(diffX * diffX + diffY * diffY);
|
206
|
-
|
207
|
-
var shiftX = b.width * (diffX - dist) / (dist * 2);
|
208
|
-
shiftX = Math.max(-b.width, Math.min(0, shiftX));
|
209
|
-
var shiftY = 5;
|
210
|
-
this.childNodes[1].setAttribute("transform", "translate(" + shiftX + "," + shiftY + ")");
|
211
|
-
}
|
212
|
-
});
|
213
|
-
|
214
|
-
|
215
|
-
anchorNode.call(updateNode);
|
216
|
-
|
217
|
-
link.call(updateLink);
|
218
|
-
anchorLink.call(updateLink);
|
219
|
-
|
220
|
-
});
|
221
|
-
});
|
222
|
-
</script>
|
223
|
-
</body>
|
224
|
-
</html>
|
data/assets/relationships
DELETED
@@ -1,387 +0,0 @@
|
|
1
|
-
body {
|
2
|
-
font-family: Helvetica, arial, sans-serif;
|
3
|
-
font-size: 14px;
|
4
|
-
line-height: 1.6;
|
5
|
-
padding-top: 10px;
|
6
|
-
padding-bottom: 10px;
|
7
|
-
background-color: white;
|
8
|
-
padding: 30px;
|
9
|
-
color: #333;
|
10
|
-
}
|
11
|
-
|
12
|
-
body > *:first-child {
|
13
|
-
margin-top: 0 !important;
|
14
|
-
}
|
15
|
-
|
16
|
-
body > *:last-child {
|
17
|
-
margin-bottom: 0 !important;
|
18
|
-
}
|
19
|
-
|
20
|
-
a {
|
21
|
-
color: #4183C4;
|
22
|
-
text-decoration: none;
|
23
|
-
}
|
24
|
-
|
25
|
-
a.absent {
|
26
|
-
color: #cc0000;
|
27
|
-
}
|
28
|
-
|
29
|
-
a.anchor {
|
30
|
-
display: block;
|
31
|
-
padding-left: 30px;
|
32
|
-
margin-left: -30px;
|
33
|
-
cursor: pointer;
|
34
|
-
position: absolute;
|
35
|
-
top: 0;
|
36
|
-
left: 0;
|
37
|
-
bottom: 0;
|
38
|
-
}
|
39
|
-
|
40
|
-
h1, h2, h3, h4, h5, h6 {
|
41
|
-
margin: 20px 0 10px;
|
42
|
-
padding: 0;
|
43
|
-
font-weight: bold;
|
44
|
-
-webkit-font-smoothing: antialiased;
|
45
|
-
cursor: text;
|
46
|
-
position: relative;
|
47
|
-
}
|
48
|
-
|
49
|
-
h2:first-child, h1:first-child, h1:first-child + h2, h3:first-child, h4:first-child, h5:first-child, h6:first-child {
|
50
|
-
margin-top: 0;
|
51
|
-
padding-top: 0;
|
52
|
-
}
|
53
|
-
|
54
|
-
h1:hover a.anchor, h2:hover a.anchor, h3:hover a.anchor, h4:hover a.anchor, h5:hover a.anchor, h6:hover a.anchor {
|
55
|
-
text-decoration: none;
|
56
|
-
}
|
57
|
-
|
58
|
-
h1 tt, h1 code {
|
59
|
-
font-size: inherit;
|
60
|
-
}
|
61
|
-
|
62
|
-
h2 tt, h2 code {
|
63
|
-
font-size: inherit;
|
64
|
-
}
|
65
|
-
|
66
|
-
h3 tt, h3 code {
|
67
|
-
font-size: inherit;
|
68
|
-
}
|
69
|
-
|
70
|
-
h4 tt, h4 code {
|
71
|
-
font-size: inherit;
|
72
|
-
}
|
73
|
-
|
74
|
-
h5 tt, h5 code {
|
75
|
-
font-size: inherit;
|
76
|
-
}
|
77
|
-
|
78
|
-
h6 tt, h6 code {
|
79
|
-
font-size: inherit;
|
80
|
-
}
|
81
|
-
|
82
|
-
h1 {
|
83
|
-
font-size: 28px;
|
84
|
-
color: black;
|
85
|
-
}
|
86
|
-
|
87
|
-
h2 {
|
88
|
-
font-size: 24px;
|
89
|
-
border-bottom: 1px solid #cccccc;
|
90
|
-
color: black;
|
91
|
-
}
|
92
|
-
|
93
|
-
h3 {
|
94
|
-
font-size: 18px;
|
95
|
-
}
|
96
|
-
|
97
|
-
h4 {
|
98
|
-
font-size: 16px;
|
99
|
-
}
|
100
|
-
|
101
|
-
h5 {
|
102
|
-
font-size: 14px;
|
103
|
-
}
|
104
|
-
|
105
|
-
h6 {
|
106
|
-
color: #777777;
|
107
|
-
font-size: 14px;
|
108
|
-
}
|
109
|
-
|
110
|
-
p, blockquote, ul, ol, dl, li, table, pre {
|
111
|
-
margin: 15px 0;
|
112
|
-
}
|
113
|
-
|
114
|
-
hr {
|
115
|
-
background: transparent url("http://tinyurl.com/bq5kskr") repeat-x 0 0;
|
116
|
-
border: 0 none;
|
117
|
-
color: #cccccc;
|
118
|
-
height: 4px;
|
119
|
-
padding: 0;
|
120
|
-
}
|
121
|
-
|
122
|
-
body > h2:first-child {
|
123
|
-
margin-top: 0;
|
124
|
-
padding-top: 0;
|
125
|
-
}
|
126
|
-
|
127
|
-
body > h1:first-child {
|
128
|
-
margin-top: 0;
|
129
|
-
padding-top: 0;
|
130
|
-
}
|
131
|
-
|
132
|
-
body > h1:first-child + h2 {
|
133
|
-
margin-top: 0;
|
134
|
-
padding-top: 0;
|
135
|
-
}
|
136
|
-
|
137
|
-
body > h3:first-child, body > h4:first-child, body > h5:first-child, body > h6:first-child {
|
138
|
-
margin-top: 0;
|
139
|
-
padding-top: 0;
|
140
|
-
}
|
141
|
-
|
142
|
-
a:first-child h1, a:first-child h2, a:first-child h3, a:first-child h4, a:first-child h5, a:first-child h6 {
|
143
|
-
margin-top: 0;
|
144
|
-
padding-top: 0;
|
145
|
-
}
|
146
|
-
|
147
|
-
h1 p, h2 p, h3 p, h4 p, h5 p, h6 p {
|
148
|
-
margin-top: 0;
|
149
|
-
}
|
150
|
-
|
151
|
-
li p.first {
|
152
|
-
display: inline-block;
|
153
|
-
}
|
154
|
-
|
155
|
-
ul, ol {
|
156
|
-
padding-left: 30px;
|
157
|
-
}
|
158
|
-
|
159
|
-
ul :first-child, ol :first-child {
|
160
|
-
margin-top: 0;
|
161
|
-
}
|
162
|
-
|
163
|
-
ul :last-child, ol :last-child {
|
164
|
-
margin-bottom: 0;
|
165
|
-
}
|
166
|
-
|
167
|
-
dl {
|
168
|
-
padding: 0;
|
169
|
-
}
|
170
|
-
|
171
|
-
dl dt {
|
172
|
-
font-size: 14px;
|
173
|
-
font-weight: bold;
|
174
|
-
font-style: italic;
|
175
|
-
padding: 0;
|
176
|
-
margin: 15px 0 5px;
|
177
|
-
}
|
178
|
-
|
179
|
-
dl dt:first-child {
|
180
|
-
padding: 0;
|
181
|
-
}
|
182
|
-
|
183
|
-
dl dt > :first-child {
|
184
|
-
margin-top: 0;
|
185
|
-
}
|
186
|
-
|
187
|
-
dl dt > :last-child {
|
188
|
-
margin-bottom: 0;
|
189
|
-
}
|
190
|
-
|
191
|
-
dl dd {
|
192
|
-
margin: 0 0 15px;
|
193
|
-
padding: 0 15px;
|
194
|
-
}
|
195
|
-
|
196
|
-
dl dd > :first-child {
|
197
|
-
margin-top: 0;
|
198
|
-
}
|
199
|
-
|
200
|
-
dl dd > :last-child {
|
201
|
-
margin-bottom: 0;
|
202
|
-
}
|
203
|
-
|
204
|
-
blockquote {
|
205
|
-
border-left: 4px solid #dddddd;
|
206
|
-
padding: 0 15px;
|
207
|
-
color: #777777;
|
208
|
-
}
|
209
|
-
|
210
|
-
blockquote > :first-child {
|
211
|
-
margin-top: 0;
|
212
|
-
}
|
213
|
-
|
214
|
-
blockquote > :last-child {
|
215
|
-
margin-bottom: 0;
|
216
|
-
}
|
217
|
-
|
218
|
-
table {
|
219
|
-
padding: 0;
|
220
|
-
}
|
221
|
-
table tr {
|
222
|
-
border-top: 1px solid #cccccc;
|
223
|
-
background-color: white;
|
224
|
-
margin: 0;
|
225
|
-
padding: 0;
|
226
|
-
}
|
227
|
-
|
228
|
-
table tr:nth-child(2n) {
|
229
|
-
background-color: #f8f8f8;
|
230
|
-
}
|
231
|
-
|
232
|
-
table tr th {
|
233
|
-
font-weight: bold;
|
234
|
-
border: 1px solid #cccccc;
|
235
|
-
text-align: left;
|
236
|
-
margin: 0;
|
237
|
-
padding: 6px 13px;
|
238
|
-
}
|
239
|
-
|
240
|
-
table tr td {
|
241
|
-
border: 1px solid #cccccc;
|
242
|
-
text-align: left;
|
243
|
-
margin: 0;
|
244
|
-
padding: 6px 13px;
|
245
|
-
}
|
246
|
-
|
247
|
-
table tr th :first-child, table tr td :first-child {
|
248
|
-
margin-top: 0;
|
249
|
-
}
|
250
|
-
|
251
|
-
table tr th :last-child, table tr td :last-child {
|
252
|
-
margin-bottom: 0;
|
253
|
-
}
|
254
|
-
|
255
|
-
img {
|
256
|
-
max-width: 100%;
|
257
|
-
}
|
258
|
-
|
259
|
-
span.frame {
|
260
|
-
display: block;
|
261
|
-
overflow: hidden;
|
262
|
-
}
|
263
|
-
|
264
|
-
span.frame > span {
|
265
|
-
border: 1px solid #dddddd;
|
266
|
-
display: block;
|
267
|
-
float: left;
|
268
|
-
overflow: hidden;
|
269
|
-
margin: 13px 0 0;
|
270
|
-
padding: 7px;
|
271
|
-
width: auto;
|
272
|
-
}
|
273
|
-
|
274
|
-
span.frame span img {
|
275
|
-
display: block;
|
276
|
-
float: left;
|
277
|
-
}
|
278
|
-
|
279
|
-
span.frame span span {
|
280
|
-
clear: both;
|
281
|
-
color: #333333;
|
282
|
-
display: block;
|
283
|
-
padding: 5px 0 0;
|
284
|
-
}
|
285
|
-
|
286
|
-
span.align-center {
|
287
|
-
display: block;
|
288
|
-
overflow: hidden;
|
289
|
-
clear: both;
|
290
|
-
}
|
291
|
-
|
292
|
-
span.align-center > span {
|
293
|
-
display: block;
|
294
|
-
overflow: hidden;
|
295
|
-
margin: 13px auto 0;
|
296
|
-
text-align: center;
|
297
|
-
}
|
298
|
-
|
299
|
-
span.align-center span img {
|
300
|
-
margin: 0 auto;
|
301
|
-
text-align: center;
|
302
|
-
}
|
303
|
-
|
304
|
-
span.align-right {
|
305
|
-
display: block;
|
306
|
-
overflow: hidden;
|
307
|
-
clear: both;
|
308
|
-
}
|
309
|
-
|
310
|
-
span.align-right > span {
|
311
|
-
display: block;
|
312
|
-
overflow: hidden;
|
313
|
-
margin: 13px 0 0;
|
314
|
-
text-align: right;
|
315
|
-
}
|
316
|
-
|
317
|
-
span.align-right span img {
|
318
|
-
margin: 0;
|
319
|
-
text-align: right;
|
320
|
-
}
|
321
|
-
|
322
|
-
span.float-left {
|
323
|
-
display: block;
|
324
|
-
margin-right: 13px;
|
325
|
-
overflow: hidden;
|
326
|
-
float: left;
|
327
|
-
}
|
328
|
-
|
329
|
-
span.float-left span {
|
330
|
-
margin: 13px 0 0;
|
331
|
-
}
|
332
|
-
|
333
|
-
span.float-right {
|
334
|
-
display: block;
|
335
|
-
margin-left: 13px;
|
336
|
-
overflow: hidden;
|
337
|
-
float: right;
|
338
|
-
}
|
339
|
-
|
340
|
-
span.float-right > span {
|
341
|
-
display: block;
|
342
|
-
overflow: hidden;
|
343
|
-
margin: 13px auto 0;
|
344
|
-
text-align: right;
|
345
|
-
}
|
346
|
-
|
347
|
-
code, tt {
|
348
|
-
margin: 0 2px;
|
349
|
-
padding: 0 5px;
|
350
|
-
white-space: nowrap;
|
351
|
-
border: 1px solid #eaeaea;
|
352
|
-
background-color: #f8f8f8;
|
353
|
-
border-radius: 3px;
|
354
|
-
}
|
355
|
-
|
356
|
-
pre code {
|
357
|
-
margin: 0;
|
358
|
-
padding: 0;
|
359
|
-
white-space: pre;
|
360
|
-
border: none;
|
361
|
-
background: transparent;
|
362
|
-
}
|
363
|
-
|
364
|
-
.highlight pre {
|
365
|
-
background-color: #f8f8f8;
|
366
|
-
border: 1px solid #cccccc;
|
367
|
-
font-size: 13px;
|
368
|
-
line-height: 19px;
|
369
|
-
overflow: auto;
|
370
|
-
padding: 6px 10px;
|
371
|
-
border-radius: 3px;
|
372
|
-
}
|
373
|
-
|
374
|
-
pre {
|
375
|
-
background-color: #f8f8f8;
|
376
|
-
border: 1px solid #cccccc;
|
377
|
-
font-size: 13px;
|
378
|
-
line-height: 19px;
|
379
|
-
overflow: auto;
|
380
|
-
padding: 6px 10px;
|
381
|
-
border-radius: 3px;
|
382
|
-
}
|
383
|
-
|
384
|
-
pre code, pre tt {
|
385
|
-
background-color: transparent;
|
386
|
-
border: none;
|
387
|
-
}
|