Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
Simon Brooke 2021-03-23 15:59:08 +00:00
commit ad18d2eb1e
No known key found for this signature in database
GPG key ID: A7A4F18D1D4DF987
6 changed files with 89 additions and 73 deletions

View file

@ -3,7 +3,7 @@
:url "https://github.com/simon-brooke/smeagol" :url "https://github.com/simon-brooke/smeagol"
:license {:name "GNU General Public License,version 2.0 or (at your option) any later version" :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"} :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"] [clj-yaml "0.4.0"]
[clojure.java-time "0.3.2"] [clojure.java-time "0.3.2"]
[com.cemerick/url "0.1.1"] [com.cemerick/url "0.1.1"]

View file

@ -1,4 +1,7 @@
<!-- this is the whole of the photoswipe boilerplate as documented <div class="gallery" id="gallery{{index}}">
<div class="pswp" id="pswp-{{index}}" tabindex="-1" role="dialog" aria-hidden="true">
<!-- this is the whole of the photoswipe boilerplate as documented
[here](https://photoswipe.com/documentation/getting-started.html) with the [here](https://photoswipe.com/documentation/getting-started.html) with the
outermost div removed; it is supplied by the function outermost div removed; it is supplied by the function
`smeagol.extensions.photoswipe/photoswipe-processor`, q.v. --> `smeagol.extensions.photoswipe/photoswipe-processor`, q.v. -->
@ -36,7 +39,7 @@
<button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button> <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>
<!-- Preloader demo https://codepen.io/dimsemenov/pen/yyBWoR --> <!-- Preloader demo https://codepen.io/dimsemenov/pen/yyBWoR -->
<!-- element will get class pswp__preloader--active when preloader is running --> <!-- element will get class pswp__preloader active when preloader is running -->
<div class="pswp__preloader"> <div class="pswp__preloader">
<div class="pswp__preloader__icn"> <div class="pswp__preloader__icn">
<div class="pswp__preloader__cut"> <div class="pswp__preloader__cut">
@ -63,3 +66,32 @@
</div> </div>
</div> </div>
</div>
<script>
//<![CDATA[
var gallery{{index}} = null;
var spec{{index}} = {{spec}};
var openGallery{{index}} = function() {
if (gallery{{index}}) {
try {
gallery{{index}}.destroy();
}
catch (error) {
console.error(error);
}
}
gallery{{index}} = new PhotoSwipe(document.getElementById("pswp-{{index}}"),
PhotoSwipeUI_Default,
spec{{index}}.slides,
spec{{index}}.options);
gallery{{index}}.init();
};
if (spec{{index}}.openImmediately) {
openGallery{{index}}();
}
//]]>
</script>
<p>
<button id="open-gallery-{{index}}" onclick="openGallery{{index}}()">Open the gallery</button>
</p>
</div>

View file

@ -9,6 +9,8 @@
[instaparse.core :as insta] [instaparse.core :as insta]
[me.raynes.fs :as fs] [me.raynes.fs :as fs]
[noir.io :as io] [noir.io :as io]
[selmer.parser :refer [render]]
[selmer.util :refer [without-escaping]]
[smeagol.configuration :refer [config]] [smeagol.configuration :refer [config]]
[smeagol.extensions.utils :refer [resource-url-or-data->data uploaded?]] [smeagol.extensions.utils :refer [resource-url-or-data->data uploaded?]]
[smeagol.util :refer [content-dir upload-dir]] [smeagol.util :refer [content-dir upload-dir]]
@ -41,31 +43,11 @@
"Process a specification for a photoswipe gallery, using a JSON "Process a specification for a photoswipe gallery, using a JSON
specification based on that documented on the Photoswipe website." specification based on that documented on the Photoswipe website."
[^String spec ^Integer index] [^String spec ^Integer index]
(str (without-escaping
"<div class='gallery'> (render
<div class=\"pswp\" id=\"pswp-"
index "\" tabindex=\"-1\" role=\"dialog\" aria-hidden=\"true\">\n"
(slurp (slurp
(str (io/resource-path) "html-includes/photoswipe-boilerplate.html")) (str (io/resource-path) "html-includes/photoswipe-boilerplate.html"))
"</div> {:spec spec :index index})))
<p><button id=\"open-gallery-" index "\" onclick=\"gallery" index
".init(); document.getElementById(`open-gallery-" index "`).style.display = 'none';\">Open the gallery</button></p>
<script>
\n//<![CDATA[\n
var pswpElement = document.getElementById('pswp-" index "');
var spec" index " = "
spec
";
var gallery" index
" = new PhotoSwipe( pswpElement, PhotoSwipeUI_Default, spec"
index ".slides, spec" index ".options);
if (spec" index ".openImmediately) {
document.getElementById(`open-gallery-" index "`).style.display = 'none';
gallery" index ".init();
}
\n//]]\n
</script>
</div>"))
(def simple-grammar (def simple-grammar

View file

@ -54,9 +54,9 @@
(git/load-repo git-directory-path) (git/load-repo git-directory-path)
(catch java.io.FileNotFoundException _ (catch java.io.FileNotFoundException _
(log/info "Initialising Git repository at" git-directory-path) (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)] (let [repo (git/load-repo git-directory-path)]
(git/git-add-and-commit repo "Initial commit") (git/git-commit repo "Initial commit")
repo)))) repo))))

View file

@ -72,7 +72,7 @@
(log/info (format "Saving %s's changes ('%s') to %s in file '%s'" user summary page file-path)) (log/info (format "Saving %s's changes ('%s') to %s in file '%s'" user summary page file-path))
(spit file-path source-text) (spit file-path source-text)
(git/git-add git-repo file-name) (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 (response/redirect
(str (str
"/wiki?page=" "/wiki?page="

View file

@ -156,8 +156,10 @@
(defn get-servlet-context-path (defn get-servlet-context-path
"Return the servlet context path, if we're running as a servlet; if
not, return `nil`."
[request] [request]
(if-let [context (:servlet-context request)] (when-let [context (:servlet-context request)]
;; If we're not inside a serlvet environment (for ;; If we're not inside a serlvet environment (for
;; example when using mock requests), then ;; example when using mock requests), then
;; .getContextPath might not exist ;; .getContextPath might not exist