From cf227b498a30c7c9679e2d9bc8f4d3fd0f339146 Mon Sep 17 00:00:00 2001 From: Simon Brooke Date: Sat, 29 Feb 2020 19:23:34 +0000 Subject: [PATCH] I *think* I've fixed the Tomcat redirect bug. --- resources/public/content/Iceland.md | 9 +++++++++ src/smeagol/extensions/geocsv.clj | 2 +- src/smeagol/routes/wiki.clj | 8 ++++++-- src/smeagol/util.clj | 10 ++++++++++ 4 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 resources/public/content/Iceland.md diff --git a/resources/public/content/Iceland.md b/resources/public/content/Iceland.md new file mode 100644 index 0000000..f6877cb --- /dev/null +++ b/resources/public/content/Iceland.md @@ -0,0 +1,9 @@ +Iceland (Icelandic: *Ísland*) is a Nordic island country in the North Atlantic, with a population of 360,390 and an area of 103,000 km2 (40,000 sq mi), making it the most sparsely populated country in Europe. The capital and largest city is Reykjavík. Reykjavik and the surrounding areas in the southwest of the country are home to over two-thirds of the population. Iceland is volcanically and geologically active. The interior consists of a plateau characterised by sand and lava fields, mountains, and glaciers, and many glacial rivers flow to the sea through the lowlands. Iceland is warmed by the Gulf Stream and has a temperate climate, despite a high latitude just outside the Arctic Circle. Its high latitude and marine influence keep summers chilly, with most of the archipelago having a tundra climate. + +![Eyjafjallajökull glacier; photo by Andreas Tille](uploads/med/Eyjafjallajökull.jpg) + +According to the ancient manuscript *Landnámabók*, the settlement of Iceland began in 874 AD when the Norwegian chieftain Ingólfr Arnarson became the first permanent settler on the island. In the following centuries, Norwegians, and to a lesser extent other Scandinavians, emigrated to Iceland, bringing with them thralls (i.e., slaves or serfs) of Gaelic origin. + +The island was governed as an independent commonwealth under the *Alþingi*, one of the world's oldest functioning legislative assemblies. Following a period of civil strife, Iceland acceded to Norwegian rule in the 13th century. The establishment of the Kalmar Union in 1397 united the kingdoms of Norway, Denmark, and Sweden. Iceland thus followed Norway's integration into that union, coming under Danish rule after Sweden's secession from the union in 1523. Although the Danish kingdom introduced Lutheranism forcefully in 1550, Iceland remained a distant semi-colonial territory in which Danish institutions and infrastructures were conspicuous by their absence. + +In the wake of the French Revolution and the Napoleonic Wars, Iceland's struggle for independence took form and culminated in independence in 1918 and the founding of a republic in 1944. Although its parliament (Althing) was suspended from 1799 to 1845, the island republic has been credited with sustaining the world's oldest and longest-running parliament. \ No newline at end of file diff --git a/src/smeagol/extensions/geocsv.clj b/src/smeagol/extensions/geocsv.clj index 95c06b8..58523f5 100644 --- a/src/smeagol/extensions/geocsv.clj +++ b/src/smeagol/extensions/geocsv.clj @@ -48,7 +48,7 @@ GeoCSV.setIconUrlBase( \"" (-> config :formatters :geocsv :icon-url-base) "\"); GeoCSV.initialiseMapElement(\"geocsv-" index "\", - document.getElementById(\"geocsv-" index "\").innerText.trim().replace(/\\[\\[([^\\[\\]]*)\\]\\]/, \"$1\")); + document.getElementById(\"geocsv-" index "\").innerText.trim().replace(/\\[\\[([^\\[\\]]*)\\]\\]/g, \"$1\")); }}; //]] diff --git a/src/smeagol/routes/wiki.clj b/src/smeagol/routes/wiki.clj index d529104..e5ae10a 100644 --- a/src/smeagol/routes/wiki.clj +++ b/src/smeagol/routes/wiki.clj @@ -32,7 +32,8 @@ [smeagol.configuration :refer [config]] [smeagol.include.resolve-local-file :as resolve] [smeagol.include :as include] - [smeagol.util :refer [content-dir local-url local-url-base upload-dir]])) + [smeagol.util :refer [content-dir get-servlet-context-path + local-url local-url-base upload-dir]])) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; @@ -398,7 +399,10 @@ (and username password (auth/authenticate username password)) (do (session/put! :user username) - (response/redirect redirect-to)) + (response/redirect + (or + redirect-to + (get-servlet-context-path request)))) true (layout/render "auth.html" (merge (util/standard-params request) diff --git a/src/smeagol/util.clj b/src/smeagol/util.clj index 5cda9ee..c91f981 100644 --- a/src/smeagol/util.clj +++ b/src/smeagol/util.clj @@ -156,6 +156,16 @@ :version (System/getProperty "smeagol.version")})) +(defn get-servlet-context-path + [request] + (if-let [context (:servlet-context request)] + ;; If we're not inside a serlvet environment (for + ;; example when using mock requests), then + ;; .getContextPath might not exist + (try (.getContextPath context) + (catch IllegalArgumentException _ context)))) + + (def get-messages "Return the most acceptable messages collection we have given the `Accept-Language` header in this `request`."