muruca_widgets 0.2.4 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/timeline_source.rb +43 -9
- metadata +27 -7
data/lib/timeline_source.rb
CHANGED
@@ -158,31 +158,65 @@ class TimelineSource
|
|
158
158
|
start_predicate = date_predicate_from_array(original_start_predicate, src)
|
159
159
|
end_predicate = date_predicate_from_array(original_end_predicate, src)
|
160
160
|
|
161
|
+
# we expect to have a TaliaCore::SemanticCollectionWrapper for the dates
|
162
|
+
# if it's not the case, we create an array with the single value
|
163
|
+
if src[start_predicate].is_a? TaliaCore::SemanticCollectionWrapper
|
164
|
+
start_dates = src[start_predicate]
|
165
|
+
else
|
166
|
+
start_dates = [src[start_predicate]]
|
167
|
+
end
|
168
|
+
|
169
|
+
if src[end_predicate].is_a? TaliaCore::SemanticCollectionWrapper
|
170
|
+
end_dates = src[end_predicate]
|
171
|
+
else
|
172
|
+
end_dates = [src[end_predicate]]
|
173
|
+
end
|
174
|
+
|
175
|
+
|
161
176
|
# Ignore all sources that do not have a timestamp
|
162
|
-
next if((stamp =
|
177
|
+
next if((stamp = start_dates.first).blank?)
|
163
178
|
new_event = {}
|
164
179
|
|
165
180
|
# Fill the start and end date fields
|
166
181
|
dates = process_timestamp(stamp)
|
167
182
|
# Overwrite the second date if we have a predefined "end" field
|
168
|
-
dates[1] = process_timestamp(
|
183
|
+
dates[1] = process_timestamp(end_dates.first).first unless end_dates.empty?
|
169
184
|
new_event[:start], new_event[:end] = dates.collect { |d| to_iso8601(d) }
|
170
185
|
|
171
186
|
update_first_last_year(dates)
|
172
187
|
|
173
188
|
# Fill the title/description fields
|
174
|
-
|
175
|
-
|
189
|
+
|
190
|
+
if (titles = src[@options[:title_property]]).is_a? TaliaCore::SemanticCollectionWrapper and !titles.empty?
|
191
|
+
title = titles.first
|
192
|
+
else
|
193
|
+
title = titles unless titles.nil?
|
194
|
+
title = src[N::RDFS.label].first if title.nil?
|
195
|
+
title = N::URI.new(src.uri).to_name_s if title.nil?
|
196
|
+
end
|
197
|
+
|
198
|
+
# src[@options[:title_property]].first || src[N::RDFS.label].first || N::URI.new(src.uri).to_name_s
|
199
|
+
|
200
|
+
if (descriptions = src[@options[:description_property]]).is_a? TaliaCore::SemanticCollectionWrapper and !descriptions.empty?
|
201
|
+
description = descriptions.first
|
202
|
+
else
|
203
|
+
description = descriptions unless descriptions.nil?
|
204
|
+
description = title if description.nil?
|
205
|
+
end
|
206
|
+
|
207
|
+
|
208
|
+
new_event[:title] = title
|
209
|
+
new_event[:description] = description
|
176
210
|
# new_event['image'] = ''
|
177
211
|
# The link field may either be filled from a property, or with a link to the element itself (default)
|
178
212
|
new_event[:link] = if(@options[:link_property])
|
179
213
|
src[@options[:link_property]].first || ''
|
180
214
|
else
|
181
|
-
if((uri = src.to_uri).local?)
|
182
|
-
'/' << uri.local_name
|
183
|
-
else
|
184
|
-
|
185
|
-
end
|
215
|
+
# if((uri = src.to_uri).local?)
|
216
|
+
# '/' << uri.local_name
|
217
|
+
# else
|
218
|
+
src.to_uri.to_s
|
219
|
+
# end
|
186
220
|
end
|
187
221
|
# We have a duration event if we have a non-nil end date
|
188
222
|
new_event[:duration_event] = true unless(new_event[:end])
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: muruca_widgets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 2
|
8
|
+
- 6
|
9
|
+
version: 0.2.6
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Daniel Hahn
|
@@ -9,10 +14,23 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date: 2010-
|
17
|
+
date: 2010-11-29 00:00:00 +01:00
|
13
18
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: json
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 1
|
29
|
+
- 1
|
30
|
+
- 0
|
31
|
+
version: 1.1.0
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
16
34
|
description: Some additional interface elements to be used on Muruca sites.
|
17
35
|
email: ghub@limitedcreativity.org
|
18
36
|
executables: []
|
@@ -209,18 +227,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
209
227
|
requirements:
|
210
228
|
- - ">="
|
211
229
|
- !ruby/object:Gem::Version
|
230
|
+
segments:
|
231
|
+
- 0
|
212
232
|
version: "0"
|
213
|
-
version:
|
214
233
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
215
234
|
requirements:
|
216
235
|
- - ">="
|
217
236
|
- !ruby/object:Gem::Version
|
237
|
+
segments:
|
238
|
+
- 0
|
218
239
|
version: "0"
|
219
|
-
version:
|
220
240
|
requirements: []
|
221
241
|
|
222
242
|
rubyforge_project:
|
223
|
-
rubygems_version: 1.3.
|
243
|
+
rubygems_version: 1.3.6
|
224
244
|
signing_key:
|
225
245
|
specification_version: 3
|
226
246
|
summary: Additional interface elements for Muruca Sites.
|