mirror of
https://github.com/journeyman-cc/smeagol.git
synced 2026-04-12 18:05:06 +00:00
Merge branch 'feature/15' into develop
This commit is contained in:
commit
6873b11fbd
18 changed files with 300 additions and 191 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -13,4 +13,5 @@ pom.xml.asc
|
||||||
.lein-plugins/
|
.lein-plugins/
|
||||||
.lein-failures
|
.lein-failures
|
||||||
.lein-env
|
.lein-env
|
||||||
|
.nrepl-port
|
||||||
|
smeagol.log*
|
||||||
|
|
|
||||||
104
resources/config.edn
Normal file
104
resources/config.edn
Normal file
|
|
@ -0,0 +1,104 @@
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;;;;
|
||||||
|
;;;; 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
|
||||||
|
;;;;
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
;;; config.edn: a simple configuration map for Smeagol; inspired by Cryogen.
|
||||||
|
;;; 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
|
||||||
|
: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
|
||||||
|
}
|
||||||
|
|
@ -1 +1 @@
|
||||||
{:admin {:admin true, :email "info@weft.scot", :password "admin"}}
|
{:admin {:admin true, :email "info@weft.scot", :password "admin"}}
|
||||||
|
|
|
||||||
|
|
@ -1,91 +1,88 @@
|
||||||

|

|
||||||
|
|
||||||
# Welcome to Smeagol!
|
# Welcome to Smeagol!
|
||||||
Smeagol is a simple Wiki engine inspired by [Gollum](https://github.com/gollum/gollum/wiki). Gollum is a Wiki engine written in Ruby, which uses a number of simple text formats including [Markdown](http://daringfireball.net/projects/markdown/), and which uses [Git](http://git-scm.com/) to provide versioning and backup. I needed a new Wiki for a project and thought Gollum would be ideal - but unfortunately it doesn't provide user authentication, which I needed, and it was simpler for me to reimplement the bits I did need in Clojure than to modify Gollum.
|
Smeagol is a simple Wiki engine inspired by [Gollum](https://github.com/gollum/gollum/wiki). Gollum is a Wiki engine written in Ruby, which uses a number of simple text formats including [Markdown](http://daringfireball.net/projects/markdown/), and which uses [Git](http://git-scm.com/) to provide versioning and backup. I needed a new Wiki for a project and thought Gollum would be ideal - but unfortunately it doesn't provide user authentication, which I needed, and it was simpler for me to reimplement the bits I did need in Clojure than to modify Gollum.
|
||||||
|
|
||||||
So at this stage Smeagol is a Wiki engine written in Clojure which uses Markdown as its text format, which does have user authentication, and which uses Git as its versioning and backup system.
|
So at this stage Smeagol is a Wiki engine written in Clojure which uses Markdown as its text format, which does have user authentication, and which uses Git as its versioning and backup system.
|
||||||
|
|
||||||
## Status
|
## Status
|
||||||
Smeagol is now a fully working small Wiki engine, and meets my own immediate needs.
|
Smeagol is now a fully working small Wiki engine, and meets my own immediate needs.
|
||||||
|
|
||||||
## Markup syntax
|
## Markup syntax
|
||||||
Smeagol uses the Markdown format as provided by [markdown-clj](https://github.com/yogthos/markdown-clj), with the addition that anything enclosed in double square brackets, \[\[like this\]\], will be treated as a link into the wiki itself.
|
Smeagol uses the Markdown format as provided by [markdown-clj](https://github.com/yogthos/markdown-clj), with the addition that anything enclosed in double square brackets, \[\[like this\]\], will be treated as a link into the wiki itself.
|
||||||
|
|
||||||
## Security and authentication
|
## Security and authentication
|
||||||
Security is now greatly improved. There is a file called *passwd* in the *resources* directory, which contains a clojure map which maps usernames to maps with plain-text passwords and emails thus:
|
Security is now greatly improved. There is a file called *passwd* in the *resources* directory, which contains a clojure map which maps usernames to maps with plain-text passwords and emails thus:
|
||||||
|
|
||||||
{:admin {:password "admin" :email "admin@localhost" :admin true}
|
{:admin {:password "admin" :email "admin@localhost" :admin true}
|
||||||
:adam {:password "secret" :email "adam@localhost"}}
|
:adam {:password "secret" :email "adam@localhost"}}
|
||||||
|
|
||||||
that is to say, the username is a keyword and the corresponding password is a string. However, since version 0.5.0, users can now change their own passwords, and when the user changes their password their new password is encrypted using the [scrypt](http://www.tarsnap.com/scrypt.html) one-way encryption scheme. The password file is now no longer either in the *resources/public* directory so cannot be downloaded through the browser, nor in the git archive to which the Wiki content is stored, so that even if that git archive is remotely clonable an attacker cannot get the password file that way.
|
that is to say, the username is a keyword and the corresponding password is a string. However, since version 0.5.0, users can now change their own passwords, and when the user changes their password their new password is encrypted using the [scrypt](http://www.tarsnap.com/scrypt.html) one-way encryption scheme. The password file is now no longer either in the *resources/public* directory so cannot be downloaded through the browser, nor in the git archive to which the Wiki content is stored, so that even if that git archive is remotely clonable an attacker cannot get the password file that way.
|
||||||
|
|
||||||
## Images
|
## Images
|
||||||
Smeagol does not currently have any mechanism to upload images. You can, however, link to images already available on the web, like this:
|
Smeagol does not currently have any mechanism to upload images. You can, however, link to images already available on the web, like this:
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Todo
|
## Advertisement
|
||||||
* Mechanism to add users through the user interface;
|
If you like what you see here, I am available for work on open source Clojure projects. Contact me via [WEFT](http://www.weft.scot/).
|
||||||
|
|
||||||
## Advertisement
|
### Phoning home
|
||||||
If you like what you see here, I am available for work on open source Clojure projects. Contact me via [WEFT](http://www.weft.scot/).
|
Smeagol currently requests the WEFT logo in the page footer from my home site. This is mainly so I can get a feel for how many people are using the product. If you object to this, edit the file
|
||||||
|
|
||||||
### Phoning home
|
resources/templates/base.html
|
||||||
Smeagol currently requests the WEFT logo in the page footer from my home site. This is mainly so I can get a feel for how many people are using the product. If you object to this, edit the file
|
|
||||||
|
and replace the line
|
||||||
resources/templates/base.html
|
|
||||||
|
<img height="16" width="16" alt="The Web Engineering Factory & Toolworks" src="http://www.weft.scot/images/weft.logo.64.png"> Developed by <a href="http://www.weft.scot/">WEFT</a>
|
||||||
and replace the line
|
|
||||||
|
with the line
|
||||||
<img height="16" width="16" alt="The Web Engineering Factory & Toolworks" src="http://www.weft.scot/images/weft.logo.64.png"> Developed by <a href="http://www.weft.scot/">WEFT</a>
|
|
||||||
|
<img height="16" width="16" alt="The Web Engineering Factory & Toolworks" src="img/weft.logo.64.png"> Developed by <a href="http://www.weft.scot/">WEFT</a>
|
||||||
with the line
|
|
||||||
|
## License
|
||||||
<img height="16" width="16" alt="The Web Engineering Factory & Toolworks" src="img/weft.logo.64.png"> Developed by <a href="http://www.weft.scot/">WEFT</a>
|
Copyright © 2014-2015 Simon Brooke. Licensed under the GNU General Public License,
|
||||||
|
version 2.0 or (at your option) any later version. If you wish to incorporate
|
||||||
## License
|
parts of Smeagol into another open source project which uses a less restrictive
|
||||||
Copyright © 2014-2015 Simon Brooke. Licensed under the GNU General Public License,
|
license, please contact me; I'm open to dual licensing it.
|
||||||
version 2.0 or (at your option) any later version. If you wish to incorporate
|
|
||||||
parts of Smeagol into another open source project which uses a less restrictive
|
## Prerequisites
|
||||||
license, please contact me; I'm open to dual licensing it.
|
You will need [Leiningen](https://github.com/technomancy/leiningen) 2.0 or above installed.
|
||||||
|
|
||||||
## Prerequisites
|
You will need [node](https://nodejs.org/en/) and [bower](https://bower.io/) installed.
|
||||||
You will need [Leiningen](https://github.com/technomancy/leiningen) 2.0 or above installed.
|
|
||||||
|
## Running
|
||||||
You will need [node](https://nodejs.org/en/) and [bower](https://bower.io/) installed.
|
To start a web server for the application, run:
|
||||||
|
|
||||||
## Running
|
lein bower install
|
||||||
To start a web server for the application, run:
|
lein ring server
|
||||||
|
|
||||||
lein bower install
|
Alternatively, if you want to deploy to a servlet container (which I would strongly recommend), the simplest thing is to run:
|
||||||
lein ring server
|
|
||||||
|
lein bower install
|
||||||
Alternatively, if you want to deploy to a servlet container (which I would strongly recommend), the simplest thing is to run:
|
lein ring uberwar
|
||||||
|
|
||||||
lein bower install
|
(a command which I'm sure Smeagol would entirely appreciate) and deploy the resulting war file.
|
||||||
lein ring uberwar
|
|
||||||
|
## Experimental Docker image
|
||||||
(a command which I'm sure Smeagol would entirely appreciate) and deploy the resulting war file.
|
|
||||||
|
You can now run Smeagol as a [Docker](http://www.docker.com) image. To run my Docker image, use
|
||||||
## Experimental Docker image
|
|
||||||
|
docker run simonbrooke/smeagol
|
||||||
You can now run Smeagol as a [Docker](http://www.docker.com) image. To run my Docker image, use
|
|
||||||
|
Smeagol will run, obviously, on the IP address of your Docker image, on port 8080. To find the IP address, start the image using the command above and then use
|
||||||
docker run simonbrooke/smeagol
|
|
||||||
|
docker inspect --format '{{ .NetworkSettings.IPAddress }}' $(docker ps -q)
|
||||||
Smeagol will run, obviously, on the IP address of your Docker image, on port 8080. To find the IP address, start the image using the command above and then use
|
|
||||||
|
Suppose this prints '10.10.10.10', then the URL to browse to will be http://10.10.10.10:8080/smeagol/
|
||||||
docker inspect --format '{{ .NetworkSettings.IPAddress }}' $(docker ps -q)
|
|
||||||
|
This image is _experimental_, but it does seem to work fairly well. What it does **not** yet do, however, is push the git repository to a remote location, so when you tear the Docker image down your edits will be lost. My next objective for this image is for it to have a cammand line parameter being the git address of a repository from which it can initialise the Wiki content, and to which it will periodically push local changes to the Wiki content.
|
||||||
Suppose this prints '10.10.10.10', then the URL to browse to will be http://10.10.10.10:8080/smeagol/
|
|
||||||
|
To build your own Docker image, run:
|
||||||
This image is _experimental_, but it does seem to work fairly well. What it does **not** yet do, however, is push the git repository to a remote location, so when you tear the Docker image down your edits will be lost. My next objective for this image is for it to have a cammand line parameter being the git address of a repository from which it can initialise the Wiki content, and to which it will periodically push local changes to the Wiki content.
|
|
||||||
|
lein clean
|
||||||
To build your own Docker image, run:
|
lein bower install
|
||||||
|
lein ring uberwar
|
||||||
lein clean
|
lein docker build
|
||||||
lein bower install
|
|
||||||
lein ring uberwar
|
This will build a new Docker image locally; you can, obviously, push it to your own Docker repository if you wish.
|
||||||
lein docker build
|
|
||||||
|
|
||||||
This will build a new Docker image locally; you can, obviously, push it to your own Docker repository if you wish.
|
|
||||||
|
|
|
||||||
|
|
@ -224,20 +224,20 @@ li.nav-item a:active { background: gray; color: white; }
|
||||||
width: 30%;
|
width: 30%;
|
||||||
float: right;
|
float: right;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
bottom: 1.5em;
|
bottom: 3.5em;
|
||||||
right: 0;
|
right: 0;
|
||||||
z-index: 150;
|
z-index: 175;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* about-cookies box: permanently visible part of cookies information box */
|
/* about-cookies box: permanently visible part of cookies information box */
|
||||||
#about-cookies {
|
#about-cookies {
|
||||||
clear: right;
|
clear: right;
|
||||||
width: 10em;
|
|
||||||
font-size: 66%;
|
font-size: 66%;
|
||||||
float: right;
|
float: right;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
padding: 0.25em 2em;
|
padding: 0.25em 2em;
|
||||||
|
border-radius: 0.25em;
|
||||||
color: white;
|
color: white;
|
||||||
background:rgba(40,40,40,0.8);
|
background:rgba(40,40,40,0.8);
|
||||||
}
|
}
|
||||||
|
|
@ -245,7 +245,8 @@ li.nav-item a:active { background: gray; color: white; }
|
||||||
/* more-about-cookies box, normally hidden */
|
/* more-about-cookies box, normally hidden */
|
||||||
#more-about-cookies {
|
#more-about-cookies {
|
||||||
display: none;
|
display: none;
|
||||||
padding: 0.25em 2em;
|
padding: 0.5em 2em;
|
||||||
|
border-radius: 0.5em;
|
||||||
color: white;
|
color: white;
|
||||||
background:rgba(40,40,40,0.8);
|
background:rgba(40,40,40,0.8);
|
||||||
border-bottom: thin solid white;
|
border-bottom: thin solid white;
|
||||||
|
|
@ -277,7 +278,9 @@ li.nav-item a:active { background: gray; color: white; }
|
||||||
.minor-controls {
|
.minor-controls {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
float: right;
|
float: right;
|
||||||
|
right: 0;
|
||||||
padding: 0.25em 2em;
|
padding: 0.25em 2em;
|
||||||
|
border-radius: 0.25em;
|
||||||
color: white;
|
color: white;
|
||||||
background:rgba(40,40,40,0.8);
|
background:rgba(40,40,40,0.8);
|
||||||
font-size: 66%;
|
font-size: 66%;
|
||||||
|
|
|
||||||
|
|
@ -5,21 +5,21 @@
|
||||||
<input type="hidden" name="redirect-to" value="{{redirect-to}}"/>
|
<input type="hidden" name="redirect-to" value="{{redirect-to}}"/>
|
||||||
{% if user %}
|
{% if user %}
|
||||||
<p class="widget">
|
<p class="widget">
|
||||||
<label for="submit">To finish editing</label>
|
<label for="submit">{{config.save-prompt}}</label>
|
||||||
<input name="action" id="action" type="submit" class="action-dangerous" value="Logout!"/>
|
<input name="action" id="action" type="submit" class="action-dangerous" value="{{config.logout-label}}"/>
|
||||||
</p>
|
</p>
|
||||||
{% else %}
|
{% else %}
|
||||||
<p class="widget">
|
<p class="widget">
|
||||||
<label for="username">Your username</label>
|
<label for="username">{{config.your-uname-prompt}}</label>
|
||||||
<input name="username" id="username" type="text" required/>
|
<input name="username" id="username" type="text" required/>
|
||||||
</p>
|
</p>
|
||||||
<p class="widget">
|
<p class="widget">
|
||||||
<label for="password">Your password</label>
|
<label for="password">{{config.old-pass-prompt}}</label>
|
||||||
<input name="password" id="password" type="password" required/>
|
<input name="password" id="password" type="password" required/>
|
||||||
</p>
|
</p>
|
||||||
<p class="widget">
|
<p class="widget">
|
||||||
<label for="submit">To edit this wiki</label>
|
<label for="submit">{{config.login-prompt}}</label>
|
||||||
<input name="action" id="action" type="submit" class="action" value="Login!"/>
|
<input name="action" id="action" type="submit" class="action" value="{{config.login-label}}"/>
|
||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</form>
|
</form>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>{{title}}</title>
|
<title>{{config.site-title}}: {{title}}</title>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
<link href="{{servlet-context}}/content/stylesheet.css" media="screen and (min-device-width: 1025px)" rel="stylesheet" type="text/css" />
|
<link href="{{servlet-context}}/content/stylesheet.css" media="screen and (min-device-width: 1025px)" rel="stylesheet" type="text/css" />
|
||||||
<link href="{{servlet-context}}/css/print.css" media="print" rel="stylesheet" type="text/css" />
|
<link href="{{servlet-context}}/css/print.css" media="print" rel="stylesheet" type="text/css" />
|
||||||
|
|
@ -13,23 +13,23 @@
|
||||||
<!-- navbar -->
|
<!-- navbar -->
|
||||||
<div id="nav">
|
<div id="nav">
|
||||||
{% if user %}
|
{% if user %}
|
||||||
<p class="user" id="user">You are logged in as {{user}} | <a href="passwd">change password</a></p>
|
<p class="user" id="user">{{config.logged-in-as}} {{user}} | <a href="passwd">{{config.change-pass-link}}</a></p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<img id="nav-icon" src="{{servlet-context}}/img/threelines.png" alt="Menu"/>
|
<img id="nav-icon" src="{{servlet-context}}/img/threelines.png" alt="Menu"/>
|
||||||
<ul id="nav-menu" class="nav">
|
<ul id="nav-menu" class="nav">
|
||||||
<li class="{{wiki-selected}}"><a href="{{servlet-context}}/">Home</a></li>
|
<li class="{{wiki-selected}}"><a href="{{servlet-context}}/">{{config.home-link}}</a></li>
|
||||||
{% if admin %}
|
{% if admin %}
|
||||||
<li class="{{admin-selected}}"><a href="{{servlet-context}}/edit-users">Edit users</a></li>
|
<li class="{{admin-selected}}"><a href="{{servlet-context}}/edit-users">{{config.edit-users-link}}</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<li class="{{auth-selected}}"><a href="{{servlet-context}}/auth">
|
<li class="{{auth-selected}}"><a href="{{servlet-context}}/auth">
|
||||||
{% if user %}
|
{% if user %}
|
||||||
Log out
|
{{config.logout-link}}
|
||||||
{% else %}
|
{% else %}
|
||||||
Log in
|
{{config.login-link}}
|
||||||
{% endif %}</a></li>
|
{% endif %}</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<h1>{{title}}</h1>
|
<h1>{{config.site-title}}: {{title}}</h1>
|
||||||
{{header|safe}}
|
{{header|safe}}
|
||||||
{% if message %}
|
{% if message %}
|
||||||
<div id="message">
|
<div id="message">
|
||||||
|
|
@ -52,13 +52,10 @@
|
||||||
</div>
|
</div>
|
||||||
<div id="cookies">
|
<div id="cookies">
|
||||||
<div id="more-about-cookies">
|
<div id="more-about-cookies">
|
||||||
This website stores session information as a 'cookie' on your browser. This helps us show you the content
|
{{config.cookies-more}}
|
||||||
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.
|
|
||||||
</div>
|
</div>
|
||||||
<div id="about-cookies">
|
<div id="about-cookies">
|
||||||
About cookies
|
{{config.cookies-about}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<footer>
|
<footer>
|
||||||
|
|
|
||||||
|
|
@ -6,17 +6,14 @@
|
||||||
<input type="hidden" name="page" value="{{page}}"/>
|
<input type="hidden" name="page" value="{{page}}"/>
|
||||||
<textarea name="src" id="src" rows="25" cols="80">{{content}}</textarea>
|
<textarea name="src" id="src" rows="25" cols="80">{{content}}</textarea>
|
||||||
<p class="widget">
|
<p class="widget">
|
||||||
<label for="summary">What have you changed?</label>
|
<label for="summary">{{config.what-changed-prompt}}</label>
|
||||||
<input name="summary" id="summary" type="text"
|
<input name="summary" id="summary" type="text"
|
||||||
value="{%if exists%}{%else%}New file {{title}}{%endif%}" required/>
|
value="{%if exists%}{%else%}New file {{title}}{%endif%}" required/>
|
||||||
</p>
|
</p>
|
||||||
<p class="widget">
|
<p class="widget">
|
||||||
<label for="submit">When you have finished editing</label>
|
<label for="submit">{{config.save-prompt}}</label>
|
||||||
<input name="submit" id="submit" type="submit" class="action" value="Save!"/>
|
<input name="submit" id="submit" type="submit" class="action" value="{{config.save-label}}"/>
|
||||||
</p>
|
</p>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
|
||||||
var simplemde = new SimpleMDE();
|
|
||||||
</script>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
||||||
|
|
@ -4,28 +4,28 @@
|
||||||
<div id="content" class="edit">
|
<div id="content" class="edit">
|
||||||
<form action="{{servlet-context}}/edit-user" method="POST">
|
<form action="{{servlet-context}}/edit-user" method="POST">
|
||||||
<p class="widget">
|
<p class="widget">
|
||||||
<label for="target">Username</label>
|
<label for="target">{{config.username-prompt}}</label>
|
||||||
<input type="text" name="target" id="target" value="{{target}}" required/>
|
<input type="text" name="target" id="target" value="{{target}}" required/>
|
||||||
</p>
|
</p>
|
||||||
<p class="widget">
|
<p class="widget">
|
||||||
<label for="pass1">New password</label>
|
<label for="pass1">{{config.new-pass-prompt}}</label>
|
||||||
<input name="pass1" id="pass1" type="password"/>
|
<input name="pass1" id="pass1" type="password"/>
|
||||||
</p>
|
</p>
|
||||||
<p class="widget">
|
<p class="widget">
|
||||||
<label for="pass2">And again</label>
|
<label for="pass2">{{config.rpt-pass-prompt}}</label>
|
||||||
<input name="pass2" id="pass2" type="password"/>
|
<input name="pass2" id="pass2" type="password"/>
|
||||||
</p>
|
</p>
|
||||||
<p class="widget">
|
<p class="widget">
|
||||||
<label for="email">Email address</label>
|
<label for="email">{{config.email-prompt}}</label>
|
||||||
<input name="email" id="email" type="text" value="{{details.email}}" required/>
|
<input name="email" id="email" type="text" value="{{details.email}}" required/>
|
||||||
</p>
|
</p>
|
||||||
<p class="widget">
|
<p class="widget">
|
||||||
<label for="admin">Is administrator?</label>
|
<label for="admin">{{config.is-admin-prompt}}</label>
|
||||||
<input name="admin" id="admin" type="checkbox" {% if details.admin %}checked{% endif %}/>
|
<input name="admin" id="admin" type="checkbox" {% if details.admin %}checked{% endif %}/>
|
||||||
</p>
|
</p>
|
||||||
<p class="widget">
|
<p class="widget">
|
||||||
<label for="submit">When you have finished editing</label>
|
<label for="submit">{{config.save-prompt}}</label>
|
||||||
<input name="submit" id="submit" type="submit" class="action" value="Save!"/>
|
<input name="submit" id="submit" type="submit" class="action" value="{{config.save-label}}"/>
|
||||||
</p>
|
</p>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -4,16 +4,16 @@
|
||||||
<div id="content">
|
<div id="content">
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Edit</th><th>Delete</th>
|
<th>{{config.edit-col-hdr}}</th><th>{{config.del-col-hdr}}</th>
|
||||||
</tr>
|
</tr>
|
||||||
{% for user in users %}
|
{% for user in users %}
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="edit-user?target={{user}}">Edit {{user}}</a></td>
|
<td><a href="edit-user?target={{user}}">{{config.edit-col-hdr}} {{user}}</a></td>
|
||||||
<td><a href="delete-user?target={{user}}">Delete {{user}}</a></td>
|
<td><a href="delete-user?target={{user}}">{{config.del-col-hdr}} {{user}}</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="edit-user">Add new user</a></td>
|
<td><a href="edit-user">{{config.add-user-label}}</a></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
||||||
|
|
@ -10,13 +10,13 @@
|
||||||
<input type="hidden" name="page" value="{{page}}"/>
|
<input type="hidden" name="page" value="{{page}}"/>
|
||||||
<textarea name="src" id="src" rows="25" cols="80">{{content}}</textarea>
|
<textarea name="src" id="src" rows="25" cols="80">{{content}}</textarea>
|
||||||
<p class="widget">
|
<p class="widget">
|
||||||
<label for="summary">What have you changed?</label>
|
<label for="summary">{{config.what-changed-prompt}}</label>
|
||||||
<input name="summary" id="summary" type="text"
|
<input name="summary" id="summary" type="text"
|
||||||
value="{%if exists%}{%else%}New file {{title}}{%endif%}" required/>
|
value="{%if exists%}{%else%}New file {{title}}{%endif%}" required/>
|
||||||
</p>
|
</p>
|
||||||
<p class="widget">
|
<p class="widget">
|
||||||
<label for="submit">When you have finished editing</label>
|
<label for="submit">{{config.save-prompt}}</label>
|
||||||
<input name="submit" id="submit" type="submit" class="action" value="Save!"/>
|
<input name="submit" id="submit" type="submit" class="action" value="{{config.save-label}}"/>
|
||||||
</p>
|
</p>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,29 @@
|
||||||
{% extends "templates/base.html" %}
|
{% extends "templates/base.html" %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div id="content" class="history">
|
<div id="content" class="history">
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th>When</th><th>What</th><th>Version</th><th>Changes</th>
|
<th>{{config.when-col-hdr}}</th>
|
||||||
</tr>
|
<th>{{config.what-col-hdr}}</th>
|
||||||
{% for entry in history %}
|
<th>{{config.vers-col-hdr}}</th>
|
||||||
<tr>
|
<th>{{config.change-col-hdr}}</th>
|
||||||
<td>S
|
</tr>
|
||||||
{{entry.time}}
|
{% for entry in history %}
|
||||||
</td>
|
<tr>
|
||||||
<td>
|
<td>S
|
||||||
{{entry.message}}
|
{{entry.time}}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="version?page={{page}}&version={{entry.id}}">Show version</a>
|
{{entry.message}}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="changes?page={{page}}&version={{entry.id}}">What's changed since?</a>
|
<a href="version?page={{page}}&version={{entry.id}}">Show version</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
<td>
|
||||||
{% endfor %}
|
<a href="changes?page={{page}}&version={{entry.id}}">What's changed since?</a>
|
||||||
</table>
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
||||||
|
|
@ -3,20 +3,20 @@
|
||||||
<div id="content" class="auth">
|
<div id="content" class="auth">
|
||||||
<form action="{{servlet-context}}/passwd" method="POST">
|
<form action="{{servlet-context}}/passwd" method="POST">
|
||||||
<p class="widget">
|
<p class="widget">
|
||||||
<label for="oldpass">Your password</label>
|
<label for="oldpass">{{config.old-pass-prompt}}</label>
|
||||||
<input name="oldpass" id="oldpass" type="password" required/>
|
<input name="oldpass" id="oldpass" type="password" required/>
|
||||||
</p>
|
</p>
|
||||||
<p class="widget">
|
<p class="widget">
|
||||||
<label for="pass1">New password</label>
|
<label for="pass1">{{config.new-pass-prompt}}</label>
|
||||||
<input name="pass1" id="pass1" type="password" required/>
|
<input name="pass1" id="pass1" type="password" required/>
|
||||||
</p>
|
</p>
|
||||||
<p class="widget">
|
<p class="widget">
|
||||||
<label for="pass2">And again</label>
|
<label for="pass2">{{config.rpt-pass-prompt}}</label>
|
||||||
<input name="pass2" id="pass2" type="password" required/>
|
<input name="pass2" id="pass2" type="password" required/>
|
||||||
</p>
|
</p>
|
||||||
<p class="widget">
|
<p class="widget">
|
||||||
<label for="submit">To edit this wiki</label>
|
<label for="submit">{{config.change-pass-prompt}}</label>
|
||||||
<input name="action" id="action" type="submit" class="action" value="Change password!"/>
|
<input name="action" id="action" type="submit" class="action" value="{{config.change-pass-link}}!"/>
|
||||||
</p>
|
</p>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@
|
||||||
<div id="content" class="wiki">
|
<div id="content" class="wiki">
|
||||||
{% if editable %}
|
{% if editable %}
|
||||||
<ul class="minor-controls">
|
<ul class="minor-controls">
|
||||||
<li><a href="{{servlet-context}}/edit?page={{title}}">Edit this page</a></li>
|
<li><a href="{{servlet-context}}/edit?page={{title}}">{{config.edit-page-link}}</a></li>
|
||||||
<li><a href="history?page={{page}}">History</a></li>
|
<li><a href="history?page={{page}}">{{config.history-link}}</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{{content|safe}}
|
{{content|safe}}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
smeagol.layout
|
smeagol.layout
|
||||||
(:require [selmer.parser :as parser]
|
(:require [selmer.parser :as parser]
|
||||||
[clojure.string :as s]
|
[clojure.string :as s]
|
||||||
|
[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]]))
|
||||||
|
|
@ -33,6 +34,10 @@
|
||||||
|
|
||||||
(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
|
||||||
|
|
@ -40,6 +45,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
|
||||||
: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 "Select user to edit"
|
{:title (:edit-users-title layout/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 "Successfully deleted user " target))
|
message (if deleted (str (:del-user-success layout/config) " " target "."))
|
||||||
error (if (not deleted) (str "Could not delete user " target))]
|
error (if (not deleted) (str (:del-user-fail layout/config) " " target "."))]
|
||||||
(layout/render "edit-users.html"
|
(layout/render "edit-users.html"
|
||||||
(merge (util/standard-params request)
|
(merge (util/standard-params request)
|
||||||
{:title "Select user to edit"
|
{:title (:edit-users-title layout/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 "User " target " was stored successfully."))
|
message (if stored (str (:save-user-success layout/config) " " target "."))
|
||||||
error (if (and (:email params) (not stored))
|
error (if (and (:email params) (not stored))
|
||||||
(str "User " target " was not stored."))
|
(str (:save-user-fail layout/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 user " target)
|
{:title (str (:edit-title-prefix layout/config) " " target)
|
||||||
:message message
|
:message message
|
||||||
:error error
|
:error error
|
||||||
:target target
|
:target target
|
||||||
|
|
|
||||||
|
|
@ -74,14 +74,14 @@
|
||||||
(if
|
(if
|
||||||
(= suffix ".md")
|
(= suffix ".md")
|
||||||
(url-encode page)
|
(url-encode page)
|
||||||
"Introduction")))))
|
(:default-page-title layout/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 "Introduction" ".md" "edit.html" "/content/_edit-side-bar.md"))
|
(edit-page request (:default-page-title layout/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)
|
||||||
|
|
@ -96,7 +96,7 @@
|
||||||
true
|
true
|
||||||
(layout/render template
|
(layout/render template
|
||||||
(merge (util/standard-params request)
|
(merge (util/standard-params request)
|
||||||
{:title (str "Edit " page)
|
{:title (str (:edit-title-prefix layout/config) " " page)
|
||||||
:page page
|
:page page
|
||||||
:side-bar (util/local-links (util/md->html side-bar))
|
:side-bar (util/local-links (util/md->html side-bar))
|
||||||
:content (if exists? (io/slurp-resource (str "/content/" page suffix)) "")
|
:content (if exists? (io/slurp-resource (str "/content/" page suffix)) "")
|
||||||
|
|
@ -106,14 +106,14 @@
|
||||||
(defn edit-css-page
|
(defn edit-css-page
|
||||||
"Render a stylesheet in a text-area for editing.."
|
"Render a stylesheet in a text-area for editing.."
|
||||||
[request]
|
[request]
|
||||||
(edit-page request "stylesheet" ".css" "edit-css.html" "/content/_edit-side-bar.md"))
|
(edit-page request "stylesheet" ".css" "edit-css.html" "/content/_edit-side-bar.md"))
|
||||||
|
|
||||||
|
|
||||||
(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]
|
||||||
(let [params (keywordize-keys (:params request))
|
(let [params (keywordize-keys (:params request))
|
||||||
page (or (:page params) "Introduction")
|
page (or (:page params) (:default-page-title layout/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))]
|
||||||
|
|
@ -135,7 +135,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) "Introduction"))
|
page (url-decode (or (:page params) (:default-page-title layout/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/")]
|
||||||
(layout/render "history.html"
|
(layout/render "history.html"
|
||||||
|
|
@ -149,13 +149,13 @@
|
||||||
"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) "Introduction"))
|
page (url-decode (or (:page params) (:default-page-title layout/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/")]
|
||||||
(layout/render "wiki.html"
|
(layout/render "wiki.html"
|
||||||
(merge (util/standard-params request)
|
(merge (util/standard-params request)
|
||||||
{:title (str "Version " version " of " page)
|
{:title (str (:vers-col-hdr layout/config) " " version " of " page)
|
||||||
:page page
|
:page page
|
||||||
:content (util/local-links
|
:content (util/local-links
|
||||||
(md/md-to-html-string
|
(md/md-to-html-string
|
||||||
|
|
@ -167,13 +167,13 @@
|
||||||
"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) "Introduction"))
|
page (url-decode (or (:page params) (:default-page-title layout/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/")]
|
||||||
(layout/render "wiki.html"
|
(layout/render "wiki.html"
|
||||||
(merge (util/standard-params request)
|
(merge (util/standard-params request)
|
||||||
{:title (str "Changes since version " version " of " page)
|
{:title (str (:diff-title-prefix layout/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))}))))
|
||||||
|
|
||||||
|
|
@ -188,7 +188,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!")
|
(= action (:logout-label layout/config))
|
||||||
(do
|
(do
|
||||||
(timbre/info (str "User " user " logging out"))
|
(timbre/info (str "User " user " logging out"))
|
||||||
(session/remove! :user)
|
(session/remove! :user)
|
||||||
|
|
@ -200,7 +200,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 " user) "Log in")
|
{:title (if user (str (:logout-link layout/config) " " user) (:login-link layout/config))
|
||||||
:redirect-to ((:headers request) "referer")
|
:redirect-to ((:headers request) "referer")
|
||||||
:side-bar (util/local-links (util/md->html "/content/_side-bar.md"))
|
:side-bar (util/local-links (util/md->html "/content/_side-bar.md"))
|
||||||
:header (util/local-links (util/md->html "/content/_header.md"))
|
:header (util/local-links (util/md->html "/content/_header.md"))
|
||||||
|
|
@ -215,19 +215,20 @@
|
||||||
pass1 (:pass1 params)
|
pass1 (:pass1 params)
|
||||||
pass2 (:pass2 params)
|
pass2 (:pass2 params)
|
||||||
user (session/get :user)
|
user (session/get :user)
|
||||||
message (cond
|
changed? (and
|
||||||
(nil? oldpass) nil
|
(auth/evaluate-password pass1 pass2)
|
||||||
(and (auth/evaluate-password pass1 pass2) (auth/change-pass user oldpass pass2))
|
(auth/change-pass user oldpass pass2))]
|
||||||
"Your password was changed"
|
|
||||||
(< (count pass1) 8) "You proposed password wasn't long enough: 8 characters required"
|
|
||||||
(not (= pass1 pass2)) "Your proposed passwords don't match"
|
|
||||||
true "Your password was not changed")] ;; but I don't know why...
|
|
||||||
(layout/render "passwd.html"
|
(layout/render "passwd.html"
|
||||||
(merge (util/standard-params request)
|
(merge (util/standard-params request)
|
||||||
{:title (str "Change passord for " user)
|
{:title (str (:chpass-title-prefix layout/config) " " user)
|
||||||
:side-bar (util/local-links (util/md->html "/content/_side-bar.md"))
|
:side-bar (util/local-links (util/md->html "/content/_side-bar.md"))
|
||||||
:header (util/local-links (util/md->html "/content/_header.md"))
|
:header (util/local-links (util/md->html "/content/_header.md"))
|
||||||
:message message}))))
|
:message (if changed? (:chpass-success layout/config))
|
||||||
|
:error (cond
|
||||||
|
changed? nil
|
||||||
|
(< (count pass1) 8) (:chpass-too-short layout/config)
|
||||||
|
(not (= pass1 pass2)) (:chpass-bad-match layout/config)
|
||||||
|
true (:chpass-fail layout/config))}))))
|
||||||
|
|
||||||
|
|
||||||
(defroutes wiki-routes
|
(defroutes wiki-routes
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue