This repository has been archived by the owner on Jun 22, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathindex.html
177 lines (143 loc) · 7.89 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>🔎🚢 Stevedore: A tool for exploring document sets</title>
<script type="text/javascript">window.Stevedore = {};</script>
<script src="app/config.js?_cachebuster=201705041358" type="text/javascript"></script>
<script src="lib/js/jquery-2.1.3.min.js" type="text/javascript"></script>
<script src="lib/js/underscore-min.js" type="text/javascript"></script>
<script src="lib/js/elasticsearch-js/elasticsearch.min.js" type="text/javascript"></script>
<script src="lib/js/elasticsearch-js/elasticsearch.jquery.min.js" type="text/javascript"></script>
<script src="lib/js/backbone-min.js" type="text/javascript"></script>
<script src="lib/js/js-yaml.min.js" type="text/javascript"></script>
<script src="lib/js/adcom.min.js" type="text/javascript"></script>
<script src="lib/js/bootstrap.min.js" type="text/javascript"></script>
<script src="app/app.js?_cachebuster=201705041358" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" media="screen" href="lib/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" media="screen" href="lib/css/adcom.min.css" />
<link href="app/css/app.css" type="text/css" rel="stylesheet" />
</head>
<body>
<div class="navbar navbar-default navbar-nyt-default navbar-nyt-primary">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="/">Stevedore</a>
</div>
<ul class="nav navbar-nav navbar-left">
<li class="navbar-summary"><span>A tool for exploring document sets</span></li>
</ul>
<ul class="nav navbar-nav navbar-right navbar-bits">
<!-- <li><a href="#">About</a></li>
<li><a href="#">Support</a></li>
<li><a href="#">Roadmap</a></li>
--> </ul>
</div>
</div>
<div class="container">
<div id="tools-list" class="row section" style="margin-left:20px;">
<div id="loading" class="row loading" data-loading-msg="Getting lists of document sets ..."></div>
</div>
</div>
</div><!-- /.container -->
<footer class="footer">
<div class="container tool-credit">
<p>An <a href="http://github.com/newsdev/stevedore">open-source project</a> by Jeremy B. Merrill, The New York Times and <em>Contributors Like You<em></p>
</div>
</footer>
<script type="text/template" id="document-set-template">
<div class="row tool">
<h4 style="float:left;">
<a href="{{= Stevedore.config.use_slash_based_routing ? '/search/' : 'search.html#'}}{{= set }}">{{= name }}</a></h4>
<!-- <span style="float:left; margin-top:5px; margin-left: 10px; font-size:10px;">
</span> -->
<p>{{= desc }}</p>
{{ if (samplesearches != '') { }}
<h5 style="margin-top:20px;">Sample searches</h5>
<ul>
{{ _(samplesearches).each(function(search){ }}
<li><a href="{{= Stevedore.config.use_slash_based_routing ? '/search/' : 'search.html#'}}{{= set }}/search/{{= search.search }}">{{= search.name }}</a></li>
{{ }) }}
</ul>
</div>
{{ } }}
</script>
<script type="text/template" id="group-template">
<div class="drawer group-{{= index}}">
<a class="drawer-toggle {{= index == 0 ? '' : 'collapsed'}}" data-toggle="collapse" href="#drawer-content-{{= index }}">
<div class="container">
<span class="drawer-visible-on-out"><span class="group">{{= String(group_name) }}</span> <span class="text-muted">(Click to show)</span></span>
<span class="drawer-visible-on-in"><span class="group">{{= String(group_name) }}</span> <span class="text-muted">(Click to hide)</span></span>
<span class="vee"></span>
</div>
</a>
<div id="drawer-content-{{= index }}" class="drawer-content {{= index == 0 ? '' : 'collapse'}}">
<div class="container">
</div>
</div>
</div>
</script>
<script type="text/javascript">
var name_for_group_of_orphaned_document_sets = "Document sets that aren\'t ready yet (Ask first...)"
function render(){
var template_func = _.template($('#document-set-template').html())
$('#tools-list').empty();
function renderSet(set, groupClass){
var default_obj = {
desc: '<span class="red">Caution!</span> No description yet. This document set may not be ready -- so it might be mislabeled, incomplete, wrong or just not what you think it is.',
name: 'Unnamed: ' + set,
set: set,
samplesearches: []
}
var set_metadata = _.extend(default_obj, Stevedore.document_set_metadata[set]);
if(typeof groupClass !== 'undefined'){
$('#tools-list .' + groupClass + ' .drawer-content .container').append(template_func(set_metadata));
}else{
$('#tools-list').append(template_func(set_metadata));
}
}
_(Stevedore.document_set_metadata).chain()
.groupBy(function(key_and_obj){ return key_and_obj["group"]; })
.pairs()
.sortBy(function(key_and_obj){return parseInt(Stevedore.document_set_groups[key_and_obj[0]] || 123456); })
.map(function(group_name_and_docsets){
var group_name = group_name_and_docsets[0];
var list_of_document_sets = group_name_and_docsets[1];
list_of_document_sets = _(list_of_document_sets).reject(function(metadata){
var index_name = metadata["index_name"];
// don't render document sets with no name (or a name identical to the index name) yet -- they'll be rendered when we loop through Stevedore.document_sets (which is the list of indexes in ES)
if((typeof metadata["name"] === "undefined") || (metadata["name"] == index_name) && group_name != name_for_group_of_orphaned_document_sets) return true;
// if the metadata entry doesn't exist in the list of indexes in ElasticSearch (and therefore it probably lives on a different ElasticSearch), so don't render it.
if(Stevedore.document_sets.indexOf(index_name) == -1 && group_name != name_for_group_of_orphaned_document_sets) return true;
// if it has some metadata, but no title, don't render it yet.
return false;
})
return [group_name, list_of_document_sets];
})
.filter(function(group_name_and_list_of_document_sets){ return group_name_and_list_of_document_sets[1].length })
.each(renderGroupOfDocumentSets);
function renderGroupOfDocumentSets(group_name_list_of_document_sets, group_index){
var group_name = group_name_list_of_document_sets[0];
var list_of_document_sets = group_name_list_of_document_sets[1];
var group_template_func = _.template($('#group-template').html());
$('#tools-list').append(group_template_func({'group_name': group_name, 'index': group_index}))
_(list_of_document_sets).each(function(metadata){
// first render out the document sets with metadata and descriptions
// then remove them from the list...
var index_name = metadata['index_name'];
var indexToRemove = Stevedore.document_sets.indexOf(index_name);
if (indexToRemove != -1) Stevedore.document_sets.splice(indexToRemove, 1);
if(metadata["private?"] == "TRUE") return true;
renderSet(index_name, 'group-' + group_index.toString());
})
}
// we removed all the ones that had metadata from Stevedore.document_sets. (with `splice`, above)
// so that now we can render out the unloved, unmetadataed orphan document sets
var orphaned_document_sets = _(Stevedore.document_sets).map(function(index_name){ return {index_name: index_name, name: index_name} })
if(orphaned_document_sets.length)
renderGroupOfDocumentSets([name_for_group_of_orphaned_document_sets, orphaned_document_sets], 1234567);
}
Stevedore.get_config(render);
</script>
</body>
</html>