├── .gitignore
├── .jshintrc
├── CHANGELOG
├── LICENSE
├── README.md
├── app.js
├── css
├── app.css
└── main.css
├── debug.html
├── directives
└── quickHelp
│ ├── quickHelp.html
│ └── quickHelp.js
├── favicon.ico
├── imgs
├── banner.svg
└── icons.svg
├── index.html
├── js
├── timeline.js
└── wdq-mode.js
├── package.json
├── planning.md
├── sample.svg
├── services
├── urlParamManager.js
├── userSettings.js
├── wdqSamples.js
└── wikidata.js
├── toolinfo.json
└── views
├── newTimelineView
├── newTimelineView.html
└── newTimelineView.js
├── staticSampleView
├── staticSampleView.html
└── staticSampleView.js
└── timelineView
├── timelineView.html
└── timelineView.js
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 |
--------------------------------------------------------------------------------
/.jshintrc:
--------------------------------------------------------------------------------
1 | {
2 | "browser": true,
3 | "predef": [ "angular", "d3", "$", "console", "CodeMirror" ]
4 | }
5 |
--------------------------------------------------------------------------------
/CHANGELOG:
--------------------------------------------------------------------------------
1 | 1.2.1: Update dependencies
2 | Switch from bower to node for dependency management
3 | 1.2.0: SPARQL url parameter support
4 | 1.0.0: First release
5 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Drini Cami
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 | View it live here: https://tools.wmflabs.org/wikidata-timeline/
3 |
4 | Web app for visualizing Wikidata items in the form of a timeline.
5 |
6 |
7 | Developed on/for Chrome 44+. Firefox/IE also tested to be stable, but might have some issues.
8 |
9 | When using WDQ, these properties are used for determining time:
10 | * startTime: 'P577', 'P580', 'P569', 'P571'
11 | * endTime: 'P577', 'P582', 'P570', 'P576'
12 |
13 | If endTime is missing, applies a default value (see the `defaultEndTime` url parameter).
14 | If startTime = endTime, displayed as a point.
15 | Performs rounding when endtime is 'someValue'.
16 |
17 | # URL Params
18 | Valid on the [timeline view](https://tools.wmflabs.org/wikidata-timeline/#/timeline) and the [new view](https://tools.wmflabs.org/wikidata-timeline/#/new).
19 |
20 | Note: Boolean parameters are true for any value which is not "false".
21 |
22 | Name | Type | Default | Description
23 | -------------------- | ----------- | --------------- | -------------
24 | title | String | Untitled | Timeline's title. Useful so that your browser's history doesn't display the same thing for different timelines.
25 | sparql | String | | The SPARQL Query to use for the visualization. Expects the 1st variable to be items, 2nd to be labels, 3rd to be start time, and 4th to be end time (optional; see `defaultEndTime` parameter)). Try it/learn more at [Wikidata Query Service](https://query.wikidata.org).
26 | wdq | String | | The Wikidata Query from which to get items. See [WDQ's Documentation](https://wdq.wmflabs.org/api_documentation.html) for help. Note this is translated to SPARQL using [WDQ2SPARQL](http://tools.wmflabs.org/wdq2sparql/w2s.php), so some features might not be available.
27 | defaultEndTime | String | now | One of "now" or "start".
(also useful for resolving ``P571(inception)`` ambiguity).
28 | embed | Boolean | false | If true, optimizes view for embedding in an iframe.
29 | widthOfYear | Number | widthOfYear | How many pixels wide a year should be on the timeline
30 |
31 | ## WDQ URL Params
32 | The url parameters work if the `wdq` is present.
33 |
34 | Name | Type | Default | Description
35 | -------------------- | ----------- | --------------- | -------------
36 | languages | CSV | en,fr | The languages to use, ordered by preference. If no label in the given lang(s), stays blank
37 | sitelink | String | wikidata | What an item links to when clicked. Language determined by ``languages``. Possible values: ``[ 'wikisource', 'commonswiki', 'wikibooks', 'wikiquote', 'wiki', 'wikinews', 'wikidata' ]``
38 | sitelinkFallback | Boolean | true | If true, when the desired sitelink is not available, links to wikidata. If false, links to nothing.
39 |
40 | ## Deprecated URL Params
41 | Please do not use these parameters.
42 | - `query`: Now an alias for `wdq`
43 |
44 | # Credits
45 |
46 | ## Services/APIs
47 | * [WDQ2SPARQL](http://tools.wmflabs.org/wdq2sparql/w2s.php)
48 | * [Wikidata API](https://www.wikidata.org/w/api.php)
49 | * [Wikidata Query](https://wdq.wmflabs.org/api_documentation.html)
50 | * [Wikidata Query Service SPARQL Endpoint](https://www.mediawiki.org/wiki/Wikidata_query_service/User_Manual#SPARQL_endpoint)
51 |
52 | ## Libraries
53 | * [AngularJS](https://github.com/angular/angular.js)
54 | * [Bootstrap](https://github.com/twbs/bootstrap)
55 | * [Codemirror](https://github.com/codemirror/CodeMirror)
56 | * [D3](https://github.com/mbostock/d3)
57 | * [jQuery](https://github.com/jquery/jquery)
58 |
--------------------------------------------------------------------------------
/app.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | // Declare app level module which depends on views, and components
4 | angular.module('wikidataTimeline', [
5 | 'ngRoute',
6 | 'wikidataTimeline.newTimelineView',
7 | 'wikidataTimeline.timelineView',
8 | 'wikidataTimeline.staticSampleView'
9 | ])
10 | .config(['$routeProvider', function($routeProvider) {
11 | $routeProvider.otherwise({
12 | templateUrl: 'views/newTimelineView/newTimelineView.html',
13 | controller: 'NewTimelineViewCtrl'
14 | });
15 | }])
16 |
17 | .config(['$compileProvider', function($compileProvider) {
18 | $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|blob):/);
19 | }])
20 |
21 | .config(['$sceDelegateProvider', function($sceDelegateProvider) {
22 | $sceDelegateProvider.resourceUrlWhitelist([
23 | 'self', // Allow same origin resource loads.
24 | 'https://www.wikidata.org/w/api.php' // Allow JSONP calls that match this pattern
25 | ]);
26 | }])
27 |
28 | .config(['$locationProvider', function($locationProvider) {
29 | $locationProvider.hashPrefix('');
30 | }])
31 |
32 | .controller('AppController', ['$scope', '$urlParamManager', '$wdqSamples',
33 | function($scope, $urlParamManager, $wdqSamples) {
34 | var paramManager = $urlParamManager({
35 | embed: false
36 | });
37 |
38 | $scope.embedded = paramManager.get('embed');
39 | $scope.samples = $wdqSamples.getSamples();
40 | }]);
41 |
--------------------------------------------------------------------------------
/css/app.css:
--------------------------------------------------------------------------------
1 | html, body {
2 | width:100%;
3 | width: -moz-calc(100% - 8px); /* firefox fix :/ */
4 | height:100%;
5 |
6 | margin: 0;
7 | }
8 |
9 | body {
10 | padding-top: 50px; /* fixed header */
11 | }
12 |
13 | body.embedded {
14 | padding-top: 0;
15 | }
16 |
17 | #main-content, div[ng-view] {
18 | height: 100%;
19 | overflow: auto;
20 | position: relative;
21 | }
22 |
23 | .alert {
24 | margin: 10px;
25 | }
26 |
27 | .alert-info.dark {
28 | color: #B5B5B5;
29 | background-color: rgba(20, 20, 20, 0.95);
30 | border-color: #3A3A3A;
31 | }
32 |
33 | .alert-info.plain {
34 | background-color: #F7F7F7;
35 | border: 1px solid #DDD;
36 | color: #555;
37 | }
38 |
39 | .notification-container {
40 | position: fixed;
41 | width: 100%;
42 | bottom: 0;
43 | }
44 |
45 | .notification-container > .alert {
46 | text-align: center;
47 | box-shadow: 0 0 4px #000;
48 |
49 | position: absolute;
50 | max-width: 300px;
51 | width: 100%;
52 | transform: translateX(-50%);
53 | margin-bottom: 20px;
54 | padding: 8px;
55 | bottom: 0;
56 | left: 50%;
57 | }
58 |
59 | .notification-container > .alert > .progress {
60 | background-color: rgba(0, 0, 0, 0.24);
61 | margin-bottom: 8px;
62 |
63 | overflow: visible;
64 | height: 6px;
65 | }
66 |
67 | .notification-container > .alert > .progress > .progress-bar {
68 | background-color: #0067BF;
69 | box-shadow: 0 0 10px 0px #338BB7;
70 | }
71 |
72 | .notification-container > .alert > .progress > .progress-bar.hidden-items {
73 | background-color: #5B5B5B;
74 | box-shadow: 0 0 10px 0px #5B5B5B;
75 | }
76 |
77 | .notification-container button {
78 | background: none;
79 | border: none;
80 | text-transform: uppercase;
81 | font-weight: 700;
82 | color: #1D6CAF;
83 | text-shadow: 0 0 10px #338BB7;
84 | padding: 8px;
85 | font-size: 0.8em;
86 | border-radius: 4px;
87 |
88 | transition-property: background-color;
89 | transition-duration: 0.2s;
90 | }
91 | .notification-container button:hover:not([disabled]) {
92 | background-color: rgba(255,255,255,0.1);
93 | }
94 | .notification-container button[disabled] {
95 | color: #797A7B;
96 | text-shadow: none;
97 | }
98 |
99 | .progress-bar:first-child {
100 | border-radius: 4px 0 0 4px;
101 | }
102 | .progress-bar:last-child {
103 | border-radius: 0 4px 4px 0;
104 | }
105 | .progress-bar:first-child:last-child {
106 | border-radius: 4px;
107 | }
108 |
109 | .flex-row {
110 | display: flex;
111 | flex-direction: row;
112 | align-items: center;
113 | }
114 |
115 | .wdt-banner {
116 | position: relative;
117 | margin: 10px auto;
118 | }
119 | .wdt-banner .bg-holder {
120 | background: url("../imgs/banner.svg");
121 | background-size: auto 100%;
122 | background-repeat: no-repeat;
123 | background-position: center;
124 | max-width: 800px;
125 | margin: 0 auto;
126 | }
127 | .wdt-banner .bg-holder img {
128 | width: 100%;
129 | min-width: 506px;
130 | visibility: hidden;
131 | max-width: inherit;
132 | }
133 |
134 | form {
135 | padding: 14px;
136 | }
137 |
138 | label {
139 | margin-top: 16px;
140 | margin-bottom: 3px;
141 | }
142 |
143 | a:not([disabled]) {
144 | cursor: pointer;
145 | }
146 |
147 | a[disabled] {
148 | color: #888;
149 | }
150 |
151 | a[disabled]:hover {
152 | text-decoration: none;
153 | }
154 |
155 | button[type="submit"] {
156 | display:block;
157 | margin: 10px auto;
158 | }
159 |
160 | .panel-footer {
161 | overflow: auto;
162 | }
163 |
164 | /* NEW VIEW */
165 |
166 | .query-editor .CodeMirror {
167 | height: auto;
168 | }
169 |
170 | .query-panel .panel-body {
171 | padding: 5px;
172 | }
173 |
174 | .query-panel .query-editor {
175 | margin: 5px;
176 | margin-bottom: -14px;
177 | }
178 |
179 | .query-panel .sample-queries {
180 | text-align: right;
181 | }
182 |
183 | .query-panel .sample-queries .collapse-toggle {
184 | font-size: 80%;
185 | }
186 |
187 | .query-panel .sample-queries .items {
188 | text-align: left;
189 |
190 | border-top: 1px solid #ddd;
191 | }
192 |
193 | .query-panel .sample-queries .items a {
194 | display: block;
195 | color: #555;
196 |
197 | border-bottom: 1px solid #ddd;
198 | padding: 2px 8px;
199 | font-size: 90%;
200 | }
201 |
202 | .query-panel .sample-queries .items a:hover {
203 | text-decoration: none;
204 | background-color: #EEE;
205 | }
206 |
207 | .query-panel .sample-queries .items a code {
208 | color: #555;
209 | display: block;
210 | background: none;
211 | padding: 0;
212 | }
213 |
214 | form.new-view {
215 | width:100%;
216 | max-width: 600px;
217 | margin: 0 auto;
218 | }
219 |
220 | .wdq-docs {
221 | max-height: 280px;
222 | overflow: auto;
223 | margin-top: 6px;
224 | }
225 | .wdq-docs tt {
226 | margin:2px;
227 | padding:1px;
228 | border:dotted 1px #AAAAAA;
229 | background-color:#CEDEF4;
230 | }
231 | span.property {
232 | background-color:#CAFFD8;
233 | font-family:Courier, monospace;
234 | font-size:11pt;
235 | }
236 | span.item {
237 | background-color:#FFCECE;
238 | font-family:Courier, monospace;
239 | font-size:11pt;
240 | }
241 | .wdq-docs .qualifiers {
242 | color:#1FCB4A;
243 | font-style:italic;
244 | }
245 |
246 | .wdq-docs.contextual-only > ul {
247 | padding: 0;
248 | }
249 | .wdq-docs.contextual-only > ul > li {
250 | list-style: none;
251 | }
252 |
253 | /** timeline view **/
254 | .options-bar {
255 | height: 32px;
256 | line-height: 32px;
257 | background-color: #FFF;
258 | width: 100%;
259 | position: absolute;
260 | top: 0;
261 | }
262 | body.embedded .options-bar {
263 | opacity: 0;
264 | transition: opacity 0.2s;
265 | }
266 | body.embedded:hover .options-bar {
267 | opacity: 1;
268 | }
269 |
270 | .left-right-bar > .left {
271 | float: left;
272 | margin-left: 8px;
273 | }
274 | .left-right-bar > .right {
275 | float: right;
276 | margin-right: 8px;
277 | }
278 |
279 | .embed-modal pre {
280 | max-height: 140px;
281 | }
282 |
283 | .embed-modal .embed-preview {
284 | overflow:auto;
285 | }
286 |
287 | span[data-toggle="tooltip"] {
288 | border-bottom: 1px dotted #999;
289 | transition: border-style 0.2s;
290 | }
291 |
292 | wdt-help {
293 |
294 | }
295 | .help-icon {
296 | display: inline-block;
297 |
298 | padding: 0 4px;
299 | font-size: 14px;
300 | line-height: 15px;
301 | border-radius: 20px;
302 | }
303 |
--------------------------------------------------------------------------------
/css/main.css:
--------------------------------------------------------------------------------
1 | .timeline-container {
2 | width: 100%;
3 | height: 100%;
4 | overflow: auto;
5 | box-sizing: border-box;
6 |
7 | background-color: #F0F0F0;
8 | }
9 |
10 | .mini-chart {
11 | position: absolute;
12 | bottom: 0;
13 | left: 0;
14 |
15 | background-color: #FCFCFC;
16 | cursor: move;
17 | }
18 |
19 | .timeline-container .main-chart-container {
20 | width: 100%;
21 | height: 100%;
22 |
23 | overflow: auto;
24 | }
25 |
26 | .timeline-container .main-chart {
27 | font-family: Roboto, sans-serif;
28 | }
29 | .timeline-container text,
30 | .timeline-container tspan {
31 | -webkit-touch-callout: none;
32 | -webkit-user-select: none;
33 | -khtml-user-select: none;
34 | -moz-user-select: none;
35 | -ms-user-select: none;
36 | user-select: none;
37 | }
38 |
39 | .timeline-container .main-chart .item rect,
40 | .timeline-container .main-chart .item circle {
41 | fill: #FD5;
42 | /*stroke: #C92;*/
43 | }
44 |
45 | /*.timeline-container .main-chart .item rect {
46 | shape-rendering: crispEdges;
47 | }*/
48 |
49 | .timeline-container .main-chart .item circle {
50 | stroke: #C92;
51 | }
52 |
53 | .timeline-container .mini-chart .items-path {
54 | stroke: #FD5;
55 | shape-rendering: crispEdges;
56 | fill: transparent;
57 | }
58 |
59 | .timeline-container .main-chart .item text {
60 | font-size: 12px;
61 | }
62 |
63 | .timeline-container .main-chart .axis .tick line {
64 | stroke-width: 1px;
65 | stroke: #000;
66 | }
67 |
68 | .timeline-container .main-chart .grid .tick line {
69 | stroke-width: 1px;
70 | stroke: #AAA;
71 | stroke-dasharray: 1,1;
72 | shape-rendering: crispEdges;
73 | }
74 |
75 | .timeline-container .mini-chart .viewfield {
76 | fill: #08D;
77 | fill-opacity: 0.1;
78 | stroke: #08E;
79 | stroke-width: 1px;
80 |
81 | shape-rendering: crispEdges;
82 | }
83 |
--------------------------------------------------------------------------------
/debug.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | Wikidata Timeline
10 |
11 |
12 |
13 |
14 |
15 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
66 |
67 |
70 |
71 |
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 |
--------------------------------------------------------------------------------
/directives/quickHelp/quickHelp.html:
--------------------------------------------------------------------------------
1 |
6 |
7 |
--------------------------------------------------------------------------------
/directives/quickHelp/quickHelp.js:
--------------------------------------------------------------------------------
1 | angular.module('wikidataTimeline')
2 |
3 | .directive('wdtHelp', [function() {
4 | return {
5 | restrict: 'E',
6 | transclude: true,
7 | scope: {},
8 | templateUrl: 'directives/quickHelp/quickHelp.html',
9 | link: function($scope, $element, $attrs) {
10 | $scope.quickHelpActive = false;
11 | }
12 | };
13 | }]);
14 |
--------------------------------------------------------------------------------
/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cdrini/wikidata-timeline/d3ff5051b6d5f4af448ce7ac36797d0686755f8a/favicon.ico
--------------------------------------------------------------------------------
/imgs/banner.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
461 |
--------------------------------------------------------------------------------
/imgs/icons.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
251 |
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | Wikidata Timeline
10 |
11 |
12 |
13 |
14 |
15 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
66 |
67 |
70 |
71 |
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 |
--------------------------------------------------------------------------------
/js/timeline.js:
--------------------------------------------------------------------------------
1 | /******************************************
2 | ****** Helpers
3 | ******************************************/
4 |
5 | /**
6 | * @private
7 | * Helper function which will assign principal[key] to secondary[key] if
8 | * defined, otherwise to defaultValue.
9 | */
10 | function setParam(principal, secondary, key, defaultValue) {
11 | if(typeof(secondary[key]) == 'undefined') {
12 | principal[key] = defaultValue;
13 | } else {
14 | principal[key] = secondary[key];
15 | }
16 | }
17 |
18 | /**
19 | * @private
20 | * Helper function which converts ms to years
21 | * @param {Integer} ms
22 | * @return {Integer} years
23 | */
24 | function msToYears(ms) {
25 | return ms / 3.15569e10;
26 | }
27 |
28 | /**
29 | * @private
30 | * Helper function which takes a string with '%%' as placeholders. Replaces
31 | * ith placeholder with (i+1)th param (first being the string)
32 | * @param {String} str with '%%' placeholders
33 | * @param {...*} [items] items to replace placeholders with
34 | * @return {String}
35 | */
36 | function sprintf(str) {
37 | var args = arguments;
38 | var i = 1;
39 | return str.replace(/%%/g, function() { return args[i++];});
40 | }
41 |
42 | /******************************************
43 | ****** Main
44 | ******************************************/
45 |
46 | /**
47 | * @class
48 | * @param {Array