-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.html
More file actions
227 lines (199 loc) · 10.9 KB
/
test.html
File metadata and controls
227 lines (199 loc) · 10.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
<!-- REQUIRES_LOGIN=0; -->
<!-- PAGE_TITLE=PBDB Test Application; -->
<!-- This web form provides documentation about how to write PBDB web -->
<!-- apps, and about the available variables. -->
<!-- Author: Michael McClennen -->
<style>
.datatable td,th {
padding: 5px;
border: 1px solid black;
vertical-align: top;
font: Helvetica;
}
.valuetable td {
padding: 5px;
border: 0px;
vertical-align: top;
}
.code {
font-family: monospace;
}
.value {
font-family: monospace;
}
.example {
font-family: monospace;
}
.desc {
font-style: italic;
}
</style>
<!-- <link rel="stylesheet" type="text/css" href="%%app_resources%%/test.css"> -->
<div name="variables" style="margin-left: 1em; margin-right: 1em">
<p align="center" class="pageTitle">Paleobiology Database Web Application Test Page and Documentation</p>
<h3>Variables</h3>
<p>The following variables can be included anywhere in the web application HTML file. Text
substitution is done on the file at the server, before it is sent to the browser. Therefore, the
variables can appear literally anywhere: in a tag, in a comment, in Javascript code, etc. When
you use them in code, you should make sure to enclose each variable in quotes so that it appears
to the Javascript engine as a string literal. It is often useful to set these variables at the
top of the file, using one of the following techniques:</p>
<p class="code" style="margin-left: 20px">
<script language="JavaScript" type="text/javascript"> <br>
var user_name = '%%user_name%%'; <br>
var data_url = '%%data_url%%'; <br>
</script>
</p>
<p class="code" style="margin-left: 20px">
<script language="JavaScript" type="text/javascript"> <br>
initMyApp('%%user_name%%', '%%data_url%%'); <br>
</script> <br>
<!-- The initMyApp() function can be placed later in the HTML file, or else in a separate
javascript file. -->
</p>
<p>Try logging in to Classic and reloading this page, then log out and reload again. You
will see the values of the variables change.</p>
<table class="datatable">
<tr><th>Variable name</th>
<th>Current value</th>
<th>Description</th></tr>
<tr><td class="code">%%params%%</td>
<td class="value">%%params%%</td>
<td class="desc">The URL parameters as a Javascript object.</td></tr>
<tr><td class="code">%%param[foo]%%</td>
<td class="value">%%param[foo]%%</td>
<td class="desc">The value of a particular parameter, as a Javascript value. If the
parameter was not present in the request, the value will be undefined.
<tr><td class="code">%%data_url%%</td>
<td class="value">%%data_url%%</td>
<td class="desc"><p>The base URL for API requests made by this web
application. For example:</p>
<p class="example"><script language="JavaScript" type="text/javascript">
var data_service_url = '%%data_url%%';</script></p>
<p class="desc">If you put this at the top of your file, you can then use the variable
<span class="code">data_service_url</span> in your javascript code to construct URL arguments to jQuery,
XMLHttpRequest, or whatever mechanism you use make data service requests.
</td></tr>
<tr><td class="code">%%test_data_url%%</td>
<td class="value">%%test_data_url%%</td>
<td class="desc">The base URL to use if this web application needs to call the test API
instead of, or in addition to, the production one.</td></tr>
<tr><td class="code">%%classic_url%%</td>
<td class="value">%%classic_url%%</td>
<td class="desc"><p>The base URL for links to web pages in the Classic application. All such
request URLs must continue with the name of the subroutine to be called. Arguments can
be included as well. For example:</p>
<p class="code"><a href="%%classic_url%%/basicTaxonInfo?taxon_no=69296">href="%%classic_url%%/basicTaxonInfo?taxon_no=69296"</a></p></td></tr>
<tr><td class="code">%%app_resources%%</td>
<td class="value">%%app_resources%%</td>
<td class="desc"><p>The base URL for javascript, css, or other files included from the application directory for
this web app. In other words, any files from the same directory as this page can be
included by using this URL followed by the file name. For example:</p>
<p class="code"><script src="%%app_resources%%/test.js" language="JavaScript" type="text/javascript"></script></p></td>
</tr>
<tr><td class="code">%%common_resources%%</td>
<td class="value">%%common_resources%%</td>
<td class="desc">The base URL for javascript, css, or other files included from the common directory for
Paleobiology Database web app resources. The best way to find what files are available is to look
at the HTML code for the existing web apps.</td></tr>
<tr><td class="code">%%user_name%%</td>
<td class="value">%%user_name%%</td>
<td class="desc">The name of the user who is executing this app, or the empty
string if the user is not logged in.</td></tr>
<tr><td class="code">%%user_email %%</td>
<td class="value">%%user_email%%</td>
<td class="desc">The email address of the user who is executing
this app, or the empty string if the user is not logged in.</td></tr>
<tr><td class="code">%%user_institution%%</td>
<td class="value">%%user_institution%%</td>
<td class="desc">The institution of the user who is executing this app, or the empty
string if the user is not logged in.</td></tr>
<tr><td class="code">%%user_orcid%%</td>
<td class="value">%%user_orcid%%</td>
<td class="desc">The ORCID of the user who is executing this app, or the empty
string if the user is not logged in or has not entered an ORCID.</td></tr>
<tr><td class="code">%%user_role%%</td>
<td class="value">%%user_role%%</td>
<td class="desc"><p>The database role for the user who is executing this app. The
value will be one of the following:</p>
<table class="valuetable">
<tr><td class="code">authorizer</td>
<td class="desc">The user is an authorizer</td></tr>
<tr><td class="code">enterer</td>
<td class="desc">The user is an enterer</td></tr>
<tr><td class="code">student</td>
<td class="desc">The user is a student enterer</td></tr>
<tr><td class="code">guest</td>
<td class="desc">The user is logged in but is not a database member, or is a member who does not have
an assigned authorizer</td></tr>
<tr><td class="code">anonymous</td>
<td class="desc">The user is not logged in, and is executing this app anonymously</td></tr>
</table>
</td></tr>
<tr><td class="code">%%is_member%%</td>
<td class="value">%%is_member%%</td>
<td class="desc">Has the value 1 if the user is a database member, 0 otherwise.</td></tr>
<tr><td class="code">%%is_loggedin%%</td>
<td class="value">%%is_loggedin%%</td>
<td class="desc">Has the value 1 if the user is logged in, 0 otherwise.</td></tr>
<tr><td class="code">%%is_admin%%</td>
<td class="value">%%is_admin%%</td>
<td class="desc">Has the value 1 if the user is a database administrator, 0
otherwise. Note that this is separate from the user's database role.</td></tr>
<tr><td class="code">%%enterer_name%%</td>
<td class="value">%%enterer_name%%</td>
<td class="desc">The name of the database member who is executing this app, or the empty
string if the user is not logged in or not a member. This is the name as known to the
Classic environment, which may not always be the same as <span class="code">%%user_name%%</span>.</td></tr>
<tr><td class="code">%%enterer_reversed%%</td>
<td class="value">%%enterer_reversed%%</td>
<td class="desc">The same as <span class="code">%%enterer_name%%</span>, but with last
name first.</td></tr>
<tr><td class="code">%%enterer_id%%</td>
<td class="value">%%enterer_id%%</td>
<td class="desc">The identifier corresponding to the user, for use in API calls. This can
be used, for example, to retrieve all records entered by the user.</td></tr>
<tr><td class="code">%%authorizer_name%%</td>
<td class="value">%%authorizer_name%%</td>
<td class="desc">The name of the user's authorizer, if they have one, or their own name
if they are an authorizer. If the user is not a database member or is not logged in, the
value will be the empty string.</td></tr>
<tr><td class="code">%%authorizer_reversed%%</td>
<td class="value">%%authorizer_reversed%%</td>
<td class="desc">The same as <span class="code">%%authorizer_name%%</span>, but with last
name first.</td></tr>
<tr><td class="code">%%authorizer_id%%</td>
<td class="value">%%authorizer_id%%</td>
<td class="desc">The identifier corresponding to the user's authorizer, for use in API calls. This can
be used, for example, to retrieve all records authorized by that person.</td></tr>
<tr><td class="code">%%unknown_variable%%</td>
<td class="value">%%unknown_variable%%</td>
<td class="desc">This is an example of a bad variable name. These do not get substituted.</td></tr>
<tr><td class="code">%%errors%%</td>
<td class="value">%%errors%%</td>
<td class="desc">If any errors have occurred during the substitution process, this
variable reports the error messages. Otherwise, it will be empty. Consequently, if
you are going to use it you should place it at the end of the HTML file where it will
be able to report any substitution errors. If there
are multiple error messages, they will be separated by semicolons.</td></tr>
</table>
<h3>Settings</h3>
<p>You can also indicate to Classic that it should execute this application in particular
ways. The following settings must appear in the first 1000 characters of the HTML file in order
to be recognized. It is usually most convenient to put them in an HTML comment at the top of
the file. The syntax is: SETTING=value;</p>
<table class="datatable">
<tr><th>Setting </th>
<th>Effect</th></tr>
<tr><td class="code">PAGE_TITLE</td>
<td class="desc">Specifies the title for this application's web page</td></tr>
<tr><td class="code">REQUIRES_LOGIN=1</td>
<td class="desc">If a user tries to execute this application and is not logged in,
they will be redirected to the login page. When they log in, they will be redirected
back to this application.</td></tr>
<tr><td class="code">REQUIRES_MEMBER=1</td>
<td class="desc">If a user tries to execute this application, they will be redirected
to the login page unless they are already logged in <em>and are a database member</em>.
This means they must be either an authorizer, an enterer, or a student.</td></tr>
</table>
</div>