yaz/commit

add explicit concept parameter

authorMichiel Hildebrand
Thu Jan 26 19:15:15 2012 +0100
committerMichiel Hildebrand
Thu Jan 26 19:15:15 2012 +0100
commit95f27612604ec542877de85a7f52dabe008df9a9
tree1c783c41056683f1818949d804c0a22f4a6d42f9
parent262162196ae82457c2a47fd0a262b39bed566224
Diff style: patch stat
diff --git a/applications/yaz_tag.pl b/applications/yaz_tag.pl
index cbd3ef1..5b68024 100644
--- a/applications/yaz_tag.pl
+++ b/applications/yaz_tag.pl
@@ -38,22 +38,57 @@
 
 http_yaz_tag(Request) :-
 	http_parameters(Request,
-			[  tag(TagList0,
+			[  concept(Concept,
+				   []),
+			   tag(TagList0,
 			       [zero_or_more])
 			]),
+	confirmed_annotations(Concept, Annotations),
 	sort(TagList0, TagList),
 	related_tags(TagList, RelatedTags),
-	tag_annotations(TagList, Annotations),
-	%list_limit(Annotations0, 20, Annotations, _),
-	html_tag_page(TagList, RelatedTags, Annotations).
+	tag_entries(TagList, TagEntries),
+	html_tag_page(Concept, TagList, RelatedTags, Annotations, TagEntries).
 
-%%	tag_annotations(+Tag, -Annotations)
+%%	confirmed_annotations(+Concept, -Annotations)
 %
-%	Shots is a list of Shots annotated with tag.
+%	Annotations is a list of shots for which it is confirmed that
+%	Concept appears in it.
+%
+%       @TBD group by video
+
+
+confirmed_annotations(Concept, Annotations) :-
+	concept_value(Concept, Value, TagTerm),
+	findall(annotation(TagTerm, Video, StartTime, EndTime),
+		confirmed_annotation(Value, Video, StartTime, EndTime),
+		Annotations).
+
+concept_value(Concept, Concept, uri(Concept, Label)) :-
+	rdf_subject(Concept),
+	!,
+	rdf_display_label(Concept, Label).
+concept_value(Concept, literal(Concept), literal(Concept)).
+
+confirmed_annotation(Concept, Video, StartTime, EndTime) :-
+	rdf(FragmentProxy, dc:subject, Concept),
+	rdf(FragmentProxy, ebucore:start , Start),
+	rdf(FragmentProxy, ma:duration, Duration0),
+	rdf(VideoProxy, ma:hasFragment, FragmentProxy),
+	rdf(VideoProxy, ore:proxyIn, VideoAggregation),
+	rdf(VideoAggregation, ens:hasView, Video),
+	literal_to_number(Start, StartTime),
+	literal_to_number(Duration0, Duration),
+	EndTime is StartTime + Duration.
+
+
 
-tag_annotations(TagList, Annotations) :-
+%%	tag_annotations(+TagList, -TagEntries)
+%
+%	TagEntries is a list of Shots annotated with tag.
+
+tag_entries(TagList, Annotations) :-
 	findall(Time-entry(Entry,Video,Value,Process,User,Time),
-		annotated_shot(TagList, Entry, Value, Video, Process, User, Time),
+		tag_entry(TagList, Entry, Value, Video, Process, User, Time),
 		Entries),
 	keysort(Entries, TimeSorted0),
 	pairs_values(TimeSorted0, TimeSorted),
@@ -66,7 +101,7 @@ group_entries([E|Es], [A|As]) :-
 	group_entries(Es, As).
 
 
-annotated_shot(Tags, Entry, TagTerm, Video, Process, User, Time) :-
+tag_entry(Tags, Entry, TagTerm, Video, Process, User, Time) :-
 	member(Tag, Tags),
 	tag_value(Tag, Value, TagTerm),
 	value_annotation(Value, Process, User, Video, Entry, Time).
@@ -89,7 +124,8 @@ tag_value(Tag, literal(Tag), literal(Tag)).
 related_tags(TagList, RelatedTags) :-
 	findall(Rel-Value,
 		(   member(Tag, TagList),
-		    related_tag(Tag, Value, Rel)
+		    related_tag(Tag, Value, Rel),
+		    \+ member(Value, TagList)
 		),
 		RelatedTags0),
 	sort(RelatedTags0, RelatedTags).
@@ -137,31 +173,92 @@ is_tag_label(S,_P,_Lit) :-
 		 *               HTML		*
 		 *******************************/
 
-html_tag_page(Tag, RelatedTags, Shots) :-
-	length(Shots, NumberOfShots),
-	reply_html_page(yaz,
-			[title(['YAZ -- ',Tag])],
-			[\html_requires(css('tag_garden.css')),
-			 div(class(bd),
-			     [ h1(Tag),
-			       div(id(related),
-				   [ h2(['Related tags']),
-				     ul(\html_tags(RelatedTags))
-				   ]),
-			       div(id(shots),
-				   [ h2([NumberOfShots,
-					 ' shots annotated']),
-				     div(id(frames), [])
-				   ])
-			     ]),
-			 script(type('text/javascript'),
-			       \yui_script(Tag, RelatedTags, Shots))
-			]).
-
-html_tags([]) --> !.
-html_tags([Type-Tag|T]) -->
-	html(li(class(Type), Tag)),
-	html_tags(T).
+html_tag_page(Concept, TagList, RelatedTags, Annotations, TagEntries) :-
+	maplist(tag_term, TagList, TagTerms),
+	http_link_to_id(http_yaz_tag, TagTerms, Link),
+	reply_html_page([title(['YAZ -- ',Concept])],
+			[\html_requires(css('yaz.css')),
+			 \html_requires(css('tag_garden.css')),
+			 \html_requires(yui3('cssgrids/grids-min.css')),
+			 \html_page_header,
+			 div(id(body),
+			     div([id(layout), class('yui3-g')],
+				 [ div([class('yui3-u'), id(tags)],
+				       [ h3(class(hd), 'User tags'),
+					 div(id(active),
+					     ul(class(taglist),
+						\html_tags(TagList, TagTerms))
+					    ),
+					 div(id(related),
+					     [ ul(class(taglist),
+						  \html_related_tags(RelatedTags, Link))
+					     ])
+
+				       ]),
+				   div([class('yui3-u'), id(shots)],
+				       [ \html_annotations(Annotations, Concept),
+					 \html_unconfirmed(TagEntries, Concept)
+				       ])
+				 ])),
+			     script(type('text/javascript'),
+				    \yui_script(TagList, RelatedTags, TagEntries))
+			     ]).
+
+html_annotations(Annotations, Tag) -->
+	{ length(Annotations, Count)
+	},
+	html([ h2([Tag, ' ', Count, ' shots']),
+	       div(id(annotations), [])
+	     ]).
+
+html_unconfirmed(Annotations, Tag) -->
+	{ length(Annotations, Count)
+	},
+	html([ h2([Tag, ' may appear in ', Count, ' shots']),
+	       div(class(desc), 'click title to confirm and image to play the shot'),
+	       div(id(unconfirmed), [])
+	     ]).
+
+
+tag_term(Tag, tag(Tag)).
+
+html_page_header -->
+	html(div(id(header),
+		 div(class('header-content'),
+		     [ h1(a(href(location_by_id(http_yaz_home)), 'YAZ')),
+		       %div(id(pagesearch), \html_concept_search),
+		       div(id(pagecontrols), \html_page_controls)
+		     ]))).
+
+
+html_concept_search -->
+	html([input([type(text), class(inp), id(q)]),
+	      input([type(submit), class(btn), value(search)])
+	     ]).
+
+
+
+html_tags([], _) --> !.
+html_tags([Tag|T], TagTerms) -->
+	{  select(tag(Tag), TagTerms, Rest),
+	   http_link_to_id(http_yaz_tag, Rest, Link)
+	},
+	html(li(class(current),
+		[a([class(tag)], Tag),
+		 a([class(remove), href(Link)], 'x')
+		])),
+	html_tags(T, TagTerms).
+
+
+html_related_tags([], _) --> !.
+html_related_tags([Type-Tag|T], Link) -->
+	{ http_link_to_id(http_yaz_tag, [tag(Tag)], TagLink)
+	},
+	html(li(class(Type),
+		[a([class(tag), href(TagLink)], Tag),
+		 a([class(add), href(Link+'&tag='+Tag)], 'add')
+		])),
+	html_related_tags(T, Link).
 
 
 yui_script(_Tag, _RelatedTags, Annotations) -->
@@ -186,6 +283,6 @@ yui_script(_Tag, _RelatedTags, Annotations) -->
 					      disabled:symbol(false),
 					      maxFrames:500
 					     })),
-	      \yui3_render(videoFrames, #(frames))
+	      \yui3_render(videoFrames, #(unconfirmed))
 	     ]).
 
diff --git a/components/yaz_page.pl b/components/yaz_page.pl
index f5f3738..9ff781d 100644
--- a/components/yaz_page.pl
+++ b/components/yaz_page.pl
@@ -1,5 +1,6 @@
 :- module(yaz_page,
-	  [yaz_page//1
+	  [yaz_page//1,
+	   html_page_controls//0
 	  ]).
 
 :- use_module(library(http/html_write)).
diff --git a/web/css/tag_garden.css b/web/css/tag_garden.css
index 60b3f10..932fc23 100644
--- a/web/css/tag_garden.css
+++ b/web/css/tag_garden.css
@@ -1,20 +1,48 @@
-/* related */
-#related {
-	overflow: auto;
+body {
+	padding: 0;
+	margin: 0;
+	background-color: #DDD;
+}
+/* layout */
+#layout {
+	width: 980px;
+	background-color: white;
+	border: 1px solid #AAA;
+	padding: 0 10px;
+}
+#shots {
+	width: 738px;
+	margin-left: 20px;
+}
+#tags {
+	width: 200px;
+}
+#active {
+	border-bottom: 1px solid #CCCCCC;
 }
-#related ul {
+
+/* tag list */
+.taglist {
 	margin: 0;
 	padding: 0;
+	overflow: auto;
 }
-#related li {
-	background-color: #EEEEEE;
-    border: 1px solid #AAAAAA;
-    border-radius: 5px 5px 5px 5px;
-    float: left;
+.taglist li {
     list-style: none outside none;
     margin: 0 5px 5px 0;
     padding: 3px 5px;
 }
+.taglist .add {
+	color: green;
+	float: right;
+}
+.taglist .remove {
+	color: red;
+	float: right;
+}
+.taglist .d {
+	padding: 0 5px;
+}
 
 /* video frames */
 .yui3-video-frames {
diff --git a/web/css/yaz.css b/web/css/yaz.css
index ecce930..9b6a6ea 100644
--- a/web/css/yaz.css
+++ b/web/css/yaz.css
@@ -3,16 +3,19 @@ body {
 	font-family: Arial,Helvetica,sans-serif;
 	font-size: 12px;
 	text-align: center;
+	margin: 0;
+	padding: 0;
 }
 
 /* header */
 #header {
-	border-bottom: 1px solid #EEE;
+	border-bottom: 2px solid #3875D7;
+	background-color: white;
 }
 #header .header-content {
 	height:2em;
-	margin:1.5em auto 0;
-	padding-bottom:0.8em;
+	padding: 0.8em 0;
+	margin:0 auto;
 	text-align:left;
 	width:980px;
 }
@@ -79,7 +82,7 @@ body {
 
 #body {
 	width: 980px;
-	margin: 20px auto;
+	margin: 8px auto 20px;
 	text-align: left;
 }