55
55
default_type_icon = "txt.png";
57
57
/* Relative to IVLE root */
58
type_icons_path = "+media/ivle.webapp.core/images/mime";
59
type_icons_path_large = "+media/ivle.webapp.core/images/mime/large";
58
type_icons_path = "media/images/mime";
59
type_icons_path_large = "media/images/mime/large";
61
61
/* Mapping SVN status to icons, just the file's basename */
63
"unversioned": "unversioned.png",
64
64
"normal": "normal.png",
65
65
"added": "added.png",
66
66
"missing": "missing.png",
87
87
default_svn_icon = null;
88
88
default_svn_nice = "Unknown status";
90
svn_icons_path = "+media/ivle.webapp.core/images/svn";
90
svn_icons_path = "media/images/svn";
92
published_icon = "+media/ivle.webapp.core/images/interface/published.png";
92
published_icon = "media/images/interface/published.png";
94
94
/* List of MIME types considered "executable" by the system.
95
95
* Executable files offer a "run" link, implying that the "serve"
134
134
* May be "application/x-www-form-urlencoded" or "multipart/form-data".
135
135
* Defaults to "application/x-www-form-urlencoded".
136
136
* "multipart/form-data" is recommended for large uploads.
137
* \param callback, optional.
138
* A callback function for after the action has been handled.
140
function do_action(action, path, args, content_type, callback)
138
function do_action(action, path, args, content_type, ignore_response)
142
140
args.action = action;
143
141
/* Callback action, when the server returns */
144
var callback_inner = function(response)
142
var callback = function(response)
146
144
/* Check for action errors reported by the server, and report them
148
146
var error = response.getResponseHeader("X-IVLE-Action-Error");
149
if (error != null && error != "")
150
148
/* Note: This header (in particular) comes URI-encoded, to
151
149
* allow multi-line error messages. Decode */
152
150
alert("Error: " + decodeURIComponent(error.toString()) + ".");
153
151
/* Now read the response and set up the page accordingly */
154
if (callback != null)
155
callback(path, response);
152
if (ignore_response != true)
153
handle_response(path, response, true);
157
155
/* Call the server and perform the action. This mutates the server. */
158
ajax_call(callback_inner, service_app, path, args, "POST", content_type);
156
ajax_call(callback, service_app, path, args, "POST", content_type);
161
159
/** Calls the server using Ajax, requesting a directory listing. This should
380
378
if (upload_callback_count >= 2)
382
380
myFrame = frames['upload_iframe'].document;
383
/* Browsers will turn the raw returned JSON into an HTML document. We
384
* need to get the <pre> from inside the <body>, and look at its text.
386
data = myFrame.firstChild.getElementsByTagName(
387
'body')[0].firstChild.firstChild.nodeValue;
381
data = myFrame.firstChild.childNodes[1].firstChild.firstChild.nodeValue;
388
382
data = JSON.parse(data);
389
383
if ('Error' in data)
390
384
alert("Error: " + decodeURIComponent(data['Error']));
734
728
publish.setAttribute("value", "unpublish");
735
729
publish.setAttribute("title" ,"Make it so this directory "
736
730
+ "can not be seen by anyone on the web");
737
publish.firstChild.nodeValue = "Unpublish";
731
publish.textContent = "Unpublish";
739
733
publish.setAttribute("value", "publish");
740
734
publish.setAttribute("title","Make it so this directory "
741
735
+ "can be seen by anyone on the web");
742
publish.firstChild.nodeValue = "Publish";
736
publish.textContent = "Publish";
745
739
set_action_state(["publish", "submit"], pubcond);
766
760
/* Subversion actions */
767
761
/* These are only useful if we are in a versioned directory and have some
768
762
* files selected. */
769
set_action_state(["svnadd"], numsel >= 1 && current_file.svnstatus);
763
set_action_state(["svnadd",], numsel >= 1 && current_file.svnstatus);
770
764
/* And these are only usefull is ALL the selected files are versioned */
771
765
set_action_state(["svnremove", "svnrevert", "svncommit", "svncopy",
772
766
"svncut"], numsel >= 1 && current_file.svnstatus && svn_selection);
787
781
/* Log should be available for revisions as well. */
788
782
set_action_state("svnlog", single_versioned_path, true);
790
/* Cleanup should be available for revisions as well. */
791
set_action_state("svncleanup", single_versioned_path, true);
793
single_ivle_versioned_path = (
795
(numsel == 1 && (stat = file_listing[selected_files[0]])) ||
796
(numsel == 0 && (stat = current_file))
797
) && stat.svnstatus != "unversioned"
799
&& stat.svnurl.substr(0, svn_base.length) == svn_base);
800
set_action_state(["submit"], single_ivle_versioned_path);
802
784
/* There is currently nothing on the More Actions menu of use
803
785
* when the current file is not a directory. Hence, just remove
853
835
action_unpublish(selected_files);
856
window.open(public_app_path("~" + current_path, filename), 'share')
838
//alert("Not yet implemented: Sharing files");
839
window.open(public_app_path(serve_app, current_path, filename), 'share')
859
if (selected_files.length == 1)
860
stat = file_listing[selected_files[0]];
863
path = stat.svnurl.substr(svn_base.length);
865
/* The working copy might not have an up-to-date version of the
866
* directory. While submitting like this could yield unexpected
867
* results, we should really submit the latest revision to minimise
868
* terrible mistakes - so we run off and ask fileservice for the
870
$.post(app_path(service_app, current_path),
871
{"action": "svnrepostat", "path": path},
874
window.location = path_join(app_path('+submit'), path) + '?revision=' + result.svnrevision;
843
alert("Not yet implemented: Submit");
880
846
action_rename(filename);
960
923
* This causes the page to be populated with whatever is at that address,
961
924
* whether it be a directory or a file.
963
var path = get_path();
967
/** Gets the current path of the window */
968
function get_path() {
969
926
var path = parse_url(window.location.href).path;
970
927
/* Strip out root_dir + "/files" from the front of the path */
971
928
var strip = make_path(this_app);