Browse Source

fix: Use correct variable-names

master
Bonface Munyoki 2 years ago
parent
commit
47dc8bd559
Signed by: bonfacemunyoki GPG Key ID: F5BBAE1E0392253F
  1. 2
      private/github.rkt
  2. 12
      private/server.rkt
  3. 7
      private/templates/polling.html
  4. 2
      private/twitter.rkt

2
private/github.rkt

@ -112,4 +112,4 @@
`(,commits)))]))
(define (vote-commit! client key #:upvote? [upvote #t])
(vote! client "commit-score:" key #:upvote upvote))
(vote! client "commit-score:" key #:upvote? upvote))

12
private/server.rkt

@ -17,23 +17,23 @@
(let ([google-font-link "https://fonts.googleapis.com/css2?family=Amatic+SC&family=Josefin+Sans:ital,wght@1,300&display=swap"]
[tweets/time (get-tweets/redis client #:key "tweet-time:")]
[commits (get-commits/redis client)]
[tweets/score (get-tweets/redis client)])
[tweets/score (get-tweets/redis client #:key "tweet-score:")])
(include-template "templates/polling.html"))))
(post "/vote/tweets"
(lambda (req)
(let* ([json/vals (bytes->jsexpr (request-post-data/raw req))]
[tweet-hash (hash-ref json/vals 'hash)]
[upvote (hash-ref json/vals 'upvote)])
(vote-tweet! client tweet-hash #:upvote? (string=? upvote "upvote"))
[vote (hash-ref json/vals 'vote)])
(vote-tweet! client tweet-hash #:upvote? (string=? vote "upvote"))
"OK")))
(post "/vote/commits"
(lambda (req)
(let* ([json/vals (bytes->jsexpr (request-post-data/raw req))]
[commit-hash (hash-ref hash)]
[upvote (hash-ref json/vals 'upvote)])
(vote-commit! #:upvote? (string=? upvote "upvote"))
[commit-hash (hash-ref json/vals 'hash)]
[vote (hash-ref json/vals 'vote)])
(vote-commit! client commit-hash #:upvote? (string=? vote "upvote"))
"OK")))
(displayln (string-append "Running the server on port " (number->string port)))

7
private/templates/polling.html

@ -191,7 +191,7 @@
"No commits stored :("
@for/list[([c commits])]{
@list{
<li class="commit" data-hash='@(hash-ref c #"hash")'>
<li class="commit" data-hash='commit:@(hash-ref c #"hash")'>
<div class="wrap">
<div class="vote up" data-vote="upvote">
<i class="fa fa-angle-up"></i>
@ -225,13 +225,14 @@
let hash = this.parentElement.parentElement.parentElement.dataset.hash;
let vote = this.parentElement.dataset.vote;
let voteURL = "/vote/tweets"
if (!hash.includes("tweet:"))
console.log(vote, hash);
if (!(hash.includes("tweet:")))
voteURL = "/vote/commits"
fetch(voteURL, {
method: "POST",
body: JSON.stringify({
"hash": hash,
"upvote": vote
"vote": vote
}),
headers: {"content-type": "application/json"},
})

2
private/twitter.rkt

@ -95,7 +95,7 @@
(define (vote-tweet! client key #:upvote? [upvote #t])
(vote! client "tweet-score" key #:upvote upvote))
(vote! client "tweet-score:" key #:upvote? upvote))
;; Given a list of feed-tweets, store them in REDIS

Loading…
Cancel
Save