Merge pull request #2 from NotAShelf/master

PR out of spite but it's friendly spite
pull/15/head
Facinorous 2 years ago committed by GitHub
commit 82ecf72c1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

6
.gitignore vendored

@ -7,6 +7,7 @@ lib-cov
*.pid
*.gz
*.swp
assets/
pids
logs
@ -14,7 +15,7 @@ results
tmp
# Constants
src/CONSTANTS.ts
src/constants.ts
# Dependency directory
node_modules
@ -26,4 +27,5 @@ Thumbs.db
# Ignore built files
dist/**/*
package-lock.json
package-lock.json
yarn.lock

@ -1,12 +1,12 @@
<br />
<p align="center">
<a href="dick_example_2.png">
<img src="dick_example_2.png" alt="Login">
<a href="assets/dick_example_2.png">
<img src="assets/dick_example_2.png" alt="Login">
</a>
<details align="center">
<summary>Profile Preview</summary>
<a href="dick_example_1.png">
<img src="dick_example_1.png" alt="Profile">
<a href="assets/dick_example_1.png">
<img src="assets/dick_example_1.png" alt="Profile">
</a>
</details>
@ -82,16 +82,19 @@ Inside this file, is some basic configuration you can change for your set up. Th
| Variable | Description |
| --------------------------------------------- | :---------------------: |
| `DICK_SUBMODULE = false` | Put this to true if you wish to run DICK as an ASS submoduke, false if seperate |
| `ASSLOCATION = "../ass"` | If running DICK seperately, DICK will use this to find your ASS install folder |
| `ASSSECURE = false` | Put this to true if you are running ASS behind a domain with HTTPS,. false if HTTP |
| `ASS_LOCATION = "../ass"` | If running DICK seperately, DICK will use this to find your ASS install folder |
| `ASS_SECURE = false` | Put this to true if you are running ASS behind a domain with HTTPS,. false if HTTP |
| `ASSDOMAIN = "127.0.0.1:40115"` | Put this to your ASS domain. Can be an ip, or domain for example `https://cdn.mydomain.com` |
| `STAFF_IDS = ["ass"]` | Change this to whatever your username is in your ASS `auth.json` file. Default user in ASS, is `ass` |
### Running
#### Development
<details>
<summary><sub>Open to view the development set up steps</sub></summary>
<summary>
<sub>Open to view the development set up steps</sub>
</summary>
1. Create a folder, call it whatever you wish
2. Install, and run ASS https://github.com/tycrek/ass#installation (This will create an `ass` folder)
@ -107,16 +110,18 @@ Inside this file, is some basic configuration you can change for your set up. Th
#### Production
<details>
<summary><sub>Open to view the production set up steps</sub></summary><br/>
<summary>
<sub>Open to view the production set up steps</sub>
</summary><br/>
1. Create a folder, call it whatever you wish
2. Install, and run ASS https://github.com/tycrek/ass#installation (This will create an `ass` folder)
3. Go back into the folder you created and clone this repo `git clone https://github.com/Facinorous-420/dick`
3. Go back into the folder you created and clone this repo `git clone https://github.com/Facinorous-420/dick.git`
4. Go into the newly created `dick` folder `cd dick`
5. Go into `/src` and copy `CONSTANTS.ts.example` to `CONSTANTS.ts` and edit it as needed
6. Go back to the root of `dick` and install the dependancies for the frontend, `npm i`
7. Run `npm start` to compile the code base and run DICK
</details>
When you approach the login screen, your secret key is the key generated for your account. You should not share this with anyone.

Before

Width:  |  Height:  |  Size: 82 KiB

After

Width:  |  Height:  |  Size: 82 KiB

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

@ -1,33 +0,0 @@
import { templatePathBuilder } from "./utils/utils"
/*
------------------- USER CONSTANTS ------------------------
*/
// Variable to set DICK to run as a submodule to ASS or seperately: true = submodule | false = seperate
export const DICK_SUBMODULE = false
// * ------------------- ASS HOST INFORMATION ----------------------------
// Boolean variable if your ASS is secured with HTTPS: true = https | false = http
export const ASSSECURE = false
// This is the domain your ASS is hosted at: "127.0.0.1" | "cdn.domain.com"
export const ASSDOMAIN = "127.0.0.1:40115"
// If running DICK in seperate mode, it will need to know where your ASS is installed
export const ASSLOCATION = "../ass"
// * ------------------- STAFF ID CONSTANTS ---------------------------- <--- this will eventually be moved away from constants
// Array of all USERNAMES in your ASS auth.json file that will have admin access: ["ass", "dick", "frank"]
export const STAFF_IDS = ["ass"]
/*
------------------- SYSTEM CONSTANTS ------------------------
*/
// * ------------------- TEMPLATE PATH CONSTANTS ------------------------
export const TEMPLATE = {
USER: templatePathBuilder("/user.ejs"),
PUBLIC: templatePathBuilder("/public.ejs"),
ERRORS: {
403: templatePathBuilder("/errors/403.ejs"),
404: templatePathBuilder("/errors/404.ejs")
}
}

@ -1,7 +1,7 @@
import { Response } from "express"
import { parseAuthFile, parseDataFile } from "./utils/assJSONStructure"
import { RenderOptions } from "./typings/Pager"
import { ASSDOMAIN, ASSSECURE, STAFF_IDS } from "./CONSTANTS"
import { ASS_DOMAIN, ASS_SECURE, STAFF_IDS } from "./constants"
import { convertTimestamp, formatSize } from "./utils/utils"
import { ASSUser, ASSItem } from "./typings/ASSTypes"
import { IExtendedRequest } from "./typings/express-ext"
@ -120,8 +120,8 @@ export class Pager {
*/
const baseData = {
assDomain: ASSDOMAIN,
assSecure: ASSSECURE,
assDomain: ASS_DOMAIN,
assSecure: ASS_SECURE,
user: req.user,
totalSize,
totalUsers,

@ -0,0 +1,40 @@
import { templatePathBuilder } from "./utils/utils"
/* ------------------- USER CONSTANTS ------------------------ */
// Variable to set DICK to run as a submodule to ASS or separately
// true = submodule | false = separate
export const DICK_SUBMODULE = false
/* ------------------- ASS HOST INFORMATION ---------------------------- */
// Boolean variable if your ASS is secured with HTTPS
// true = https | false = http
export const ASS_SECURE = false
// This is the domain your ASS is hosted at: "127.0.0.1" | "cdn.domain.com"
export const ASS_DOMAIN = "127.0.0.1:40115"
// If running DICK in separate mode, it will need to know where your ASS is installed
// do note that it must be a *relative* location.
// For example "../ass" means ass is installed in the parent directory.
export const ASS_LOCATION = "../ass"
/* ------------------- STAFF ID CONSTANTS ---------------------------- */
// this will eventually be moved away from constants
// Array of all USERNAMES in your ASS auth.json file that will have admin access: ["ass", "dick", "frank"]
export const STAFF_IDS = ["ass"]
/* ------------------- SYSTEM CONSTANTS ------------------------ */
// Port to run the server on, change if you have something else running on that port
export const PORT = "3000"
/* ------------------- TEMPLATE PATH CONSTANTS ------------------------ */
export const TEMPLATE = {
USER: templatePathBuilder("/user.ejs"),
PUBLIC: templatePathBuilder("/public.ejs"),
ERRORS: {
403: templatePathBuilder("/errors/403.ejs"),
404: templatePathBuilder("/errors/404.ejs")
}
}

@ -8,11 +8,12 @@ import flash from 'connect-flash'
import errorHandler from "errorhandler"
import { Pager } from "./Pager"
import { TEMPLATE } from "./CONSTANTS"
import { TEMPLATE } from "./constants"
import { authRoutes } from "./routes/route.auth"
import { publicRoutes } from "./routes/route.public"
import { userRoutes } from "./routes/route.user"
import { adminRoutes } from "./routes/route.admin"
import { PORT } from "./constants"
// Add async into express cause async is megachad
const app = express()

@ -1,6 +1,6 @@
import { Request, Response, Router } from "express"
import { authCheck, adminCheck, wrap } from "../utils/utils"
import { TEMPLATE } from "../CONSTANTS"
import { TEMPLATE } from "../constants"
import { Pager } from "../Pager"
export const adminRoutes = (app: Router) => {

@ -1,5 +1,5 @@
import { Request, Response, Router } from "express"
import { TEMPLATE } from "../CONSTANTS"
import { TEMPLATE } from "../constants"
import { Pager } from "../Pager"
export const publicRoutes = (app: Router) => {

@ -1,6 +1,6 @@
import { Request, Response, Router } from "express"
import { adminCheck, authCheck, wrap } from "../utils/utils"
import { TEMPLATE } from "../CONSTANTS"
import { TEMPLATE } from "../constants"
import { Pager } from "../Pager"
import { parseAuthFile } from "../utils/assJSONStructure"

@ -1,10 +1,10 @@
import { DICK_SUBMODULE, ASSLOCATION } from "../CONSTANTS"
import { DICK_SUBMODULE, ASS_LOCATION } from "../constants"
import fs from "fs"
import path from "path"
import { ASSItem } from "typings/ASSTypes"
let DATA_FILE_PATH = path.resolve(`${ASSLOCATION}/data.json`)
let AUTH_FILE_PATH = path.resolve(`${ASSLOCATION}/auth.json`)
let DATA_FILE_PATH = path.resolve(`${ASS_LOCATION}/data.json`)
let AUTH_FILE_PATH = path.resolve(`${ASS_LOCATION}/auth.json`)
if (DICK_SUBMODULE !== false) {
DATA_FILE_PATH = path.resolve(`data.json`)
AUTH_FILE_PATH = path.resolve(`auth.json`)

@ -1,5 +1,5 @@
import { Log } from "@callmekory/logger"
import { STAFF_IDS } from "../CONSTANTS"
import { STAFF_IDS } from "../constants"
import { Response, NextFunction } from "express"
import { join, normalize } from "path"
import { IExtendedRequest } from "../typings/express-ext"

Loading…
Cancel
Save