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 */
66
66
"missing": "missing.png",
67
67
"deleted": "deleted.png",
68
68
"modified": "modified.png",
69
"conflicted": "conflicted.png",
70
69
"revision": "revision.png"
87
86
default_svn_icon = null;
88
87
default_svn_nice = "Unknown status";
90
svn_icons_path = "+media/ivle.webapp.core/images/svn";
89
svn_icons_path = "media/images/svn";
92
published_icon = "+media/ivle.webapp.core/images/interface/published.png";
91
published_icon = "media/images/interface/published.png";
94
93
/* List of MIME types considered "executable" by the system.
95
94
* Executable files offer a "run" link, implying that the "serve"
245
var top_level_dir = path==username;
248
var req = ajax_call(null, "userservice", "get_enrolments", null, "GET")
249
subjects = decode_response(req);
253
242
/* This will always return a listing, whether it is a dir or a file.
255
244
var listing = response.responseText;
298
287
current_file = file_listing["."]; /* Global */
299
288
delete file_listing["."];
301
if ('revision' in listing)
303
current_revision = listing.revision;
306
290
/* Check if this is a directory listing or file contents */
307
291
var isdir = response.getResponseHeader("X-IVLE-Return") == "Dir";
311
home_listing(listing, subjects, path);
294
handle_dir_listing(path, listing);
377
360
upload_callback_count++;
378
361
if (upload_callback_count >= 2)
380
myFrame = frames['upload_iframe'].document;
381
data = myFrame.firstChild.childNodes[1].firstChild.firstChild.nodeValue;
382
data = JSON.parse(data);
384
alert("Error: " + decodeURIComponent(data['Error']));
385
363
document.getElementsByName('data')[0].value = '';
449
427
files.appendChild(txt_elem);
452
/** Given a path, filename and optional revision, returns a URL to open that
453
* revision of that file.
455
function build_revision_url(path, filename, revision)
457
bits = {'path': app_path(this_app, path, filename)};
458
if (current_revision)
460
bits['query_string'] = 'r=' + revision;
462
return build_url(bits);
465
430
/** Given a mime type, returns the path to the icon.
466
431
* \param type String, Mime type.
467
432
* \param sizelarge Boolean, optional.
528
493
/* Enable or disable actions1 moreactions actions. Takes either a single
529
494
* name, or an array of them.*/
530
function set_action_state(names, which, allow_on_revision)
495
function set_action_state(names, which)
532
497
if (!(names instanceof Array)) names = Array(names);
534
499
for (var i=0; i < names.length; i++)
536
501
element = document.getElementById('act_' + names[i]);
538
!(current_file.svnstatus == 'revision' && !allow_on_revision))
541
505
element.setAttribute("class", "choice");
553
/* Updates the list of available actions based on files selected */
554
517
function update_actions()
557
520
var numsel = selected_files.length;
558
var svn_selection = false;
562
svn_selection = true;
563
for (var i = 0; i < selected_files.length; i++){
564
if (file_listing[selected_files[i]]["svnstatus"] == "unversioned")
566
svn_selection = false;
600
550
open.setAttribute("title",
601
551
"Edit or view this file");
602
open.setAttribute("href", build_revision_url(current_path, filename,
552
open.setAttribute("href", app_path(this_app, current_path, filename));
613
562
/* Available if zero or one files are selected,
614
563
* and only if this is a file, not a directory */
615
564
var serve = document.getElementById("act_serve");
616
if (numsel <= 1 && !file.isdir && current_file.svnstatus != 'revision')
565
if (numsel <= 1 && !file.isdir)
618
567
serve.setAttribute("class", "choice");
619
568
serve.setAttribute("onclick",
639
588
var run = document.getElementById("act_run");
641
if (numsel <= 1 && !file.isdir && file.type == "text/x-python"
642
&& current_file.svnstatus != 'revision')
590
if (!file.isdir && file.type == "text/x-python" && numsel <= 1)
664
/* Always available for current files.
665
613
* If 0 files selected, download the current file or directory as a ZIP.
666
614
* If 1 directory selected, download it as a ZIP.
667
615
* If 1 non-directory selected, download it.
668
616
* If >1 files selected, download them all as a ZIP.
670
618
var download = document.getElementById("act_download");
671
if (current_file.svnstatus == 'revision')
673
download.setAttribute("class", "disabled");
674
download.removeAttribute("onclick");
676
else if (numsel <= 1)
678
download.setAttribute("class", "choice")
681
623
download.setAttribute("href",
706
648
for (var i=0; i<numsel; i++)
707
649
dlpath += "path=" + encodeURIComponent(selected_files[i]) + "&";
708
650
dlpath = dlpath.substr(0, dlpath.length-1);
709
download.setAttribute("class", "choice")
710
651
download.setAttribute("href", dlpath);
711
652
download.setAttribute("title",
712
653
"Download the selected files as a ZIP file");
760
702
/* Subversion actions */
761
703
/* These are only useful if we are in a versioned directory and have some
762
704
* files selected. */
763
set_action_state(["svnadd",], numsel >= 1 && current_file.svnstatus);
764
/* And these are only usefull is ALL the selected files are versioned */
765
set_action_state(["svnremove", "svnrevert", "svncommit", "svncopy",
766
"svncut"], numsel >= 1 && current_file.svnstatus && svn_selection);
768
/* Diff, log and update only support one path at the moment, so we must
769
* have 0 or 1 versioned files selected. If 0, the directory must be
771
single_versioned_path = (
773
(numsel == 1 && (svnst = file_listing[selected_files[0]].svnstatus)) ||
774
(numsel == 0 && (svnst = current_file.svnstatus))
775
) && svnst != "unversioned");
776
set_action_state(["svndiff", "svnupdate"], single_versioned_path);
778
/* We can resolve if we have a file selected and it is conflicted. */
779
set_action_state("svnresolved", single_versioned_path && numsel == 1 && svnst == "conflicted");
781
/* Log should be available for revisions as well. */
782
set_action_state("svnlog", single_versioned_path, true);
705
set_action_state(["svnadd", "svnrevert", "svncommit"], numsel >= 1 && current_file.svnstatus);
707
/* Diff and log only support one path at the moment. */
708
single_versioned_path = (numsel == 1 &&
709
(svnst = file_listing[selected_files[0]].svnstatus) &&
710
svnst != "unversioned");
711
set_action_state("svnlog", single_versioned_path);
712
set_action_state("svndiff", single_versioned_path && svnst != "normal");
714
/* current_path == username: We are at the top level */
715
set_action_state("svncheckout", current_path == username);
784
717
/* There is currently nothing on the More Actions menu of use
785
718
* when the current file is not a directory. Hence, just remove
793
726
var actions2_directory = document.getElementById("actions2_directory");
794
727
actions2_directory.setAttribute("style", "display: inline;");
795
var moreactions = document.getElementById("moreactions_area");
796
moreactions.setAttribute("style", "display: inline;");
800
731
var actions2_file = document.getElementById("actions2_file");
801
732
actions2_file.setAttribute("style", "display: inline;");
733
var moreactions = document.getElementById("moreactions_area");
734
moreactions.setAttribute("style", "display: none;");
835
768
action_unpublish(selected_files);
838
window.open(public_app_path("~" + current_path, filename), 'share')
771
//alert("Not yet implemented: Sharing files");
772
window.open(public_app_path(serve_app, current_path, filename), 'share')
869
803
action_add(selected_files);
872
action_remove(selected_files);
874
805
case "svnrevert":
875
806
action_revert(selected_files);
878
window.location = path_join(app_path('diff'), current_path, selected_files[0] || '');
881
action_update(selected_files);
884
action_resolved(selected_files);
809
window.location = path_join(app_path('diff'), current_path, selected_files[0]);
886
811
case "svncommit":
887
812
action_commit(selected_files);
890
window.location = path_join(app_path('svnlog'), current_path, selected_files[0] || '');
893
action_svncopy(selected_files);
896
action_svncut(selected_files);
815
window.location = path_join(app_path('svnlog'), current_path, selected_files[0]);