aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtur Malabarba <bruce.connor.am@gmail.com>2015-01-04 23:16:44 -0200
committerArtur Malabarba <bruce.connor.am@gmail.com>2015-01-05 11:18:29 -0200
commitd26df2730db01a4904ad71eb3590b5d90c015767 (patch)
tree33c274586cc85e143ff2e0a750946c63e01fda1f
parent01aac931f90c1251ed6b3c30df672cf3073b16c5 (diff)
Implement sx-tag-list--get
-rw-r--r--sx-tag.el17
1 files changed, 17 insertions, 0 deletions
diff --git a/sx-tag.el b/sx-tag.el
index 5e75890..0f726fd 100644
--- a/sx-tag.el
+++ b/sx-tag.el
@@ -63,6 +63,23 @@ Returns a list."
(sx-tag--get-some-tags-containing site string)))
+;;; Getting tags from our data branch. Without the API.
+;;;; @TODO: Once the cache is finished, this can probably be made into
+;;;; a cache variasble with 1 day expiration time.
+(defvar sx-tag-list-alist nil
+ "Alist where the tag list for each site is stored.
+Elements are of the type (SITE . TAG-LIST).")
+
+(defun sx-tag-list--get (site)
+ "Retrieve all tags from SITE in a single request.
+This does not access the API. Instead, it uses
+`sx-request-get-data', which accesses SX's tag cache."
+ (or (cdr (assoc site sx-tag-list-alist))
+ (let ((list (sx-request-get-data (concat "tags/" site))))
+ (push (cons site list) sx-tag-list-alist)
+ list)))
+
+
;;; Check tag validity
(defun sx-tag--invalid-name-p (site tags)
"Nil if TAGS exist in SITE.