88 |
--------------------------------------------------------------------------------
/dist/README.md:
--------------------------------------------------------------------------------
1 | # Camouflage Filemanager
2 |
3 | Camouflage Filemanager is a web based filemanager that allows you to browse and create files/folders, edit text based files, download files.
4 |
5 | ## Preview
6 | 
7 | 
8 | 
9 |
10 | ## Installation
11 |
12 | ### NPM
13 |
14 | ```bash
15 | npm install -g camouflage-filemanager
16 | ```
17 | Filemanager requires two environment variables
18 | * `FS_ROOT`: Root Directory for filemanager; default value is current working directory
19 | * `WRITE_PROTECTED`: Default value is `true`, which means creation/deletion/updates of any kind are not allowed.
20 |
21 | Start filemanager after npm installation by running command: `filemanager` in your desired directory. Optionally you can override aforementioned environment variables by exporting or by creating a `.env` file in your current working directory.
22 |
23 | ### Docker
24 |
25 | 1. Default:
26 | ```bash
27 | docker run -d -p 3000:3000 --name filemanager shubhendumadhukar/camouflage-filemanager
28 | ```
29 | 2. Specify root directory:
30 | ```bash
31 | docker run -d -p 3000:3000 -e FS_ROOT="/opt" --name filemanager shubhendumadhukar/camouflage-filemanager
32 | ```
33 | 3. Specify if write is allowed (not allowed by default):
34 | ```bash
35 | docker run -d -p 3000:3000 -e FS_ROOT="/opt" -e WRITE_PROTECTED=false --name filemanager shubhendumadhukar/camouflage-filemanager
36 | ```
37 | 4. Mount a local volume:
38 | ```bash
39 | docker run -d -p 3000:3000 -e FS_ROOT="/opt/virtual_services" -e WRITE_PROTECTED=false -v ~/Desktop:/opt/Desktop --name filemanager shubhendumadhukar/camouflage-filemanager
40 | ```
41 |
42 | ## License
43 | ```
44 | MIT License
45 |
46 | Copyright (c) 2021 testinggospels
47 |
48 | Permission is hereby granted, free of charge, to any person obtaining a copy
49 | of this software and associated documentation files (the "Software"), to deal
50 | in the Software without restriction, including without limitation the rights
51 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
52 | copies of the Software, and to permit persons to whom the Software is
53 | furnished to do so, subject to the following conditions:
54 |
55 | The above copyright notice and this permission notice shall be included in all
56 | copies or substantial portions of the Software.
57 |
58 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
59 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
60 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
61 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
62 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
63 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
64 | SOFTWARE.
65 | ```
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Camouflage Filemanager
2 |
3 | Camouflage Filemanager is a web based filemanager that allows you to browse and create files/folders, edit text based files, download files.
4 |
5 | ## Preview
6 | 
7 | 
8 | 
9 | 
10 | 
11 | 
12 |
13 | ## Installation
14 |
15 | ### NPM
16 |
17 | ```bash
18 | npm install -g camouflage-filemanager
19 | ```
20 | Filemanager requires two environment variables
21 | * `FS_ROOT`: Root Directory for filemanager; default value is current working directory
22 | * `WRITE_PROTECTED`: Default value is `true`, which means creation/deletion/updates of any kind are not allowed.
23 |
24 | Start filemanager after npm installation by running command: `filemanager` in your desired directory. Optionally you can override aforementioned environment variables by exporting or by creating a `.env` file in your current working directory.
25 |
26 | ### Docker
27 |
28 | 1. Default:
29 | ```bash
30 | docker run -d -p 3000:3000 --name filemanager shubhendumadhukar/camouflage-filemanager
31 | ```
32 | 2. Specify root directory:
33 | ```bash
34 | docker run -d -p 3000:3000 -e FS_ROOT="/opt" --name filemanager shubhendumadhukar/camouflage-filemanager
35 | ```
36 | 3. Specify if write is allowed (not allowed by default):
37 | ```bash
38 | docker run -d -p 3000:3000 -e FS_ROOT="/opt" -e WRITE_PROTECTED=false --name filemanager shubhendumadhukar/camouflage-filemanager
39 | ```
40 | 4. Mount a local volume:
41 | ```bash
42 | docker run -d -p 3000:3000 -e FS_ROOT="/opt/virtual_services" -e WRITE_PROTECTED=false -v ~/Desktop:/opt/Desktop --name filemanager shubhendumadhukar/camouflage-filemanager
43 | ```
44 |
45 | ## License
46 | ```
47 | MIT License
48 |
49 | Copyright (c) 2021 testinggospels
50 |
51 | Permission is hereby granted, free of charge, to any person obtaining a copy
52 | of this software and associated documentation files (the "Software"), to deal
53 | in the Software without restriction, including without limitation the rights
54 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
55 | copies of the Software, and to permit persons to whom the Software is
56 | furnished to do so, subject to the following conditions:
57 |
58 | The above copyright notice and this permission notice shall be included in all
59 | copies or substantial portions of the Software.
60 |
61 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
62 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
63 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
64 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
65 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
66 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
67 | SOFTWARE.
68 | ```
69 |
--------------------------------------------------------------------------------
/src/lib/components/Clipboard.svelte:
--------------------------------------------------------------------------------
1 |
41 |
42 | {#if !CLIPBOARD_EMPTY}
43 |
62 |
63 |
137 |
--------------------------------------------------------------------------------
/src/lib/fsutils.js:
--------------------------------------------------------------------------------
1 | import fs from 'fs-extra'
2 | import path from 'path';
3 | import dotenv from 'dotenv'
4 | dotenv.config();
5 |
6 | export function dirStat(inputFolder) {
7 | let fsRoot = path.resolve(process.env['FS_ROOT'] || process.cwd())
8 | if (inputFolder) {
9 | fsRoot = path.join(path.resolve(process.env['FS_ROOT'] || process.cwd()), inputFolder)
10 | }
11 | const files = fs.readdirSync(fsRoot)
12 | const dirStat = [];
13 | files.forEach(file => {
14 | let filePath = path.join(fsRoot, file);
15 | let stats = fs.lstatSync(filePath)
16 | let fileDetails = {
17 | file,
18 | createdTime: stats.ctime,
19 | modifiedTime: stats.mtime,
20 | isDirectory: stats.isDirectory(),
21 | }
22 | dirStat.push(fileDetails)
23 | });
24 | return dirStat;
25 | }
26 |
27 | export function readFile(inputFile) {
28 | const fsRoot = path.join(path.resolve(process.env['FS_ROOT'] || process.cwd()), inputFile)
29 | const isDirectory = fs.lstatSync(fsRoot).isDirectory()
30 | if (isDirectory) {
31 | return {
32 | status: 400,
33 | body: {
34 | error: 'Directory can not be treated as a text file.'
35 | }
36 | }
37 | }
38 | return fs.readFileSync(fsRoot).toString()
39 | }
40 |
41 | export function deleteFile(inputFile) {
42 | const fsRoot = path.resolve(process.env["FS_ROOT"] || process.cwd())
43 | const delResource = path.join(fsRoot, inputFile)
44 | const parent = path.dirname(delResource)
45 | try {
46 | fs.removeSync(delResource)
47 | if (parent === fsRoot) {
48 | return dirStat();
49 | } else {
50 | return dirStat(parent.replace(fsRoot, ""))
51 | }
52 | } catch (err) {
53 | return { error: true, message: err.message }
54 | }
55 | }
56 |
57 | export function createFolder(inputFile) {
58 | const fsRoot = path.resolve(process.env["FS_ROOT"] || process.cwd())
59 | const file = path.join(fsRoot, inputFile)
60 | fs.mkdirpSync(file);
61 | return create(file, fsRoot)
62 | }
63 |
64 | export function createFile(inputFile) {
65 | const fsRoot = path.resolve(process.env["FS_ROOT"] || process.cwd())
66 | const file = path.join(fsRoot, inputFile)
67 | fs.createFileSync(file);
68 | return create(file, fsRoot);
69 | }
70 |
71 | function create(createPath, fsRoot) {
72 | const parent = path.dirname(createPath)
73 | try {
74 | if (parent === fsRoot) {
75 | return dirStat()
76 | } else {
77 | return dirStat(parent.replace(fsRoot, ""))
78 | }
79 | } catch (err) {
80 | return { error: true, message: err.message }
81 | }
82 | }
83 |
84 | export function writeFile(inputFile, content) {
85 | const fsRoot = path.resolve(process.env["FS_ROOT"] || process.cwd())
86 | const file = path.join(fsRoot, inputFile)
87 | try {
88 | fs.writeFileSync(file, content)
89 | return "success";
90 | } catch (err) {
91 | return err.message;
92 | }
93 | }
94 |
95 | export function copy(source, dest) {
96 | try {
97 | const fsRoot = path.resolve(process.env["FS_ROOT"] || process.cwd());
98 | const originalLocation = path.join(fsRoot, source);
99 | const newLocation = path.join(fsRoot, dest, path.basename(source));
100 | if (!fs.existsSync(newLocation)) {
101 | fs.copySync(originalLocation, newLocation, { overwrite: false, errorOnExist: true })
102 | } else {
103 | return { success: false, err: "dest already exists" }
104 | }
105 | return { success: true }
106 | } catch (err) {
107 | return { success: false, err: err.message }
108 | }
109 | }
110 |
111 | export function cut(source, dest) {
112 | try {
113 | const fsRoot = path.resolve(process.env["FS_ROOT"] || process.cwd());
114 | const originalLocation = path.join(fsRoot, source);
115 | const newLocation = path.join(fsRoot, dest, path.basename(source));
116 | if (!fs.existsSync(newLocation)) {
117 | fs.moveSync(originalLocation, newLocation, { overwrite: false, errorOnExist: true })
118 | } else {
119 | return { success: false, err: "dest already exists" }
120 | }
121 | return { success: true }
122 | } catch (err) {
123 | return { success: false, err: err.message }
124 | }
125 | }
126 |
127 | export function rename(source, dest) {
128 | const fsRoot = path.resolve(process.env["FS_ROOT"] || process.cwd());
129 | const oldPath = path.join(fsRoot, source)
130 | const newPath = path.join(fsRoot, dest)
131 | try {
132 | if (!fs.existsSync(newPath)) {
133 | fs.renameSync(oldPath, newPath)
134 | } else {
135 | return { success: false, err: "dest already exists" }
136 | }
137 | } catch (err) {
138 | return { success: false, err: err.message }
139 | }
140 | }
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | We as members, contributors, and leaders pledge to make participation in our
6 | community a harassment-free experience for everyone, regardless of age, body
7 | size, visible or invisible disability, ethnicity, sex characteristics, gender
8 | identity and expression, level of experience, education, socio-economic status,
9 | nationality, personal appearance, race, religion, or sexual identity
10 | and orientation.
11 |
12 | We pledge to act and interact in ways that contribute to an open, welcoming,
13 | diverse, inclusive, and healthy community.
14 |
15 | ## Our Standards
16 |
17 | Examples of behavior that contributes to a positive environment for our
18 | community include:
19 |
20 | * Demonstrating empathy and kindness toward other people
21 | * Being respectful of differing opinions, viewpoints, and experiences
22 | * Giving and gracefully accepting constructive feedback
23 | * Accepting responsibility and apologizing to those affected by our mistakes,
24 | and learning from the experience
25 | * Focusing on what is best not just for us as individuals, but for the
26 | overall community
27 |
28 | Examples of unacceptable behavior include:
29 |
30 | * The use of sexualized language or imagery, and sexual attention or
31 | advances of any kind
32 | * Trolling, insulting or derogatory comments, and personal or political attacks
33 | * Public or private harassment
34 | * Publishing others' private information, such as a physical or email
35 | address, without their explicit permission
36 | * Other conduct which could reasonably be considered inappropriate in a
37 | professional setting
38 |
39 | ## Enforcement Responsibilities
40 |
41 | Community leaders are responsible for clarifying and enforcing our standards of
42 | acceptable behavior and will take appropriate and fair corrective action in
43 | response to any behavior that they deem inappropriate, threatening, offensive,
44 | or harmful.
45 |
46 | Community leaders have the right and responsibility to remove, edit, or reject
47 | comments, commits, code, wiki edits, issues, and other contributions that are
48 | not aligned to this Code of Conduct, and will communicate reasons for moderation
49 | decisions when appropriate.
50 |
51 | ## Scope
52 |
53 | This Code of Conduct applies within all community spaces, and also applies when
54 | an individual is officially representing the community in public spaces.
55 | Examples of representing our community include using an official e-mail address,
56 | posting via an official social media account, or acting as an appointed
57 | representative at an online or offline event.
58 |
59 | ## Enforcement
60 |
61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
62 | reported to the community leaders responsible for enforcement at
63 | shubhendumadhukar@gmail.com.
64 | All complaints will be reviewed and investigated promptly and fairly.
65 |
66 | All community leaders are obligated to respect the privacy and security of the
67 | reporter of any incident.
68 |
69 | ## Enforcement Guidelines
70 |
71 | Community leaders will follow these Community Impact Guidelines in determining
72 | the consequences for any action they deem in violation of this Code of Conduct:
73 |
74 | ### 1. Correction
75 |
76 | **Community Impact**: Use of inappropriate language or other behavior deemed
77 | unprofessional or unwelcome in the community.
78 |
79 | **Consequence**: A private, written warning from community leaders, providing
80 | clarity around the nature of the violation and an explanation of why the
81 | behavior was inappropriate. A public apology may be requested.
82 |
83 | ### 2. Warning
84 |
85 | **Community Impact**: A violation through a single incident or series
86 | of actions.
87 |
88 | **Consequence**: A warning with consequences for continued behavior. No
89 | interaction with the people involved, including unsolicited interaction with
90 | those enforcing the Code of Conduct, for a specified period of time. This
91 | includes avoiding interactions in community spaces as well as external channels
92 | like social media. Violating these terms may lead to a temporary or
93 | permanent ban.
94 |
95 | ### 3. Temporary Ban
96 |
97 | **Community Impact**: A serious violation of community standards, including
98 | sustained inappropriate behavior.
99 |
100 | **Consequence**: A temporary ban from any sort of interaction or public
101 | communication with the community for a specified period of time. No public or
102 | private interaction with the people involved, including unsolicited interaction
103 | with those enforcing the Code of Conduct, is allowed during this period.
104 | Violating these terms may lead to a permanent ban.
105 |
106 | ### 4. Permanent Ban
107 |
108 | **Community Impact**: Demonstrating a pattern of violation of community
109 | standards, including sustained inappropriate behavior, harassment of an
110 | individual, or aggression toward or disparagement of classes of individuals.
111 |
112 | **Consequence**: A permanent ban from any sort of public interaction within
113 | the community.
114 |
115 | ## Attribution
116 |
117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118 | version 2.0, available at
119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120 |
121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct
122 | enforcement ladder](https://github.com/mozilla/diversity).
123 |
124 | [homepage]: https://www.contributor-covenant.org
125 |
126 | For answers to common questions about this code of conduct, see the FAQ at
127 | https://www.contributor-covenant.org/faq. Translations are available at
128 | https://www.contributor-covenant.org/translations.
129 |
--------------------------------------------------------------------------------