source: MILK/trunk/milk_server/milk_server/templates/ndgPage.kid @ 5305

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/MILK/trunk/milk_server/milk_server/templates/ndgPage.kid@5305
Revision 5305, 8.7 KB checked in by cbyrom, 10 years ago (diff)

Improve structure of DiscoveryState? module by adding a new object,
PagerState? to hold the data connected to the results table paging.
Also tidy up code layout and simplify logic. Create new template
method, pagerControl, to represent the results table paging control

  • to allow reuse across the results and short_results templates.
Line 
1<!-- This is a bunch of named templates for use in pages -->
2<html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://purl.org/kid/ns#">
3   
4    <!-- HTML Header and Document header follow -->
5   
6    <head py:def="pagehead()" py:strip="True">
7        <title py:content="c.title">title</title>
8        <!--! The following includes the javascript, note that the XML
9        function is needed to avoid escaping the < character -->
10        ${XML(h.javascript_include_tag(builtins=True))}
11        <script type="text/javascript" src="$g.server/js/toggleDiv.js"/>
12
13        <link media="all, screen" href="$g.server/layout/style/ndg2.css" type="text/css" rel="stylesheet"/>
14    </head>
15   
16    <div py:def="header()">
17        <div py:if="g.browseEnabled and not g.discoveryEnabled and not g.atomEditorEnabled" id="browseheader"/>
18        <div py:if="not (g.browseEnabled and not g.discoveryEnabled and not g.atomEditorEnabled)" id="editorheader"/>
19        <div id="logo"><img src="$g.LeftLogo" alt="$g.LeftAlt" /></div>
20    </div>
21
22    <div py:def="pageControl(state, discoveryURL)" class="resultsBar">
23    <!-- NB, can only have one main page control on the page since it has a form and
24    help div associated with it - for the main control, set the discoveryURL to a valid
25    value, otherwise set to None
26    -->
27            <div>
28                <?python
29                formID = "xyz"
30                if discoveryURL:
31                        formID = "orderByForm"
32                ?>
33                <form action="$discoveryURL" name="$formID">
34                <input type="hidden" name="constraints" value="${state.urlformattedconstraints}"/>
35                <a href="${state.constrainedurl}"> Refine search</a><span py:replace="helpIcon('refser_help')"/>
36                <span py:if="state.hits != 0" py:strip="">
37                        <span py:if="discoveryURL" py:strip="">
38                            | Order By ${XML(h.select('orderBy',option_tags = c.orderByList, onchange="orderByForm.submit()"))}
39                        ${XML(h.select('orderDirection',option_tags = c.orderDirection, onchange="orderByForm.submit()"))}
40                    </span>
41                        | Found ${state.hits}
42                    <span py:if="state.pager.previousPageURL"> | <a href="$state.pager.startPageURL"> &lt;&lt; </a>
43                    | <a href="$state.pager.previousPageURL"> Previous ${state.pager.previousNumber}</a> </span>
44                                | Showing ${state.pager.lowerRange}-${state.pager.upperRange}
45                    <span py:if="state.pager.nextPageURL"> | <a href="$state.pager.nextPageURL"> Next ${state.pager.nextNumber}</a>
46                    | <a href="$state.pager.lastPageURL"> &gt;&gt; </a></span>
47                 </span>
48                </form>
49            </div>
50            <div py:if="discoveryURL" id="refser_help" class="hidden">
51                <div class="helptxt"><p>
52                The refined search option allows you to constrain your search by returning you to the advanced search page, but retaining your current search parameters
53                </p></div>
54            </div>
55        </div>
56   
57    <!-- One line search box for top of many pages follows -->
58    <div py:def="searchOneLine(targets=0)" class="searchBar">
59        <table width="100%"><tr><td align="left">
60        <form action="$g.discoveryURL">
61            New text search<span py:replace="helpIcon('nts_help')"/>&nbsp;
62            <input type="text" size="25" name="searchString"/>
63            <select name="textTarget">
64            <option value="Authors">Authors</option>
65            <option value="All" selected="selected">All</option>
66            <option value="Params">Parameters</option>
67            </select>
68            <span py:if="targets"> in
69            <?python
70            sel=[['Discovery','Discovery'],['Browse','Browse'],['Simulation','NumSim']]
71            ?>
72            <select name="searchTarget">
73                ${XML(h.options_for_select(sel,targets))}
74            </select>
75            </span>
76            <input type="submit" value="Search"/>
77         </form>
78         </td><!--<td align="right">
79         <form action="$g.discoveryURL">
80            <input type="submit" value="New Search"/>
81            <span py:replace="helpIcon('ns_help')"/>
82         </form>
83         </td>--><td py:if="not g.standalone" align="right">
84            <span py:if="'ndgSec' in session" id="loginBar">
85            <span py:replace="logOut()"/></span>
86            <span py:if="'ndgSec' not in session" id="loginBar">
87            <span py:replace="logIn()"/></span>
88        </td></tr></table>
89          <div id="nts_help" class="hidden">
90            <div class="helptxt"><p> This will do a completely new text search with no constraints beyond the target of the
91            text search from the drop down list (All, Authors, Parameters) </p></div>
92          </div>
93          <div id="ns_help" class="hidden">
94            <div class="helptxt"><p> This will return you to the new search page</p></div>
95          </div>
96    </div>
97   
98    <div py:def="PageTabs(tabv)" id="PageTabs">
99        <div id="PageTabRow">
100            <ul>
101                <span py:for="tab in c.pageTabs">
102                    <?python
103                    linkto=True
104                    if tab[0] == tabv:
105                        status='current'
106                        linkto=False
107                    else: status='hidden'
108                    ?>
109                    <li class="$status"><span class="pagetab">
110                        ${XML(h.link_to_if(linkto,tab[0],tab[1]))}
111                    </span></li>
112                 </span>
113            </ul>
114        </div>
115        <div class="line"/>
116        <div class="clear"/>
117    </div>
118    <py if="c.UpdatePageTabs" py:replace="PageTabs(c.current)"/>
119
120    <!-- Page Footer follows -->
121    <div py:def="footer()" id="Footer">
122        <center><table><tbody>
123            <tr>
124                <td align="left" width="60%">
125                    <table><tbody>
126                    <tr><td><span py:replace="linkimage(g.ndgLink,g.ndgImage,'NDG')"/></td>
127                    <td> This portal is a product of the <a href="http://ndg.nerc.ac.uk"> NERC DataGrid</a>
128                    ${g.disclaimer} </td>
129                    </tr>
130                    </tbody></table>
131                </td>
132                <td width="40%" align="center">
133                    <div py:if="not g.standalone" id="loginStatus">
134                        <!--! now we choose one of the next two (logged in or not) -->
135                        <div py:if="'ndgSec' in session"><table><tbody><tr><td>
136                        User [${session['ndgSec']['u']}] logged in at
137                        ${session['ndgSec']['org']} with roles
138                        [${len(session['ndgSec']['roles'])==1 and session['ndgSec']['roles'][0] or ', '.join(session['ndgSec']['roles'])}]</td><td>
139                        &nbsp;<span py:replace="logOut()"/></td></tr></tbody></table></div>
140                        <div py:if="'ndgSec' not in session">Further services may be available if you can
141                            <span py:replace="logIn()"/></div>
142                    </div>
143                </td>
144                <td align="right"><span py:replace="linkimage(g.stfcLink,g.stfcImage,'Hosted by the STFC CEDA')"/></td>
145            </tr>
146        </tbody></table></center>
147    </div>
148   
149    <!-- Utility Functions follow -->
150   
151    <!-- hyperlinked image -->
152    <span py:def="linkimage(linkref,imageref,alttext)">
153        <a href="$linkref"><image src="$imageref" alt="$alttext" title="$alttext"/></a>
154    </span>
155   
156    <!-- Help Icons -->
157    <span py:def="helpIcon(value)">
158        <span>
159            <a href="javascript:;" title="Toggle help" onclick="toggleDiv(1,'$value','shown','hidden','div'); return false;">
160            <img src="$g.helpIcon" alt="Toggle help" class="helpicon"/></a>
161     
162        </span>
163    </span>
164   
165    <!-- Login and out buttons --> 
166    <span py:def="logOut()" class="logOut">
167            <?python
168            from base64 import urlsafe_b64encode
169           
170            # Base 64 encode to enable passing around in 'r' argument of query
171            # string for use with login/logout
172            g.ndg.security.common.sso.state.returnToURL = str(c.requestURL)
173            g.ndg.security.common.sso.state.b64encReturnToURL = urlsafe_b64encode(c.requestURL)
174            ?>
175        <form action="$g.logout">
176            <input type="hidden" name="r" value="${g.ndg.security.common.sso.state.b64encReturnToURL}"/>
177            <input type="submit" value="Logout"/>
178        </form>
179    </span>
180   
181    <span py:def="logIn()" class="logIn">
182            <?python
183            from base64 import urlsafe_b64encode
184           
185            # Base 64 encode to enable passing around in 'r' argument of query
186            # string for use with login/logout
187            g.ndg.security.common.sso.state.returnToURL = str(c.requestURL)
188            g.ndg.security.common.sso.state.b64encReturnToURL = urlsafe_b64encode(c.requestURL)
189            ?>
190        <form action="$g.wayfuri">
191            <input type="hidden" name="r" value="${g.ndg.security.common.sso.state.b64encReturnToURL}"/>
192            <input type="submit" value="Login"/>
193        </form>
194    </span>
195   
196   
197   
198</html>
Note: See TracBrowser for help on using the repository browser.