sort by modified time, add user count
parent
35f28bac5c
commit
b91a817f11
|
@ -1,4 +1,5 @@
|
||||||
(import [os [listdir]])
|
(import [os [listdir]])
|
||||||
|
(import [os.path [getmtime]])
|
||||||
(import [datetime [datetime]])
|
(import [datetime [datetime]])
|
||||||
|
|
||||||
;; this script emits HTML on standard out that constitutes a user
|
;; this script emits HTML on standard out that constitutes a user
|
||||||
|
@ -23,10 +24,23 @@
|
||||||
"(default :3)"
|
"(default :3)"
|
||||||
""))))
|
""))))
|
||||||
|
|
||||||
(def user-list (->> (listdir "/home")
|
(defn modify-time [username]
|
||||||
sorted
|
(getmtime (.format "/home/{}/public_html" username)))
|
||||||
|
|
||||||
|
|
||||||
|
(defn sort-user-list [usernames]
|
||||||
|
(apply sorted [usernames] {"key" modify-time}))
|
||||||
|
|
||||||
|
(defn users [] (listdir "/home"))
|
||||||
|
|
||||||
|
(def user-list (->> (users)
|
||||||
|
sort-user-list
|
||||||
|
reversed
|
||||||
(filter (fn [f] (and (not (= f "ubuntu")) (not (= f "poetry")))))
|
(filter (fn [f] (and (not (= f "ubuntu")) (not (= f "poetry")))))
|
||||||
(map dir->html)
|
(map dir->html)
|
||||||
(.join "\n")))
|
(.join "\n")))
|
||||||
|
|
||||||
(print (.format "<sub>generated at {}</sub><br><ul>{}</ul>" timestamp user-list))
|
(print (.format "our esteemed users ({}) <sub>generated at {}</sub><br><ul>{}</ul>"
|
||||||
|
(len (users))
|
||||||
|
timestamp
|
||||||
|
user-list))
|
||||||
|
|
Reference in New Issue