From d26df2730db01a4904ad71eb3590b5d90c015767 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sun, 4 Jan 2015 23:16:44 -0200 Subject: Implement sx-tag-list--get --- sx-tag.el | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'sx-tag.el') diff --git a/sx-tag.el b/sx-tag.el index 5e75890..0f726fd 100644 --- a/sx-tag.el +++ b/sx-tag.el @@ -62,6 +62,23 @@ Returns a list." (mapcar (lambda (x) (cdr (assoc 'name x))) (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) -- cgit v1.2.3