KPAC: Won't somebody think of the children's record details?
authorDan Scott <dscott@laurentian.ca>
Thu, 23 Jan 2014 14:10:59 +0000 (09:10 -0500)
committerDan Scott <dscott@laurentian.ca>
Sat, 25 Jan 2014 14:20:04 +0000 (09:20 -0500)
Factor out the library name link logic into a separate template that can be
included by TPAC search results, TPAC record details, and KPAC record details.

Notice along the way that the KPAC is devoid of copy-level structured data,
but save that for later.

Signed-off-by: Dan Scott <dscott@laurentian.ca>
Signed-off-by: Ben Shum <bshum@biblio.org>
Open-ILS/src/templates/kpac/parts/copy_table.tt2
Open-ILS/src/templates/opac/parts/library_name_link.tt2 [new file with mode: 0644]
Open-ILS/src/templates/opac/parts/record/copy_table.tt2
Open-ILS/src/templates/opac/parts/result/table.tt2

index 58fc329..7427220 100644 (file)
@@ -37,13 +37,7 @@ END;
         -%]
         <tr>
             <td class="location">
-            [%-
-                org_name = ctx.get_aou(copy_info.circ_lib).name;
-                lib_url = ctx.get_org_setting(copy_info.circ_lib, 'lib.info_url');
-                IF lib_url; '<a href="'; lib_url | url; '">'; END;
-                org_name | html;
-                IF lib_url; '</a>'; END;
-            -%]
+            [%- INCLUDE "opac/parts/library_name_link.tt2"; -%]
             </td>
             [%- IF has_parts == 'true' %]
             <td class="callnumber">[% l('[_1] ([_2])', callnum, copy_info.part_label) | html %]</td>
diff --git a/Open-ILS/src/templates/opac/parts/library_name_link.tt2 b/Open-ILS/src/templates/opac/parts/library_name_link.tt2
new file mode 100644 (file)
index 0000000..c002ce2
--- /dev/null
@@ -0,0 +1,13 @@
+[%-
+    org_name = ctx.get_aou(copy_info.circ_lib).name;
+    org_sname = ctx.get_aou(copy_info.circ_lib).shortname;
+    lib_url = ctx.get_org_setting(copy_info.circ_lib, 'lib.info_url');
+    prefer_external_url = ctx.get_org_setting(copy_info.circ_lib, 'lib.prefer_external_url');
+    UNLESS lib_url && prefer_external_url;
+        lib_url = mkurl(ctx.opac_root _ '/library/' _ ctx.get_aou(copy_info.circ_lib).shortname, {}, 1);
+    END; 
+    IF lib_url; '<a property="seller" typeof="Library" href="'; lib_url | url; '">'; END;
+    '<span property="name">'; org_name | html; '</span>';
+    IF lib_url; '</a>'; END;
+-%]
+
index be0d62c..b5fdd94 100644 (file)
@@ -94,17 +94,8 @@ END; # FOREACH bib
                 [%- copy_info.holding_label | html; -%]
             </td>
             [%- ELSE %]<td headers='copy_header_library'>
-            [%-
-                org_name = ctx.get_aou(copy_info.circ_lib).name;
-                org_sname = ctx.get_aou(copy_info.circ_lib).shortname;
-                lib_url = ctx.get_org_setting(copy_info.circ_lib, 'lib.info_url');
-                prefer_external_url = ctx.get_org_setting(copy_info.circ_lib, 'lib.prefer_external_url');
-                UNLESS lib_url && prefer_external_url;
-                    lib_url = mkurl(ctx.opac_root _ '/library/' _ ctx.get_aou(copy_info.circ_lib).shortname, {}, 1);
-                END; 
-                IF lib_url; '<a property="seller" typeof="Library" href="'; lib_url | url; '">'; END;
-                '<span property="name">'; org_name | html; '</span>';
-                IF lib_url; '</a>'; END;
+            [%- copy_info = copy;
+                INCLUDE "opac/parts/library_name_link.tt2";
             -%]
                 <link property="businessFunction" href="http://purl.org/goodrelations/v1#LeaseOut">
                 <link property="itemOffered" href="#schemarecord">
index ff2766b..0122152 100644 (file)
@@ -247,18 +247,7 @@ END;
                                                                 [% FOR copy IN args.holdings %]
                                                                         <tr>
                                                                             <td>
-[%-
-    org_name = ctx.get_aou(copy.circ_lib).name;
-    org_sname = ctx.get_aou(copy.circ_lib).shortname;
-    lib_url = ctx.get_org_setting(copy.circ_lib, 'lib.info_url');
-    prefer_external_url = ctx.get_org_setting(copy.circ_lib, 'lib.prefer_external_url');
-    UNLESS lib_url && prefer_external_url;
-        lib_url = mkurl(ctx.opac_root _ '/library/' _ ctx.get_aou(copy.circ_lib).shortname, {}, 1);
-    END; 
-    IF lib_url; '<a property="seller" typeof="Library" href="'; lib_url | url; '">'; END;
-    '<span property="name">'; org_name | html; '</span>';
-    IF lib_url; '</a>'; END;
--%]
+[%- INCLUDE "opac/parts/library_name_link.tt2" %]
                                                                             </td>
                                                                             <td>[% copy.location | html %]</td>
                                                                             <td>[% copy.label | html %]</td>