Skip to content
Snippets Groups Projects
Commit 8bd7f3d6 authored by Iain Bryson's avatar Iain Bryson
Browse files

Add tree view. Support subfolders properly. For Issue#58

parent e3ab5957
Branches
No related tags found
No related merge requests found
......@@ -45,7 +45,7 @@ end
gem 'activemodel', '~> 4.2.5'
gem 'dtu-core', :git => 'https://github.com/dtu-compute/dtu-enote-core.git', :branch => '2016', :tag => 'v0.7'
gem 'dtu-core', :git => 'https://github.com/dtu-compute/dtu-enote-core.git', :branch => '2016', :tag => '0.8'
#gem 'dtu-core', :path => '../dtu-core'
gem 'awesome_print', '~> 1.6', '>= 1.6.1'
......
GIT
remote: https://github.com/dtu-compute/dtu-enote-core.git
revision: 1faedb4fcde3b6630fbb08d95159059c09e6c8d7
branch: 2016
tag: v0.7
remote: https://github.com/rubycas/rubycas-client
revision: 7b67c8f1b5515ee4e28479d640d2da0a5aadfbe0
specs:
rubycas-client (2.3.10.rc1)
activesupport
PATH
remote: ../dtu-core
specs:
dtu-auth (0.0.0)
dtu-auth2 (0.0.0)
dtu-core (0.0.7)
dtu-core (0.0.8)
dtu-auth
dtu-auth2
dtu-file-management
rails (~> 4.2.5)
dtu-file-management (0.0.0)
GIT
remote: https://github.com/rubycas/rubycas-client
revision: 195a4b70333029be474b0ac70efdc85bd4288861
specs:
rubycas-client (2.3.10.rc1)
activesupport
GEM
remote: https://rubygems.org/
specs:
......@@ -58,17 +55,18 @@ GEM
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
addressable (2.4.0)
arel (6.0.3)
addressable (2.5.0)
public_suffix (~> 2.0, >= 2.0.2)
arel (6.0.4)
awesome_print (1.7.0)
backport_new_renderer (1.0.0)
rails
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
bower-rails (0.10.0)
bower-rails (0.11.0)
builder (3.2.2)
byebug (9.0.5)
capybara (2.7.1)
byebug (9.0.6)
capybara (2.11.0)
addressable
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
......@@ -82,22 +80,22 @@ GEM
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.10.0)
coffee-script-source (1.12.2)
commonjs (0.2.7)
concurrent-ruby (1.0.2)
daemons (1.2.3)
concurrent-ruby (1.0.4)
daemons (1.2.4)
database_cleaner (1.5.3)
debug_inspector (0.0.2)
diff-lcs (1.2.5)
erubis (2.7.0)
eventmachine (1.2.0.1)
eventmachine (1.2.1)
execjs (2.7.0)
factory_girl (4.7.0)
factory_girl (4.8.0)
activesupport (>= 3.0.0)
factory_girl_rails (4.7.0)
factory_girl (~> 4.7.0)
factory_girl_rails (4.8.0)
factory_girl (~> 4.8.0)
railties (>= 3.0.0)
fakefs (0.9.0)
fakefs (0.10.2)
ffi (1.9.14)
formatador (0.2.5)
git (1.3.0)
......@@ -113,29 +111,29 @@ GEM
shellany (~> 0.0)
thor (>= 0.18.1)
guard-compat (1.2.1)
guard-rspec (4.7.2)
guard-rspec (4.7.3)
guard (~> 2.1)
guard-compat (~> 1.1)
rspec (>= 2.99.0, < 4.0)
i18n (0.7.0)
jbuilder (2.6.0)
jbuilder (2.6.1)
activesupport (>= 3.0.0, < 5.1)
multi_json (~> 1.2)
json (1.8.3)
json (1.8.6)
less (2.6.0)
commonjs (~> 0.2.7)
less-rails (2.7.1)
less-rails (2.8.0)
actionpack (>= 4.0)
less (~> 2.6.0)
sprockets (> 2, < 4)
tilt
libv8 (3.16.14.15)
libv8 (3.16.14.17)
listen (3.1.1)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9.7)
loofah (2.0.3)
nokogiri (>= 1.5.9)
lumberjack (1.0.10)
lumberjack (1.0.11)
mail (2.6.4)
mime-types (>= 1.16, < 4)
method_source (0.8.2)
......@@ -143,21 +141,20 @@ GEM
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_portile2 (2.1.0)
minitest (5.9.0)
minitest (5.10.1)
multi_json (1.12.1)
nenv (0.3.0)
nokogiri (1.6.8)
nokogiri (1.7.0.1)
mini_portile2 (~> 2.1.0)
pkg-config (~> 1.1.7)
notiffany (0.1.0)
notiffany (0.1.1)
nenv (~> 0.1)
shellany (~> 0.0)
pkg-config (1.1.7)
pry (0.10.4)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
rack (1.6.4)
public_suffix (2.0.5)
rack (1.6.5)
rack-cache (1.6.1)
rack (>= 0.4)
rack-test (0.6.3)
......@@ -175,9 +172,9 @@ GEM
sprockets-rails
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.7)
rails-dom-testing (1.0.8)
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6.0)
nokogiri (~> 1.6)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
......@@ -186,51 +183,50 @@ GEM
activesupport (= 4.2.5)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (11.2.2)
rb-fsevent (0.9.7)
rake (12.0.0)
rb-fsevent (0.9.8)
rb-inotify (0.9.7)
ffi (>= 0.5.0)
rdoc (4.2.2)
json (~> 1.4)
redis (3.3.1)
redis-actionpack (4.0.1)
actionpack (~> 4)
redis-rack (~> 1.5.0)
redis-store (~> 1.1.0)
redis-activesupport (4.1.5)
activesupport (>= 3, < 5)
redis-store (~> 1.1.0)
rdoc (4.3.0)
redis (3.3.2)
redis-actionpack (5.0.1)
actionpack (>= 4.0, < 6)
redis-rack (>= 1, < 3)
redis-store (>= 1.1.0, < 1.4.0)
redis-activesupport (5.0.1)
activesupport (>= 3, < 6)
redis-store (~> 1.2.0)
redis-namespace (1.5.2)
redis (~> 3.0, >= 3.0.4)
redis-rack (1.5.0)
redis-rack (1.6.0)
rack (~> 1.5)
redis-store (~> 1.1.0)
redis-rack-cache (1.2.4)
rack-cache (~> 1.2)
redis-store (~> 1.1.0)
redis-rails (4.0.0)
redis-actionpack (~> 4)
redis-activesupport (~> 4)
redis-store (~> 1.1.0)
redis-store (1.1.7)
redis-store (~> 1.2.0)
redis-rack-cache (2.0.0)
rack-cache (~> 1.6.0)
redis-store (~> 1.2.0.pre)
redis-rails (5.0.1)
redis-actionpack (~> 5.0.0)
redis-activesupport (~> 5.0.0)
redis-store (~> 1.2.0)
redis-store (1.2.0)
redis (>= 2.2)
ref (2.0.0)
rspec (3.5.0)
rspec-core (~> 3.5.0)
rspec-expectations (~> 3.5.0)
rspec-mocks (~> 3.5.0)
rspec-core (3.5.1)
rspec-core (3.5.4)
rspec-support (~> 3.5.0)
rspec-expectations (3.5.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.5.0)
rspec-html-matchers (0.8.0)
rspec-html-matchers (0.8.2)
nokogiri (~> 1)
rspec (>= 3.0.0.a, < 4)
rspec-mocks (3.5.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.5.0)
rspec-rails (3.5.1)
rspec-rails (3.5.2)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
......@@ -239,42 +235,43 @@ GEM
rspec-mocks (~> 3.5.0)
rspec-support (~> 3.5.0)
rspec-support (3.5.0)
sass (3.4.22)
sass (3.4.23)
sass-rails (5.0.6)
railties (>= 4.0.0, < 6)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
sdoc (0.4.1)
sdoc (0.4.2)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
shellany (0.0.1)
slop (3.6.0)
spring (1.7.2)
sprockets (3.7.0)
spring (2.0.0)
activesupport (>= 4.2)
sprockets (3.7.1)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.1.1)
sprockets-rails (3.2.0)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
therubyracer (0.12.2)
libv8 (~> 3.16.14.0)
therubyracer (0.12.3)
libv8 (~> 3.16.14.15)
ref
thin (1.7.0)
daemons (~> 1.0, >= 1.0.9)
eventmachine (~> 1.0, >= 1.0.4)
rack (>= 1, < 3)
thor (0.19.1)
thor (0.19.4)
thread_safe (0.3.5)
tilt (2.0.5)
turbolinks (5.0.0)
turbolinks (5.0.1)
turbolinks-source (~> 5)
turbolinks-source (5.0.0)
tzinfo (1.2.2)
thread_safe (~> 0.1)
uglifier (3.0.0)
uglifier (3.0.4)
execjs (>= 0.3.0, < 3)
web-console (2.3.0)
activemodel (>= 4.0)
......@@ -324,4 +321,4 @@ DEPENDENCIES
web-console (~> 2.0)
BUNDLED WITH
1.13.6
1.13.7
......@@ -15,6 +15,7 @@
//= require jquery-readyselector
//= require turbolinks
//= require bootstrap
//= require bootstrap-treeview
//= require admin
//= require enotes
//= require nav
......
require 'pathname'
class AdminController < ApplicationController
include AdminHelper
before_filter CASClient::Frameworks::Rails::Filter, :if => proc {Rails.env.production?}
before_filter :require_login, :if => proc {!Rails.env.production?}
......@@ -9,7 +13,8 @@ class AdminController < ApplicationController
attr_accessor(:taught_courses,
:course,
:course_uploads_files,
:course_enotes_files)
:course_enotes_files,
:filemanager_tree)
def index
@parse_errors_path = File.join(Rails.root, 'public/assets', "parse-errors.html")
......@@ -47,6 +52,29 @@ class AdminController < ApplicationController
Rails.logger.info(DTUFileManagement::FileManager.instance.enotes_files)
redirect_to admin_path(:anchor => 'filemanager')
end
root = File.join(DTUFileManagement::FileManager.instance.uploads_folder my_course_id)
files = Dir.glob(File.join(root, "**/*"))
root_path = Pathname.new(File.expand_path(root))
def directory_hash(root_path, path, name=nil)
data = {:text => (name || path)}
data[:nodes] = children = []
Dir.foreach(path) do |entry|
next if (entry == '..' || entry == '.')
full_path = File.join(path, entry)
rel = Pathname.new(full_path).relative_path_from(root_path)
if File.directory?(full_path)
children << directory_hash(root_path, full_path, entry)
else
children << {:text => rel.to_s, :tags => [File.mtime("#{full_path}").to_s(:quiz)], :href => url_for_file(:uploads, my_course_id, rel.to_s) }
end
end
return data
end
@filemanager_tree = directory_hash(root_path, root_path.to_s)
ap @filemanager_tree
end
def update
......
module AdminHelper
def url_for_file(kind, course, file)
return DTUFileManagement::FileManager.instance.get_file_path(kind.to_s, course, file)
'/filemanager/' + kind.to_s + '/' + course + '/' + file
end
end
......@@ -327,10 +327,9 @@ class UpdateService
Rails.logger.info("copying #{gitinfo.local_repo_folder} to #{fm_folder}")
# FileUtils.copy_entry gitinfo.local_repo_folder, fm_folder
files = Dir["#{gitinfo.local_repo_folder}/{[!.git/]**/*,*}"]
Rails.logger.info files.ai
FileUtils.copy files, fm_folder, :verbose => true
FileUtils.copy_entry gitinfo.local_repo_folder, fm_folder, :remove_destination => true
FileUtils.rm_rf(Dir.glob(fm_folder+'/.git'))
Rails.logger.info("Updating file manager")
......
......@@ -32,27 +32,7 @@
<div class="col-md-8" style="display:block;"><h2>Uploads</h2>
<table class="table">
<thead>
<tr>
<th></th>
<th>Filename</th>
<th>Uploaded</th>
</tr>
</thead>
<tbody>
<% if @course_uploads_files.any? %>
<% @course_uploads_files.each do |file| %>
<tr>
<td><%= check_box_tag 'files[]', file %></td>
<td>
<a href="<%= url_for_file(:uploads, my_course_id, File.basename(file)) %>"> <%= File.basename(file) %></a></td>
<td><%= File.mtime("#{file}").to_s(:quiz) %></td>
</tr>
<% end %>
<% end %>
</tbody>
</table>
<div id="filemanager_tree"></div>
<button class="btn btn-primary" id="update-uploads" onclick='return updateFileManager(event, "<%= update_filemanager_path %>");'> Update </button>
<hr/>
</div>
......@@ -71,4 +51,7 @@ function renameClicked(event) {
$('#rename-modal').on("click", 'input[type="submit"]', function(d) { $('#rename-modal').modal('hide'); });
$('#rename-modal').modal('show');
}
var filemanager_tree = <%= filemanager_tree.to_json.html_safe %>;
$('#filemanager_tree').treeview({data: filemanager_tree.nodes, showTags: true, enableLinks: true});
</script>
......@@ -35,7 +35,7 @@
</div>
<div role="tabpanel" class="tab-pane" id="filemanager">
<div style="margin-top:25px"></div>
<%= render :partial => "admin/filemanager" %>
<%= render :partial => "admin/filemanager", :locals => {:filemanager_tree => @filemanager_tree} %>
</div>
</div>
......
......@@ -28,6 +28,7 @@
"require-less": "0.1.2",
"pagedown-extra": "https://github.com/jmcmanus/pagedown-extra.git#ea782c3d11eb78f57d00aa819527338996a70721",
"yaml.js": "https://github.com/jeremyfa/yaml.js.git#~0.1.4",
"MathJax": "~2.5.0"
"MathJax": "~2.5.0",
"bootstrap-treeview": "^1.2.0"
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment