npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fmgr-express

v1.1.6

Published

File manager for CKEditor in express.js

Downloads

6

Readme

fmgr-express

File manager for CKEditor in express.js

Installation

Install with npm

npm i fmgr-express

or

npm i [email protected]:faikdjikic/fmgr-express.git

Usage

const options={
    fmRootDir: '/public/assets',
    fmRootUrl: '/assets',
    locale: 'en-US',
    overwrite: false, 
    maxsize: '5M',
    maxfiles: 10
    }
const filemanager = require("fmgr-express")(options);
const app = express();
app.use('/filemanager',filemanager);

Using with CKEditor

//add to CKEditor's config.js following lines
config.filebrowserBrowseUrl='/filemanager/';
config.filebrowserImageBrowseUrl='/filemanager/?type=image';
config.filebrowserUploadUrl='/filemanager/';
config.filebrowserImageUploadUrl='/filemanager/?type=image';
config.filebrowserWindowWidth='1200'; //set your own value for window width
config.filebrowserWindowHeight='800'; //set your own value for window height

Using with custom input and fancybox

<input type="text" name="MainImage" id="MainImage">
    <a
    href="javascript:void(0)"
    onclick="$.fancybox.open(
    {
        src: '/filemanager/?tElement=MainImage&cb=closeFancyBox',
        type: 'iframe',
        iframe:{
            css:{
                width : '75%',
                height: '100%'
            }
        }
    });">
    Select image
    </a>
    <script>
    function closeFancyBox(){
	    $.fancybox.close();
    }
    </script>

Using with custom input and vanilla JS

<input type="text" name="MainImage" id="MainImage">
    <a
    href="javascript:void(0)"
    onclick="window.open('/filemanager/?tElement=MainImage');">
    Select image
    </a>

:warning: Warning!!!

Filemanager does not implement access control by itself. Please use proper middleware to limit user access and avoid abuse. This is sample code for basic authentication using passport:


const passport = require('passport');
const Strategy = require('passport-http').BasicStrategy;
const options={
    fmRootDir: '/public/assets',
    fmRootUrl: '/assets',
    locale: 'en-US',
    overwrite: false, 
    maxsize: '5M',
    maxfiles: 10
    }
const filemanager = require("fmgr-express")(options);
const app = express();
app.use(passport.initialize());
passport.use(new Strategy({ realm: loginfn.getRealm },
  function (username, password, cb) {
    findByUsername(username, function (err, user) {
      if (err) { return cb(err); }
      if (!user) return cb(null, false);
      if (user.password != password) return cb(null, false);
      return cb(null, user);
    });
  }));
app.use('/filemanager',
  passport.authenticate('basic', { session: false }),
  filemanager
);

Default values (to change these values modify options object)


module.exports = {
    fmRootDir: '/public/assets', //assets directory path relative to wwwroot
    fmRootUrl: '/assets', //assets directory url
    locale: 'de-DE', //locale for file dates
    overwrite: false, 
    /*
    * If overwrite is set to true, existing file will be overwritten, 
    * otherwise the new file will be renamed on upload
    */
    maxsize:'20M', 
    /**************************************************************************************
    * Sets the maximum size for single file, default 2M. 
    * Use K for kilobytes, M for megabytes and G for gigabytes. 
    * Default unit is M. 
    * To disable size limit set maxsize to 0
    */
    maxfiles: 20, //maximum number of files that can be uploaded at once
    allowExtensions: ["svg", "jpg", "jpeg", "gif", "png", "xls", "xlsx", "ppt", "pptx", 
    "pps", "ppsx", "zip", "doc", "docx", "mp3", "ogg", "oga", "mogg", "wav", "webm", "ogv", 
    "ogg", "mng", "avi", "mp4", "mpg", "mpeg", "pdf"], 
    /* The list of file extensions that are allowed for upload */
    
    /**************************************************************************************
    * fileTypes array groups files by extensions, 
    * define file icon (except for images where image itself is used as an icon). 
    * fileTypes type properties are used for filtering by type 
    * (e.g. /filemanager/?type=word,excel,pdf).
    */
    fileTypes: [
        {
            type: "image",
            extensions: ["svg", "jpg", "jpeg", "gif", "png"],
            icon: "file-item-img"
        },
        {
            type: "archive",
            extensions: ["7z", "ace", "afa", "alz", "apk", "arc", "arj", "ark", "b1", "b6z", 
            "ba", "bh", "bz2", "cab", "car", "cdx", "cfs", "cpt", "dar", "dd", "dgc", "dmg", 
            "ear", "gca", "genozip", "gz", "ha", "hki", "ice", "jar", "kgb", "lha", "lz", "lzh", 
            "lzx", "pak", "paq6", "paq7", "paq8", "partimg", "pea", "phar", "pim", "pit", "qda", 
            "rar", "rk", "s7z", "sda", "sea", "sen", "sfx", "shk", "sit", "sitx", "sqx", "tbz2", 
            "tgz", "tlz", "txz", "uc", "uc0", "uc2", "uca", "ucn", "ue2", "uha", "ur2", "war", 
            "wim", "xar", "xp3", "xz", "yz1", "Z", "zip", "zipx", "zoo", "zpaq", "zst", "zz"],
            icon: "fa-file-archive"
        },
        {
            type: "word",
            extensions: ["doc", "docm", "docx", "dot", "dotm", "dotx"],
            icon: "fa-file-word"
        },
        {
            type: "excel",
            extensions: ["xlsx", "xlsm", "xlsb", "xltx", "xltm", "xls", "xlt", "xlam", "xla", 
            "xlw", "xlr"],
            icon: "fa-file-excel"
        },
        {
            type: "powerpoint",
            extensions: ["pptx", "pptm", "ppt", "potx", "potm", "pot", "ppsx", "ppsm", "pps", 
            "ppa", "ppam"],
            icon: "fa-file-powerpoint"
        },
        {
            type: "sound",
            extensions: ["3gp", "aa", "aac", "aax", "act", "aiff", "alac", "amr", "ape", "au", 
            "awb", "dss", "dvf", "flac", "gsm", "iklax", "ivs", "m4a", "m4b", "m4p", "mmf", "mp3", 
            "mpc", "msv", "nmf", "ogg", "oga", "mogg", "opus", "ra", "rm", "raw", "rf64", "sln", 
            "tta", "voc", "vox", "wav", "wma", "wv", "8svx", "cda"],
            icon: "fa-file-audio"
        },
        {
            type: "video",
            extensions: ["webm", "mkv", "flv", "flv", "vob", "ogv", "ogg", "drc", "gifv", "mng", 
            "avi", "MTS", "M2TS", "TS", "mov", "qt", "wmv", "yuv", "rm", "rmvb", "viv", "asf", 
            "amv", "mp4", "m4p", "m4v", "mpg", "mp2", "mpe", "mpv", "mpeg", "m2v", "m4v", "svi", 
            "3gp", "3g2", "mxf", "roq", "nsv", "flv", "f4v", "f4p", "f4a", "f4b"],
            icon: "fa-file-video"
        },
        {
            type: "pdf",
            extensions: ["pdf"],
            icon: "fa-file-pdf"
        },
        {
            type: "file",
            extensions: ["*"],
            icon: "fa-file"
        },

    ]
}