From ea520547858ba7f2da817ed634c3b984fd7bc19a Mon Sep 17 00:00:00 2001 From: Simon Brooke Date: Tue, 18 Aug 2020 11:26:37 +0100 Subject: [PATCH 1/3] Upgraded to clj-jgit 1.0.0; not yet working. --- project.clj | 2 +- src/smeagol/history.clj | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/project.clj b/project.clj index 083ca2a..c55a4d5 100644 --- a/project.clj +++ b/project.clj @@ -3,7 +3,7 @@ :url "https://github.com/simon-brooke/smeagol" :license {:name "GNU General Public License,version 2.0 or (at your option) any later version" :url "https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html"} - :dependencies [[clj-jgit "0.8.10"] + :dependencies [[clj-jgit "1.0.0"] [clj-yaml "0.4.0"] [clojure.java-time "0.3.2"] [com.cemerick/url "0.1.1"] diff --git a/src/smeagol/history.clj b/src/smeagol/history.clj index e567db3..42eaa49 100644 --- a/src/smeagol/history.clj +++ b/src/smeagol/history.clj @@ -6,11 +6,17 @@ [clj-jgit.querying :as q] [taoensso.timbre :as log]) (:import [org.eclipse.jgit.api Git] - [org.eclipse.jgit.lib Repository ObjectId] - [org.eclipse.jgit.revwalk RevCommit RevTree RevWalk] - [org.eclipse.jgit.treewalk TreeWalk AbstractTreeIterator CanonicalTreeParser] + [org.eclipse.jgit.lib + ;; Repository + ObjectId] + ;; [org.eclipse.jgit.revwalk RevCommit RevTree RevWalk] + [org.eclipse.jgit.treewalk TreeWalk + ;; AbstractTreeIterator + CanonicalTreeParser] [org.eclipse.jgit.treewalk.filter PathFilter] - [org.eclipse.jgit.diff DiffEntry DiffFormatter])) + [org.eclipse.jgit.diff + ;; DiffEntry + DiffFormatter])) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; From f9587f1e1608593d5c4806db7df40879ae7b7d4b Mon Sep 17 00:00:00 2001 From: Simon Brooke Date: Tue, 18 Aug 2020 17:40:36 +0100 Subject: [PATCH 2/3] #22: H'mmm, clj-git API has changed considerably. This isn't working, but does compile. More work needed. --- src/smeagol/history.clj | 4 ++-- src/smeagol/routes/wiki.clj | 2 +- src/smeagol/util.clj | 10 ++++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/smeagol/history.clj b/src/smeagol/history.clj index 42eaa49..3e38e3c 100644 --- a/src/smeagol/history.clj +++ b/src/smeagol/history.clj @@ -61,9 +61,9 @@ (git/load-repo git-directory-path) (catch java.io.FileNotFoundException fnf (log/info "Initialising Git repository at" git-directory-path) - (git/git-init git-directory-path) + (git/git-init :dir git-directory-path) (let [repo (git/load-repo git-directory-path)] - (git/git-add-and-commit repo "Initial commit") + (git/git-commit repo "Initial commit") repo)))) diff --git a/src/smeagol/routes/wiki.clj b/src/smeagol/routes/wiki.clj index e5ae10a..876fe87 100644 --- a/src/smeagol/routes/wiki.clj +++ b/src/smeagol/routes/wiki.clj @@ -75,7 +75,7 @@ (log/info (format "Saving %s's changes ('%s') to %s in file '%s'" user summary page file-path)) (spit file-path source-text) (git/git-add git-repo file-name) - (git/git-commit git-repo summary {:name user :email email}) + (git/git-commit git-repo summary :name user :email email) (response/redirect (str "/wiki?page=" diff --git a/src/smeagol/util.clj b/src/smeagol/util.clj index ec37e06..1587f5b 100644 --- a/src/smeagol/util.clj +++ b/src/smeagol/util.clj @@ -79,15 +79,15 @@ (cjio/file local-url-base file-path))] (cond (cs/includes? file-path "..") - (cs/join " " file-path - "Attempts to ascend the file hierarchy are disallowed.") + (cs/join " " [file-path + "Attempts to ascend the file hierarchy are disallowed."]) (not (cs/starts-with? path local-url-base)) (cs/join " " [path "is not servable"]) (not (fs/exists? path)) (cs/join " " [path "does not exist"]) (not (fs/readable? path)) (cs/join " " [path "is not readable"]))) - (catch Exception any (cs/join " " file-path "is not servable because" (.getMessage any))))) + (catch Exception any (cs/join " " [file-path "is not servable because" (.getMessage any)])))) ;; (not-servable-reason "/home/simon/workspace/smeagol/resources/public/content/vendor/node_modules/photoswipe/dist/photoswipe.min.js") @@ -157,8 +157,10 @@ (defn get-servlet-context-path + "Return the servlet context path, if we're running as a servlet; if + not, return `nil`." [request] - (if-let [context (:servlet-context request)] + (when-let [context (:servlet-context request)] ;; If we're not inside a serlvet environment (for ;; example when using mock requests), then ;; .getContextPath might not exist From c217a8381db1cb94232b400b3b63232c2e1b354d Mon Sep 17 00:00:00 2001 From: Simon Brooke Date: Wed, 2 Sep 2020 14:14:33 +0100 Subject: [PATCH 3/3] Reopenable photoswipe galleries (bug) Previously, a closed photoswipe gallery could not be reopened. Fixed. --- .gitignore | 2 +- .../html-includes/photoswipe-boilerplate.html | 120 +++++++++++------- src/smeagol/extensions/photoswipe.clj | 30 +---- src/smeagol/repl.clj | 5 +- 4 files changed, 87 insertions(+), 70 deletions(-) diff --git a/.gitignore b/.gitignore index ea914ae..777d72f 100644 --- a/.gitignore +++ b/.gitignore @@ -17,7 +17,7 @@ pom.xml.asc smeagol.log* /node_modules/ .DS_Store - +/.calva resources/public/content/uploads/ diff --git a/resources/public/html-includes/photoswipe-boilerplate.html b/resources/public/html-includes/photoswipe-boilerplate.html index 2dec488..aa53882 100644 --- a/resources/public/html-includes/photoswipe-boilerplate.html +++ b/resources/public/html-includes/photoswipe-boilerplate.html @@ -1,65 +1,97 @@ - - -
+