forked from HAWK-Digital-Environments/HAWKI
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
453 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.github | ||
.git | ||
.gitignore | ||
.dockerignore | ||
Caddyfile | ||
compose.yml | ||
docker-compose.yml | ||
README.md | ||
SECURITY.md | ||
LICENSE.txt | ||
Changelog.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
on: | ||
push: | ||
pull_request: | ||
|
||
name: CI build | ||
jobs: | ||
build: | ||
name: CI build | ||
runs-on: ubuntu-latest | ||
env: | ||
# Use docker.io for Docker Hub if empty | ||
REGISTRY: ghcr.io | ||
# github.repository as <account>/<repo> | ||
IMAGE_NAME: ${{ github.repository }} | ||
permissions: | ||
contents: read | ||
packages: write | ||
steps: | ||
|
||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
|
||
|
||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Log into registry ${{ env.REGISTRY }} | ||
if: github.event_name != 'pull_request' | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Extract Docker metadata | ||
id: meta-php | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-php | ||
tags: | | ||
type=schedule | ||
type=ref,event=branch | ||
type=ref,event=tag | ||
type=ref,event=pr | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }} | ||
type=raw,value=latest,enable={{is_default_branch}} | ||
type=raw,value={{branch}}-{{sha}}-{{date 'X'}},enable=${{ github.event_name != 'pull_request' && !contains(github.ref, 'refs/tags/') }} | ||
- name: Build and push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: ./Dockerfile.php | ||
push: ${{ github.event_name != 'pull_request' && github.actor != 'dependabot[bot]'}} | ||
tags: ${{ steps.meta-php.outputs.tags }} | ||
labels: ${{ steps.meta-php.outputs.labels }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
.env | ||
.DS_Store | ||
.DS_Store | ||
compose.yml | ||
docker-compose.yml | ||
Caddyfile | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
FROM php:8.3-fpm-alpine AS BUILD | ||
COPY . /var/www/html/ | ||
ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/download/2.2.16/install-php-extensions /usr/local/bin/ | ||
RUN apk add --no-cache git libzip-dev zip \ | ||
&& docker-php-ext-install zip \ | ||
&& cd /var/www/html \ | ||
&& chmod +x composer_install.sh && ./composer_install.sh \ | ||
&& mv composer.phar /usr/local/bin/composer \ | ||
&& composer install --no-cache \ | ||
&& install-php-extensions pdo pdo_pgsql | ||
|
||
FROM php:8.3-fpm-alpine | ||
WORKDIR /var/www/html | ||
COPY --from=BUILD /var/www/html /var/www/html | ||
# pdo pdo_pgsql dependencies | ||
COPY --from=BUILD /usr/lib/libpgtypes.so.* /usr/lib/ | ||
COPY --from=BUILD /usr/lib/libpq.so.* /usr/lib/ | ||
COPY --from=BUILD /usr/lib/libecpg.so.* /usr/lib | ||
COPY --from=BUILD /usr/local/etc/php/conf.d/docker-php-ext-pdo_pgsql.ini /usr/local/etc/php/conf.d/ | ||
COPY --from=BUILD /usr/local/lib/php/extensions /usr/local/lib/php/extensions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<script> | ||
//#region USER FEEDBACK | ||
//----------------------------------------------------------------------------------------// | ||
//save users feedback on server. | ||
//other users can up or downvote othes feedback | ||
async function send_feedback(){ | ||
const messagesElement = document.querySelector(".messages"); | ||
const inputField = document.querySelector(".userpost-field"); | ||
|
||
if(inputField.value == ''){ | ||
return; | ||
} | ||
|
||
let message = {}; | ||
message.role = '<?= htmlspecialchars($_SESSION['username']) ?>'; | ||
message.content = inputField.value.trim(); | ||
|
||
// const feedback_send = "../private/app/php/feedback_send.php"; | ||
const feedback_send = "api/feedback_send" | ||
const csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content'); | ||
|
||
fetch(feedback_send, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', // Set content type to application/json | ||
'X-CSRF-TOKEN': csrfToken, // Include CSRF token in the request headers | ||
}, | ||
body: JSON.stringify({message: message}), | ||
}) | ||
.then(response => response.json()) | ||
.then(data => { | ||
//UPDATE NEW TOKEN | ||
document.querySelector('meta[name="csrf-token"]').setAttribute('content', data.csrf_token); | ||
|
||
if(data.success){ | ||
load(document.querySelector("#feedback"), 'feedback_loader.php'); | ||
inputField.value = ""; | ||
} | ||
}) | ||
.catch(error => console.error(error)); | ||
} | ||
|
||
function SubmitVote(element, action) { | ||
if (localStorage.getItem(element.dataset.id)) { | ||
return; | ||
} | ||
|
||
const pureId = element.dataset.id.replace('.json', ''); // assuming all IDs end with '.json' | ||
const csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content'); | ||
const submit_vote = "api/submit_vote"; | ||
|
||
fetch(submit_vote, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', // Set content type to application/json | ||
'X-CSRF-TOKEN': csrfToken, // Include CSRF token in the request headers | ||
}, | ||
body: JSON.stringify({ id: pureId, action: action }), // Send the action and CSRF token in the request body | ||
}) | ||
.then(response => { | ||
if (!response.ok) { | ||
throw new Error(`HTTP error! status: ${response.status}`); | ||
} | ||
return response.json(); | ||
}) | ||
.then(data => { | ||
|
||
document.querySelector('meta[name="csrf-token"]').setAttribute('content', data.csrf_token); | ||
if(data.success){ | ||
|
||
// Update the UI accordingly | ||
if (action === "upvote") { | ||
element.querySelector("span").textContent = data.content.up || 0; // Assuming 'data.up' contains the updated upvote count | ||
} | ||
if (action === "downvote") { | ||
element.querySelector("span").textContent = data.content.down || 0; // Assuming 'data.down' contains the updated downvote count | ||
} | ||
} | ||
}) | ||
.catch(error => { | ||
console.error('Fetch error:', error); | ||
}); | ||
localStorage.setItem(element.dataset.id, "true"); | ||
|
||
voteHover(); | ||
} | ||
|
||
async function voteHover(){ | ||
let messages = document.querySelectorAll(".message"); | ||
|
||
messages.forEach((message)=>{ | ||
let voteButtons = message.querySelectorAll(".vote") | ||
|
||
voteButtons.forEach((voteButton)=>{ | ||
if(localStorage.getItem(voteButton.dataset.id)){ | ||
voteButton.classList.remove("vote-hover"); | ||
}else{ | ||
voteButton.classList.add("vote-hover"); | ||
} | ||
}) | ||
}) | ||
} | ||
//#endregion | ||
</script> |
Oops, something went wrong.