From 05db4e6977e398d9d11cbb569b8b5935b9268155 Mon Sep 17 00:00:00 2001 From: simon Date: Fri, 16 Sep 2016 13:46:17 +0100 Subject: [PATCH 01/79] Reversioned to 0.5.1-SNAPSHOT (not issuing a new develop version, because fix was so minor). --- project.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project.clj b/project.clj index 8b26724..a6c9d31 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject smeagol "0.5.0-rc3" +(defproject smeagol "0.5.1-SNAPSHOT" :description "A simple Git-backed Wiki inspired by Gollum" :url "https://github.com/simon-brooke/smeagol" :dependencies [[org.clojure/clojure "1.7.0"] From 2fd03caade2ee8dfb99475276aaab2cc6eef635f Mon Sep 17 00:00:00 2001 From: simon Date: Sun, 18 Sep 2016 17:36:14 +0100 Subject: [PATCH 02/79] Very small change, fixes #9, no apparent downside. --- src/smeagol/routes/wiki.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/smeagol/routes/wiki.clj b/src/smeagol/routes/wiki.clj index e81662f..51151bd 100644 --- a/src/smeagol/routes/wiki.clj +++ b/src/smeagol/routes/wiki.clj @@ -66,7 +66,7 @@ summary (format "%s: %s" user (or (:summary params) "no summary"))] (timbre/info (format "Saving %s's changes ('%s') to %s" user summary page)) (spit file-path source-text) - (if (not exists?) (git/git-add git-repo file-name)) + (git/git-add git-repo file-name) (git/git-commit git-repo summary {:name user :email email}) (response/redirect (str From a8929894d48518cc34a50071991d81ee04b79dfb Mon Sep 17 00:00:00 2001 From: simon Date: Tue, 20 Dec 2016 12:13:04 +0000 Subject: [PATCH 03/79] Fixed a nasty breaking bug when the side bar file wasn't named as expected! --- src/smeagol/routes/wiki.clj | 1 + src/smeagol/util.clj | 22 ++++++++++++++-------- test/smeagol/test/util.clj | 13 +++++++++++++ 3 files changed, 28 insertions(+), 8 deletions(-) create mode 100644 test/smeagol/test/util.clj diff --git a/src/smeagol/routes/wiki.clj b/src/smeagol/routes/wiki.clj index 51151bd..da1ff41 100644 --- a/src/smeagol/routes/wiki.clj +++ b/src/smeagol/routes/wiki.clj @@ -124,6 +124,7 @@ (merge (util/standard-params request) {:title page :page page + :side-bar (util/local-links (util/md->html "/content/_side-bar.md")) :content (util/local-links (util/md->html file-name)) :editable true}))) true (response/redirect (str "/edit?page=" page))))) diff --git a/src/smeagol/util.clj b/src/smeagol/util.clj index 8a45339..67f7203 100644 --- a/src/smeagol/util.clj +++ b/src/smeagol/util.clj @@ -37,17 +37,23 @@ (md/md-to-html-string (io/slurp-resource filename))) +;; Error to show if text to be rendered is nil. +(def no-text-error "No text: does the file exist?") + + (defn local-links "Rewrite text in `html-src` surrounded by double square brackets as a local link into this wiki." [^String html-src] - (cs/replace html-src #"\[\[[^\[\]]*\]\]" - #(let [text (clojure.string/replace %1 #"[\[\]]" "") - encoded (url-encode text) - ;; I use '\_' to represent '_' in wiki markup, because - ;; '_' is meaningful in Markdown. However, this needs to - ;; be stripped out when interpreting local links. - munged (cs/replace encoded #"%26%2395%3B" "_")] - (format "%s" munged text)))) + (if html-src + (cs/replace html-src #"\[\[[^\[\]]*\]\]" + #(let [text (clojure.string/replace %1 #"[\[\]]" "") + encoded (url-encode text) + ;; I use '\_' to represent '_' in wiki markup, because + ;; '_' is meaningful in Markdown. However, this needs to + ;; be stripped out when interpreting local links. + munged (cs/replace encoded #"%26%2395%3B" "_")] + (format "%s" munged text))) + no-text-error)) (defn standard-params diff --git a/test/smeagol/test/util.clj b/test/smeagol/test/util.clj new file mode 100644 index 0000000..d5e94f9 --- /dev/null +++ b/test/smeagol/test/util.clj @@ -0,0 +1,13 @@ +(ns smeagol.test.util + (:use clojure.test + ring.mock.request + smeagol.util)) + +(deftest test-local-links + (testing "Rewriting of local links" + (is (= (local-links nil) no-text-error) "Should NOT fail with a no pointer exception!") + (is (= (local-links "") "") "Empty string should pass through unchanged.") + (is (= (local-links "[[froboz]]") "froboz") "Local link should be rewritten.") + (let [text (str "# This is a heading" + "[This is a foreign link](http://to.somewhere)")] + (is (= (local-links text) text) "Foreign links should be unchanged")))) From fb18ebef5183f21dd2cc2de988a62b70e395ed6d Mon Sep 17 00:00:00 2001 From: simon Date: Tue, 20 Dec 2016 13:48:15 +0000 Subject: [PATCH 04/79] Reformatting of history page to make it a bit clearer how it works. --- resources/templates/history.html | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/resources/templates/history.html b/resources/templates/history.html index 1b520e3..21b4dbc 100644 --- a/resources/templates/history.html +++ b/resources/templates/history.html @@ -5,11 +5,6 @@ WhenWhatVersionChanges - - Now - [current] - [no changes] - {% for entry in history %} S @@ -22,7 +17,7 @@ Show version - What's changed? + What's changed since? {% endfor %} From 7e13e25d14e17ec6b76051cc91f489718affa732 Mon Sep 17 00:00:00 2001 From: simon Date: Tue, 20 Dec 2016 14:36:22 +0000 Subject: [PATCH 05/79] Added a bit on how to troubleshoot the bug I've been dealing with today. --- resources/public/content/Introduction.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/resources/public/content/Introduction.md b/resources/public/content/Introduction.md index ae4b565..625f612 100644 --- a/resources/public/content/Introduction.md +++ b/resources/public/content/Introduction.md @@ -23,8 +23,14 @@ Smeagol does not currently have any mechanism to upload images. You can, however ![Smeagol](http://vignette3.wikia.nocookie.net/lotr/images/e/e1/Gollum_Render.png/revision/latest?cb=20141218075509) -## Todo -* Mechanism to add users through the user interface; + +## Troubleshooting +### History +If the history mechanism does not seem to be working, or the git repository does not seem to be updating, login to your server box as the user under whose account the web app runs, go to the directory WEB-INF/classes/public/content and try + + git commit -a + +If you get error messages, fix them. The most likely thing is that the web app doesn't have sufficient authority to commit. ## Advertisement If you like what you see here, I am available for work on open source Clojure projects. Contact me vis [WEFT](http://www.weft.scot/). From 05db88dd9764bc8bc2219fe92142f462efd51ff1 Mon Sep 17 00:00:00 2001 From: simon Date: Tue, 27 Dec 2016 13:12:56 +0000 Subject: [PATCH 06/79] Now with added Docker goodness! --- Dockerfile | 3 +++ README.md | 22 ++++++++++++++++++++++ project.clj | 9 ++++++--- 3 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0dfae96 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,3 @@ +FROM tomcat:alpine +COPY target/smeagol-*-standalone.war $CATALINA_HOME/webapps/smeagol.war + diff --git a/README.md b/README.md index c809a8a..ce62681 100644 --- a/README.md +++ b/README.md @@ -67,3 +67,25 @@ Alternatively, if you want to deploy to a servlet container (which I would stron (a command which I'm sure Smeagol would entirely appreciate) and deploy the resulting war file. +## Experimental Docker image + +You can now run Smeagol as a [Docker](http://www.docker.com) image. To run my Docker image, use + + docker run simonbrooke/smeagol + +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 inspect --format '{{ .NetworkSettings.IPAddress }}' $(docker ps -q) + +Suppose this prints '10.10.10.10', then the URL to browse to will be http://10.10.10.10:8080/smeagol/ + +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. + +To build your own Docker image, run: + + lein clean + lein bower install + lein ring uberwar + lein docker build + +This will build a new Docker image locally; you can, obviously, push it to your own Docker repository if you wish. diff --git a/project.clj b/project.clj index a6c9d31..5b3236a 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject smeagol "0.5.1-SNAPSHOT" +(defproject smeagol "0.5.2-SNAPSHOT" :description "A simple Git-backed Wiki inspired by Gollum" :url "https://github.com/simon-brooke/smeagol" :dependencies [[org.clojure/clojure "1.7.0"] @@ -16,7 +16,7 @@ com.sun.jmx/jmxri]] [com.taoensso/timbre "4.7.4" :exclusions [org.clojure/tools.reader]] [com.taoensso/tower "3.0.2" :exclusions [com.taoensso/encore]] - [markdown-clj "0.9.89" :exclusions [com.keminglabs/cljx]] + [markdown-clj "0.9.91" :exclusions [com.keminglabs/cljx]] [crypto-password "0.2.0"] [clj-jgit "0.8.9"] [environ "1.1.0"] @@ -30,8 +30,11 @@ [lein-environ "1.0.0"] [lein-bower "0.5.1"] [lein-ancient "0.5.5" :exclusions [org.clojure/clojure org.clojure/data.xml]] - [lein-marginalia "0.7.1" :exclusions [org.clojure/clojure]]] + [lein-marginalia "0.7.1" :exclusions [org.clojure/clojure]] + [io.sarnowski/lein-docker "1.1.0"]] :bower-dependencies [[simplemde "1.11.2"]] + :docker {:image-name "simonbrooke/smeagol" + :dockerfile "Dockerfile"} :ring {:handler smeagol.handler/app :init smeagol.handler/init :destroy smeagol.handler/destroy} From 4a7781ef05cbe81b824c166dac52143f3368e25c Mon Sep 17 00:00:00 2001 From: simon Date: Tue, 27 Dec 2016 13:15:53 +0000 Subject: [PATCH 07/79] Added information about Docker image to README and Introduction. --- README.md | 2 +- resources/public/content/Introduction.md | 168 ++++++++++++----------- 2 files changed, 92 insertions(+), 78 deletions(-) diff --git a/README.md b/README.md index ce62681..88de98d 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Smeagol does not currently have any mechanism to upload images. You can, however * Mechanism to add users through the user interface; ## Advertisement -If you like what you see here, I am available for work on open source Clojure projects. Contact me vis [WEFT](http://www.weft.scot/). +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/). ### Phoning home 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 diff --git a/resources/public/content/Introduction.md b/resources/public/content/Introduction.md index 625f612..88de98d 100644 --- a/resources/public/content/Introduction.md +++ b/resources/public/content/Introduction.md @@ -1,77 +1,91 @@ -# 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. - -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 -Smeagol is now a fully working small Wiki engine, and meets my own immediate needs. There are some obvious -things which could be improved - see **TODO** list below - but it works now and doesn't seem to have any major problems. - -## 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. Here's an example [[Internal Link]]. - -## 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: - - {:admin {:password "admin" :email "admin@localhost" :admin true} - :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. - -## 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](http://vignette3.wikia.nocookie.net/lotr/images/e/e1/Gollum_Render.png/revision/latest?cb=20141218075509) - - -## Troubleshooting -### History -If the history mechanism does not seem to be working, or the git repository does not seem to be updating, login to your server box as the user under whose account the web app runs, go to the directory WEB-INF/classes/public/content and try - - git commit -a - -If you get error messages, fix them. The most likely thing is that the web app doesn't have sufficient authority to commit. - -## Advertisement -If you like what you see here, I am available for work on open source Clojure projects. Contact me vis [WEFT](http://www.weft.scot/). - -### Phoning home -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 - - resources/templates/base.html - -and replace the line - - The Web Engineering Factory & Toolworks Developed by WEFT - -with the line - - The Web Engineering Factory & Toolworks Developed by WEFT - -## License -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 -parts of Smeagol into another open source project which uses a less restrictive -license, please contact me; I'm open to dual licensing it. - -## Prerequisites -You will need [Leiningen](https://github.com/technomancy/leiningen) 2.0 or above installed. - -You will need [node](https://nodejs.org/en/) and [bower](https://bower.io/) installed. - -## Running -To start a web server for the application, run: - - lein bower install - lein ring server - -Alternatively, if you want to deploy to a servlet container (which I would strongly recommend), the simplest thing is to run: - - lein bower install - lein ring uberwar - -(a command which I'm sure Smeagol would entirely appreciate) and deploy the resulting war file. - - -## Editing the framing content -You can edit the [stylesheet](/edit-css?page=stylesheet), the [[\_left-bar]], the [[\_edit-left-bar]], and the [[\_header]]. +![One wiki to rule them all](https://www.weft.scot/images/smeagol.png) + +# 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. + +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 +Smeagol is now a fully working small Wiki engine, and meets my own immediate needs. + +## 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. + +## 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: + + {:admin {:password "admin" :email "admin@localhost" :admin true} + :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. + +## 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](http://vignette3.wikia.nocookie.net/lotr/images/e/e1/Gollum_Render.png/revision/latest?cb=20141218075509) + +## Todo +* Mechanism to add users through the user interface; + +## Advertisement +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/). + +### Phoning home +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 + + resources/templates/base.html + +and replace the line + + The Web Engineering Factory & Toolworks Developed by WEFT + +with the line + + The Web Engineering Factory & Toolworks Developed by WEFT + +## License +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 +parts of Smeagol into another open source project which uses a less restrictive +license, please contact me; I'm open to dual licensing it. + +## Prerequisites +You will need [Leiningen](https://github.com/technomancy/leiningen) 2.0 or above installed. + +You will need [node](https://nodejs.org/en/) and [bower](https://bower.io/) installed. + +## Running +To start a web server for the application, run: + + lein bower install + lein ring server + +Alternatively, if you want to deploy to a servlet container (which I would strongly recommend), the simplest thing is to run: + + lein bower install + lein ring uberwar + +(a command which I'm sure Smeagol would entirely appreciate) and deploy the resulting war file. + +## Experimental Docker image + +You can now run Smeagol as a [Docker](http://www.docker.com) image. To run my Docker image, use + + docker run simonbrooke/smeagol + +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 inspect --format '{{ .NetworkSettings.IPAddress }}' $(docker ps -q) + +Suppose this prints '10.10.10.10', then the URL to browse to will be http://10.10.10.10:8080/smeagol/ + +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. + +To build your own Docker image, run: + + lein clean + lein bower install + lein ring uberwar + lein docker build + +This will build a new Docker image locally; you can, obviously, push it to your own Docker repository if you wish. From 5d9462b7c30058e89a8f97dd72bbac13549ad81f Mon Sep 17 00:00:00 2001 From: simon Date: Sun, 12 Mar 2017 13:44:22 +0000 Subject: [PATCH 08/79] Added resources/public/vendor to .gitignore Since (I think) that's where bower installs stuff. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index b510bc5..210f0dc 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ pom.xml.asc /target/ /checkouts/ /resources/public/content/.git +/resources/public/vendor .lein-deps-sum .lein-repl-history .lein-plugins/ From 2f897089fee461776f102a7229de2d431e086905 Mon Sep 17 00:00:00 2001 From: simon Date: Sun, 12 Mar 2017 17:14:43 +0000 Subject: [PATCH 09/79] #15: Fix Rather nice and satisfactory. Slightly conflates the issue of configuration and internationalisation at present, but I think internationalisation is a target to hit as a separate job. --- .gitignore | 3 +- resources/config.edn | 104 +++++++++++++ resources/passwd | 2 +- resources/public/content/Introduction.md | 179 +++++++++++------------ resources/public/content/stylesheet.css | 11 +- resources/templates/auth.html | 12 +- resources/templates/base.html | 21 ++- resources/templates/edit-css.html | 9 +- resources/templates/edit-user.html | 14 +- resources/templates/edit-users.html | 8 +- resources/templates/edit.html | 6 +- resources/templates/history.html | 45 +++--- resources/templates/wiki.html | 4 +- src/smeagol/layout.clj | 6 + src/smeagol/routes/admin.clj | 14 +- src/smeagol/routes/params.clj | 0 src/smeagol/routes/wiki.clj | 43 +++--- 17 files changed, 295 insertions(+), 186 deletions(-) create mode 100644 resources/config.edn delete mode 100644 src/smeagol/routes/params.clj diff --git a/.gitignore b/.gitignore index 210f0dc..3d808a9 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,5 @@ pom.xml.asc .lein-plugins/ .lein-failures .lein-env - +.nrepl-port +smeagol.log* diff --git a/resources/config.edn b/resources/config.edn new file mode 100644 index 0000000..6afb713 --- /dev/null +++ b/resources/config.edn @@ -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 + } diff --git a/resources/passwd b/resources/passwd index 3744ac1..ddaec33 100644 --- a/resources/passwd +++ b/resources/passwd @@ -1 +1 @@ -{:admin {:admin true, :email "info@weft.scot", :password "admin"}} \ No newline at end of file +{:admin {:admin true, :email "info@weft.scot", :password "$s0$f0801$27PoPWXDignJVpW1YZ9XTQ==$7cBOqLnlfohYYVY+Xiwr0CNyXDaw5TasRdG3D2v7G90="}, :fred {:email "fred@flintstone.bc", :admin false, :password "$s0$f0801$DOSa7z2466L994V9VIsoCA==$5/GueN3WsR+r+fiSdmiJqZnbzdIwUx0BXR3yd9OK8Wc="}} \ No newline at end of file diff --git a/resources/public/content/Introduction.md b/resources/public/content/Introduction.md index 88de98d..18df529 100644 --- a/resources/public/content/Introduction.md +++ b/resources/public/content/Introduction.md @@ -1,91 +1,88 @@ -![One wiki to rule them all](https://www.weft.scot/images/smeagol.png) - -# 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. - -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 -Smeagol is now a fully working small Wiki engine, and meets my own immediate needs. - -## 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. - -## 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: - - {:admin {:password "admin" :email "admin@localhost" :admin true} - :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. - -## 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](http://vignette3.wikia.nocookie.net/lotr/images/e/e1/Gollum_Render.png/revision/latest?cb=20141218075509) - -## Todo -* Mechanism to add users through the user interface; - -## Advertisement -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/). - -### Phoning home -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 - - resources/templates/base.html - -and replace the line - - The Web Engineering Factory & Toolworks Developed by WEFT - -with the line - - The Web Engineering Factory & Toolworks Developed by WEFT - -## License -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 -parts of Smeagol into another open source project which uses a less restrictive -license, please contact me; I'm open to dual licensing it. - -## Prerequisites -You will need [Leiningen](https://github.com/technomancy/leiningen) 2.0 or above installed. - -You will need [node](https://nodejs.org/en/) and [bower](https://bower.io/) installed. - -## Running -To start a web server for the application, run: - - lein bower install - lein ring server - -Alternatively, if you want to deploy to a servlet container (which I would strongly recommend), the simplest thing is to run: - - lein bower install - lein ring uberwar - -(a command which I'm sure Smeagol would entirely appreciate) and deploy the resulting war file. - -## Experimental Docker image - -You can now run Smeagol as a [Docker](http://www.docker.com) image. To run my Docker image, use - - docker run simonbrooke/smeagol - -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 inspect --format '{{ .NetworkSettings.IPAddress }}' $(docker ps -q) - -Suppose this prints '10.10.10.10', then the URL to browse to will be http://10.10.10.10:8080/smeagol/ - -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. - -To build your own Docker image, run: - - lein clean - lein bower install - lein ring uberwar - lein docker build - -This will build a new Docker image locally; you can, obviously, push it to your own Docker repository if you wish. +![One wiki to rule them all](https://www.weft.scot/images/smeagol.png) + +# 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. + +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 +Smeagol is now a fully working small Wiki engine, and meets my own immediate needs. + +## 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. + +## 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: + + {:admin {:password "admin" :email "admin@localhost" :admin true} + :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. + +## 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](http://vignette3.wikia.nocookie.net/lotr/images/e/e1/Gollum_Render.png/revision/latest?cb=20141218075509) + +## Advertisement +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/). + +### Phoning home +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 + + resources/templates/base.html + +and replace the line + + The Web Engineering Factory & Toolworks Developed by WEFT + +with the line + + The Web Engineering Factory & Toolworks Developed by WEFT + +## License +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 +parts of Smeagol into another open source project which uses a less restrictive +license, please contact me; I'm open to dual licensing it. + +## Prerequisites +You will need [Leiningen](https://github.com/technomancy/leiningen) 2.0 or above installed. + +You will need [node](https://nodejs.org/en/) and [bower](https://bower.io/) installed. + +## Running +To start a web server for the application, run: + + lein bower install + lein ring server + +Alternatively, if you want to deploy to a servlet container (which I would strongly recommend), the simplest thing is to run: + + lein bower install + lein ring uberwar + +(a command which I'm sure Smeagol would entirely appreciate) and deploy the resulting war file. + +## Experimental Docker image + +You can now run Smeagol as a [Docker](http://www.docker.com) image. To run my Docker image, use + + docker run simonbrooke/smeagol + +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 inspect --format '{{ .NetworkSettings.IPAddress }}' $(docker ps -q) + +Suppose this prints '10.10.10.10', then the URL to browse to will be http://10.10.10.10:8080/smeagol/ + +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. + +To build your own Docker image, run: + + lein clean + lein bower install + lein ring uberwar + lein docker build + +This will build a new Docker image locally; you can, obviously, push it to your own Docker repository if you wish. diff --git a/resources/public/content/stylesheet.css b/resources/public/content/stylesheet.css index c19d52b..41020bb 100644 --- a/resources/public/content/stylesheet.css +++ b/resources/public/content/stylesheet.css @@ -224,20 +224,20 @@ li.nav-item a:active { background: gray; color: white; } width: 30%; float: right; position: fixed; - bottom: 1.5em; + bottom: 3.5em; right: 0; - z-index: 150; + z-index: 175; background: transparent; } /* about-cookies box: permanently visible part of cookies information box */ #about-cookies { clear: right; - width: 10em; font-size: 66%; float: right; text-align: right; padding: 0.25em 2em; + border-radius: 0.25em; color: white; 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 { display: none; - padding: 0.25em 2em; + padding: 0.5em 2em; + border-radius: 0.5em; color: white; background:rgba(40,40,40,0.8); border-bottom: thin solid white; @@ -277,7 +278,9 @@ li.nav-item a:active { background: gray; color: white; } .minor-controls { list-style: none; float: right; + right: 0; padding: 0.25em 2em; + border-radius: 0.25em; color: white; background:rgba(40,40,40,0.8); font-size: 66%; diff --git a/resources/templates/auth.html b/resources/templates/auth.html index 4eb63b0..ce56af0 100644 --- a/resources/templates/auth.html +++ b/resources/templates/auth.html @@ -5,21 +5,21 @@ {% if user %}

- - + +

{% else %}

- +

- +

- - + +

{% endif %} diff --git a/resources/templates/base.html b/resources/templates/base.html index 2d5c822..bc71820 100644 --- a/resources/templates/base.html +++ b/resources/templates/base.html @@ -1,7 +1,7 @@ - {{title}} + {{config.site-title}}: {{title}} @@ -13,23 +13,23 @@ -

{{title}}

+

{{config.site-title}}: {{title}}

{{header|safe}} {% if message %}
@@ -52,13 +52,10 @@

{{title}}

- 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. + {{config.cookies-more}}
- About cookies + {{config.cookies-about}}