This commit is contained in:
simon 2017-09-09 22:18:22 +01:00
parent 6f22517f0c
commit 85097f942a
5 changed files with 11 additions and 37 deletions

View file

@ -128,7 +128,7 @@
"Return the map of features of this user, if any." "Return the map of features of this user, if any."
[username] [username]
(if (if
(and username (> (count (str username)) 0)) (and username (pos? (count (str username))))
((keyword username) (get-users)))) ((keyword username) (get-users))))
@ -138,7 +138,7 @@
(timbre/info "Trying to add user " username) (timbre/info "Trying to add user " username)
(cond (cond
(not (string? username)) (throw (Exception. "Username must be a string.")) (not (string? username)) (throw (Exception. "Username must be a string."))
(= (count username) 0) (throw (Exception. "Username cannot be zero length")) (zero? (count username)) (throw (Exception. "Username cannot be zero length"))
true (let [users (get-users) true (let [users (get-users)
user ((keyword username) users) user ((keyword username) users)
password (if password (if
@ -146,7 +146,7 @@
(password/encrypt newpass)) (password/encrypt newpass))
details {:email email details {:email email
:admin (if :admin (if
(and (string? admin) (> (count admin) 0)) (and (string? admin) (pos? (count admin)))
true true
false)} false)}
;; if we have a valid password we want to include it in the details to update. ;; if we have a valid password we want to include it in the details to update.

View file

@ -47,16 +47,6 @@
(defn diff2html (defn diff2html
"Convert this string, assumed to be in diff format, to HTML." "Convert this string, assumed to be in diff format, to HTML."
[^String diff-text] [^String diff-text]
(apply str (clojure.string/join (flatten (list "<div class='change'>" (join "\n" (remove nil? (map mung-line (drop 5 (split-lines diff-text))))) "</div>"))))
(flatten
(list "<div class='change'>"
(join "\n"
(remove nil?
(map mung-line
;; The first five lines are boilerplate, and
;; uninteresting for now
(drop 5
(split-lines diff-text)))))
"</div>"))))

View file

@ -115,7 +115,7 @@
corresponding inclusion should be inserted." corresponding inclusion should be inserted."
[index result fragment fragments processed] [index result fragment fragments processed]
(process-text (process-text
(+ index 1) (inc index)
result result
fragments fragments
(cons fragment processed))) (cons fragment processed)))
@ -133,18 +133,8 @@
(let (let
[kw (keyword (str "inclusion-" index))] [kw (keyword (str "inclusion-" index))]
(process-text (process-text
(+ index 1) (inc index)
(assoc (assoc-in result [:inclusions kw] (apply formatter (list (subs fragment (count token)) index)))
result
:inclusions
(assoc
(:inclusions result)
kw
(apply
formatter
(list
(subs fragment (count token))
index))))
(rest fragments) (rest fragments)
(cons kw processed)))) (cons kw processed))))

View file

@ -41,11 +41,7 @@
[^String log-entry ^String file-path] [^String log-entry ^String file-path]
(timbre/info (format "searching '%s' for '%s'" log-entry file-path)) (timbre/info (format "searching '%s' for '%s'" log-entry file-path))
(cond (cond
(not (seq (filter (fn* [p1__341301#] (= (first p1__341301#) file-path)) (:changed_files log-entry)))
(empty?
(filter
#(= (first %) file-path)
(:changed_files log-entry))))
log-entry)) log-entry))
@ -121,7 +117,7 @@
new-parse) new-parse)
(PathFilter/create file-path)) (PathFilter/create file-path))
out)))) out))))
(.toString out)))) (str out))))
(defn fetch-version (defn fetch-version
@ -144,4 +140,4 @@
(throw (IllegalStateException. (throw (IllegalStateException.
(str "Did not find expected file '" file-path "'")))) (str "Did not find expected file '" file-path "'"))))
(.copyTo (.open repo (.getObjectId tw 0)) out) (.copyTo (.open repo (.getObjectId tw 0)) out)
(.toString out))) (str out)))

View file

@ -92,9 +92,7 @@
file-path (cjio/file util/content-dir file-name) file-path (cjio/file util/content-dir file-name)
exists? (.exists (cjio/as-file file-path)) exists? (.exists (cjio/as-file file-path))
user (session/get :user)] user (session/get :user)]
(if (not exists?) (if-not exists? (timbre/info (format "File '%s' not found; creating a new file" file-path)) (timbre/info (format "Opening '%s' for editing" file-path)))
(timbre/info (format "File '%s' not found; creating a new file" file-path))
(timbre/info (format "Opening '%s' for editing" file-path)))
(cond src-text (process-source params suffix request) (cond src-text (process-source params suffix request)
true true
(layout/render template (layout/render template