Skip to content

Commit c05dec4

Browse files
Merge pull request #1 from PromptExecution/feature/cookies
feature/cookies
2 parents b43f955 + ad18d7a commit c05dec4

8 files changed

Lines changed: 224 additions & 5 deletions

File tree

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111
"dependencies": {
1212
"path": "^0.12.7",
1313
"vue": "^3.3.8",
14-
"vue-command": "^35.2.1"
14+
"vue-command": "^35.2.1",
15+
"vue-cookie-law": "github:elasticdotventures/vue-cookie-law",
16+
"vue-cookie-next": "^1.3.0",
17+
"vue-gtag": "^2.0.1"
1518
},
1619
"devDependencies": {
1720
"@vitejs/plugin-vue": "^4.5.0",

pysrc/evlib/build.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,25 @@
1+
import io
2+
import base64
3+
4+
from PIL import Image
5+
6+
# src/evlib/build.py
17
def main():
2-
print("hello")
8+
print("hello world!") # output: hello world!
9+
10+
# Load the image from file
11+
img_path = './public/PromptExecution-LogoV2-semi-transparent.webp'
12+
img = Image.open(img_path)
13+
14+
img = img.resize((256, 256), resample=Image.LANCZOS)
15+
ico_buffer = io.BytesIO()
16+
# img.save(ico_buffer, format='ICO', sizes=[(256, 256)])
17+
18+
img.save('./public/favicon.ico', format='ICO', sizes=[(256, 256)])
19+
20+
21+
# # Convert to base64
22+
# base64_ico = base64.b64encode(ico_buffer.getvalue()).decode()
23+
24+
# # Output the base64 encoded favicon
25+
# print(base64_ico)

src/App.vue

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
1+
<!-- src/App.vue -->
12
<script setup lang="ts">
3+
import { ref, onMounted } from 'vue';
4+
import CookieBanner from './components/CookieBanner.vue';
5+
26
import CommandLineInterface from './components/CommandLineInterface.vue';
37
import PromptExecutionLogo from './components/PromptExecutionLogo.vue';
8+
9+
const showBanner = ref(true); // Or whatever logic you need to show/hide the banner
10+
11+
// Example of how you might control the visibility of the banner
12+
// This is just a placeholder logic, adjust according to your needs
13+
onMounted(() => {
14+
// Logic to determine if the banner should be shown
15+
// For example, check if the user has already accepted cookies
16+
// showBanner.value = ...;
17+
});
418
import TheFooter from './components/TheFooter.vue';
519
620
</script>
@@ -11,6 +25,8 @@ import TheFooter from './components/TheFooter.vue';
1125
</div>
1226
<CommandLineInterface />
1327
<TheFooter />
28+
29+
<CookieBanner v-if="showBanner" />
1430
</template>
1531

1632
<style scoped>
@@ -23,9 +39,10 @@ import TheFooter from './components/TheFooter.vue';
2339
.logo:hover {
2440
filter: drop-shadow(0 0 2em #646cffaa);
2541
}
26-
.logo.vue:hover {
42+
/* .logo.vue:hover {
2743
filter: drop-shadow(0 0 2em #42b883aa);
2844
}
45+
*/
2946
3047
3148
</style>

src/components/CommandLineInterface.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
<template #help-text>asdfasdf</template>
1414
<template #invert>true</template>
1515
<template #font></template>
16+
1617
</vue-command>
17-
</div>
18+
</div>
1819
</template>
1920

2021
<script lang="ts">

src/components/CookieBanner.vue

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<!-- CookieBanner.vue -->
2+
<template>
3+
<div class="cookie-banner">
4+
<!-- Cookie banner content -->
5+
🍪 Do you want milk with your cookies?
6+
<button @click="handleConsent" class="accept-button">Accept Cookies</button>
7+
<button @click="handleReject" class="reject-button">Reject Cookies</button>
8+
9+
</div>
10+
</template>
11+
12+
<script lang="ts">
13+
import useCookies from '../useCookies';
14+
import { defineComponent, getCurrentInstance } from 'vue';
15+
16+
export default defineComponent({
17+
setup() {
18+
const instance = getCurrentInstance();
19+
const gtag = instance?.appContext.config.globalProperties.$gtag;
20+
21+
const { allowCookies } = useCookies(gtag);
22+
23+
const handleConsent = () => {
24+
allowCookies.value = true;
25+
if (gtag) {
26+
gtag.optIn();
27+
}
28+
};
29+
30+
const handleReject = () => {
31+
allowCookies.value = false;
32+
if (gtag) {
33+
gtag.optOut();
34+
}
35+
};
36+
37+
return { handleConsent, handleReject };
38+
}
39+
});
40+
</script>
41+
42+
<style scoped>
43+
.cookie-banner {
44+
position: fixed;
45+
left: 0;
46+
right: 0;
47+
bottom: 0;
48+
background-color: #fff; /* Or any color you prefer */
49+
color: #000;
50+
padding: 8px;
51+
box-shadow: 0px -2px 10px rgba(0, 0, 0, 0.1);
52+
animation: slideUp 0.5s ease-out;
53+
54+
/* Artistic Border */
55+
border: 2px solid #000; /* Basic solid border, change as needed */
56+
border-radius: 10px; /* Rounded corners */
57+
/* You can add more artistic styles like border-image or box-shadow for more effects */
58+
59+
}
60+
61+
@keyframes slideUp {
62+
from {
63+
transform: translateY(100%);
64+
}
65+
to {
66+
transform: translateY(0);
67+
}
68+
}
69+
70+
.accept-button {
71+
background-color: green;
72+
color: white;
73+
border: none;
74+
padding: 10px 20px;
75+
margin: 5px;
76+
cursor: pointer;
77+
}
78+
79+
.reject-button {
80+
background-color: grey;
81+
color: white;
82+
border: none;
83+
padding: 10px 20px;
84+
margin: 5px;
85+
cursor: pointer;
86+
}
87+
88+
/* Optional: Add hover effects */
89+
.accept-button:hover {
90+
background-color: darkgreen;
91+
}
92+
93+
.reject-button:hover {
94+
background-color: darkgrey;
95+
}
96+
</style>

src/components/CookiePolicy.vue

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!-- CookiePolicy.vue -->
2+
<template>
3+
<div>
4+
<!-- Cookie policy content -->
5+
We use Cookies.
6+
<input type="checkbox" v-model="allowCookies" /> Accept Cookies
7+
</div>
8+
</template>
9+
10+
<script lang="ts">
11+
import { useCookies } from '../useCookies'
12+
export default {
13+
setup() {
14+
const { allowCookies } = useCookies()
15+
return { allowCookies }
16+
}
17+
}
18+
</script>
19+

src/main.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
1+
// src/main.ts
2+
13
import { createApp } from 'vue'
24
import './style.css'
35
import App from './App.vue'
6+
// https://matteo-gabriele.gitbook.io/vue-gtag/
7+
import VueGtag from "vue-gtag";
8+
import { VueCookieNext } from 'vue-cookie-next';
9+
import { useCookies } from './useCookies'
410

511
// An application instance won't render anything until its .mount() method is called
6-
createApp(App).mount('#app')
12+
const app = createApp(App);
13+
14+
app
15+
.use(VueCookieNext)
16+
.use(VueGtag, {
17+
config: {
18+
id: "G-XP9X9LHTDV",
19+
params: {
20+
anonymize_ip: true
21+
}
22+
},
23+
enabled: false
24+
})
25+
.provide('gtag', app.config.globalProperties.$gtag)
26+
.mount('#app')

src/useCookies.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { ref, watch, computed } from 'vue';
2+
import { useCookie } from 'vue-cookie-next';
3+
4+
const allowCookies = ref<boolean>();
5+
6+
export default function useCookies(gtag: any) {
7+
const cookie = useCookie();
8+
9+
if (cookie.isCookieAvailable('cookies_consent')) {
10+
allowCookies.value = cookie.getCookie('cookies_consent') === 'true';
11+
gtag.optIn();
12+
} else {
13+
allowCookies.value = undefined;
14+
}
15+
16+
watch(allowCookies, () => {
17+
if (allowCookies.value != undefined) {
18+
cookie.setCookie('cookies_consent', allowCookies.value.toString(), {
19+
expire: new Date(2022, 1, 1),
20+
});
21+
if (allowCookies.value) {
22+
gtag.optIn();
23+
} else {
24+
gtag.optOut();
25+
}
26+
}
27+
});
28+
29+
const showBanner = computed(() => {
30+
return allowCookies.value === undefined;
31+
});
32+
33+
const okClicked = () => (allowCookies.value = true);
34+
35+
return {
36+
allowCookies,
37+
showBanner,
38+
okClicked,
39+
};
40+
}

0 commit comments

Comments
 (0)