EDM/commit
ADDED: Present EDM data for isearch by means of hooks
author | Jan Wielemaker |
---|---|
Tue Mar 1 14:43:02 2011 +0100 | |
committer | Jan Wielemaker |
Tue Mar 1 14:43:02 2011 +0100 | |
commit | 7521933b96f1b2002a0e33be5ea9d1d232ecf4f3 |
tree | 4391f70a176f28896ddd9b20110e26970a1d3408 |
parent | 55dd51b39dc956a3459e8c9f3d90afa13822e522 |
Diff style: patch stat
diff --git a/components/edm/components.pl b/components/edm/components.pl index ce51b89..6ce8399 100644 --- a/components/edm/components.pl +++ b/components/edm/components.pl @@ -30,7 +30,8 @@ :- module(edm_components, [ edm_display_link//2, % +URI, +Options - edm_proxy_view//2 % +URI, +Options + edm_proxy_view//2, % +URI, +Options + edm_result_summary//2 % +URI, +Options ]). :- use_module(cliopatria(hooks)). :- use_module(library(http/page_info)). @@ -72,7 +73,8 @@ edm_display_link(R, Options) --> ; { http_absolute_location(icons('external-link-ltr-icon.png'), External, []) }, - html(span([ \rdf_link(R, [edm(false)|Options]), + html(span(class(no_img), + [ \rdf_link(R, [edm(false)|Options]), html(a([class(img), href(R)], img(src(External)))) ])) ). @@ -106,6 +108,26 @@ edm_proxy_view(URI, _Options) --> div(class(fullview), a(href(FullHREF), 'Full view')) ])). +%% edm_result_summary(+URI, +Options)// is det. +% +% Format a search-result. + +edm_result_summary(URI, _Options) --> + { type_styles(URI, Styles), + http_link_to_id(list_resource, [r=URI], HREF) + }, + html_requires(css('edm.css')), + html(div(class(Styles), + [ a(href(HREF), \values(div, URI, dcterms:title)), + \values(div, URI, ore:proxyIn -> ens:object), + \values(div, URI, dcterms:creator), + \values(div, URI, dcterms:description, + [ resource_format(label), + max_length(100), + max_count(2) + ]) + ])). + type_styles(URI, Styles) :- findall(Style, type_style(URI, Style), Styles). @@ -114,29 +136,63 @@ type_style(URI, Class) :- uri_css_class(Type, Class). values(Element, URI, Path) --> - { has_values(URI, Path, Pairs) + values(Element, URI, Path, [resource_format(label)]). + +values(Element, URI, Path, Options) --> + { has_values(URI, Path, Pairs, Options) }, - values(Pairs, Element). + html_values(Pairs, Element, Options). -values([], _) --> []. -values([V-Classes|T], Element) --> - { HTML =.. [Element, class(Classes), \value(V)] }, +html_values([], _, _) --> []. +html_values([V-Classes|T], Element, Options) --> + { HTML =.. [Element, class(Classes), \value(V, Options)] }, html(HTML), - values(T, Element). + html_values(T, Element, Options). + +%% value(+Value, +Options)// is det. +% +% Show the actual value +:- public value//2. % Called by values//3 -%% has_values(+URI, +Path, -Pairs) is det. +value(Literal, Options) --> + { rdf_is_literal(Literal), !, + literal_text(Literal, Text0), + truncate_text(Text0, Text, Options) + }, + html(Text). +value(R, Options) --> + rdf_link(R, Options). + +truncate_text(Text, Text, []) :- !. +truncate_text(Text, Truncated, Options) :- + option(max_length(Len), Options), !, + truncate_atom(Text, Len, Truncated). +truncate_text(Text, Text, _). + +%% has_values(+URI, +Path, -Pairs, +Options) is det. % % Pairs is a list of Value-Classes pairs. -has_values(URI, Path, Pairs) :- +has_values(URI, Path, Pairs, Options) :- findall(Value-Classes, has_value(Path, URI, Classes, Value), Pairs0), partition(pair_preferred_lang, Pairs0, Preferred, NonPreferred), ( Preferred == [] - -> Pairs = NonPreferred - ; Pairs = Preferred + -> Pairs1 = NonPreferred + ; Pairs1 = Preferred + ), + ( option(max_count(Max), Options) + -> limit(Pairs1, Max, Pairs) + ; Pairs = Pairs1 ). +limit([], _, []) :- !. +limit(_, 0, []) :- !. +limit([H|T0], N, [H|T]) :- + succ(N2, N), + limit(T0, N2, T). + + pair_preferred_lang(Value-_CSS) :- preferred_lang(Value). @@ -165,18 +221,6 @@ uri_css_class(URI, Class) :- iri_xml_namespace(URI, _, Class). -%% value(+Value)// is det. -% -% Show the actual value - -value(Literal) --> - { rdf_is_literal(Literal), !, - literal_text(Literal, Text) - }, - html(Text). -value(R) --> - rdf_link(R). - %% preferred_lang(+Object) % % True if Object is stated in the preferred language of the user diff --git a/config-available/EDM.pl b/config-available/EDM.pl index d8594e3..af8142a 100644 --- a/config-available/EDM.pl +++ b/config-available/EDM.pl @@ -27,3 +27,7 @@ cliopatria:node_shape(URI, Shape, Options) :- cliopatria:list_resource(Proxy) --> { rdfs_individual_of(Proxy, ore:'Proxy') }, edm_proxy_view(Proxy, []). + +cliopatria:format_search_result(Proxy, _Graph) --> + { rdfs_individual_of(Proxy, ore:'Proxy') }, + edm_result_summary(Proxy, []). diff --git a/web/css/edm.css b/web/css/edm.css index df031c3..cbf9687 100644 --- a/web/css/edm.css +++ b/web/css/edm.css @@ -18,6 +18,24 @@ div.Proxy div.title font-weight: bold; } +ol.result-list div.Proxy div.title +{ font-size: 120%; +} + +ol.result-list div.Proxy div.title:hover +{ font-size: 120%; + color: #00f; + text-decoration: underline; +} + +ol.result-list div.Proxy div.creator +{ font-size: 100%; +} + +ol.result-list span.no_img +{ display: none; +} + div.Proxy div.creator { font-size: 130%; font-weight: bold; @@ -40,6 +58,10 @@ div.Proxy div.hasThumbnail { margin-right: 1em; } +ol.result-list div.Proxy img.thumbnail +{ max-height: 64px; +} + div.Proxy img.thumbnail { max-height: 250px; margin: 0px 1em;