Git Product home page Git Product logo

el_finder's Introduction

NOTICE

I no longer have the time to maintain this (haven't for a long time). If you have an interest in picking this up, let's talk and I can transfer the repository to you.

el_finder

Gem Version

Description:

Ruby library to provide server side functionality for elFinder. elFinder is an open-source file manager for web, written in JavaScript using jQuery UI.

Note regarding 2.x API:

8 months ago I said: FYI, I'm working on a pure 2.x API implementation. Nothing to release yet, and the holidays are in the way, but wanted to "get the word out."

Today: No update :/

Requirements:

The gem, by default, relies upon the 'image_size' ruby gem and ImageMagick's 'mogrify' and 'convert' commands. These requirements can be changed by implementing custom methods for determining image size and resizing of an image.

NOTE: There is another ruby gem 'imagesize' that also defines the class ImageSize and requires 'image_size' If you have that one installed, elfinder will fail. Make sure you only have 'image_size' installed if you use the defaults.

Install:

  • Install elFinder
  • Install ImageMagick (http://www.imagemagick.org/)
  • Do whatever is necessary for your Ruby framework to tie it together.

Rails 3

  • Add gem 'el_finder' to Gemfile
  • % bundle install
  • Switch to using jQuery instead of Prototype
  • Add the following action to a controller of your choosing.
  skip_before_filter :verify_authenticity_token, :only => ['elfinder']

  def elfinder
    h, r = ElFinder::Connector.new(
      :root => File.join(Rails.public_path, 'system', 'elfinder'),
      :url => '/system/elfinder',
       :perms => {
         /^(Welcome|README)$/ => {:read => true, :write => false, :rm => false},
         '.' => {:read => true, :write => false, :rm => false}, # '.' is the proper way to specify the home/root directory.
         /^test$/ => {:read => true, :write => true, :rm => false},
         'logo.png' => {:read => true},
         /\.png$/ => {:read => false} # This will cause 'logo.png' to be unreadable.  
                                      # Permissions err on the safe side. Once false, always false.
       },
       :extractors => { 
         'application/zip' => ['unzip', '-qq', '-o'], # Each argument will be shellescaped (also true for archivers)
         'application/x-gzip' => ['tar', '-xzf'],
       },
       :archivers => { 
         'application/zip' => ['.zip', 'zip', '-qr9'], # Note first argument is archive extension
         'application/x-gzip' => ['.tgz', 'tar', '-czf'],
         },

    ).run(params)

    headers.merge!(h)

    render (r.empty? ? {:nothing => true} : {:text => r.to_json}), :layout => false
  end
  • Or, use ElFinder::Action and el_finder, which handles most of the boilerplate for an ElFinder action:
  require 'el_finder/action'

  class MyController < ApplicationController
    include ElFinder::Action

    el_finder(:action_name) do
      {
        :root => File.join(Rails.public_path, 'system', 'elfinder'),
        :url => '/system/elfinder',
         :perms => {
           /^(Welcome|README)$/ => {:read => true, :write => false, :rm => false},
           '.' => {:read => true, :write => false, :rm => false}, # '.' is the proper way to specify the home/root directory.
           /^test$/ => {:read => true, :write => true, :rm => false},
           'logo.png' => {:read => true},
           /\.png$/ => {:read => false} # This will cause 'logo.png' to be unreadable.  
                                        # Permissions err on the safe side. Once false, always false.
        },
        :extractors => { 
          'application/zip' => ['unzip', '-qq', '-o'], # Each argument will be shellescaped (also true for archivers)
          'application/x-gzip' => ['tar', '-xzf'],
        },
        :archivers => { 
          'application/zip' => ['.zip', 'zip', '-qr9'], # Note first argument is archive extension
          'application/x-gzip' => ['.tgz', 'tar', '-czf'],
        },
      }
    end
  end
  • Add the appropriate route to config/routes.rb such as:
  match 'elfinder' => 'home#elfinder'
  • Add the following to your layout. The paths may be different depending on where you installed the various js/css files.
  <%= stylesheet_link_tag 'jquery-ui/base/jquery.ui.all', 'elfinder' %>
  <%= javascript_include_tag :defaults, 'elfinder/elfinder.min' %>
  • Add the following to the view that will display elFinder:
  <%= javascript_tag do %>
    $().ready(function() { 
      $('#elfinder').elfinder({ 
        url: '/elfinder',
        lang: 'en'
      })
    })
  <% end %>
  <div id='elfinder'></div>

Using with very large file systems

@gudata added a configuration option to not load child directories. This breaks V1, but if you are using V2 it should work and speed up the responsiveness quite a bit. To enable it set :tree_sub_folders to false.

License:

(The MIT License)

Copyright (c) 2010 Philip Hallstrom

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

el_finder's People

Contributors

akzhan avatar coorasse avatar dup2 avatar gamecreature avatar gudata avatar johnbintz avatar martinsp avatar p-kolacz avatar phallstrom avatar shenhf avatar troex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

el_finder's Issues

UTF-8 Filename Support

To support UTF-8 filename, Edit:

gems/el_finder-1.1.0/lib/el_finder/connector.rb

line 21
from: lambda { |file| file.original_filename}
to: lambda { |file| file.original_filename.force_encoding('utf-8')}

Authentication

Does authentication work with the connector? I see it is disabled in the example. This seems to be necessary though for most situations.

{"error":"Invalid command ''"}

Hello,

First of all, thanks for this gem, really appreciate.

But unfortunatly I have some trouble with installation, even when I'm using cloned example app.
I've got an error in browser when trying to get page with el_finder:

{"error":"Invalid command ''"}

My environment is Ubuntu 10.10, ruby-1.9.2-p290 via rvm, ImageMagick 6.6.2-6 , and a separate gemset for prevent any gem conflicts.

Would be really appreciate for any help.

Frequent "Invalid backend response. Data is not JSON" error problem ?

folders_controller.rb:

 def root
    h, r = ElFinder::Connector.new(
      :root => File.join(Rails.root, 'companies_folders', "#{current_user.root_folder}"),
      :url => "/companies_folders/#{current_user.root_folder}",
      :perms => {
        'forbidden' => {:read => false, :write => false, :rm => false},
        /README/ => {:write => false},
        /pjkh\.png$/ => {:write => false, :rm => false},
      },
      :extractors => {
        'application/zip' => ['unzip', '-qq', '-o'],
        'application/x-gzip' => ['tar', '-xzf'],
      },
      :archivers => {
        'application/zip' => ['.zip', 'zip', '-qr9'],
        'application/x-gzip' => ['.tgz', 'tar', '-czf'],
      },
      :thumbs => true
    ).run(params)

    headers.merge!(h)
    render (r.empty? ? {:nothing => true} : {:text => r.to_json}), :layout => false
  end

routes.rb

  get 'elfinder', to: 'folders#root'
  put 'elfinder', to: 'folders#root'
  patch 'elfinder', to: 'folders#root'
  delete 'elfinder', to: 'folders#root'
  post 'elfinder', to: 'folders#root'

CSS and js are properly configured, I think.
screenshot from 2017-07-23 23-03-20

application.js

$(function() {
  //var rails_csrf = {};
  //rails_csrf[$('meta[name=csrf-param]').attr('content')] = $('meta[name=csrf-token]').attr('content');

  $('#elfinder').elfinder({
    lang: 'en',
    height: '500',
    driver: 'LocalFileSystem',
    url: '/elfinder'
    // transport : new elFinderSupportVer1(),
    // customData: rails_csrf,
  });
});

and the root.html.erb is as:-

<div class="row">
  <div class="col-md-12">
    <div id='elfinder'></div>
  </div>
</div>

I'm frequently getting "Invalid backend response.
Data is not JSON." error, I tried changing url, path for connector class hard coded. The example apps works for rails 3.2.* with ruby 1.9.3, but my config is rails 5.1.2, ruby 2.4.0(bundle install succeeds with el_finder version 1.1.0). Any Idea ! on getting to solve this problem or Is there a way to make this gem compatible with rails 5.1.2 and ruby 2.4.0. Thankyou.

Thumbnails not created

Hi phallstromg,

Glad to see that your working in the 2.x API. Really nice!

I've set the thumb variable in the controller to true but when uploading images the Thumbnails are not created. Meanwhile I can see that the .thumbs folder was created without any problem.

I tried the example project and it does the same.

So am I missing some configuration? Checking the connector.rb in the method _upload I cannot see the _tmb method been called (not even by send).

Is this a issue or am i doing something wrong? Can you give me a help on this?

rails 4 compability

Hi.
Thank you for your gem. I've been using it for a long time in my projects, but I started using rails 4 and I had a problem with file uploading.
I got such kind of error "ActionController::InvalidAuthenticityToken"
Can you help me with this problem?

Bug fix

gems/el_finder-1.1.0/lib/el_finder/connector.rb

line 243

FileUtils.mv(file.path, dst.fullpath)

should be:

FileUtils.mv(file.tempfile.path, dst.fullpath)

Support for elfinder 2.0

Hi Philip,

Thanks for creating such an excellent integration with elfinder - it was a breeze to set up and get running!

I was wondering if you had any plans for evolving this gem to provide support for elfinder 2.0 at some point, or whether your projects are currently using elfinder 1.x only and, as such, you're not looking at doing this.

Either way, thanks again!

Cheers,

Mark.

Invalid backend response

I'm trying to implement el_finder using the el_finder GEM. the UI loads up okay and I am seeing what looks to be good JSON data being returned but no files show up and I keep getting the "Invalid backend response".

Here is the JSON that is returned.

{"cwd":{"name":".","hash":"Lg","mime":"directory","rel":"Home","size":0,"date":"2013-05-01 11:45:38 -0400","read":true,"write":false,"rm":false,"hidden":false},"cdc":[{"name":".thumbs","hash":"LnRodW1icw","date":"2013-05-01 11:36:49 -0400","read":true,"write":true,"rm":true,"hidden":false,"size":0,"mime":"directory"},{"name":"logo.png","hash":"bG9nby5wbmc","date":"2012-04-10 10:05:34 -0400","read":false,"write":true,"rm":true,"hidden":false,"size":14681,"mime":"image/png","url":"/system/elfinder/logo.png","resize":true,"dim":"100x96"}],"tree":{"name":"Home","hash":"Lg","dirs":[{"name":".thumbs","hash":"LnRodW1icw","dirs":[],"read":true,"write":true,"rm":true,"hidden":false}],"read":true,"write":false,"rm":false,"hidden":false},"disabled":[],"params":{"dotFiles":true,"uplMaxSize":"50M","archives":["application/zip","application/x-gzip"],"extract":["application/zip","application/x-gzip"],"url":"/system/elfinder"}}

And the controller looks like:

class DocumentLibraryController < ApplicationController
skip_before_filter :verify_authenticity_token, :only => ['elfinder']

def index

end

def elfinder
h, r = ElFinder::Connector.new(
:root => File.join(Rails.public_path, 'system', 'elfinder'),
:url => '/system/elfinder',
:perms => {
/^(Welcome|README)$/ => {:read => true, :write => false, :rm => false},
'.' => {:read => true, :write => false, :rm => false}, # '.' is the proper way to specify the home/root directory.
/^test$/ => {:read => true, :write => true, :rm => false},
'logo.png' => {:read => true},
/.png$/ => {:read => false} # This will cause 'logo.png' to be unreadable.
# Permissions err on the safe side. Once false, always false.
},
:extractors => {
'application/zip' => ['unzip', '-qq', '-o'], # Each argument will be shellescaped (also true for archivers)
'application/x-gzip' => ['tar', '-xzf'],
},
:archivers => {
'application/zip' => ['.zip', 'zip', '-qr9'], # Note first argument is archive extension
'application/x-gzip' => ['.tgz', 'tar', '-czf'],
},

).run(params)

headers.merge!(h)

render (r.empty? ? {:nothing => true} : {:text => r.to_json}), :layout => false

end

def create
end

def destroy
end
end

I've made sure that public/system/elfinder has full read/write permissions as well.

Anyone have any ideas of what i can try?

I'm running rails 3.2.2 with JQuery 1.7

License missing from gemspec

RubyGems.org doesn't report a license for your gem. This is because it is not specified in the gemspec of your last release.

via e.g.

spec.license = 'MIT'
# or
spec.licenses = ['MIT', 'GPL-2']

Including a license in your gemspec is an easy way for rubygems.org and other tools to check how your gem is licensed. As you can imagine, scanning your repository for a LICENSE file or parsing the README, and then attempting to identify the license or licenses is much more difficult and more error prone. So, even for projects that already specify a license, including a license in your gemspec is a good practice. See, for example, how rubygems.org uses the gemspec to display the rails gem license.

There is even a License Finder gem to help companies/individuals ensure all gems they use meet their licensing needs. This tool depends on license information being available in the gemspec. This is an important enough issue that even Bundler now generates gems with a default 'MIT' license.

I hope you'll consider specifying a license in your gemspec. If not, please just close the issue with a nice message. In either case, I'll follow up. Thanks for your time!

Appendix:

If you need help choosing a license (sorry, I haven't checked your readme or looked for a license file), GitHub has created a license picker tool. Code without a license specified defaults to 'All rights reserved'-- denying others all rights to use of the code.
Here's a list of the license names I've found and their frequencies

p.s. In case you're wondering how I found you and why I made this issue, it's because I'm collecting stats on gems (I was originally looking for download data) and decided to collect license metadata,too, and make issues for gemspecs not specifying a license as a public service :). See the previous link or my blog post about this project for more information.

Search/Filter Not Working

I have cloned the example rails app as well as installed this with my own app, and everything seems to be working great except that attempting to search your files returns a "Invalid backend response". Also, after getting the error, the search field no longer accepts keypresses for backspace and arrow keys (although it will still allow you to type letters etc).

Multiple Roots

I'm trying to mount multiple roots, but seems like I can mount only the one. How can I access to this feature?

Performance problems with 10k directories

We're currently using your Connector with ElFinder (version is 2.1rc1).

When a directory with about 10k subdirectories gets opened, it takes about 15 seconds until the connector returns the response to the client, which I think is a really long time. Do you have any idea how to improve the performance here?

max file size

Hi all ,
I can' t find where to set the max file size upload. Could you help me?
nunzio

Routing error for some paths

When creating a Folder with a name like "Multimédia" and try to open images inside that folder we get the following error:

No route matches [GET] "/elfinder//Multime%EF%BF%BD%EF%BF%BDdia/

Is there any quick solution for this?

Add support for uploading large files (>1GB)

How hard is it to add support for uploading very large files?

I tried to upload a 40GB file and got the following on the webrick backend:
ERROR NoMemoryError: failed to allocate memory

FTP Connector

Hi !

Is there any way to make this gem works with an FTP ?

Thanks !

Error: Cannot load such file -- image_size

Hi phallstrom,

Thanks for keeping updating this gem. More utf8 support and max upload size rocks. ;)

Just a heads up...After updating today it's not possible to start the application without adding:

gem image_size

to the gemfile.

Maybe it should be some warning in the README.md for that.

Best regards.

Crop and Rotatate button not visible in image Resize dialog ?

When I run elfinder-2.1.27 front-end with rails as backend, I can't see crop and rotate button in image resize elfinder dialog. When I run php version of elfinder the buttons are seen but when I use elfinder in rails app, same button are not seen. Elfinder version I'm using is 2.1.27 with elfinder gem.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.