wontomedia 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 2
4
- :patch: 0
4
+ :patch: 1
@@ -143,7 +143,7 @@ class ConnectionsController < ApplicationController
143
143
  redirect_to connection_path(@connection)
144
144
  else
145
145
  @connection.destroy
146
- redirect_to connections_url
146
+ redirect_to( params[:goto] ? params[:goto] : connections_url )
147
147
  end
148
148
  end
149
149
 
@@ -261,7 +261,23 @@ class ItemsController < ApplicationController
261
261
  # add blank-object connections to serve as basis for connection "quick add"
262
262
  @intances_of_type_item_classes = {}
263
263
  if class_item = @item.instance_of
264
- find_applied_properties( class_item ).each do |property_item|
264
+ find_applied_properties( class_item ).select do |property_item|
265
+ if (max_connection = Connection.first( :conditions => [
266
+ "subject_id = ? AND predicate_id = ?",
267
+ property_item.id, Item.find_by_name('max_uses_per_item').id ])) &&
268
+ max_connection.kind_of_obj == Connection::OBJECT_KIND_SCALAR &&
269
+ (max = max_connection.scalar_obj.to_i) > 0
270
+
271
+ count = Connection.all(
272
+ :conditions => [ "subject_id = ? AND predicate_id = ?",
273
+ @item.id, property_item.id ]).
274
+ length
275
+
276
+ count < max
277
+ else
278
+ true
279
+ end
280
+ end.each do |property_item|
265
281
  if connection = Connection.first( :conditions =>
266
282
  [ "subject_id = ? AND predicate_id = ?",
267
283
  property_item.id, Item.find_by_name('has_scalar_object').id ])
@@ -348,11 +364,17 @@ class ItemsController < ApplicationController
348
364
  unless used_as_obj.empty?
349
365
  @connection_list << used_as_obj
350
366
  end
351
-
352
-
353
367
  unless used_as_pred.empty?
354
368
  @connection_list << used_as_pred
355
369
  end
370
+
371
+
372
+ @properties_of_url_type = {}
373
+ Connection.all( :conditions => [
374
+ "predicate_id = ? AND obj_id = ?",
375
+ Item.find_by_name('has_scalar_object').id,
376
+ Item.find_by_name('URL_Value').id
377
+ ]).each {|con| @properties_of_url_type[con.subject_id] = true }
356
378
  end
357
379
 
358
380
  # GET /items/1/edit
@@ -34,7 +34,7 @@ module ConnectionsHelper
34
34
  # the first occurrance of that link in the current view. An instance
35
35
  # variable is created within the current view object to flag the
36
36
  # generation of each type of link.
37
- def generate_connection_links(con)
37
+ def generate_connection_links(con, after_delete = nil)
38
38
  concat(
39
39
  link_with_help_icon({
40
40
  :destination => link_to( 'Show', connection_path(con) ),
@@ -53,10 +53,11 @@ module ConnectionsHelper
53
53
  :which_help => 'ConnectionEdit' }) )
54
54
  @edit_help_icon_used = true
55
55
 
56
+ goto_param = after_delete ? '?goto='+after_delete : ''
56
57
  concat(
57
58
  link_with_help_icon({
58
59
  :destination => link_to(
59
- 'Delete', connection_path(con), :rel => 'nofollow',
60
+ 'Delete', connection_path(con)+goto_param, :rel => 'nofollow',
60
61
  :confirm => 'Are you sure?', :method => :delete ),
61
62
  :already_generated => @delete_help_icon_used,
62
63
  :help_alt => 'Help delete connection',
@@ -38,6 +38,11 @@ module FormatHelper
38
38
  title_out
39
39
  end
40
40
 
41
+ def last_word(text)
42
+ text =~ /([^\s]+)$/
43
+ $1
44
+ end
45
+
41
46
  # This method is used to wrap long strings that don't contain spaces
42
47
  # (which would allow the browser to wrap them), such as an
43
48
  # <tt>Item.name</tt> string. The +len+ parameter is a length in
@@ -145,4 +145,36 @@ module ItemsHelper
145
145
  options_for_select( option_array,
146
146
  this_class_item.nil? ? "" : this_class_item.id )
147
147
  end
148
+
149
+ def link_to_item_by_name(name, text=nil)
150
+ init_name_to_item_hash unless defined? @items_by_name
151
+
152
+ item = @items_by_name[name]
153
+ if item
154
+ return link_to( (text ? text : h(item.title)),
155
+ item_by_name_path(item.name) )
156
+ else
157
+ return '<i>[missing]</i>'
158
+ end
159
+ end
160
+
161
+ def link_to_create_instance_of(name, text=nil)
162
+ init_name_to_item_hash unless defined? @items_by_name
163
+
164
+ item = @items_by_name[name]
165
+ if item
166
+ return link_to(
167
+ text ? text : "Add a new <b>#{h name}</b>",
168
+ new_item_path + "?class_item=" + item.id.to_s )
169
+ else
170
+ return '<i>[missing]</i>'
171
+ end
172
+ end
173
+
174
+ def init_name_to_item_hash
175
+ @items_by_name = {}
176
+ @nouns.each do |item|
177
+ @items_by_name[item.name] = item
178
+ end
179
+ end
148
180
  end
@@ -35,8 +35,8 @@
35
35
  }
36
36
  </style>
37
37
 
38
- <div style="padding-left: 10%;">
39
- <div id="add-class-instances-list" style="width: 88.9%;">
38
+ <div>
39
+ <div id="add-class-instances-list">
40
40
  <ul><%
41
41
  spo_item_id = Item.find_by_name('sub_property_of').id
42
42
  @class_list.select do |class_item|
@@ -0,0 +1,34 @@
1
+ <%
2
+ # WontoMedia - a wontology web application
3
+ # Copyright (C) 2010 - Glen E. Ivey
4
+ # www.wontology.com
5
+ #
6
+ # This program is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU Affero General Public License version
8
+ # 3 as published by the Free Software Foundation.
9
+ #
10
+ # This program is distributed in the hope that it will be useful, but
11
+ # WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Affero General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Affero General Public License
16
+ # along with this program in the file COPYING and/or LICENSE. If not,
17
+ # see "http://www.gnu.org/licenses/".
18
+ %>
19
+
20
+ <div id='inline-add-<%= id -%>-link'>
21
+ <div style='font-size: 70%;'>
22
+ <%= link_to_function 'Add new',
23
+ "$('inline-add-#{id}-link').style.display = 'none'; " +
24
+ "$('inline-add-#{id}-form').style.display = 'block';" +
25
+ "$('object-item-#{id}').style.listStyleType = 'circle';"
26
+ %>
27
+ <script type='text/javascript'>
28
+ $('object-item-<%= id -%>').style.listStyleType = 'none';
29
+ </script>
30
+ </div>
31
+ </div>
32
+ <div id='inline-add-<%= id -%>-form' style='display: none;'>
33
+ <%= yield %>
34
+ </div>
@@ -18,7 +18,6 @@
18
18
  %>
19
19
 
20
20
 
21
-
22
21
  <% form_for( con, :url => connections_path+"?goto=#{@item.name}" ) do |f|
23
22
  @connection = con # yes, fibbing to Rails, so shoot me....
24
23
  %>
@@ -97,7 +97,7 @@
97
97
  padding-left: 0;
98
98
  }
99
99
  .instance-list li {
100
- color: #ffff60;
100
+ color: #f4f420;
101
101
  margin-right: 1.5em;
102
102
  display: inline;
103
103
  }
@@ -107,35 +107,40 @@
107
107
  }
108
108
  .instance-list li span {
109
109
  color: black;
110
+ white-space: nowrap;
110
111
  }
111
112
  </style>
112
113
 
113
114
  <% if @item.is_class? %>
115
+ <div style='margin-bottom: 5ex;'>
114
116
  <h2 class="subheading"><%= h filter_parenthetical @item.title -%></h2>
115
- <ul class='instance-list'>
117
+ <ul class='instance-list' style='font-size: 115%;'>
116
118
  <%
117
119
  # we know that all the connections where this item is the object are
118
120
  # located in the last array within @connection_list. Search through
119
121
  # it for all of the connections where 'is_instance_of' is the predicate
120
122
 
121
123
  iio_item_id = nil
122
- @connection_list[-1].each do |maybe_iio_connection|
123
- unless iio_item_id
124
- if @item_hash[maybe_iio_connection.predicate_id].
125
- name == 'is_instance_of'
126
- iio_item_id = maybe_iio_connection.predicate_id
124
+ @connection_list[-1].select do |maybe_iio_connection|
125
+ unless iio_item_id
126
+ if @item_hash[maybe_iio_connection.predicate_id].
127
+ name == 'is_instance_of'
128
+ iio_item_id = maybe_iio_connection.predicate_id
129
+ end
127
130
  end
128
- end
129
131
 
130
- if iio_item_id == maybe_iio_connection.predicate_id %>
132
+ iio_item_id == maybe_iio_connection.predicate_id
133
+ end.
134
+ map{|connection| @item_hash[connection.subject_id] }.
135
+ sort{|a,b| last_word(filter_parenthetical(a.title)) <=>
136
+ last_word(filter_parenthetical(b.title)) }.
137
+ each do |item| %>
131
138
  <li><span>
132
- <%= item = @item_hash[maybe_iio_connection.subject_id]
133
- link_to (h item.name), item_by_name_path(item.name) %>
139
+ <%= link_to (h filter_parenthetical item.title), item_by_name_path(item.name) %>
134
140
  </span></li>
135
- <% end %>
136
- <% end %>
141
+ <% end %>
137
142
  </ul>
138
- <% end %>
143
+ </div><% end %>
139
144
 
140
145
 
141
146
  <h3 class="subheading">This Class' Relationships</h3>
@@ -153,6 +158,8 @@
153
158
  @delete_help_icon_used = false
154
159
  @add_scalar_help_icon_used = false
155
160
  @add_item_help_icon_used = false
161
+ item_counter = 0
162
+
156
163
 
157
164
  array_of_arrays_of_connections = @connection_list.to_enum
158
165
 
@@ -194,12 +201,15 @@
194
201
  link_with_tooltip (h filter_parenthetical item.title ),
195
202
  h( item.name ), item_by_name_path(item.name) %>
196
203
  <ul style="list-style-type: circle;">
197
- <% end %>
204
+ <% end
205
+
198
206
 
199
- <li>
200
- <div style="float: right; font-size: 80%; margin-right: 6em;">
207
+ item_counter += 1
208
+ %> <li id='object-item-<%= item_counter -%>' >
209
+ <div class="floating-links">
201
210
  <% if connection.id
202
- generate_connection_links(connection)
211
+ generate_connection_links(connection,
212
+ item_by_name_path(@item.name) )
203
213
  elsif connection.obj_id
204
214
  generate_inverse_link(@inverses_map[connection])
205
215
  end %>
@@ -208,14 +218,17 @@
208
218
  <% if connection.kind_of_obj == Connection::OBJECT_KIND_SCALAR &&
209
219
  connection.scalar_obj.nil? %>
210
220
  <%= render :partial => "inline_scalar_add_form",
211
- :locals => { :con => connection } %>
221
+ :layout => "inline_add_popopen",
222
+ :locals => { :con => connection, :id => item_counter } %>
212
223
 
213
224
  <% elsif connection.kind_of_obj == Connection::OBJECT_KIND_ITEM &&
214
225
  connection.obj_id.nil? %>
215
226
  <%= items = @intances_of_type_item_classes[connection.type_item]
216
227
  items = Item.all unless !items.nil?
217
228
  render :partial => "inline_item_add_form",
218
- :locals => { :con => connection, :items => items } %>
229
+ :layout => "inline_add_popopen",
230
+ :locals => { :con => connection, :items => items,
231
+ :id => item_counter } %>
219
232
 
220
233
  <% elsif connection.kind_of_obj == Connection::OBJECT_KIND_ITEM %>
221
234
  <%= item = @item_hash[connection.obj_id]
@@ -223,7 +236,10 @@
223
236
  h( item.name ), item_by_name_path(item.name) %>
224
237
 
225
238
  <% else %>
226
- <%= h connection.scalar_obj %>
239
+ <%= @properties_of_url_type[connection.predicate_id] ?
240
+ link_to( h(connection.scalar_obj), connection.scalar_obj) :
241
+ h(connection.scalar_obj)
242
+ %>
227
243
  <% end %>
228
244
  </li>
229
245
 
@@ -277,7 +293,8 @@
277
293
  <% end %>
278
294
  </td><td style="font-size: 80%">
279
295
  <% if connection.id
280
- generate_connection_links(connection)
296
+ generate_connection_links(connection,
297
+ item_by_name_path(@item.name) )
281
298
  else
282
299
  generate_inverse_link(@inverses_map[connection])
283
300
  end %>
@@ -14,6 +14,7 @@
14
14
  (logo fill, bullets)
15
15
  subdued accent: light yellow #ffff60
16
16
  (question-mark help icon)
17
+ accent text: dark yellow #f4f420
17
18
  */
18
19
 
19
20
 
@@ -167,7 +168,11 @@ hr {
167
168
  padding-left: 1em;
168
169
  text-indent: -1em;
169
170
  }
170
-
171
+ .floating-links {
172
+ float: right;
173
+ font-size: 80%;
174
+ margin-right: 6em;
175
+ }
171
176
 
172
177
  /* set apart stuff that is in development */
173
178
  .unimplemented {
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 0
9
- version: 0.2.0
8
+ - 1
9
+ version: 0.2.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Glen E. Ivey
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-22 00:00:00 -07:00
17
+ date: 2010-03-23 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -70,6 +70,7 @@ files:
70
70
  - app/views/items/_content_examples.html.erb
71
71
  - app/views/items/_core_tasks.html.erb
72
72
  - app/views/items/_form_fields.html.erb
73
+ - app/views/items/_inline_add_popopen.html.erb
73
74
  - app/views/items/_inline_item_add_form.html.erb
74
75
  - app/views/items/_inline_scalar_add_form.html.erb
75
76
  - app/views/items/_list_outbound_links.html.erb