Skip to content

Commit

Permalink
feat(/description): Encode the token for learn-ocaml 0.13.0+
Browse files Browse the repository at this point in the history
* (learn-ocaml-compute-questions-url):
  Add learn-ocaml-compute-questions-url-token1-compat
  to implement the elisp counterpart of PR
  <ocaml-sf/learn-ocaml#423>
  • Loading branch information
erikmd committed Oct 3, 2021
1 parent ff921ea commit d8fad81
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions learn-ocaml.el
Original file line number Diff line number Diff line change
Expand Up @@ -758,10 +758,18 @@ Argument CALLBACK will receive the token."
;; Wrappers
;;

(defconst learn-ocaml-compute-questions-url-token1-compat
(learn-ocaml-since-upto "0.13.0" nil))

(defun learn-ocaml-compute-questions-url (server id token)
"Get subject url for SERVER, exercise ID and user TOKEN."
;; TODO: Use token1=
(concat server "/description/" id "#token=" token))
(let ((token-param
(if (learn-ocaml-compat
learn-ocaml-compute-questions-url-token1-compat
(version-to-list (learn-ocaml-client-server-min-version server)))
(concat "#token1=" (base64-encode-string (format "%192s" token) t))
(concat "#token=" token))))
(concat server "/description/" id token-param)))

(defun learn-ocaml-show-questions (id)
"Open the questions for exercise ID in the default browser."
Expand Down

0 comments on commit d8fad81

Please sign in to comment.