1 [%- USE money = format(l('$%.2f'));
6 SET DATE_FORMAT = l('%m/%d/%Y');
7 PROCESS "opac/parts/config.tt2";
9 # Don't wrap in l() here; do that where this format string is actually used.
10 SET HUMAN_NAME_FORMAT = '[_1] [_2] [_3] [_4] [_5]';
12 is_advanced = CGI.param("_adv").size || CGI.param("query").size;
13 is_special = CGI.param("_special").size;
15 # Check if we want to show the detail record view. Doing this
16 # here because we don't want to repeat logic in multiple other
17 # files, nor do we want to add a new tt2 file just for this. The
18 # below is currently needed for parts/result/table.tt2,
19 # parts/searchbar.tt2, and results.tt2.
21 IF CGI.param("detail_record_view").defined;
22 show_detail_view = CGI.param("detail_record_view");
23 ELSIF show_more_details.default == "true" OR
24 show_more_details.default == "hide";
28 #variables to use to remove parameters via mkurk
29 expert_search_parms = ['tag','subfield','term','_special'];
30 general_search_parms = ['page','sort','query','bool','contains','pubdate'];
31 browse_search_parms = ['fi:has_browse_entry','bterm','blimit','bpivot'];
32 facet_search_parms = ['facet'];
35 # -----------------------------------------------------------------------------
36 # mkurl( destination_page, params_to_set, params_to_clear )
38 # Current page, updated params:
39 # mkurl('', {foo => 'bar', boo => 'baz'});
41 # New page, one param is a list:
42 # mkurl('http://flarg.baz/squz', {foo => 'bar', boo => ['baz', 'faz']});
44 # New page, clear all existing params before applying new ones:
45 # mkurl('/fuz/buster', {foo => 'bar', boo => 'baz'}, 1);
47 # Current page, clear 'some_param' from the existing params:
48 # mkurl('', {foo => 'bar', boo => 'baz'}, ['some_param']);
50 # Current page to a named anchor 'copies'
51 # mkurl('', {}, [], 'copies');
52 MACRO mkurl(page, params, clear_params, named_anchor) BLOCK;
54 # clone the query string to avoid clobberation
55 cgi = CGI.new(CGI.query_string);
57 # remove requested params
58 IF clear_params.0; # array
59 FOR p IN clear_params; cgi.delete(p); END;
64 # some standing, hardcoded parameters to always clear
65 # because they're used for specific, transitory purposes
66 cgi.delete('move_cart_by_default');
67 cgi.delete('cart_none_selected');
68 cgi.delete('list_none_selected');
70 # x and y are artifacts of using <input type="image" /> tags
71 # instead of true submit buttons, and their values are never used.
79 # The following commented-out line can be fooled. Its replacement
80 # below is what you really mean.
81 # list = (params.$k.0 OR max == -1) ? params.$k : [params.$k];
82 list = params.$k.list;
84 IF list.size == 0; NEXT; END;
85 # CGI croaks on already-decoded strings. force-encode to be safe.
86 FOR p IN list; encoded.push(ctx.encode_utf8(p)); END;
87 foo = cgi.param("-name", k, "-values", encoded);
90 # for url brevity, remove any params that have no value
93 IF val == ''; cgi.delete(p); END;
95 # Delete POST vars unless we asked for them
96 UNLESS CGI.url_param(p).defined OR params.defined(p);
101 final = named_anchor ? '#' _ named_anchor : '';
105 page _ '?' _ cgi.query_string _ final;
110 # staying on the current page
111 cgi.url("-absolute" => 1, "-path" => 1, "-query" => 1) _ final;
115 # Dojo is required for the copy locations advanced search filter
116 IF ctx.page == 'advanced';
120 # ... and for code that tweaks visibility of types on the added
122 IF ctx.page == 'record' AND (ctx.expand_addedcontent OR ctx.expand_all);
126 use_autosuggest = ctx.get_cgf("opac.use_autosuggest");
128 IF use_autosuggest.enabled == "t";
132 IF ENV.OILS_NOVELIST_URL;
136 IF ebook_api.enabled == 'true';
140 # Especially useful for image 'alt' tags and link title tags,
141 # where the content may need to be unique (making it longer)
142 # but should not exceed 75 chars for ideal screen reader support.
143 # usage: html_text_attr('title', 'Link to item I Have A Super Long Title')
144 # the full HTML attribute key="value" is produced
145 MACRO html_text_attr(name, value) BLOCK;
146 IF value.length >= 75;
147 value = value.substr(71, value.length, '...');
149 value = value.replace('\s*$', ''); # remove trailing whitespace
150 HTML.attributes($name => value);
153 MACRO img_alt(text) BLOCK;
154 html_text_attr('alt', text);
157 # Browser cache-busting key
158 # Fall back to the eg_cache_hash (set by autogen) so that we don't have to
159 # add conditionals into the rest of the templates
160 IF ctx.cache_key AND ctx.cache_key != "?" _ ctx.eg_cache_hash;
161 ctx.cache_key = "?v=" _ ctx.cache_key;
163 ctx.cache_key = "?" _ ctx.eg_cache_hash;