diff options
Diffstat (limited to 'template')
| -rwxr-xr-x | template/_includes.html | 2 | ||||
| -rwxr-xr-x | template/_meta.html | 2 | ||||
| -rwxr-xr-x | template/_navigation.html | 2 | ||||
| -rwxr-xr-x | template/post.html | 13 | ||||
| -rwxr-xr-x | template/script.js | 78 | ||||
| -rwxr-xr-x | template/style.css | 30 |
6 files changed, 120 insertions, 7 deletions
diff --git a/template/_includes.html b/template/_includes.html index 3c73ccf..d16fa3d 100755 --- a/template/_includes.html +++ b/template/_includes.html | |||
| @@ -1,3 +1,3 @@ | |||
| 1 | <!-- user code --> | 1 | <!-- user code --> |
| 2 | 2 | ||
| 3 | <script src="/script.js?v=2021-10-08" async></script> | 3 | <script src="/script.js?v=2022-01-30-01" async></script> |
diff --git a/template/_meta.html b/template/_meta.html index 93f168a..e29a9a8 100755 --- a/template/_meta.html +++ b/template/_meta.html | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | 5 | ||
| 6 | <meta name="theme-color" content="#ffffff"> | 6 | <meta name="theme-color" content="#ffffff"> |
| 7 | 7 | ||
| 8 | <link rel="stylesheet" href="/style.css?v=2021-12-07-10"> | 8 | <link rel="stylesheet" href="/style.css?v=2022-01-30-02"> |
| 9 | 9 | ||
| 10 | <link rel="alternate" type="application/rss+xml" href="/feed.rss"> | 10 | <link rel="alternate" type="application/rss+xml" href="/feed.rss"> |
| 11 | <link rel="alternate" type="application/feed+json" href="/feed.json"> | 11 | <link rel="alternate" type="application/feed+json" href="/feed.json"> |
diff --git a/template/_navigation.html b/template/_navigation.html index 8a6152c..f6567c9 100755 --- a/template/_navigation.html +++ b/template/_navigation.html | |||
| @@ -11,10 +11,8 @@ | |||
| 11 | 11 | ||
| 12 | <a href="https://git.mitjafelicijan.com" target="_blank" rel="noopener nofollow" itemprop="url">Git</a> | 12 | <a href="https://git.mitjafelicijan.com" target="_blank" rel="noopener nofollow" itemprop="url">Git</a> |
| 13 | <a href="https://files.mitjafelicijan.com" target="_blank" rel="noopener nofollow" itemprop="url">Files</a> | 13 | <a href="https://files.mitjafelicijan.com" target="_blank" rel="noopener nofollow" itemprop="url">Files</a> |
| 14 | <!--<a href="https://github.com/mitjafelicijan" target="_blank" rel="noopener nofollow" itemprop="url">Github</a>--> | ||
| 15 | <a href="/curriculum-vitae.html">CV</a> | 14 | <a href="/curriculum-vitae.html">CV</a> |
| 16 | 15 | ||
| 17 | <!-- <a href="https://feedbin.com/starred/28977384dcc292a0a400e36cd9bcf64e.xml" itemprop="url">Starred</a> --> | ||
| 18 | <a href="/feed.rss" itemprop="url">RSS</a> | 16 | <a href="/feed.rss" itemprop="url">RSS</a> |
| 19 | </nav> | 17 | </nav> |
| 20 | </header> | 18 | </header> |
diff --git a/template/post.html b/template/post.html index 0404820..31a77b6 100755 --- a/template/post.html +++ b/template/post.html | |||
| @@ -28,8 +28,17 @@ | |||
| 28 | </article> | 28 | </article> |
| 29 | 29 | ||
| 30 | {{if .Listing}} | 30 | {{if .Listing}} |
| 31 | <section class="top-margin"> | 31 | |
| 32 | <a href="mailto:m@mitjafelicijan.com">➝ Get in contact with me via email.</a> | 32 | <hr class="top-margin"> |
| 33 | |||
| 34 | <section class="comments" data-guid="{{.Slug}}"> | ||
| 35 | <h4>Comments</h4> | ||
| 36 | <form> | ||
| 37 | <p><input type="text" placeholder="Your name (optional)"></p> | ||
| 38 | <p><textarea placeholder="Your comment" required></textarea></p> | ||
| 39 | <p><button type="button">Submit your comment</button></p> | ||
| 40 | </form> | ||
| 41 | <ul></ul> | ||
| 33 | </section> | 42 | </section> |
| 34 | 43 | ||
| 35 | <hr class="top-margin"> | 44 | <hr class="top-margin"> |
diff --git a/template/script.js b/template/script.js index 4c508ed..0e1291c 100755 --- a/template/script.js +++ b/template/script.js | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | window.addEventListener('load', () => { | 1 | window.addEventListener('load', async () => { |
| 2 | // dither image on mouse over replace | 2 | // dither image on mouse over replace |
| 3 | // document.querySelectorAll('article img').forEach(img => { | 3 | // document.querySelectorAll('article img').forEach(img => { |
| 4 | // const ditheredImage = img.src; | 4 | // const ditheredImage = img.src; |
| @@ -24,4 +24,80 @@ window.addEventListener('load', () => { | |||
| 24 | evt.target.style.transform = 'scaleX(1)'; | 24 | evt.target.style.transform = 'scaleX(1)'; |
| 25 | }); | 25 | }); |
| 26 | } | 26 | } |
| 27 | |||
| 28 | // comments code | ||
| 29 | const commentsEndpoint = 'https://mitjafelicijan.com/comments-api'; | ||
| 30 | const commentsPlaceholder = document.querySelector('.comments'); | ||
| 31 | |||
| 32 | if (commentsPlaceholder) { | ||
| 33 | const guid = commentsPlaceholder.dataset.guid; | ||
| 34 | const name = commentsPlaceholder.querySelector('input'); | ||
| 35 | const comment = commentsPlaceholder.querySelector('textarea'); | ||
| 36 | const submit = commentsPlaceholder.querySelector('button'); | ||
| 37 | const comments = commentsPlaceholder.querySelector('ul'); | ||
| 38 | |||
| 39 | if (guid) { | ||
| 40 | await readAndRenderComments(guid, comments); | ||
| 41 | |||
| 42 | submit.addEventListener('click', async() => { | ||
| 43 | submit.disabled = true; | ||
| 44 | await writeComments(guid, name.value, comment.value); | ||
| 45 | |||
| 46 | submit.disabled = false; | ||
| 47 | name.value = ''; | ||
| 48 | comment.value = ''; | ||
| 49 | |||
| 50 | await readAndRenderComments(guid, comments); | ||
| 51 | }); | ||
| 52 | } | ||
| 53 | } | ||
| 54 | |||
| 55 | async function writeComments(guid, name, comment) { | ||
| 56 | const response = await fetch(commentsEndpoint, { | ||
| 57 | method: 'POST', | ||
| 58 | headers: { | ||
| 59 | 'Accept': 'application/json', | ||
| 60 | 'Content-Type': 'application/json' | ||
| 61 | }, | ||
| 62 | body: JSON.stringify({ | ||
| 63 | action: 'write', | ||
| 64 | guid, | ||
| 65 | name, | ||
| 66 | comment, | ||
| 67 | }) | ||
| 68 | }); | ||
| 69 | } | ||
| 70 | |||
| 71 | async function readAndRenderComments(guid, commentsPlaceholder) { | ||
| 72 | const response = await fetch(commentsEndpoint, { | ||
| 73 | method: 'POST', | ||
| 74 | headers: { | ||
| 75 | 'Accept': 'application/json', | ||
| 76 | 'Content-Type': 'application/json' | ||
| 77 | }, | ||
| 78 | body: JSON.stringify({ | ||
| 79 | action: 'read', | ||
| 80 | guid, | ||
| 81 | }) | ||
| 82 | }); | ||
| 83 | |||
| 84 | // remove all existing comments from list | ||
| 85 | commentsPlaceholder.innerHTML = ''; | ||
| 86 | |||
| 87 | const commentList = await response.json(); | ||
| 88 | for (const comment of commentList.reverse()) { | ||
| 89 | const date = new Date(comment.date).toLocaleDateString('en-US', { | ||
| 90 | year: 'numeric', | ||
| 91 | month: 'long', | ||
| 92 | day: 'numeric', | ||
| 93 | hour: 'numeric', | ||
| 94 | minute: 'numeric' | ||
| 95 | }); | ||
| 96 | |||
| 97 | const commentElement = document.createElement('li'); | ||
| 98 | commentElement.innerHTML = `<p><b>${comment.name}</b> - ${date}<p><p>${comment.comment}<p><hr>`; | ||
| 99 | commentsPlaceholder.appendChild(commentElement); | ||
| 100 | } | ||
| 101 | } | ||
| 102 | |||
| 27 | }); | 103 | }); |
diff --git a/template/style.css b/template/style.css index aa0be85..cce9621 100755 --- a/template/style.css +++ b/template/style.css | |||
| @@ -14,6 +14,8 @@ | |||
| 14 | --badge-label-color: #111111; | 14 | --badge-label-color: #111111; |
| 15 | 15 | ||
| 16 | --code-font-size: 13px; | 16 | --code-font-size: 13px; |
| 17 | |||
| 18 | --comment-form-font: 16px 'Times New Roman', Times, serif; | ||
| 17 | } | 19 | } |
| 18 | 20 | ||
| 19 | * { | 21 | * { |
| @@ -337,6 +339,34 @@ audio { | |||
| 337 | color: #666; | 339 | color: #666; |
| 338 | } | 340 | } |
| 339 | 341 | ||
| 342 | /* comments */ | ||
| 343 | |||
| 344 | .comments input{ | ||
| 345 | width: 100%; | ||
| 346 | font: var(--comment-form-font); | ||
| 347 | border: 1px solid #bbb; | ||
| 348 | padding: 5px; | ||
| 349 | } | ||
| 350 | |||
| 351 | .comments textarea{ | ||
| 352 | width: 100%; | ||
| 353 | height: 100px; | ||
| 354 | resize: vertical; | ||
| 355 | font: var(--comment-form-font); | ||
| 356 | border: 1px solid #bbb; | ||
| 357 | padding: 5px; | ||
| 358 | } | ||
| 359 | |||
| 360 | .comments ul { | ||
| 361 | list-style-type: none; | ||
| 362 | padding: 0; | ||
| 363 | margin-top: 30px; | ||
| 364 | } | ||
| 365 | |||
| 366 | .comments hr { | ||
| 367 | border: initial !important; | ||
| 368 | border-top: initial !important; | ||
| 369 | } | ||
| 340 | 370 | ||
| 341 | /* responsive */ | 371 | /* responsive */ |
| 342 | 372 | ||
