<?xml version="1.0" encoding="UTF-8"?>
<actions>

<meta>
  <description>Template für aleph 2007 mit PDS SSO Loginserver (vor allem für die TU-Berlin)</description>
  <variable name="server"><description>Serveraddresse, ohne Protokoll mit trailing slash</description></variable>
  <variable name="institute"><description>Institutsid des Katalogs</description></variable>
</meta>

<action id="connect">
    <page url="http://{$server}/F/?func=bor-info" >
      <template>
        <head> 
        <title>PDS SSO</title> 
        <script>  
        <template:read source="text()" var="borInfoPage" regex="http://.*bor-info"/> <!-- assuming that login server is https and books are http -->
        </script> 
        </head> 
      </template>
    </page>
    <page url="{$borInfoPage}">
      <template><script>{redirectedPage:=extract(., "https?://[^'""]+")}</script></template>
    </page>
    <page url="{$redirectedPage}">
      <post name="func" value="login"/>
      <post name="calling_system" value="aleph"/>
      <post name="bor_id" value="{$username}"/>
      <post name="bor_verification" value="{$password}"/>      
      <post name="institute" value="{$institute}"/>
      <post name="url" value="{$borInfoPage}"/>
      
      <template>
        <template:switch-prioritized>
          <html>
            <head><title>relocate</title></head>
            <body>
            <noscript><a><template:read var="borInfoPage2" source="@href" regex="http://.*"/> </a></noscript>
            </body>
          </html>
          
          <html>
            <head><title>Login</title></head>
            <body>
              <TD class=msg><t:read var="raise()" source="deep-text()"/></td>
            </body>
          </html>
         </template:switch-prioritized>
      </template>      
    </page>
    
    
    <page url="{$borInfoPage2}" templateFile="../aleph_base/loggedIn2007"/>
</action>

<action id="update-all">
  <page url="{$bookPage}" templateFile="update"/>
</action>

<action id="update-single">
  <page url="{$book.detailLink}" templateFile="../aleph_base/details"/>
</action>

<action id="renew-single">
  <page url="{$book.extendLink}"/>
  <page url="{$book.detailLink}" templateFile="../aleph_base/details"/>
</action>
</actions>
