From be014f7d62cbae826861ab65cc2a3e647407e7d1 Mon Sep 17 00:00:00 2001 From: notashelf Date: Mon, 4 Apr 2022 20:03:41 +0300 Subject: [PATCH 1/5] move images into their own directory --- README.md | 27 +++++++----- .../dick_example_1.png | Bin .../dick_example_2.png | Bin src/constants.ts | 40 ++++++++++++++++++ 4 files changed, 56 insertions(+), 11 deletions(-) rename dick_example_1.png => assets/dick_example_1.png (100%) rename dick_example_2.png => assets/dick_example_2.png (100%) create mode 100644 src/constants.ts diff --git a/README.md b/README.md index 5da4074..1e8501e 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@

- - Login + + Login

Profile Preview - - Profile + + Profile
@@ -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
- Open to view the development set up steps + + Open to view the development set up steps + 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
- Open to view the production set up steps
- + + Open to view the production set up steps +
+ 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 - +
When you approach the login screen, your secret key is the key generated for your account. You should not share this with anyone. diff --git a/dick_example_1.png b/assets/dick_example_1.png similarity index 100% rename from dick_example_1.png rename to assets/dick_example_1.png diff --git a/dick_example_2.png b/assets/dick_example_2.png similarity index 100% rename from dick_example_2.png rename to assets/dick_example_2.png diff --git a/src/constants.ts b/src/constants.ts new file mode 100644 index 0000000..c9362ad --- /dev/null +++ b/src/constants.ts @@ -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") + } +} From e4f841e9b060bc4810cddb5826ff638ec21e9639 Mon Sep 17 00:00:00 2001 From: notashelf Date: Mon, 4 Apr 2022 20:05:44 +0300 Subject: [PATCH 2/5] constants rather than CONSTANTS + rename variables --- src/dashboard.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/dashboard.ts b/src/dashboard.ts index 7a27e2e..4cc4a87 100644 --- a/src/dashboard.ts +++ b/src/dashboard.ts @@ -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() From 73b28bb73facf38744e26645ef89a327df2c5611 Mon Sep 17 00:00:00 2001 From: notashelf Date: Mon, 4 Apr 2022 20:05:59 +0300 Subject: [PATCH 3/5] rename variables for readibility --- src/Pager.ts | 6 +++--- src/routes/route.admin.ts | 2 +- src/routes/route.public.ts | 2 +- src/routes/route.user.ts | 2 +- src/utils/assJSONStructure.ts | 6 +++--- src/utils/utils.ts | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Pager.ts b/src/Pager.ts index 501e822..c453b4f 100644 --- a/src/Pager.ts +++ b/src/Pager.ts @@ -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, diff --git a/src/routes/route.admin.ts b/src/routes/route.admin.ts index 294d6b3..6674c5d 100644 --- a/src/routes/route.admin.ts +++ b/src/routes/route.admin.ts @@ -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) => { diff --git a/src/routes/route.public.ts b/src/routes/route.public.ts index 79ad557..cca7765 100644 --- a/src/routes/route.public.ts +++ b/src/routes/route.public.ts @@ -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) => { diff --git a/src/routes/route.user.ts b/src/routes/route.user.ts index 8ee673a..97b1eaf 100644 --- a/src/routes/route.user.ts +++ b/src/routes/route.user.ts @@ -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" diff --git a/src/utils/assJSONStructure.ts b/src/utils/assJSONStructure.ts index 322fc23..3f95cc4 100644 --- a/src/utils/assJSONStructure.ts +++ b/src/utils/assJSONStructure.ts @@ -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`) diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 9584cbd..25e3d87 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -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" From 24639437bb8e0fbdc84019cacbb1493a48d827f2 Mon Sep 17 00:00:00 2001 From: notashelf Date: Mon, 4 Apr 2022 20:07:14 +0300 Subject: [PATCH 4/5] cool kids use yarn --- .gitignore | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index c6968ae..3b06183 100644 --- a/.gitignore +++ b/.gitignore @@ -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 \ No newline at end of file +package-lock.json +yarn.lock \ No newline at end of file From 056800f68fd97d3814caa1259283dbc4ba1723a0 Mon Sep 17 00:00:00 2001 From: notashelf Date: Mon, 4 Apr 2022 20:07:32 +0300 Subject: [PATCH 5/5] rename CONSTANTS to constants for consistency --- src/CONSTANTS.ts.example | 33 ---------------------- src/{constants.ts => constants.ts.example} | 0 2 files changed, 33 deletions(-) delete mode 100644 src/CONSTANTS.ts.example rename src/{constants.ts => constants.ts.example} (100%) diff --git a/src/CONSTANTS.ts.example b/src/CONSTANTS.ts.example deleted file mode 100644 index 09c230e..0000000 --- a/src/CONSTANTS.ts.example +++ /dev/null @@ -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") - } -} diff --git a/src/constants.ts b/src/constants.ts.example similarity index 100% rename from src/constants.ts rename to src/constants.ts.example