Giter VIP home page Giter VIP logo

file-manager's Introduction

alt tag

File manager

==========================

Installation

OS X (DEV)
$ npm install && sudo npm install -g webpack mocha && cp dist.config.js config.js && brew install ruby && sudo gem install -n /usr/local/bin sass
OS X (PROD)
$ npm install && cp dist.config.js config.js

===

DEBIAN distros (DEV)
$ npm install && sudo npm install -g webpack mocha && cp dist.config.js config.js && sudo apt-get install ruby && sudo apt-get install ruby-sass
DEBIAN distros (PROD)
$ npm install && cp dist.config.js config.js

==========================

Running WEB server (DEV)

export TZ=utc && grunt start

Running WEB server (PROD)

Server must be set to UTC time zone

node app.js

SERVER

A server is start at 127.0.0.1:5001

API

  • initialize() Initializes the widget

  • .on(...) Listen for an event

    • delete
    • create
    • edit
    • navigate
  • set(paths) Sets an array of paths

    [
        {_id: 1, path: '/etc/etc-sub-dir/sub-sub-etc-dir/file'},
        {_id: 2, path: '/etc/etc-sub-dir/sub-sub-etc-dir/file1'},
        {_id: 3, path: '/etc/file3'},
        {_id: 4, path: '/etc/etc-sub-dir/sub-sub-etc-dir2/file5'},
        {_id: 5, path: '/tmp/dir-test/qwe2'},
        {_id: 6, path: '/tmp/dir-test-1/qwe'},
        {_id: 7, path: '/tmp/dir-test/qwe3'}
    ]
    
  • append(path) Appends a path to current array

    {_id: 1, path: '/etc/etc-sub-dir/sub-sub-etc-dir/file'}
    
  • get() Gets all paths

  • getEmitter() Gets the event emitter

    • on()
    • off()
    • once()
    • emitDelete()
    • emitCreate()
    • emitEdit()
    • emitNavigate()

Example

An example can be found in:

src/views/layout/default.html
* Notice the <div id="container"></div> it's required.
    var FileManagerObject = new FileManagerAPI();
    
    FileManagerObject.set([
        {_id: 1, path: '/etc/etc-sub-dir/sub-sub-etc-dir/file'},
        {_id: 2, path: '/etc/etc-sub-dir/sub-sub-etc-dir/file1'},
        {_id: 3, path: '/etc/file3'},
        {_id: 4, path: '/etc/etc-sub-dir/sub-sub-etc-dir2/file5'},
        {_id: 5, path: '/tmp/dir-test/qwe2'},
        {_id: 6, path: '/tmp/dir-test-1/qwe'},
        {_id: 7, path: '/tmp/dir-test/qwe3'}
    ]);
    
    FileManagerObject.on('delete', function(filename, key) {
        console.log("Delete file " + filename + " with key " + key);
    });
    
    FileManagerObject.on('create', function(filename, key) {
        console.log("Create file " + filename + " with key " + key);
    });
    
    FileManagerObject.on('edit', function(filename, oldname, key) {
        console.log("Edit file " + oldname + " with new name " + filename + " and key " + key);
    });
    
    FileManagerObject.on('navigate', function(path, isdir) {
        console.log("Navigate to " + path, ' Is directory ' + isdir);
    });
    
    FileManagerObject.initialize();

Optional

NGINX

Use NGINX for reverse proxy & serving static content

Benefits:

  • Serving static files more efficiently
  • Not having to worry about permissions for the Node.js process
  • Handles error pages if NODEJS server crashes
  • Running multiple WEB servers
  • It comes with built in security features
  • and more ...
upstream resource {
    server 127.0.0.1:5001;
}

server {
    listen example.xxx:80;
    server_name example.xxx;

    proxy_set_header Host $host; 
    proxy_set_header X-Real-IP $remote_addr; 
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
    proxy_set_header X-Forwarded-Proto http; 
    proxy_redirect off;

    location ~*  \.(jpg|jpeg|png|gif|ico|css|js)$ {
        root /www/path-to-resource/;
        expires 7d;
        add_header Pragma public;
        add_header Cache-Control "public";
    }
   
    location / {   
	
      # cross-origin HTTP request
      # include /etc/nginx/conf.d/cors.conf;

      access_log /var/log/nginx/resource.log;
      proxy_pass http://resource;
    }
 }

PM2

PM2 is a production process manager for Node.js applications with a built-in load balancer. It allows you to keep applications alive forever, to reload them without downtime and to facilitate common system admin tasks.

file-manager's People

Contributors

3webbg avatar

Watchers

 avatar

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.