mirror of https://github.com/apache/lucene.git
Add SIMILE Timeline view, currently specific to the Delicious Library dataset
git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@506457 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b764a44a18
commit
cb2e229a7c
|
@ -32,4 +32,23 @@ class SimileController < ApplicationController
|
|||
format.json { render :json => {'items' => @data}.to_json } # Exhibit seems to require data to be in a 'items' Hash
|
||||
end
|
||||
end
|
||||
|
||||
def timeline
|
||||
# TODO this code was copied from BrowseController#index, and is here only as a quick and dirty prototype.
|
||||
# TODO figuring out where these calls cleanly belong is the key.
|
||||
|
||||
@info = SOLR.send(Solr::Request::IndexInfo.new) # TODO move this call to only have it called when the index may have changed
|
||||
@facet_fields = @info.field_names.find_all {|v| v =~ /_facet$/}
|
||||
|
||||
req = Solr::Request::Standard.new :query => query,
|
||||
:filter_queries => filters,
|
||||
:facets => {:fields => @facet_fields, :limit => 20 , :mincount => 1, :sort => :count, :debug_query=>true}
|
||||
@data = SOLR.send(req)
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
format.html # renders timeline.rhtml
|
||||
format.xml # renders timeline.rxml
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
<html>
|
||||
<head>
|
||||
...
|
||||
<script src="http://simile.mit.edu/timeline/api/timeline-api.js" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
var tl;
|
||||
function onLoad() {
|
||||
var eventSource = new Timeline.DefaultEventSource();
|
||||
var bandInfos = [
|
||||
Timeline.createBandInfo({
|
||||
eventSource: eventSource,
|
||||
date: "Jun 28 2006 00:00:00 GMT",
|
||||
width: "70%",
|
||||
intervalUnit: Timeline.DateTime.CENTURY,
|
||||
intervalPixels: 200
|
||||
}),
|
||||
Timeline.createBandInfo({
|
||||
eventSource: eventSource,
|
||||
date: "Jun 28 2006 00:00:00 GMT",
|
||||
width: "30%",
|
||||
intervalUnit: Timeline.DateTime.YEAR,
|
||||
intervalPixels: 200
|
||||
})
|
||||
];
|
||||
bandInfos[0].syncWith = 1;
|
||||
bandInfos[0].highlight = true;
|
||||
|
||||
tl = Timeline.create(document.getElementById("my-timeline"), bandInfos);
|
||||
Timeline.loadXML("timeline.xml", function(xml, url) { eventSource.loadXML(xml, url); });
|
||||
}
|
||||
|
||||
var resizeTimerID = null;
|
||||
function onResize() {
|
||||
if (resizeTimerID == null) {
|
||||
resizeTimerID = window.setTimeout(function() {
|
||||
resizeTimerID = null;
|
||||
tl.layout();
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload="onLoad();" onresize="onResize();">
|
||||
<div id="my-timeline" style="height: 300px; border: 1px solid #aaa"></div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,49 @@
|
|||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
xml.data do
|
||||
@data.each do |doc|
|
||||
xml.event(doc['title_text'],
|
||||
:start => doc['published_year_facet'],
|
||||
:end => doc['published_year_facet'],
|
||||
:title => doc['title_text'],
|
||||
:image => "#{doc['asin_text']}")
|
||||
end
|
||||
end
|
||||
|
||||
# <data>
|
||||
# <event
|
||||
# start="May 28 2006 09:00:00 GMT"
|
||||
# end="Jun 15 2006 09:00:00 GMT"
|
||||
# isDuration="true"
|
||||
# title="Writing Timeline documentation"
|
||||
# image="http://simile.mit.edu/images/csail-logo.gif"
|
||||
# >
|
||||
# A few days to write some documentation for <a href="http://simile.mit.edu/timeline/">Timeline</a>.
|
||||
# </event>
|
||||
#
|
||||
# <event
|
||||
# start="Jun 16 2006 00:00:00 GMT"
|
||||
# end="Jun 26 2006 00:00:00 GMT"
|
||||
# title="Friend's wedding"
|
||||
# >
|
||||
# I'm not sure precisely when my friend's wedding is.
|
||||
# </event>
|
||||
#
|
||||
# <event
|
||||
# start="Aug 02 2006 00:00:00 GMT"
|
||||
# title="Trip to Beijing"
|
||||
# link="http://travel.yahoo.com/"
|
||||
# >
|
||||
# Woohoo!
|
||||
# </event>
|
||||
# </data>
|
Loading…
Reference in New Issue