Skip to content

Commit

Permalink
Fixed docker-compose, changed readme, fixed expiry and more
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianFun123 committed Aug 17, 2023
1 parent 3743b74 commit 0da4554
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 64 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ docker run -p 8080:80 \
--env OAUTH2_PROVIDER_CLIENT_SECRET= \
interaapps/pastefy
```
Or [Pastefy Docker in Host-Mode](https://pastefy.ga/JWLoudTI)
Or [Pastefy Docker in Host-Mode](https://pastefy.app/JWLoudTI)

### Docker-Compose
https://github.com/interaapps/pastefy/blob/master/docker-compose.yml
Expand All @@ -73,7 +73,7 @@ docker-compose up
### Custom Docker-Compose (Using Docker-Hub)
https://pastefy.ga/Hj9N3bs2
```bash
wget https://pastefy.ga/Hj9N3bs2/raw -O docker-compose.yml
wget https://pastefy.app/Hj9N3bs2/raw -O docker-compose.yml
nano docker-compose.yml
docker-compose up
```
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3.3'

services:
db:
image: mariadb:latest
image: mariadb:10.11
volumes:
- dbvol:/var/lib/mysql

Expand Down
6 changes: 4 additions & 2 deletions frontend/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@400;500;600&family=Space+Mono:ital,wght@0,400;0,700;1,400&family=DM+Mono:wght@300;400;500&display=swap" rel="stylesheet">

<link rel="shortcut icon" type="image/png" href="/assets/images/icon.png"> <meta name="theme-color" content="#212531" />

<meta id="metaThemeColor" name="theme-color" content="#212531">

<link rel="shortcut icon" type="image/png" href="/assets/images/icon.png">

<link rel="manifest" href="/manifest.json">

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/PastefyAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class PastefyAPI extends Cajax {
const json = await res.json()

if (json.error)
throw new Error()
throw json

return json
}
Expand Down
18 changes: 16 additions & 2 deletions frontend/src/components/Sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@

<label for="expiry">Paste Expires</label>
<input type="checkbox" v-model="expiry" name="expiry">
<input v-if="expiry" :min="new Date().toTimeString()" v-model="$store.state.currentPaste.expire_at" class="input" type="datetime-local">
<input v-if="expiry" :min="new Date().toTimeString()" v-model="$store.state.currentPaste.expire_at" step="1" class="input" type="datetime-local">

<br>

Expand Down Expand Up @@ -311,7 +311,14 @@ export default {
if (this.expiry) {
const date = new Date()
date.setTime(date.getTime() + 1000 * 60 * 60 * 48)
console.log(this.$store.state.currentPaste.expire_at)
this.$store.state.currentPaste.expire_at = date.toISOString().slice(0, 19).replace('T', ' ')
console.log(this.$store.state.currentPaste.expire_at)
if (this.$store.state.currentPaste.expire_at.length === 16) {
this.$store.state.currentPaste.expire_at += ':00'
}
console.log(this.$store.state.currentPaste.expire_at)
} else {
this.$store.state.currentPaste.expire_at = null
}
Expand Down Expand Up @@ -408,9 +415,16 @@ export default {
if (this.$store.state.currentPaste.folder !== "")
data.folder = this.$store.state.currentPaste.folder
if (this.expiry)
if (this.expiry) {
data.expire_at = this.$store.state.currentPaste.expire_at
data.expire_at = this.$store.state.currentPaste.expire_at.slice(0, 19).replace('T', ' ')
if (data.expire_at.length === 16) {
data.expire_at += ':00'
}
}
data.encrypted = false;
let key;
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ export function setThemeFrom(vars = {}) {
else
document.documentElement.style.setProperty(key, vars[key])
}

if (vars['--background-color']) {
document.querySelector('meta[name="theme-color"]').setAttribute('content', vars['--background-color'])
}
}

const darkThemeMq = window.matchMedia("(prefers-color-scheme: dark)");
Expand Down
117 changes: 66 additions & 51 deletions frontend/src/views/Paste.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@
<input placeholder="Password" v-model="password" type="password" class="input">
<a class="button" style="width: 100%;" @click="load($route.params.id)">ENTER PASTE</a><br>
</template>
<template v-else-if="!found">
<template v-else-if="error">
<div class="error">
404! Paste not found
<template v-if="error.exception === 'NotFoundException'">
404! Paste not found
</template>
<template v-else-if="error.exception === 'PastePrivateException'">
This paste is private
</template>
<template v-else>
{{ error.exception }}
</template>
</div>
</template>
<template v-else-if="$store.state.appInfo.login_required_for_read && !$store.state.user.logged_in">
Expand Down Expand Up @@ -112,7 +120,8 @@ export default {
multiPastes: null,
multiPastesSelected: null,
readCode: false
readCode: false,
error: null
}),
mounted() {
this.load(this.$route.params.id)
Expand All @@ -130,62 +139,68 @@ export default {
next()
},
methods: {
load(id) {
async load(id) {
let data = {}
if (this.password !== "" && this.passwordRequired)
this.error = null
if (this.password !== "" && this.passwordRequired) {
data.password = this.password
this.pastefyAPI.get("/api/v2/paste/" + id, data)
.then(res => {
let paste = res
if (paste.exists) {
this.title = paste.title
this.rawContent = paste.content
this.rawURL = paste.raw_url;
this.userid = paste.user_id
this.paste = paste
this.multiPastes = null
this.multiPastesSelected = null
this.validPassword = false
if (paste.encrypted) {
let key = this.password;
if (window.location.hash != "") {
key = window.location.hash.split("#")[1];
}
}
if (key == "") {
this.passwordRequired = true
return;
}
try {
const paste = await this.pastefyAPI.get("/api/v2/paste/" + id, data)
this.title = CryptoJS.AES.decrypt(paste.title, key).toString(CryptoJS.enc.Utf8);
this.rawContent = CryptoJS.AES.decrypt(paste.content, key).toString(CryptoJS.enc.Utf8);
if (this.rawContent === "")
this.validPassword = false
else
this.validPassword = true
} else if (paste.using_password) {
if (this.rawContent === '') {
if (this.password !== "") {
helper.showSnackBar("Invalid Password", "#EE4343")
}
} else
this.validPassword = true
} else
this.validPassword = true
if (paste.exists) {
this.title = paste.title
this.rawContent = paste.content
this.rawURL = paste.raw_url;
this.userid = paste.user_id
this.paste = paste
this.multiPastes = null
this.multiPastesSelected = null
this.validPassword = false
if (paste.type === 'PASTE') {
this.highlight(this.title, this.rawContent)
} else if (paste.type == 'MULTI_PASTE') {
this.multiPastes = JSON.parse(this.rawContent)
this.changeTab(0)
if (paste.encrypted) {
let key = this.password;
if (window.location.hash != "") {
key = window.location.hash.split("#")[1];
}
if (key == "") {
this.passwordRequired = true
return;
}
this.title = CryptoJS.AES.decrypt(paste.title, key).toString(CryptoJS.enc.Utf8);
this.rawContent = CryptoJS.AES.decrypt(paste.content, key).toString(CryptoJS.enc.Utf8);
if (this.rawContent === "")
this.validPassword = false
else
this.validPassword = true
} else if (paste.using_password) {
if (this.rawContent === '') {
if (this.password !== "") {
helper.showSnackBar("Invalid Password", "#EE4343")
}
} else
this.validPassword = true
} else
this.found = false
})
this.validPassword = true
if (paste.type === 'PASTE') {
this.highlight(this.title, this.rawContent)
} else if (paste.type == 'MULTI_PASTE') {
this.multiPastes = JSON.parse(this.rawContent)
this.changeTab(0)
}
} else
this.found = false
} catch (e) {
this.error = e
}
},
changeTab(i) {
this.multiPastesSelected = i
Expand Down
19 changes: 14 additions & 5 deletions frontend/src/views/admin/Users.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Header />
<input v-model="search" class="input" placeholder="Search" @change="page = 1; loadUsers()" @keydown.enter="page = 1; loadUsers()" style="max-width: 1200px">
<div id="users" >
<div v-for="user of users" :key="user.id">
<div v-for="(user, i) of users" :key="user.id">
<img :src="user.avatar">
<div class="name">
<h1>{{ user.unique_name }}</h1>
Expand All @@ -13,12 +13,20 @@
{{ user.e_mail }} ({{ user.auth_provider }})
</div>
<div class="action-buttons">
<router-link :to="`/admin/pastes?q=${ encodeURIComponent(`user_id=${ user.id }`) }`" class="button small" style="margin-right: 10px" @click="removeUser(user.id)">Pastes</router-link>
<router-link :to="`/admin/pastes?q=${ encodeURIComponent(`user_id=${ user.id }`) }`" class="button small" style="margin-right: 10px">Pastes</router-link>

<a v-if="user.type === 'AWAITING_ACCESS'" class="button small" style="margin-right: 10px;" @click="setUserType(user.id, 'USER')">Grant Access</a>
<a v-else-if="user.type === 'BLOCKED'" class="button small" style="margin-right: 10px;" @click="setUserType(user.id, 'USER')">UNBLOCK</a>
<a v-else-if="user.type === 'USER'" class="button small delete" style="margin-right: 10px;" @click="setUserType(user.id, 'BLOCKED')">BLOCK</a>
<a class="button small delete" @click="removeUser(user.id)">Remove</a>
<a v-else-if="user.type === 'USER'" class="button small delete" style="margin-right: 10px;" @click="$refs.blockUserConfirmation[i].open()">BLOCK</a>
<a class="button small delete" @click="$refs.deleteUserConfirmation[i].open()">Remove</a>


<ConfirmationModal ref="deleteUserConfirmation" title="Delete user?" @confirm="removeUser(user.id)">
Do you really want to delete the user '{{ user.name }}'?
</ConfirmationModal>
<ConfirmationModal ref="blockUserConfirmation" title="Block user?" @confirm="setUserType(user.id, 'BLOCKED')">
Do you really want to block the user '{{ user.name }}'?
</ConfirmationModal>
</div>

</div>
Expand All @@ -31,9 +39,10 @@
<script>
import Header from "@/components/admin/Header";
import {buildSearchAndFilterQuery} from "@/helper";
import ConfirmationModal from '@/components/ConfirmationModal.vue'
export default {
name: "Users",
components: {Header},
components: {ConfirmationModal, Header},
data: () => ({
users: [],
search: '',
Expand Down

0 comments on commit 0da4554

Please sign in to comment.