bibekyess commited on
Commit
1960505
ยท
1 Parent(s): 79c3fdd

Merged remote Readme

Browse files
Files changed (5) hide show
  1. Dockerfile +14 -0
  2. index.html +41 -0
  3. nginx.conf +10 -0
  4. restaurants.json +11 -0
  5. script.js +70 -0
Dockerfile ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM nginx:alpine
2
+
3
+ # There is a lready a user nginx in this image, so using it to avoid permission user when running in non-root env
4
+ RUN touch /var/run/nginx.pid && \
5
+ chown -R nginx:nginx /var/cache/nginx /var/run/nginx.pid /var/run /var/log/nginx && \
6
+ chmod -R 777 /var/cache/nginx /var/run /var/log/nginx /var/run/nginx.pid
7
+ USER nginx
8
+
9
+ COPY --chown=nginx:nginx nginx.conf /etc/nginx/conf.d/default.conf
10
+ COPY --chown=nginx:nginx . /usr/share/nginx/html
11
+
12
+ EXPOSE 7860
13
+
14
+ ENTRYPOINT ["nginx", "-g", "daemon off;"]
index.html ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Restaurant Suggestion</title>
7
+ <style>
8
+ body {
9
+ font-family: Arial, sans-serif;
10
+ background-color: #f0f8ff;
11
+ display: flex;
12
+ justify-content: center;
13
+ align-items: center;
14
+ height: 100vh;
15
+ margin: 0;
16
+ text-align: center;
17
+ }
18
+ .container {
19
+ background-color: #fff;
20
+ padding: 20px;
21
+ border-radius: 8px;
22
+ box-shadow: 0 4px 8px rgba(0,0,0,0.1);
23
+ }
24
+ h1 {
25
+ color: #333;
26
+ }
27
+ .restaurant {
28
+ font-size: 1.2em;
29
+ margin: 10px 0;
30
+ }
31
+ </style>
32
+ </head>
33
+ <body>
34
+ <div class="container">
35
+ <h1>Today's Restaurant Suggestions</h1>
36
+ <p id="currentDate"></p>
37
+ <div id="restaurants"></div>
38
+ </div>
39
+ <script src="script.js"></script>
40
+ </body>
41
+ </html>
nginx.conf ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ server {
2
+ listen 7860;
3
+ server_name localhost;
4
+
5
+ location / {
6
+ root /usr/share/nginx/html;
7
+ index index.html;
8
+ try_files $uri $uri/ /index.html;
9
+ }
10
+ }
restaurants.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ ["์˜จ์„ผ ๊ฐ•๋‚จ์—ญ์  (Japanese)", "https://naver.me/GvkXrQ8e"],
3
+ ["Five Guys (Hamburger, no chicken/pork, veg available)", "https://maps.app.goo.gl/hQ7c91XfxJnxtiwK8"],
4
+ ["๊ฐ“์ž‡ ๊ฐ•๋‚จ์  (Mexican)", "https://maps.app.goo.gl/M487DhMxoF4MYVaj6"],
5
+ ["ํ›„์ถ”ํฌ์ธํŠธ (Italian)", "https://naver.me/GOzRKAoO"],
6
+ ["ํŒŒ์Šคํƒ€ ํŠธ๋ฆฌ์˜ค (Italian)", "https://naver.me/5DbSwvXH"],
7
+ ["์ง„๋Œ€๊ฐ (Korean, beef+pork)", "https://naver.me/5EQ3QCXL"],
8
+ ["Taksim Kebab (Turkish, small place)", "https://naver.me/5EQ3QCXL"],
9
+ ["Proteiner (low carb, high protein wraps, bowls)", "https://naver.me/xBhHYMfk"],
10
+ ["์ฟ ์ฐจ๋ผ ๊ฐ•๋‚จ์  (Mexican)", "https://maps.app.goo.gl/pGWzvT2Zm6KtNMLS7"]
11
+ ]
script.js ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ async function fetchRestaurants() {
2
+ const response = await fetch('restaurants.json');
3
+ if (!response.ok) {
4
+ throw new Error('Network response was not ok ' + response.statusText);
5
+ }
6
+ const data = await response.json();
7
+ return data;
8
+ }
9
+
10
+ function getRandomRestaurants(restaurants) {
11
+ // Fisher-Yates Shuffle Algorithm
12
+ for (let i = restaurants.length - 1; i > 0; i--) {
13
+ const j = Math.floor(Math.random() * (i + 1));
14
+ [restaurants[i], restaurants[j]] = [restaurants[j], restaurants[i]];
15
+ }
16
+ return restaurants.slice(0, 3);
17
+ }
18
+
19
+ async function displayRestaurants() {
20
+ const today = new Date();
21
+ const day = today.getDay();
22
+
23
+ // Format the date
24
+ const options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
25
+ const formattedDate = today.toLocaleDateString(undefined, options);
26
+
27
+ // Display the date
28
+ document.getElementById('currentDate').innerText = `Today is ${formattedDate}`;
29
+
30
+ // Only display suggestions on weekdays
31
+ if (day === 0 || day === 6) {
32
+ document.getElementById('restaurants').innerHTML = "No suggestions available today!";
33
+ return;
34
+ }
35
+
36
+ const dateKey = today.toISOString().split('T')[0];
37
+ let savedData = localStorage.getItem('restaurantSuggestions');
38
+
39
+ if (savedData) {
40
+ savedData = JSON.parse(savedData);
41
+ if (savedData.date === dateKey) {
42
+ document.getElementById('restaurants').innerHTML = savedData.restaurants.map(restaurant =>
43
+ `<a href="${restaurant[1]}" target="_blank">${restaurant[0]}</a>`
44
+ ).join('<br>');
45
+ return;
46
+ }
47
+ }
48
+
49
+ try {
50
+ const restaurants = await fetchRestaurants();
51
+ console.log('Fetched Restaurants:', restaurants); // Debugging: Print fetched restaurants
52
+ const randomRestaurants = getRandomRestaurants(restaurants);
53
+ console.log('Random Restaurants:', randomRestaurants); // Debugging: Print random restaurants
54
+ document.getElementById('restaurants').innerHTML = randomRestaurants.map(restaurant =>
55
+ `<a href="${restaurant[1]}" target="_blank">${restaurant[0]}</a>`
56
+ ).join('<br>');
57
+
58
+ const dataToSave = {
59
+ date: dateKey,
60
+ restaurants: randomRestaurants
61
+ };
62
+
63
+ localStorage.setItem('restaurantSuggestions', JSON.stringify(dataToSave));
64
+ } catch (error) {
65
+ console.error('Error fetching restaurants:', error);
66
+ document.getElementById('restaurants').innerHTML = "Failed to load restaurant suggestions.";
67
+ }
68
+ }
69
+
70
+ window.onload = displayRestaurants;