Apache Lucene open-source search software
Add SIMILE Timeline view, currently specific to the Delicious Library dataset
Erik Hatchercb2e229a7c1f
diff --git a/client/ruby/flare/app/controllers/simile_controller.rb b/client/ruby/flare/app/controllers/simile_controller.rbindex 2f34ab5a8f3..834f30a7867 100755--- a/client/ruby/flare/app/controllers/simile_controller.rb+++ b/client/ruby/flare/app/controllers/simile_controller.rb@@ -32,4 +32,23 @@ class SimileController < ApplicationControllerformat.json { render :json => {'items' => @data}.to_json } # Exhibit seems to require data to be in a 'items' Hashendend++ 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+ endenddiff --git a/client/ruby/flare/app/views/simile/timeline.rhtml b/client/ruby/flare/app/views/simile/timeline.rhtmlnew file mode 100755index 00000000000..aec9d2341ed--- /dev/null+++ b/client/ruby/flare/app/views/simile/timeline.rhtml@@ -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>diff --git a/client/ruby/flare/app/views/simile/timeline.rxml b/client/ruby/flare/app/views/simile/timeline.rxmlnew file mode 100755index 00000000000..48026a53c1f--- /dev/null+++ b/client/ruby/flare/app/views/simile/timeline.rxml@@ -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>\ No newline at end of file