repertoire-faceting 0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. data/FAQ +161 -0
  2. data/INSTALL +7 -0
  3. data/LICENSE +22 -0
  4. data/README +531 -0
  5. data/TODO +104 -0
  6. data/ext/Makefile +27 -0
  7. data/ext/README.signature +33 -0
  8. data/ext/extconf.rb +3 -0
  9. data/ext/signature.c +740 -0
  10. data/ext/signature.sql.IN +338 -0
  11. data/ext/uninstall_signature.sql.IN +4 -0
  12. data/lib/repertoire-faceting/adapters/abstract_adapter.rb +18 -0
  13. data/lib/repertoire-faceting/adapters/postgresql_adapter.rb +81 -0
  14. data/lib/repertoire-faceting/controller.rb +46 -0
  15. data/lib/repertoire-faceting/errors.rb +6 -0
  16. data/lib/repertoire-faceting/facets/abstract_facet.rb +80 -0
  17. data/lib/repertoire-faceting/facets/basic_facet.rb +66 -0
  18. data/lib/repertoire-faceting/facets/nested_facet.rb +91 -0
  19. data/lib/repertoire-faceting/model.rb +204 -0
  20. data/lib/repertoire-faceting/rails/postgresql_adapter.rb +14 -0
  21. data/lib/repertoire-faceting/rails/relation.rb +10 -0
  22. data/lib/repertoire-faceting/rails/routes.rb +10 -0
  23. data/lib/repertoire-faceting/railtie.rb +17 -0
  24. data/lib/repertoire-faceting/relation/calculations.rb +54 -0
  25. data/lib/repertoire-faceting/relation/query_methods.rb +45 -0
  26. data/lib/repertoire-faceting/relation/spawn_methods.rb +26 -0
  27. data/lib/repertoire-faceting/routing.rb +28 -0
  28. data/lib/repertoire-faceting/tasks.rake +29 -0
  29. data/lib/repertoire-faceting/version.rb +5 -0
  30. data/lib/repertoire-faceting.rb +38 -0
  31. data/public/images/repertoire-faceting/proportional_symbol.png +0 -0
  32. data/public/images/repertoire-faceting/spinner_sm.gif +0 -0
  33. data/public/javascripts/google-earth-extensions.js +6805 -0
  34. data/public/javascripts/protovis.js +7725 -0
  35. data/public/javascripts/rep.faceting/context.js +133 -0
  36. data/public/javascripts/rep.faceting/ext/earth_facet.js +439 -0
  37. data/public/javascripts/rep.faceting/facet.js +131 -0
  38. data/public/javascripts/rep.faceting/facet_widget.js +88 -0
  39. data/public/javascripts/rep.faceting/nested_facet.js +92 -0
  40. data/public/javascripts/rep.faceting/results.js +64 -0
  41. data/public/javascripts/rep.faceting.js +45 -0
  42. data/public/javascripts/rep.protovis-facets.js +234 -0
  43. data/public/stylesheets/rep.faceting.css +18 -0
  44. metadata +182 -0
data/FAQ ADDED
@@ -0,0 +1,161 @@
1
+ = Repertoire Faceting FAQ =
2
+
3
+ = About facet indexing and the signature SQL type =
4
+
5
+ Q. What's the scalability of this thing?
6
+
7
+ A. Up to about 500,000 items, supposing 6-8 simultaneous facets with domains anywhere from 2-100 values. In other words, beyond
8
+ the size of most commonly available datasets. See the citizens example in the specs directory & example faceting app.
9
+
10
+ It has been tested with up to 1,000,000 items, but this requires unix configuration to give Postgresql lots of shared memory.
11
+
12
+
13
+ Q. My nested facet widget is empty!
14
+
15
+ A. Did you remember to call expand_nesting(<facet index table>, <facet name>) after creating your index?
16
+
17
+
18
+
19
+ = About the ajax faceting widgets =
20
+
21
+ Q. How do I send page-specific data (for example, a search field) to the webservice with the facet widgets' data?
22
+
23
+ A. If you provide a function to the facet_context plugin, it will merge the params you return before dispatching to
24
+ the webservice, e.g.
25
+
26
+ $('#invoices').facet_context(function() {
27
+ return {
28
+ search: $("#search_field").val()
29
+ };
30
+ });
31
+
32
+
33
+ Q. I want to change the default options for all widgets of a given class.
34
+
35
+ A. See the syntax for defining jquery plugins - you can alter the defaults for all widgets by reassigning them in your
36
+ view code.
37
+
38
+ Q. How do I make one-time, minor changes to the behaviour of a widget? For example, I want to add a control.
39
+
40
+ A. Use the inject option, which is part of the base functionality. Your injector function receives a reference to the
41
+ widget's jquery element and to the widget javascript object. Use jquery to add your control's markup, then
42
+ register an event handler to add its behaviour. For example, this injector adds a clear-all button in the title:
43
+
44
+ $('#genre').facet({
45
+ injectors: {
46
+ '.title .controls' : function(self, data) { $(this).append('<span class="clear_control">[x]</span>'); }
47
+ },
48
+ handlers: {
49
+ 'click!.clear_control' : function(self) {
50
+ self.refinements('genre').length = 0;
51
+ self.state_changed();
52
+ return false;
53
+ }
54
+ }
55
+ });
56
+
57
+ The injector adds markup for the control at the specific jquery selector, and the handler receives events on that markup. Both
58
+ receive a single argument 'self' for the widget object, and 'this' for the matched DOM element.
59
+
60
+ Note the syntax used to identify a handler's event and dom element: '<event.namespace>!<target>'. Both event and namespace
61
+ are optional - leave them out to register a click handler with a unique namespace.
62
+
63
+ In injectors and handlers, you have access to the complete faceting widget API (state, refinements, toggle, is_selected, etc.).
64
+ You can basically build a new widget, if you need to. See the documentation for the faceting_widget class for details.
65
+
66
+
67
+ Q. My additonal control needs to send data back to the webservice too.
68
+
69
+ A. You can pre-process the entire context's state before it's sent to the webservice by update():
70
+
71
+ var min = 5;
72
+ $('#genre').facet({
73
+ injectors: { ... },
74
+ handlers: { ... },
75
+ pre_update: function(state) { state.minimum = genre_min; }
76
+ }
77
+
78
+
79
+ Q. How do I subclass an existing widget, so I can reuse my changes repeatedly?
80
+
81
+ A. Basically you define a new widget class and move your injectors and handlers (above) into the appropriate places. See the
82
+ results widget for the simplest possible example, and nested_facet for a real-world example that extends the default facet
83
+ widget. At a bare minimum, you will over-ride the render() method, and possibly the update() method too. Here's a 'hello
84
+ world' that extends the default facet count widget:
85
+
86
+ var hello_world = function($elem, options) {
87
+ /* declare superclass */
88
+ var self = repertoire.facet($elem, options);
89
+
90
+ /* handlers */
91
+ handler('.hello', function() {
92
+ alert('hello, world!');
93
+ });
94
+
95
+ /* injectors */
96
+ var $template_fn = self.render;
97
+ self.render = function(data) {
98
+ var $markup = $template_fn(data);
99
+ $markup.find('.title .controls').append('<div class='hello'>click me!</div');
100
+ return $markup;
101
+ }
102
+
103
+ return self;
104
+ }
105
+
106
+
107
+ Q. That's great, but how do I turn it into a jquery plugin I can actually use?
108
+
109
+ A. Call the plugin method and assign it to a variable in the jquery prototype. If provided, the line following sets universal
110
+ options defaults for the widget.
111
+
112
+ $.fn.hello_world = repertoire.plugin(hello_world);
113
+ $.fn.hello_world.defaults = { ... }; // put default options here
114
+
115
+
116
+ Q. How do these widgets relate to each other?
117
+
118
+ A. Here is the class hierarchy:
119
+
120
+ facet_widget (abstract)
121
+ +--- facet
122
+ +--- nesting_facet
123
+ +--- results
124
+
125
+
126
+ Q. In my widget or handler, how do I override an event handler from the superclass?
127
+
128
+ A. Register another handler to the exact same event and namespace. E.g. toggling selection for facet value counts
129
+ in the default facet widget is registered under the jquery event/namespace 'click.toggle_value'. To over-ride:
130
+
131
+ ... [ in widget's constructor function ]
132
+
133
+ self.handler('click.toggle_value!.facet .value', function() {
134
+ ... redefined event handler
135
+ }
136
+ ...
137
+
138
+
139
+ Q. My widget needs to send additional data to the webservice, pre-process the state, compute my own query string, or
140
+ use a different webservice.
141
+
142
+ A. You can over-ride self.update() to alter the webservice ajax call or replace it with your own. (1) if sending additional
143
+ data that affects only the current widget, store it in a private variable and add it in update(). (2) if the additional
144
+ data affects all otherfacets, store it in the structure returned by self.state() and make sure the other widgets/webservices
145
+ can process it correctly.
146
+
147
+
148
+ Q. What Javascript OOP convention is this?
149
+
150
+ A. It's based on section 5.4, "Functional Inheritance" of Douglas Crockford, "Javascript: The Good Parts."
151
+
152
+
153
+ Q. Explain the naming conventions.
154
+
155
+ A. $foo is a jquery object, e.g. var $foo = $('.foo')
156
+ self is the object you're currently defining (as opposed to the one it inherits from, javascript's 'this', or its dom view)
157
+
158
+
159
+ Q. Why not support the metadata jquery plugin? Why not automatically turn all elements with a 'facet' class into facet widgets?
160
+
161
+ A. Possibly. It needs some thought.
data/INSTALL ADDED
@@ -0,0 +1,7 @@
1
+ == Installing Repertoire Faceting
2
+
3
+ Start with a working Rails 3 application with a PostgreSQL database.
4
+
5
+ * require repertoire-faceting in Gemfile:
6
+
7
+
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2009-2010 MIT Hyperstudio
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.