2 pagetitle = "Stemmaweb - Text tradition tools"
3 applicationjs = c.uri_for( 'js/componentload.js' )
5 <script type="text/javascript">
6 var basepath = window.location.pathname
7 if( basepath.lastIndexOf('/') == basepath.length - 1 ) {
8 basepath = basepath.slice( 0, basepath.length - 1)
12 var selectedStemmaID = -1;
15 function refreshDirectory () {
16 var lmesg = $('#loading_message').clone();
17 $('#directory').empty().append( lmesg.contents() );
18 $('#directory').load( "[% c.uri_for( 'directory' ) %]",
19 function(response, status, xhr) {
20 if (status == "error") {
21 var msg = "An error occurred: ";
22 $("#directory").html(msg + xhr.status + " " + xhr.statusText);
28 function start_upload_dialog() {
29 if( typeof uploader != 'undefined' ){ uploader.destroy() };
30 $('#upload-collation-dialog').dialog('option', 'attach_uploader')();
31 $('#upload_status').empty();
32 $('#upload_button').button('disable');
33 $('#upload-collation-dialog').dialog('open');
36 $(document).ready( function() {
37 // call out to load the directory div
38 $('#textinfo_container').hide();
39 $('#textinfo_waitbox').hide();
42 // Set up the textinfo edit dialog
43 $('#textinfo-edit-dialog').dialog({
49 Save: function (evt) {
50 $("#edit_textinfo_status").empty();
51 $(evt.target).button("disable");
52 var requrl = "[% c.uri_for( '/textinfo' ) %]/" + selectedTextID;
53 var reqparam = $('#edit_textinfo').serialize();
54 $.post( requrl, reqparam, function (data) {
55 // Reload the selected text fields
56 selectedTextInfo = data;
58 // Reenable the button and close the form
59 $(evt.target).button("enable");
60 $('#textinfo-edit-dialog').dialog('close');
64 $('#textinfo-edit-dialog').dialog('close');
68 $("#edit_textinfo_status").empty();
69 // Populate the form fields with the current values
70 // edit_(name, language, public, owner)
71 $.each([ 'name', 'language', 'owner' ], function( idx, k ) {
72 var fname = '#edit_' + k;
73 // Special case: language Default is basically language null
74 if( k == 'language' && selectedTextInfo[k] == 'Default' ) {
77 $(fname).val( selectedTextInfo[k] );
80 if( selectedTextInfo['public'] == true ) {
81 $('#edit_public').attr('checked','true');
83 $('#edit_public').removeAttr('checked');
86 }).ajaxError( function(event, jqXHR, ajaxSettings, thrownError) {
87 $(event.target).parent().find('.ui-button').button("enable");
88 if( ajaxSettings.url.indexOf( 'textinfo' ) > -1
89 && ajaxSettings.type == 'POST' ) {
90 display_error( jqXHR, $("#edit_textinfo_status") );
95 // Set up the stemma editor dialog
96 $('#stemma-edit-dialog').dialog({
102 Save: function (evt) {
103 $("#edit_stemma_status").empty();
104 $(evt.target).button("disable");
105 var stemmaseq = $('#stemmaseq').val();
106 var requrl = "[% c.uri_for( '/stemma' ) %]/" + selectedTextID + "/" + stemmaseq;
107 var reqparam = { 'dot': $('#dot_field').val() };
108 // TODO We need to stash the literal SVG string in stemmata
109 // somehow. Implement accept header on server side to decide
110 // whether to send application/json or application/xml?
111 $.post( requrl, reqparam, function (data) {
112 // We received a stemma SVG string in return.
113 // Update the current stemma sequence number
114 selectedStemmaID = data.stemmaid;
115 // Stash the answer in our SVG array
116 stemmata[selectedStemmaID] = data.stemmasvg;
117 // Display the new stemma
118 load_stemma( selectedStemmaID );
119 // Reenable the button and close the form
120 $(evt.target).button("enable");
121 $('#stemma-edit-dialog').dialog('close');
125 $('#stemma-edit-dialog').dialog('close');
128 open: function(evt) {
129 $("#edit_stemma_status").empty();
130 var stemmaseq = $('#stemmaseq').val();
131 if( stemmaseq == 'n' ) {
132 // If we are creating a new stemma, populate the textarea with a
134 $(evt.target).dialog('option', 'title', 'Add a new stemma')
135 $('#dot_field').val( "digraph stemma {\n\n}" );
137 // If we are editing a stemma, grab its stemmadot and populate the
138 // textarea with that.
139 $(evt.target).dialog('option', 'title', 'Edit selected stemma')
140 $('#dot_field').val( 'Loading, please wait...' );
141 var doturl = "[% c.uri_for( '/stemmadot' ) %]/" + selectedTextID + "/" + stemmaseq;
142 $.getJSON( doturl, function (data) {
143 // Re-insert the line breaks
144 var dotstring = data.dot.replace(/\|n/gm, "\n");
145 $('#dot_field').val( dotstring );
149 }).ajaxError( function(event, jqXHR, ajaxSettings, thrownError) {
150 $(event.target).parent().find('.ui-button').button("enable");
151 if( ajaxSettings.url.indexOf( 'stemma' ) > -1
152 && ajaxSettings.type == 'POST' ) {
153 display_error( jqXHR, $("#edit_stemma_status") );
157 $('#upload-collation-dialog').dialog({
165 id: "pick_uploadfile_button",
172 $('#upload_status').empty();
178 $('#upload-collation-dialog').dialog('close');
181 attach_uploader: function() {
182 create_uploader( "[% c.uri_for ( '/newtradition' ) %]" );
183 $('#filelist').empty().html( 'Use the \'Pick\' button to choose a source file…' );
192 <h1>Stemmaweb - a collection of tools for analysis of collated texts</h1>
193 <span class="mainnav">[% IF c.user_exists %]Hello! [% c.user.get_object.email %] <a class="navlink" href="[% c.uri_for( '/logout' ) %]">Sign out</a> | [% ELSE %]<a class="navlink" onclick="window.open('[% c.uri_for( '/login' ) %]', 'loginwindow', 'height=385,width=445')">Login</a> | <a class="navlink" onclick="window.open('[% c.uri_for( '/register' ) %]', 'regwindow', 'height=385,width=445')">Register</a> | [% END %]<a class="navlink" href="[% c.uri_for( 'about.html' ) %]">About</a> </span>
195 <div id="directory_container">
196 <h2>Text directory</h2>
197 <div id="directory"></div>
198 [% IF c.user_exists -%]
199 <div class="button" id="new_trad_button" onClick="start_upload_dialog();">
200 <span>Add a new text tradition</span>
204 <div id="textinfo_waitbox">
205 <h3>Loading tradition information, please wait...</h3>
206 <img src="[% c.uri_for( 'images', 'ajax-loader.gif' ) %]" alt="Loading tradition info..." />
208 <div id="textinfo_container">
209 <div id="textinfo_load_status"></div>
210 <h2>Text <span class="texttitle"></span></h2>
212 <li>is owned by <span id="owner_id"></span></li>
213 <li>is <span id="not_public"></span>public</li>
214 <li>has <span id="marked_language"></span> as its primary language</li>
215 <li>has <span id="witness_num"></span> witnesses: <span id="witness_list"></span></li>
218 <!-- TODO buttons on either side of the graph div to flip through the stemmata -->
219 <div id="textinfo_container_buttons">
220 <form id="open_textinfo_edit" action="" method="GET" name="edit_textinfo">
221 <div class="button" id="edit_textinfo_button"
222 onClick="$('#textinfo-edit-dialog').dialog('open')">
223 <span>Modify information about this tradition</span>
226 <form id="stemma_pager" action="" method="GET" name="stemma_pager">
227 <div class="button" id="stemma_pager_button" onClick="$('#stemma_pager').submit()">
228 <span>Left & right go here</span>
231 <form id="open_stemma_add" action="" method="GET" name="add_new_stemma">
232 <div class="button" id="stemma_add_button"
233 onClick="$('#stemmaseq').val('n'); $('#stemma-edit-dialog').dialog('open');">
234 <span>Add a new stemma</span>
237 <form id="open_stemma_edit" action="" method="GET" name="edit_current_stemma">
238 <div class="button" id="stemma_edit_button"
239 onClick="$('#stemmaseq').val(selectedStemmaID); $('#stemma-edit-dialog').dialog('open');">
240 <span>Edit this stemma</span>
243 <form id="run_stexaminer" action="" method="GET" name="run_stexaminer">
244 <div class="button" id="stexaminer_button" onClick="$('#run_stexaminer').submit()">
245 <span>Examine variants against this stemma</span>
248 <form id="run_relater" action="" method="GET" name="run_relater">
249 <div class="button" id="relater_button" onClick="$('#run_relater').submit()">
250 <span>Run relationship mapper</span>
254 <div id="stemma_graph"></div>
257 <!-- Interim 'loading' message for directory box -->
258 <div id="loading_message">
259 <h3>Loading texts, please wait...</h3>
260 <img src="[% c.uri_for( 'images', 'ajax-loader.gif' ) %]" alt="Loading tradition list..."/>
263 <!-- Textinfo editor dialog -->
264 <div id="textinfo-edit-dialog" title="Edit information about this tradition">
265 <div id="textinfo_edit_container">
266 <form id="edit_textinfo">
267 <label for="edit_name">Tradition name: </label>
268 <input id="edit_name" type="text" size="30" name="name"/><br/>
269 <label for="edit_language">Language: </label>
270 <input id="edit_language" type="text" size="12" name="language"/>
271 <label for="edit_public">Publicly viewable: </label>
272 <input id="edit_public" type="checkbox" name="public"/><br/>
273 [% IF c.user_exists -%]
274 [% IF c.user.get_object.is_admin -%]
275 <label for="edit_owner">Tradition owner: </label>
276 <input id="edit_owner" type="text" size="30" name="owner"/><br/>
280 <div id="edit_textinfo_status"></div>
284 <!-- Stemma dot editor dialog, simple textarea for now -->
285 <div id="stemma-edit-dialog">
286 <div id="stemma_edit_container">
287 <form id="edit_stemma">
288 <label for="dot_field">Dot definition for this stemma: </label><br/>
289 <textarea id="dot_field" rows="30" cols="40"></textarea>
290 <input id="stemmaseq" type="hidden" name="stemmaseq" val="n"/>
291 <div id="edit_instructions">
292 <p>All definitions begin with the line
293 <pre>digraph stemma {</pre>
294 and end with the line
295 <pre>}</pre>Please do not change these lines.</p>
296 <p>First list each witness in your stemma, whether extant or lost /
297 reconstructed / hypothetical, and assign them a class of either "extant"
298 or "hypothetical". For example:</p><pre>
299 α [ class=hypothetical ]
302 <p>Next, list the direct links between witnesses, one per line. For example, if
303 witness C descends directly from witness α, note it as follows:</p><pre>
306 <p>A witness may be the exemplar for any number of other witnesses, whether
307 extant or not; likewise, a witness may inherit from any number of other
308 witnesses. Use as may "A -> B" pairings as necessary to describe the links.</p>
311 <div id="edit_stemma_status"></div>
315 <!-- File upload dialog box -->
316 <div id="upload-collation-dialog" title="Upload a collation">
317 <div id="upload_container">
318 <form id="new_tradition">
319 <label for="new_name">Name of this text / tradition: </label>
320 <input id="new_name" type="text" name="name" size="40"/><br/>
321 <label for="new_lang">Primary language of the text: </label>
322 <input id="new_lang" type="text" name="language" size="20"/><br/>
323 <label for="new_public">Allow public display: </label>
324 <input id="new_public" name="public" type="checkbox"/><br/>
325 <div id="filelist"></div>
327 <div id="upload_status"></div>
329 <h4>Supported file types / extensions:</h4>
331 <li>*.txt - spreadsheet collation, tab-separated values</li>
332 <li>*.csv - spreadsheet collation, comma-separated values</li>
333 <li>*.xls - spreadsheet collation, Excel 97-2004 format</li>
334 <li>*.xlsx - spreadsheet collation, Excel 2007 XML format</li>
335 <li>*.xml - TEI XML parallel segmentation format</li>
336 <li>*.xml - TEI XML export from Classical Text Editor</li>
337 <li>*.xml - GraphML export from the CollateX tool</li>
339 <p>All spreadsheet collations should be arranged with the witness sigla in the first row, and the words aligned by row each in its correct witness column.</p>
343 [% PROCESS footer.tt %]