yaz/commit
waisda data
author | Michiel Hildebrand |
---|---|
Sat Feb 12 19:35:17 2011 +0100 | |
committer | Michiel Hildebrand |
Sat Feb 12 19:35:17 2011 +0100 | |
commit | a3222c724e6e50b31b92d81d02e2d327fa354e83 |
tree | 567ed17890064adaa43920a91ab310052d79b1c0 |
parent | 016186120ac11bc40e29acb6098377d2ad78f62b |
Diff style: patch stat
diff --git a/applications/yaz_player.pl b/applications/yaz_player.pl index b2429b8..bfa99b2 100644 --- a/applications/yaz_player.pl +++ b/applications/yaz_player.pl @@ -22,6 +22,7 @@ :- use_module(components(label)). :- use_module(components(yaz_page)). +:- use_module(components(yaz_video_item)). :- http_handler(yaz(player), http_yaz_player, []). @@ -45,7 +46,7 @@ http_yaz_player(Request) :- [default(10000), number, description('When set one entry per tag is returned in interval (in milliseconds)')]), confirmed(Confirmed, - [boolean, default(true), + [boolean, default(false), description('When true only tags that are entered by >1 user are shown')]), limit(Limit, [default(10000), number, @@ -53,46 +54,90 @@ http_yaz_player(Request) :- start(StartTime, [default(0),description('Start time of the video')]) ]), - Options = [process(Process), - user(User), - interval(Interval), - confirmed(Confirmed) + Options0 = [process(Process), + user(User), + interval(Interval), + confirmed(Confirmed) ], + delete_nonground(Options0, Options), + % processes + video_usage(Video, Process, User, Processes, Users), + % annotations video_annotations(Video, Annotations0, Options), sort_by_arg(Annotations0, 2, Annotations1), list_limit(Annotations1, Limit, Annotations, _), - html_video_page(Video, Annotations, StartTime, Options). + html_page(Video, Processes, Users, Annotations, StartTime, Options). +%% video_processes(+Video, ?Process, ?User, -Processes) +% +% Processes are all processes that used Video. + +video_usage(_Video, Process, User, [Process], [User]) :- + nonvar(Process), + nonvar(User), + !. +video_usage(Video, Process, User, Processes, Users) :- + findall(Process-User, + video_process(Video, Process, User), + Pairs), + pairs_keys(Pairs, Ps), + pairs_values(Pairs, Us), + sort(Ps, Processes), + sort(Us, Users). +video_process(Video, Process, User) :- + rdf(Process, opmv:used, Video), + rdf(Process, rdf:type, pprime:'Game'), + ( rdf_has(Process, opmv:wasControlledBy, User) + -> true + ; User = '' %hack + ). -%% html_video_page(+Video, +Annotations, +StartTime, +Options) + +%% html_page(+Video, +Processes, +Users, +Annotations, +StartTime, +%% +Options) % % Emit an HTML page with a video player and a tag carousel. -html_video_page(Video, Annotations, StartTime, Options) :- +html_page(Video, Processes, Users, Annotations, StartTime, Options) :- + http_link_to_id(http_yaz_player, [video(Video)|Options], Link), reply_html_page(yaz, [ title(['YAZ - ', Video]) ], [ \html_requires(css('player.css')), - div(class('video-results'), - \html_video_page_containers(Video, Options)), - script(type('text/javascript'), + \yaz_video_header(Video), + div(class(facets), + [ div(class(processes), + \html_process_list(Processes, Link)), + div(class(users), + \html_user_list(Users, Link)) + ]), + div(id(tagplayer), []), + div(id(videoplayer), []), + script(type('text/javascript'), \html_video_page_yui(Video, Annotations, StartTime, Options)) ]). -html_video_page_containers(Video, _Options) --> - { display_label(Video, Title), - video_desc(Video, Desc) - %http_link_to_id(http_yaz_tag_garden, [video(Video)], Link) +html_process_list([], _) --> !. +html_process_list([Process|T], VideoPlayer) --> + { rdf(Process, opmv:wasStartedAt, L), + literal_text(L, Time0), + display_time(Time0, Time) }, - html([ h2(Title), - div(class(desc), Desc), - %a(href(Link), 'Garden this video'), - div([id(video)], - [ div(id(tagplayer), []), - div(id(videoplayer), []) - ]) - ]). + html(li(a(href(VideoPlayer+'&process='+Process), + [Time]))), + html_process_list(T, VideoPlayer). + +html_user_list([], _) --> !. +html_user_list([User|T], VideoPlayer) --> + { rdf_display_label(User, Label) + }, + html(li(a(href(VideoPlayer+'&user='+User), + [Label]))), + html_user_list(T, VideoPlayer). + + + html_video_page_yui(Video, Annotations, StartTime, _Options) --> { video_source(Video, Src), diff --git a/applications/yaz_user.pl b/applications/yaz_user.pl index 5daf223..76573f2 100644 --- a/applications/yaz_user.pl +++ b/applications/yaz_user.pl @@ -10,13 +10,10 @@ :- use_module(library(http/html_head)). :- use_module(library(semweb/rdf_db)). :- use_module(user(user_db)). - :- use_module(library(yaz_util)). :- use_module(library(video_annotation)). - :- use_module(components(yaz_page)). - -:- use_module(applications(yaz_videos)). +:- use_module(components(yaz_video_item)). :- use_module(applications(yaz_tags)). :- http_handler(yaz(.), http_yaz_home, []). @@ -48,18 +45,20 @@ http_yaz_home(_Request) :- % When defined Videos are limited to annotated by this User. user_videos(User, SortedVideos) :- - findall(Time-(Video-process(Process, Time, [])), - annotation_process(User, Video, Process, Time), + fail, + findall(Time-Video, + annotation_process(User, Video, _Process, Time), Pairs0), keysort(Pairs0, Pairs1), reverse(Pairs1, Pairs), pairs_values(Pairs, SortedVideos). -/* - find_unique(Video-process(Process, Time, []), - annotation_process(User, Video, Process, Time), + +user_videos(User, Videos) :- + find_unique(Video, + annotation_process(User, Video, _Process, _Time), 5, - Recent), -*/ + Videos). + %% popular_tags(?User, +Limit, -AnnotationsByTag) % % Returns a list with the most popular tags, Tag-[Annotations] @@ -95,18 +94,17 @@ http_yaz_user(Request) :- http_yaz_home(Request). -%% html_home_page(+Processes, +Tags, Options) +%% html_home_page(+Videos, +Tags, Options) % % Emit home page for User. -html_home_page(Processes, Tags, Options) :- +html_home_page(Videos, Tags, Options) :- reply_html_page(yaz, [ title(['YAZ - ', \page_title(Options)]) ], - [ \html_requires(css('user.css')), - div([id(processes), class(topic)], - \html_process_stream(Processes, Options)), + [ div([id(videos), class(topic)], + \html_video_stream(Videos, Options)), div([id(tags), class(topic)], \html_tag_stream(Tags, Options)) ]). @@ -118,33 +116,9 @@ page_title(Options) --> page_title(_Options) --> html(['annotation zone']). - -html_process_stream(Processes, Options) --> - { http_link_to_id(http_yaz_videos, Options, Link) - }, - html([ div(class(header), - h2(a(href(Link), \process_stream_header(Options)))), - div(class(body), - ul(class('thumb-list'), - \html_process_list(Processes, Options))) - ]). - -html_process_list([], _) --> !. -html_process_list([Video-ProcessObj|Vs], Options) --> - { ProcessObj = process(Process, _, _) - }, - html(li(class('video'), - \html_video_item(Video, [ProcessObj], - [process(Process)|Options]))), - html_process_list(Vs, Options). - -process_stream_header(Options) --> - { option(user(_User), Options) - }, - html('Your recent activity'). -process_stream_header(_Options) --> - html('Recent activity'). - +%% html_video_stream(+Videos, +Options) +% +% Emit html with a list of videos. html_video_stream(Videos, Options) --> { http_link_to_id(http_yaz_videos, Options, Link) @@ -152,8 +126,8 @@ html_video_stream(Videos, Options) --> html([ div(class(header), h2(a(href(Link), \video_stream_header(Options)))), div(class(body), - ul(class('thumb-list'), - \html_video_list(Videos, [desc(false)|Options]))) + ul(class('result-line'), + \html_video_list(Videos, Options))) ]). video_stream_header(Options) --> @@ -163,6 +137,14 @@ video_stream_header(Options) --> video_stream_header(_Options) --> html('Recently tagged videos'). +html_video_list([], _) --> !. +html_video_list([Video|Vs], Options) --> + html(li(\yaz_video_result(Video, Options))), + html_video_list(Vs, Options). + +%% html_tag_stream(+Tags, +Options) +% +% Emit tags. html_tag_stream(TopNTags, Options) --> { http_link_to_id(http_yaz_tags, Options, Link) diff --git a/applications/yaz_videos.pl b/applications/yaz_videos.pl index 01cd05a..d579770 100644 --- a/applications/yaz_videos.pl +++ b/applications/yaz_videos.pl @@ -1,8 +1,6 @@ :- module(yaz_videos, - [ http_yaz_videos/1, - html_video_list//2, - html_video_item//3 - ]). + [ http_yaz_videos/1 + ]). :- use_module(library(http/http_dispatch)). :- use_module(library(http/http_parameters)). @@ -19,6 +17,7 @@ :- use_module(library(video_annotation)). :- use_module(components(yaz_page)). +:- use_module(components(yaz_video_item)). :- use_module(components(paginator)). :- http_handler(yaz(videos), http_yaz_videos, []). @@ -31,95 +30,50 @@ http_yaz_videos(Request) :- http_parameters(Request, [ user(User, [optional(true), description('Current user id')]), - tag(Tag, - [optional(true), description('Limit videos by tag')]), offset(Offset, [default(0), integer, description('Offset of the result list')]), limit(Limit, [default(20), integer, description('Limit on the number of results')]) ]), - user_video_processes(User, Tag, Processes), - length(Processes, NumberOfResults), - list_offset(Processes, Offset, OffsetResults), + user_videos(User, Videos), + length(Videos, NumberOfResults), + list_offset(Videos, Offset, OffsetResults), list_limit(OffsetResults, Limit, LimitResults, _), - delete_nonground([user(User), tag(Tag)], Options), - html_videos_page(LimitResults, NumberOfResults, Offset, Limit, Options). + html_page(LimitResults, NumberOfResults, Offset, Limit). -%% user_video_processes(?User, ?Value, -Pairs:video-process) -% -% Returns a list of the Nth Videos that have been recently -% annotated. -% -% Params: -% * User -% When defined Videos are limited to annotated by this User. -% -% * Value -% When defined Videos are limit to those annotated with Value. - - -user_video_processes(User, Value, Processes) :- - nonvar(Value), - !, - findall(Time-(Video-[process(Process, Time, Annotations)]), - annotation_value_process(User, Video, Value, Process, Time, Annotations), +user_videos(User, SortedVideos) :- + findall(Time-Video, + annotation_process(User, Video, _Process, Time), Pairs0), keysort(Pairs0, Pairs1), reverse(Pairs1, Pairs), - pairs_values(Pairs, Processes). -user_video_processes(User, _Value, Processes) :- - findall(Time-(Video-[process(Process, Time, [])]), - annotation_process(User, Video, Process, Time), - Pairs0), - keysort(Pairs0, Pairs1), - reverse(Pairs1, Pairs), - pairs_values(Pairs, Processes). - -annotation_value_process(User, Video, Value, Process, StartTime, [annotation(Value, Times)]) :- - annotation_process(User, Video, Process, StartTime), - findall(Time, - value_annotation(literal(Value), Process, User, Time), - Times), - Times = [_|_]. + pairs_values(Pairs, SortedVideos). -%% html_videos_page(+Video, +NumberOfResults, +Offset, +Limit, -%% +User, +Annotation) +%% html_page(+Videos, +NumberOfResults, +Offset, +Limit) % % Emit HTML page with a list of Videos. -html_videos_page(Results, NumberOfResults, Offset, Limit, Options) :- +html_page(Results, NumberOfResults, Offset, Limit) :- reply_html_page(yaz, [ title(['YAZ - sessions']) ], - [ \html_requires(css('videos.css')), - div(class(topic), + [ div(class(topic), [ div(class(header), - h2(\message(NumberOfResults, Options))), + h2(\video_count(NumberOfResults))), div(class(body), - ul(class('thumb-list'), - \html_video_list(Results, [desc(true)|Options]))), + ol(class('result-list'), + \html_video_list(Results, [desc(true)]))), div(class(footer), div(class(paginator), \html_paginator(NumberOfResults, Offset, Limit) )) ])]). -message(N, Options) --> - html([\video_count(N), - \tag_message(Options) - ]). - video_count(1) --> - html('1 session'). + html('1 tagged video'). video_count(N) --> - html([N, ' sessions']). - -tag_message(Options) --> - { option(tag(Tag), Options) - }, - html([' with tag ', Tag]). -tag_message(_) --> !. + html([N, ' videos tagged']). %% html_video_list(+Videos, +Options)// @@ -127,85 +81,6 @@ tag_message(_) --> !. % Emit html with a list of videos. html_video_list([], _) --> !. -html_video_list([Video-Processes|Vs], Options) --> - html(li(class('video'), - \html_video_item(Video, Processes, Options))), +html_video_list([Video|Vs], Options) --> + html(li(\yaz_video_result(Video, Options))), html_video_list(Vs, Options). - -html_video_item(URL, Processes, Options) --> - { display_label(URL, Title), - video_source(URL, Video), - truncate_atom(Title, 47, ShortTitle), - ( option(desc(true), Options) - -> video_desc(URL, Description) - ; Description = '' - ), - option(frame(Frame), Options, 5), - delete(Options, desc(_), Options1), - http_link_to_id(http_yaz_player, [video(URL)|Options1], Link), - http_link_to_id(serve_video_frame, [url(Video),time(Frame)], FrameURL) - }, - html(div(class('item-content'), - [ a(href(Link), - [ div(class('thumb-container'), - img([width('140px'), alt('no image available'), - title(Title), src(FrameURL)], [])), - div(class('title'), - a([href(Link),title(Title)], - ShortTitle)), - div([class('description'), title(Description)], - Description) - ]), - div(class('processes'), - \html_process_list(Processes, Video, Link)) - ])). - -%% html_process_list(+Processes, +Video, +Link)// -% -% Emit html with a list of annotation processes. - -html_process_list([], _, _) --> !. -html_process_list([process(Process, Time, Annotations)|T], Video, Link) --> - { rdf(Process, rdf:type, Session0), - rdf_display_label(Session0, Session) - }, - html(div(class('process'), - [ div(class('process-time'), - [Session, ' at ', Time]), - div(class('annotations'), - \html_annotations(Annotations, Video, Link)) - ])), - html_process_list(T, Video, Link). - -/* - process_time(StartTime, Time), - ( format_time(string(FormattedTime), '%d %B %H:%M', Time) - -> true - ; FormattedTime = StartTime - ) -*/ - - -html_annotations([], _, _) --> !. -html_annotations([annotation(Value, Times0)|Ts], Video, Link) --> - { tag_term_label(Value, _Term, TagLabel), - sort(Times0, Times) - }, - html([ div(class('annotation-value'), - [ TagLabel, ': ' ]), - ul(class('annotation-times'), - \html_annotation_times(Times, Video, Link)) - ]), - html_annotations(Ts, Video, Link). - -html_annotation_times([], _, _) --> !. -html_annotation_times([Time|T], Video, Link) --> - { Seconds is Time/1000, - SeekTime is Seconds-5, - format_time(string(FormattedTime), '%M:%S', Seconds) - }, - html(li(class('tag-time'), - a(href(Link+'&start='+SeekTime), FormattedTime))), - html_annotation_times(T, Video, Link). - - diff --git a/components/yaz_page.pl b/components/yaz_page.pl index 32b898c..e0dae9f 100644 --- a/components/yaz_page.pl +++ b/components/yaz_page.pl @@ -9,9 +9,9 @@ :- use_module(library(http/http_parameters)). :- use_module(user(user_db)). :- use_module(applications(isearch)). -:- use_module(applications(yaz_videos)). :- use_module(library(http/http_wrapper)). :- use_module(library(semweb/rdf_db)). +:- use_module(components(yaz_video_item)). :- multifile user:body//2. @@ -65,7 +65,7 @@ cliopatria:format_search_result(R, Graph) --> { result_frame(R, Graph, Frame) }, html(div(class('result-item'), - \html_video_item(R, [], [desc(true), frame(Frame)]))). + \yaz_video_result(R, [desc(true), frame(Frame)]))). cliopatria:facet_weight(P, 0) :- rdf_equal(pprime:hasAnnotation, P). diff --git a/lib/video_annotation.pl b/lib/video_annotation.pl index dd10a8b..73ccc7f 100644 --- a/lib/video_annotation.pl +++ b/lib/video_annotation.pl @@ -190,7 +190,7 @@ annotation_in_process(Process, Video, AnnotationId) :- rdf(Video, pprime:hasAnnotation, AnnotationId). annotation_in_process(Process, Video, AnnotationId) :- rdf(Video, pprime:hasAnnotation, AnnotationId, F), - ( F == Process % provenance is stored in the transaction + ( F = Process:_ % provenance is stored in the transaction -> true ; rdf(AnnotationId, opmv:used, Process) % provenance is stored explicit ). diff --git a/lib/yaz_util.pl b/lib/yaz_util.pl index 5fa274b..9195989 100644 --- a/lib/yaz_util.pl +++ b/lib/yaz_util.pl @@ -19,7 +19,8 @@ video_source/2, video_source/3, annotation_to_json/2, - video_desc/2 + video_desc/2, + display_time/2 ]). :- use_module(library(semweb/rdf_db)). @@ -349,3 +350,13 @@ video_desc(VideoURL, Desc) :- literal_text(Lit, Desc), !. video_desc(_, ''). + + +display_time(Time, FormattedTime) :- + parse_time(Time, Stamp), + !, + format_time(string(FormattedTime), '%d %B %H:%M', Stamp). +display_time(Stamp, FormattedTime) :- + catch(format_time(string(FormattedTime), '%d %B %H:%M', Stamp), _, fail), + !. +display_time(Time, Time). diff --git a/web/css/player.css b/web/css/player.css index 6c2057e..ff85397 100644 --- a/web/css/player.css +++ b/web/css/player.css @@ -228,4 +228,22 @@ ul.game-players { } .game-players li .score { float: right; +} + +/* facets */ +.facets { + overflow: hidden; + border: 1px solid #CCC; + margin-bottom: 10px; +} +.processes, +.users { + float: left; + margin-right: 15px; + height: 4em; + overflow-y: scroll; + width: 200px; +} +.facets li { + list-style: none; } \ No newline at end of file diff --git a/web/css/videos.css b/web/css/videos.css index 28b5a5c..4ed0c9f 100644 --- a/web/css/videos.css +++ b/web/css/videos.css @@ -1,34 +1,48 @@ -/* videos */ -.thumb-list { - margin: 15px 0; +.result-list { padding: 0; } -.thumb-list li.video { +.result-list .video-result { + clear: both; +} +.result-list li { overflow: auto; list-style: none; margin-bottom: 15px; } -.thumb-list .thumb-container { - float: left; - margin-right: 5px; -} -.thumb-list .processes { - font-size: 95%; - color: #666; -} -.process { +.video-item { + padding: 5px; overflow: auto; - margin-top: 4px; } -.annotation-value { +.video-result:hover { + cursor: pointer; + background-color: #D1E1FA; +} +.video-thumb { + margin-right: 10px; + width: 140px; float: left; + -moz-border-radius: 3px; + border-radius: 3px; + border: 1px solid #DDD; + overflow: hidden; + padding: 4px; + font-size: 0.8em; + text-align: center; } -ul.annotation-times { - margin-left: 5px; - padding: 0; +.video-header .title { + margin-bottom: 0; } -.annotation-times li { - float: left; - margin-left: 5px; - list-style: none; +.video-item .title, +.video-result .title { + line-height: 1.4em; + overflow: hidden; +} +.video-header .desc, +.video-item .desc, +.video-result .desc { + font-size: 0.95em; + line-height: 1.05em; + max-height: 3.15em; + overflow: hidden; + color: #666; } \ No newline at end of file diff --git a/web/css/yaz.css b/web/css/yaz.css index e6d8c27..5c1cbe0 100644 --- a/web/css/yaz.css +++ b/web/css/yaz.css @@ -123,6 +123,9 @@ a img { overflow: auto; } + +/* paginator */ + .paginator { text-align: center; margin: 10px 0 20px; @@ -137,19 +140,39 @@ a img { border-color: #CCC; } -.item-content { - padding: 5px; +/* videos */ + +.result-list, +.result-line { + padding: 0; +} +.result-list .video-result { + clear: both; +} +.result-list li { + overflow: auto; + list-style: none; + margin-bottom: 15px; +} +.result-list .video-thumb { + float: left; +} +.result-line li { overflow: auto; + list-style: none; + float: left; + margin-right: 20px; + width: 150px; } -.item-content:hover { +/* +.result-list li:hover, +.result-line li:hover { cursor: pointer; background-color: #D1E1FA; -} -.item-content .thumb-container { +}*/ +.video-thumb { margin-right: 10px; - min-height: 3em; width: 140px; - float: left; -moz-border-radius: 3px; border-radius: 3px; border: 1px solid #DDD; @@ -158,14 +181,17 @@ a img { font-size: 0.8em; text-align: center; } -.item-content .thumb-container img { +.video-header .title { + margin-bottom: 0; } -.item-content .title { - font-size: 1.05em; +.video-item .title, +.video-result .title { line-height: 1.4em; overflow: hidden; } -.item-content .description { +.video-header .desc, +.video-item .desc, +.video-result .desc { font-size: 0.95em; line-height: 1.05em; max-height: 3.15em; @@ -173,6 +199,26 @@ a img { color: #666; } +/* tags */ + +#tags .body { + background-color: #F5F5F5; +} + +#tags .tag-cloud { + width: 600px; + margin: 0 auto; + padding: 20px 0; + text-align: center; +} + +.tag-cloud a { + padding: 0 0.5em; +} + + + h4 { margin-bottom: 3px; -} \ No newline at end of file +} +