Compare commits
No commits in common. "1d3eb5f37869227726acfc044d68043df44c7773" and "953f308621ae17895f414399671b3606bade7967" have entirely different histories.
1d3eb5f378
...
953f308621
5 changed files with 22 additions and 54 deletions
5
static/ontology/d3.v3.min.js
vendored
5
static/ontology/d3.v3.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -1,8 +1,3 @@
|
||||||
body {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.node circle {
|
.node circle {
|
||||||
fill: #fff;
|
fill: #fff;
|
||||||
stroke: steelblue;
|
stroke: steelblue;
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<script src="d3.v3.min.js"></script>
|
<script src="https://d3js.org/d3.v3.min.js"></script>
|
||||||
<link rel="stylesheet" href="index.css" type="text/css">
|
<link rel="stylesheet" href="index.css">
|
||||||
<title>Ontology Tree</title>
|
<title>Ontology Tree</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,6 @@
|
||||||
var margin = {
|
var margin = {top: 20, right: 120, bottom: 20, left: 120},
|
||||||
top: 20,
|
width = 1200 - margin.right - margin.left,
|
||||||
right: 120,
|
height = 4000 - margin.top - margin.bottom;
|
||||||
bottom: 20,
|
|
||||||
left: 120
|
|
||||||
},
|
|
||||||
width = 3000 - margin.right - margin.left,
|
|
||||||
height = window.innerHeight - margin.top - margin.bottom;
|
|
||||||
|
|
||||||
var i = 0,
|
var i = 0,
|
||||||
duration = 750,
|
duration = 750,
|
||||||
|
|
@ -18,13 +13,13 @@ var diagonal = d3.svg.diagonal()
|
||||||
.projection(function(d) { return [d.y, d.x]; });
|
.projection(function(d) { return [d.y, d.x]; });
|
||||||
|
|
||||||
var svg = d3.select("body").append("svg")
|
var svg = d3.select("body").append("svg")
|
||||||
.attr("width", width)
|
.attr("width", "100%")
|
||||||
.attr("height", height + margin.top + margin.bottom)
|
.attr("height", height + margin.top + margin.bottom)
|
||||||
.append("g")
|
.append("g")
|
||||||
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
|
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
|
||||||
|
|
||||||
d3.json("sized_ontology.json", function(error, nodes) {
|
d3.json("sized_ontology.json", function(error, flare) {
|
||||||
root = nodes;
|
root = flare;
|
||||||
root.x0 = height / 2;
|
root.x0 = height / 2;
|
||||||
root.y0 = 0;
|
root.y0 = 0;
|
||||||
|
|
||||||
|
|
@ -45,11 +40,7 @@ d3.json("sized_ontology.json", function(error, nodes) {
|
||||||
update(root);
|
update(root);
|
||||||
});
|
});
|
||||||
|
|
||||||
function resize() {
|
d3.select(self.frameElement).style("height", "800px");
|
||||||
root.x0 = height / 2;
|
|
||||||
root.y0 = 0;
|
|
||||||
update(root);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function get_color(d) {
|
function get_color(d) {
|
||||||
|
|
@ -69,16 +60,12 @@ function update(source) {
|
||||||
|
|
||||||
// Update the nodes…
|
// Update the nodes…
|
||||||
var node = svg.selectAll("g.node")
|
var node = svg.selectAll("g.node")
|
||||||
.data(nodes, function(d) {
|
.data(nodes, function(d) { return d.id || (d.id = ++i); });
|
||||||
return d.id || (d.id = ++i);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Enter any new nodes at the parent's previous position.
|
// Enter any new nodes at the parent's previous position.
|
||||||
var nodeEnter = node.enter().append("g")
|
var nodeEnter = node.enter().append("g")
|
||||||
.attr("class", "node")
|
.attr("class", "node")
|
||||||
.attr("transform", function(d) {
|
.attr("transform", function(d) { return "translate(" + source.y0 + "," + source.x0 + ")"; })
|
||||||
return "translate(" + source.y0 + "," + source.x0 + ")";
|
|
||||||
})
|
|
||||||
.on("click", click);
|
.on("click", click);
|
||||||
|
|
||||||
nodeEnter.append("circle")
|
nodeEnter.append("circle")
|
||||||
|
|
@ -86,13 +73,9 @@ function update(source) {
|
||||||
.style("fill", get_color)
|
.style("fill", get_color)
|
||||||
|
|
||||||
nodeEnter.append("text")
|
nodeEnter.append("text")
|
||||||
.attr("x", function(d) {
|
.attr("x", function(d) { return d.children || d._children ? -10 : 10; })
|
||||||
return d.children || d._children ? -10 : 10;
|
|
||||||
})
|
|
||||||
.attr("dy", ".35em")
|
.attr("dy", ".35em")
|
||||||
.attr("text-anchor", function(d) {
|
.attr("text-anchor", function(d) { return d.children || d._children ? "end" : "start"; })
|
||||||
return d.children || d._children ? "end" : "start";
|
|
||||||
})
|
|
||||||
.text(function(d) {
|
.text(function(d) {
|
||||||
if (d.children || d._children) {
|
if (d.children || d._children) {
|
||||||
return d.name;
|
return d.name;
|
||||||
|
|
@ -105,9 +88,7 @@ function update(source) {
|
||||||
// Transition nodes to their new position.
|
// Transition nodes to their new position.
|
||||||
var nodeUpdate = node.transition()
|
var nodeUpdate = node.transition()
|
||||||
.duration(duration)
|
.duration(duration)
|
||||||
.attr("transform", function(d) {
|
.attr("transform", function(d) { return "translate(" + d.y + "," + d.x + ")"; });
|
||||||
return "translate(" + d.y + "," + d.x + ")";
|
|
||||||
});
|
|
||||||
|
|
||||||
nodeUpdate.select("circle")
|
nodeUpdate.select("circle")
|
||||||
.attr("r", 4.5)
|
.attr("r", 4.5)
|
||||||
|
|
@ -119,9 +100,7 @@ function update(source) {
|
||||||
// Transition exiting nodes to the parent's new position.
|
// Transition exiting nodes to the parent's new position.
|
||||||
var nodeExit = node.exit().transition()
|
var nodeExit = node.exit().transition()
|
||||||
.duration(duration)
|
.duration(duration)
|
||||||
.attr("transform", function(d) {
|
.attr("transform", function(d) { return "translate(" + source.y + "," + source.x + ")"; })
|
||||||
return "translate(" + source.y + "," + source.x + ")";
|
|
||||||
})
|
|
||||||
.remove();
|
.remove();
|
||||||
|
|
||||||
nodeExit.select("circle")
|
nodeExit.select("circle")
|
||||||
|
|
@ -132,9 +111,7 @@ function update(source) {
|
||||||
|
|
||||||
// Update the links…
|
// Update the links…
|
||||||
var link = svg.selectAll("path.link")
|
var link = svg.selectAll("path.link")
|
||||||
.data(links, function(d) {
|
.data(links, function(d) { return d.target.id; });
|
||||||
return d.target.id;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Enter any new links at the parent's previous position.
|
// Enter any new links at the parent's previous position.
|
||||||
link.enter().insert("path", "g")
|
link.enter().insert("path", "g")
|
||||||
|
|
@ -181,7 +158,7 @@ function click(d) {
|
||||||
url = '/clip/created/keywords==' + d.name
|
url = '/clip/created/keywords==' + d.name
|
||||||
}
|
}
|
||||||
window.open(url, '_blank');
|
window.open(url, '_blank');
|
||||||
} else {
|
|
||||||
update(d);
|
|
||||||
}
|
}
|
||||||
|
update(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
3
tasks.py
3
tasks.py
|
|
@ -8,9 +8,10 @@ from celery.task import periodic_task
|
||||||
def subtitles_user(**kwargs):
|
def subtitles_user(**kwargs):
|
||||||
import annotation.models
|
import annotation.models
|
||||||
from user.models import User
|
from user.models import User
|
||||||
u = User.objects.get(username='subtitles')
|
u = User.object.get(username='subtitles')
|
||||||
annotation.models.Annotation.objects.filter(layer='subtitles').exclude(user=u).update(user=u)
|
annotation.models.Annotation.objects.filter(layer='subtitles').exclude(user=u).update(user=u)
|
||||||
|
|
||||||
|
|
||||||
t = datetime.now() - annotation.models.Annotation.objects.all().order_by('-created')[0].created
|
t = datetime.now() - annotation.models.Annotation.objects.all().order_by('-created')[0].created
|
||||||
if t < timedelta(hours=1):
|
if t < timedelta(hours=1):
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue