mirror of
https://github.com/journeyman-cc/smeagol.git
synced 2026-04-12 18:05:06 +00:00
Initial work on i18n
This commit is contained in:
parent
19a715c4fb
commit
a2b6d6f72b
7 changed files with 200 additions and 30 deletions
108
resources/i18n/en-GB.edn
Normal file
108
resources/i18n/en-GB.edn
Normal file
|
|
@ -0,0 +1,108 @@
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;;;;
|
||||||
|
;;;; Smeagol: a very simple Wiki engine.
|
||||||
|
;;;;
|
||||||
|
;;;; This program is free software; you can redistribute it and/or
|
||||||
|
;;;; modify it under the terms of the GNU General Public License
|
||||||
|
;;;; as published by the Free Software Foundation; either version 2
|
||||||
|
;;;; of the License, or (at your option) any later version.
|
||||||
|
;;;;
|
||||||
|
;;;; This program is distributed in the hope that it will be useful,
|
||||||
|
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
;;;; GNU General Public License for more details.
|
||||||
|
;;;;
|
||||||
|
;;;; You should have received a copy of the GNU General Public License
|
||||||
|
;;;; along with this program; if not, write to the Free Software
|
||||||
|
;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||||
|
;;;; USA.
|
||||||
|
;;;;
|
||||||
|
;;;; Copyright (C) 2017 Simon Brooke
|
||||||
|
;;;;
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
;;; en-GB.edn: English-language messages.
|
||||||
|
;;; This is essentially all the text in the chrome - that which isn't editable
|
||||||
|
;;; through the wiki itself
|
||||||
|
|
||||||
|
;; ; ; ; ; ; ; ; ; ;
|
||||||
|
{:add-user-label "Add new user" ;; label for the add user link on edit users page
|
||||||
|
:change-pass-label "Change password!"
|
||||||
|
;; text of the change password widget itself on the
|
||||||
|
;; change password page
|
||||||
|
:change-pass-link "Change password"
|
||||||
|
;; text of the change password link on the menu
|
||||||
|
:change-pass-prompt "To change your password"
|
||||||
|
;; text of the change password widget prompt on the
|
||||||
|
;; change password page
|
||||||
|
:change-col-hdr "Changes" ;; header for the changes column in history
|
||||||
|
:chpass-bad-match "Your proposed passwords don't match"
|
||||||
|
;; error text if proposed passwords don't match
|
||||||
|
:chpass-fail "Your password was not changed"
|
||||||
|
;; error text on fail other htan too short or bad match
|
||||||
|
:chpass-success "Your password was changed"
|
||||||
|
;; confirmation text on password change
|
||||||
|
:chpass-too-short "You proposed password wasn't long enough: eight characters required"
|
||||||
|
;; error text if proposed password is too short
|
||||||
|
:chpass-title-prefix "Change password for"
|
||||||
|
;; prefix for title of change password page
|
||||||
|
:cookies-about "About cookies" ;; about cookies text
|
||||||
|
:cookies-more "This website stores session information as a 'cookie' on your browser. This helps us show you the content you want to see. This cookie does not identify you, and cannot be read by other websites. It is deleted by your browser as soon as you leave this site. This website does not use any third party cookies, so your visit here cannot be tracked by other websites."
|
||||||
|
;; more about cookies text
|
||||||
|
:default-page-title "Introduction" ;; title of the default page in this wiki
|
||||||
|
:del-col-hdr "Delete" ;; header for delete column on edit users page
|
||||||
|
:del-user-fail "Could not delete user"
|
||||||
|
;; error message on failure to delete user
|
||||||
|
:del-user-success "Successfully deleted user"
|
||||||
|
;; confirmation message on deletion of user
|
||||||
|
:diff-title-prefix "Changes since version"
|
||||||
|
;; prefix for the header of the changes page
|
||||||
|
:edit-col-hdr "Edit" ;; header for edit column on edit users page
|
||||||
|
:edit-page-link "Edit this page"
|
||||||
|
;; text of the edit page link on the content frame
|
||||||
|
:edit-title-prefix "Edit" ;; prefix for title of edit content page
|
||||||
|
:edit-users-link "Edit users" ;; text of the edit users link on the menu
|
||||||
|
:edit-users-title "Select user to edit"
|
||||||
|
;; title of edit users page
|
||||||
|
:email-prompt "Email address" ;; text of the email widget prompt on edit user page
|
||||||
|
:file-upload-link-text "You may link to this file using a link of the form"
|
||||||
|
;; Text introducing the link to an uploaded file
|
||||||
|
:file-upload-prompt "File to upload" ;; prompt string for the file upload widget
|
||||||
|
:file-upload-title "Upload a file" ;; title for the file upload page
|
||||||
|
:is-admin-prompt "Is administrator?"
|
||||||
|
:home-link "Home" ;; text of the home link on the menu
|
||||||
|
:login-label "Log in!" ;; text of the login widget on the login page
|
||||||
|
:login-link "Log in" ;; text of the login link on the menu
|
||||||
|
:login-prompt "To edit this wiki"
|
||||||
|
;; text of the action widget prompt on the login page
|
||||||
|
:logout-label "Log out!" ;; text of the logout widget on the logout page
|
||||||
|
:logout-link "Log out" ;; text of the logout link on the menu
|
||||||
|
:logged-in-as "You are logged in as"
|
||||||
|
;; text of the 'logged in as' label on the menu
|
||||||
|
:history-link "History" ;; text of the history link on the content frame
|
||||||
|
:history-title-prefix "History of" ;; prefix of the title on the history page
|
||||||
|
:new-pass-prompt "New password" ;; text of the new password widget prompt on the change
|
||||||
|
;; password and edit user pages
|
||||||
|
:old-pass-prompt "Your password"
|
||||||
|
;; text of the old password widget prompt on the change
|
||||||
|
;; password page, and password widget on login page
|
||||||
|
:rpt-pass-prompt "And again" ;; text of the new password widget prompt on the change
|
||||||
|
;; password and edit user pages
|
||||||
|
:save-prompt "When you have finished editing"
|
||||||
|
;; text of the save widget label on edit content
|
||||||
|
;; and edit user page
|
||||||
|
:save-label "Save!" ;; text of the save widget itself
|
||||||
|
:save-user-fail "Failed to store user"
|
||||||
|
:save-user-success "Successfully stored user"
|
||||||
|
:site-title "Smeagol" ;; overall title of the site, used in page headings
|
||||||
|
:username-prompt "Username" ;; text of the username widget prompt on edit user page
|
||||||
|
;; text of the is admin widget prompt on edit user page
|
||||||
|
:user-title-prefix "Edit user" ;; prefix for title of edit user page
|
||||||
|
:vers-col-hdr "Version" ;; header for the version column in history
|
||||||
|
:what-col-hdr "What" ;; header for the what column in history
|
||||||
|
:what-changed-prompt "What have you changed?"
|
||||||
|
;; text of the summary widget prompt on edit
|
||||||
|
;; content page
|
||||||
|
:when-col-hdr "When" ;; header for the when column in history
|
||||||
|
:your-uname-prompt "Your username" ;; text of the username widget prompt on the login page
|
||||||
|
}
|
||||||
|
|
@ -68,6 +68,9 @@
|
||||||
(json/write-str (yaml/parse-string yaml-src)))
|
(json/write-str (yaml/parse-string yaml-src)))
|
||||||
|
|
||||||
|
|
||||||
|
(declare process-text)
|
||||||
|
|
||||||
|
|
||||||
(defn process-vega
|
(defn process-vega
|
||||||
"Process this `vega-source` string, assumed to be in YAML format, into a specification
|
"Process this `vega-source` string, assumed to be in YAML format, into a specification
|
||||||
of a Vega chart, and add the plumbing to render it."
|
of a Vega chart, and add the plumbing to render it."
|
||||||
|
|
|
||||||
53
src/smeagol/i18n.clj
Normal file
53
src/smeagol/i18n.clj
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
(ns ^{:doc "Internationalisation."
|
||||||
|
:author "Simon Brooke"}
|
||||||
|
smeagol.i18n
|
||||||
|
(:require [noir.session :as session]
|
||||||
|
[noir.io :as io]
|
||||||
|
[smeagol.authenticate :as auth]
|
||||||
|
[smeagol.formatting :refer [md->html]]))
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;;;;
|
||||||
|
;;;; Smeagol: a very simple Wiki engine.
|
||||||
|
;;;;
|
||||||
|
;;;; This program is free software; you can redistribute it and/or
|
||||||
|
;;;; modify it under the terms of the GNU General Public License
|
||||||
|
;;;; as published by the Free Software Foundation; either version 2
|
||||||
|
;;;; of the License, or (at your option) any later version.
|
||||||
|
;;;;
|
||||||
|
;;;; This program is distributed in the hope that it will be useful,
|
||||||
|
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
;;;; GNU General Public License for more details.
|
||||||
|
;;;;
|
||||||
|
;;;; You should have received a copy of the GNU General Public License
|
||||||
|
;;;; along with this program; if not, write to the Free Software
|
||||||
|
;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||||
|
;;;; USA.
|
||||||
|
;;;;
|
||||||
|
;;;; Copyright (C) 2014 Simon Brooke
|
||||||
|
;;;;
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
|
||||||
|
(def i18n-cache {})
|
||||||
|
|
||||||
|
|
||||||
|
(defn parse-accept-language
|
||||||
|
"The `Accept-Language` header is defined in section 14.4 of RFC 2616. It is composed
|
||||||
|
of a sequence of 'language tags' defined in section 3.10 of the same document.
|
||||||
|
Generally a language tag is a short alpha string (the 'primary language tag'),
|
||||||
|
optionally followed by a hyphen and another short alpha string (a 'sub tag').
|
||||||
|
A sequence of more than one sub-tag is allowed.
|
||||||
|
|
||||||
|
Generally a two-character primary tag will be an ISO-639 language code and any
|
||||||
|
initial two-character sub tag will be an ISO-3166 country code.
|
||||||
|
|
||||||
|
Each language tag may optionally followed by a semi-colon followed by a 'q' value,
|
||||||
|
specified `q=0.8` where the numeric value is a real number in the range 0...1
|
||||||
|
and represents the user's preference for this language (higher is better). If
|
||||||
|
no q value is supplied 1 is assumed.
|
||||||
|
|
||||||
|
Language specifiers are separated by a comma followed by a space."
|
||||||
|
[accept-language-header]
|
||||||
|
)
|
||||||
|
|
@ -7,7 +7,8 @@
|
||||||
[noir.io :as io]
|
[noir.io :as io]
|
||||||
[ring.util.response :refer [content-type response]]
|
[ring.util.response :refer [content-type response]]
|
||||||
[compojure.response :refer [Renderable]]
|
[compojure.response :refer [Renderable]]
|
||||||
[environ.core :refer [env]]))
|
[environ.core :refer [env]]
|
||||||
|
[smeagol.util :as util]))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;;;;
|
;;;;
|
||||||
|
|
@ -34,10 +35,6 @@
|
||||||
|
|
||||||
(def template-path "templates/")
|
(def template-path "templates/")
|
||||||
|
|
||||||
;; the relative path to the config file.
|
|
||||||
(def config-file-path (str (io/resource-path) "../config.edn"))
|
|
||||||
|
|
||||||
(def config (read-string (slurp config-file-path)))
|
|
||||||
|
|
||||||
(deftype RenderableTemplate [template params]
|
(deftype RenderableTemplate [template params]
|
||||||
Renderable
|
Renderable
|
||||||
|
|
@ -45,7 +42,7 @@
|
||||||
(content-type
|
(content-type
|
||||||
(->> (assoc params
|
(->> (assoc params
|
||||||
(keyword (s/replace template #".html" "-selected")) "active"
|
(keyword (s/replace template #".html" "-selected")) "active"
|
||||||
:config config
|
:config util/config
|
||||||
:dev (env :dev)
|
:dev (env :dev)
|
||||||
:servlet-context
|
:servlet-context
|
||||||
(if-let [context (:servlet-context request)]
|
(if-let [context (:servlet-context request)]
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@
|
||||||
user (session/get :user)]
|
user (session/get :user)]
|
||||||
(layout/render "edit-users.html"
|
(layout/render "edit-users.html"
|
||||||
(merge (util/standard-params request)
|
(merge (util/standard-params request)
|
||||||
{:title (:edit-users-title layout/config)
|
{:title (:edit-users-title util/config)
|
||||||
:users (auth/list-users)}))))
|
:users (auth/list-users)}))))
|
||||||
|
|
||||||
(defn delete-user
|
(defn delete-user
|
||||||
|
|
@ -48,11 +48,11 @@
|
||||||
(let [params (keywordize-keys (:params request))
|
(let [params (keywordize-keys (:params request))
|
||||||
target (:target params)
|
target (:target params)
|
||||||
deleted (auth/delete-user target)
|
deleted (auth/delete-user target)
|
||||||
message (if deleted (str (:del-user-success layout/config) " " target "."))
|
message (if deleted (str (:del-user-success util/config) " " target "."))
|
||||||
error (if (not deleted) (str (:del-user-fail layout/config) " " target "."))]
|
error (if (not deleted) (str (:del-user-fail util/config) " " target "."))]
|
||||||
(layout/render "edit-users.html"
|
(layout/render "edit-users.html"
|
||||||
(merge (util/standard-params request)
|
(merge (util/standard-params request)
|
||||||
{:title (:edit-users-title layout/config)
|
{:title (:edit-users-title util/config)
|
||||||
:message message
|
:message message
|
||||||
:error error
|
:error error
|
||||||
:users (auth/list-users)}))))
|
:users (auth/list-users)}))))
|
||||||
|
|
@ -67,9 +67,9 @@
|
||||||
password (if (and pass1 (auth/evaluate-password pass1 (:pass2 params))) pass1)
|
password (if (and pass1 (auth/evaluate-password pass1 (:pass2 params))) pass1)
|
||||||
stored (if (:email params)
|
stored (if (:email params)
|
||||||
(auth/add-user target password (:email params) (:admin params)))
|
(auth/add-user target password (:email params) (:admin params)))
|
||||||
message (if stored (str (:save-user-success layout/config) " " target "."))
|
message (if stored (str (:save-user-success util/config) " " target "."))
|
||||||
error (if (and (:email params) (not stored))
|
error (if (and (:email params) (not stored))
|
||||||
(str (:save-user-fail layout/config) " " target "."))
|
(str (:save-user-fail util/config) " " target "."))
|
||||||
details (auth/fetch-user-details target)]
|
details (auth/fetch-user-details target)]
|
||||||
(if message
|
(if message
|
||||||
(timbre/info message))
|
(timbre/info message))
|
||||||
|
|
@ -77,7 +77,7 @@
|
||||||
(timbre/warn error))
|
(timbre/warn error))
|
||||||
(layout/render "edit-user.html"
|
(layout/render "edit-user.html"
|
||||||
(merge (util/standard-params request)
|
(merge (util/standard-params request)
|
||||||
{:title (str (:edit-title-prefix layout/config) " " target)
|
{:title (str (:edit-title-prefix util/config) " " target)
|
||||||
:message message
|
:message message
|
||||||
:error error
|
:error error
|
||||||
:target target
|
:target target
|
||||||
|
|
|
||||||
|
|
@ -77,14 +77,14 @@
|
||||||
(if
|
(if
|
||||||
(= suffix ".md")
|
(= suffix ".md")
|
||||||
(url-encode page)
|
(url-encode page)
|
||||||
(:default-page-title layout/config))))))
|
(:default-page-title util/config))))))
|
||||||
|
|
||||||
|
|
||||||
(defn edit-page
|
(defn edit-page
|
||||||
"Render a page in a text-area for editing. This could have been done in the same function as wiki-page,
|
"Render a page in a text-area for editing. This could have been done in the same function as wiki-page,
|
||||||
and that would have been neat, but I couldn't see how to establish security if that were done."
|
and that would have been neat, but I couldn't see how to establish security if that were done."
|
||||||
([request]
|
([request]
|
||||||
(edit-page request (:default-page-title layout/config) ".md" "edit.html" "/content/_edit-side-bar.md"))
|
(edit-page request (:default-page-title util/config) ".md" "edit.html" "/content/_edit-side-bar.md"))
|
||||||
([request default suffix template side-bar]
|
([request default suffix template side-bar]
|
||||||
(let [params (keywordize-keys (:params request))
|
(let [params (keywordize-keys (:params request))
|
||||||
src-text (:src params)
|
src-text (:src params)
|
||||||
|
|
@ -99,7 +99,7 @@
|
||||||
true
|
true
|
||||||
(layout/render template
|
(layout/render template
|
||||||
(merge (util/standard-params request)
|
(merge (util/standard-params request)
|
||||||
{:title (str (:edit-title-prefix layout/config) " " page)
|
{:title (str (:edit-title-prefix util/config) " " page)
|
||||||
:page page
|
:page page
|
||||||
:side-bar (md->html (io/slurp-resource side-bar))
|
:side-bar (md->html (io/slurp-resource side-bar))
|
||||||
:content (if exists? (io/slurp-resource (str "/content/" page suffix)) "")
|
:content (if exists? (io/slurp-resource (str "/content/" page suffix)) "")
|
||||||
|
|
@ -115,8 +115,9 @@
|
||||||
(defn wiki-page
|
(defn wiki-page
|
||||||
"Render the markdown page specified in this `request`, if any. If none found, redirect to edit-page"
|
"Render the markdown page specified in this `request`, if any. If none found, redirect to edit-page"
|
||||||
[request]
|
[request]
|
||||||
|
(timbre/debug (str "Request map: " request))
|
||||||
(let [params (keywordize-keys (:params request))
|
(let [params (keywordize-keys (:params request))
|
||||||
page (or (:page params) (:default-page-title layout/config))
|
page (or (:page params) (:default-page-title util/config))
|
||||||
file-name (str "/content/" page ".md")
|
file-name (str "/content/" page ".md")
|
||||||
file-path (str (io/resource-path) file-name)
|
file-path (str (io/resource-path) file-name)
|
||||||
exists? (.exists (clojure.java.io/as-file file-path))]
|
exists? (.exists (clojure.java.io/as-file file-path))]
|
||||||
|
|
@ -137,7 +138,7 @@
|
||||||
if any. If none, error?"
|
if any. If none, error?"
|
||||||
[request]
|
[request]
|
||||||
(let [params (keywordize-keys (:params request))
|
(let [params (keywordize-keys (:params request))
|
||||||
page (url-decode (or (:page params) (:default-page-title layout/config)))
|
page (url-decode (or (:page params) (:default-page-title util/config)))
|
||||||
file-name (str page ".md")
|
file-name (str page ".md")
|
||||||
repo-path (str (io/resource-path) "/content/")]
|
repo-path (str (io/resource-path) "/content/")]
|
||||||
(timbre/info (format "Showing history of page '%s'" page))
|
(timbre/info (format "Showing history of page '%s'" page))
|
||||||
|
|
@ -156,7 +157,7 @@
|
||||||
uploaded (if upload (ul/store-upload params))]
|
uploaded (if upload (ul/store-upload params))]
|
||||||
(layout/render "upload.html"
|
(layout/render "upload.html"
|
||||||
(merge (util/standard-params request)
|
(merge (util/standard-params request)
|
||||||
{:title (:file-upload-title layout/config)
|
{:title (:file-upload-title util/config)
|
||||||
:uploaded uploaded
|
:uploaded uploaded
|
||||||
:is-image (and
|
:is-image (and
|
||||||
uploaded
|
uploaded
|
||||||
|
|
@ -174,7 +175,7 @@
|
||||||
"Render a specific historical version of a page"
|
"Render a specific historical version of a page"
|
||||||
[request]
|
[request]
|
||||||
(let [params (keywordize-keys (:params request))
|
(let [params (keywordize-keys (:params request))
|
||||||
page (url-decode (or (:page params) (:default-page-title layout/config)))
|
page (url-decode (or (:page params) (:default-page-title util/config)))
|
||||||
version (:version params)
|
version (:version params)
|
||||||
file-name (str page ".md")
|
file-name (str page ".md")
|
||||||
repo-path (str (io/resource-path) "/content/")
|
repo-path (str (io/resource-path) "/content/")
|
||||||
|
|
@ -182,7 +183,7 @@
|
||||||
(timbre/info (format "Showing version '%s' of page '%s'" version page))
|
(timbre/info (format "Showing version '%s' of page '%s'" version page))
|
||||||
(layout/render "wiki.html"
|
(layout/render "wiki.html"
|
||||||
(merge (util/standard-params request)
|
(merge (util/standard-params request)
|
||||||
{:title (str (:vers-col-hdr layout/config) " " version " of " page)
|
{:title (str (:vers-col-hdr util/config) " " version " of " page)
|
||||||
:page page
|
:page page
|
||||||
:content (md->html content)}))))
|
:content (md->html content)}))))
|
||||||
|
|
||||||
|
|
@ -191,14 +192,14 @@
|
||||||
"Render a diff between two versions of a page"
|
"Render a diff between two versions of a page"
|
||||||
[request]
|
[request]
|
||||||
(let [params (keywordize-keys (:params request))
|
(let [params (keywordize-keys (:params request))
|
||||||
page (url-decode (or (:page params) (:default-page-title layout/config)))
|
page (url-decode (or (:page params) (:default-page-title util/config)))
|
||||||
version (:version params)
|
version (:version params)
|
||||||
file-name (str page ".md")
|
file-name (str page ".md")
|
||||||
repo-path (str (io/resource-path) "/content/")]
|
repo-path (str (io/resource-path) "/content/")]
|
||||||
(timbre/info (format "Showing diff between version '%s' of page '%s' and current" version page))
|
(timbre/info (format "Showing diff between version '%s' of page '%s' and current" version page))
|
||||||
(layout/render "wiki.html"
|
(layout/render "wiki.html"
|
||||||
(merge (util/standard-params request)
|
(merge (util/standard-params request)
|
||||||
{:title (str (:diff-title-prefix layout/config)" " version " of " page)
|
{:title (str (:diff-title-prefix util/config)" " version " of " page)
|
||||||
:page page
|
:page page
|
||||||
:content (d2h/diff2html (hist/diff repo-path file-name version))}))))
|
:content (d2h/diff2html (hist/diff repo-path file-name version))}))))
|
||||||
|
|
||||||
|
|
@ -213,7 +214,7 @@
|
||||||
user (session/get :user)
|
user (session/get :user)
|
||||||
redirect-to (or (:redirect-to params) "/wiki")]
|
redirect-to (or (:redirect-to params) "/wiki")]
|
||||||
(cond
|
(cond
|
||||||
(= action (:logout-label layout/config))
|
(= action (:logout-label util/config))
|
||||||
(do
|
(do
|
||||||
(timbre/info (str "User " user " logging out"))
|
(timbre/info (str "User " user " logging out"))
|
||||||
(session/remove! :user)
|
(session/remove! :user)
|
||||||
|
|
@ -225,7 +226,7 @@
|
||||||
true
|
true
|
||||||
(layout/render "auth.html"
|
(layout/render "auth.html"
|
||||||
(merge (util/standard-params request)
|
(merge (util/standard-params request)
|
||||||
{:title (if user (str (:logout-link layout/config) " " user) (:login-link layout/config))
|
{:title (if user (str (:logout-link util/config) " " user) (:login-link util/config))
|
||||||
:redirect-to ((:headers request) "referer")})))))
|
:redirect-to ((:headers request) "referer")})))))
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -242,14 +243,14 @@
|
||||||
(auth/change-pass user oldpass pass2))]
|
(auth/change-pass user oldpass pass2))]
|
||||||
(layout/render "passwd.html"
|
(layout/render "passwd.html"
|
||||||
(merge (util/standard-params request)
|
(merge (util/standard-params request)
|
||||||
{:title (str (:chpass-title-prefix layout/config) " " user)
|
{:title (str (:chpass-title-prefix util/config) " " user)
|
||||||
:message (if changed? (:chpass-success layout/config))
|
:message (if changed? (:chpass-success util/config))
|
||||||
:error (cond
|
:error (cond
|
||||||
(nil? oldpass) nil
|
(nil? oldpass) nil
|
||||||
changed? nil
|
changed? nil
|
||||||
(< (count pass1) 8) (:chpass-too-short layout/config)
|
(< (count pass1) 8) (:chpass-too-short util/config)
|
||||||
(not (= pass1 pass2)) (:chpass-bad-match layout/config)
|
(not (= pass1 pass2)) (:chpass-bad-match util/config)
|
||||||
true (:chpass-fail layout/config))}))))
|
true (:chpass-fail util/config))}))))
|
||||||
|
|
||||||
|
|
||||||
(defroutes wiki-routes
|
(defroutes wiki-routes
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,14 @@
|
||||||
;;;;
|
;;;;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
|
||||||
|
;; the relative path to the config file.
|
||||||
|
(def config-file-path (str (io/resource-path) "../config.edn"))
|
||||||
|
|
||||||
|
|
||||||
|
(def config (read-string (slurp config-file-path)))
|
||||||
|
|
||||||
|
|
||||||
(defn standard-params
|
(defn standard-params
|
||||||
"Return a map of standard parameters to pass to the template renderer."
|
"Return a map of standard parameters to pass to the template renderer."
|
||||||
[request]
|
[request]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue