:- module(yaz_videos, [ http_yaz_videos/1 ]). :- use_module(library(http/http_dispatch)). :- use_module(library(http/http_parameters)). :- use_module(library(http/html_write)). :- use_module(library(http/http_host)). :- use_module(library(http/http_path)). :- use_module(library(http/html_head)). :- use_module(library(semweb/rdf_db)). :- use_module(library(semweb/rdf_label)). :- use_module(user(user_db)). :- use_module(library(yaz_util)). :- use_module(library(videos)). :- use_module(components(yaz_page)). :- use_module(components(yaz_video_item)). :- use_module(components(paginator)). :- http_handler(yaz(videos), http_yaz_videos, []). %% http_yaz_videos(+Request) % % Emit a all videos a user has annotated. http_yaz_videos(Request) :- http_parameters(Request, [ user(User0, [default(''), description('Current user id')]), type(Type, [oneof([active,suggested,queue,moderated,all]), default(all)]), offset(Offset, [default(0), integer, description('Offset of the result list')]), limit(Limit, [default(20), integer, description('Limit on the number of results')]) ]), logged_on(LoggedOn0, _), ( nonvar(LoggedOn0) -> user_property(LoggedOn0, url(LoggedOn)) ; var(LoggedOn) ), ( User0 == all -> var(User) ; User0 == '' -> User = LoggedOn ; User = User0 ), ( Type == queue -> video_queue(Videos) ; Type = moderated -> moderated_videos(User, Videos) ; Type = active -> active_videos(User, Videos) ; Type = suggested -> suggested_videos(User, Videos) ; ingested_videos(Videos) ), length(Videos, NumberOfResults), list_offset(Videos, Offset, OffsetResults), list_limit(OffsetResults, Limit, LimitResults, _), html_page(LimitResults, NumberOfResults, Offset, Limit, Type, User, LoggedOn). %% html_page(+Videos, +NumberOfResults, +Offset, +Limit) % % Emit HTML page with a list of Videos. html_page(Results, NumberOfResults, Offset, Limit, Type, User, LoggedOn) :- reply_html_page(yaz, [ title(['YAZ - sessions']) ], [ div(class(topic), [ div(class(header), h2([\header(Type, User, NumberOfResults), \other_link(LoggedOn, User, Type) ])), div(class(body), ol(class('result-list'), \html_video_list(Results, [desc(true)]))), div(class(footer), div(class(paginator), \html_paginator(NumberOfResults, Offset, Limit) )) ])]). other_link(LoggedOn, all, Type) --> { nonvar(LoggedOn), http_link_to_id(http_yaz_videos, [type(Type)], HREF) }, !, html([' / ', a(href(HREF), \other_label(Type, user))]). other_link(LoggedOn, _User, Type) --> { nonvar(LoggedOn), http_link_to_id(http_yaz_videos, [type(Type),user(all)], HREF) }, !, html([' / ', a(href(HREF), \other_label(Type, all))]). other_link(_, _, _) --> !. header(queue, _, N) --> !, html([N, ' ', \video_label(N), ' waiting for moderation']). header(moderated, User, N) --> { nonvar(User) }, !, html([N, ' ', \video_label(N), ' moderated by you']). header(moderated, _, N) --> !, html([N, ' moderated ', \video_label(N)]). header(suggested, _, N) --> !, html([N, \video_label(N), ' suggested to you']). header(active, User, N) --> { nonvar(User) }, !, html([N, ' ', \video_label(N), ' being moderated by you']). header(active, _User, N) --> html([N, ' ', \video_label(N), ' under moderation']). header(all, User, N) --> { nonvar(User) }, !, html([N, ' ', \video_label(N), ' assigned to you']). header(all, _, N) --> html([N, ' ingested ', \video_label(N)]). other_label(moderated, all) --> html('all moderated videos'). other_label(moderated, user) --> html('your moderated videos'). other_label(active, all) --> html('all videos being moderated'). other_label(active, user) --> html('your active videos'). %% html_video_list(+Videos, +Options)// % % Emit html with a list of videos. html_video_list([], _) --> !. html_video_list([Video|Vs], Options) --> html(li(\yaz_video_result(Video, Options))), html_video_list(Vs, Options).