From 09fe67a26ecf848d51e5d1818a78d6e8d26bfa5e Mon Sep 17 00:00:00 2001 From: simon Date: Sun, 11 Sep 2016 16:01:51 +0100 Subject: [PATCH] Seems all to be working now. You can't actually delete users through the user interface, but you can add and edit them. --- resources/passwd | 2 +- resources/public/content/Introduction.md | 6 +- resources/public/content/_header.md | 2 +- resources/public/content/stylesheet.css | 158 ++++++++++++----------- resources/public/vendor/README.md | 1 + resources/templates/base.html | 52 ++++---- resources/templates/edit-user.html | 32 +++++ resources/templates/edit-users.html | 12 ++ resources/templates/passwd.html | 8 +- resources/templates/wiki.html | 4 +- src/smeagol/authenticate.clj | 118 +++++++++++++---- src/smeagol/handler.clj | 4 - src/smeagol/routes/wiki.clj | 145 +++++++++++++-------- 13 files changed, 351 insertions(+), 193 deletions(-) create mode 100644 resources/public/vendor/README.md create mode 100644 resources/templates/edit-user.html create mode 100644 resources/templates/edit-users.html diff --git a/resources/passwd b/resources/passwd index d7b2afd..a4caeb6 100644 --- a/resources/passwd +++ b/resources/passwd @@ -1 +1 @@ -{:admin {:password "admin", :email "admin@localhost"}} +{:admin {:admin true, :email "info@weft.scot", password "admin"}} diff --git a/resources/public/content/Introduction.md b/resources/public/content/Introduction.md index 123abf8..ae4b565 100644 --- a/resources/public/content/Introduction.md +++ b/resources/public/content/Introduction.md @@ -8,18 +8,16 @@ Smeagol is now a fully working small Wiki engine, and meets my own immediate nee 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. +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 {: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. -There's still no mechanism to add a new user to the system through the user interface; you do still have to do that by editing the password file in an editor. - ## Images Smeagol does not currently have any mechanism to upload images. You can, however, link to images already available on the web, like this: diff --git a/resources/public/content/_header.md b/resources/public/content/_header.md index 2165f3a..d50260c 100644 --- a/resources/public/content/_header.md +++ b/resources/public/content/_header.md @@ -1 +1 @@ -This is the header. There isn't yet much in it. You could [edit](edit?page=_header) it to provide internal navigation or branding. +This is the header. There isn't yet much in it. You could [edit](edit?page=_header) it to provide internal navigation or branding. diff --git a/resources/public/content/stylesheet.css b/resources/public/content/stylesheet.css index ef81280..c19d52b 100644 --- a/resources/public/content/stylesheet.css +++ b/resources/public/content/stylesheet.css @@ -20,6 +20,8 @@ USA. # The Stylesheet + + ## html elements generally in alphabetic order */ body { @@ -28,6 +30,18 @@ body { font-family: sans-serif; } +del { + color: red; +} + +div.content, form, p, pre, h1, h2, h3, h4, h5 { + padding: 0.25em 5%; +} + +dl, menu, ol, table, ul { + margin: 0.25em 5%; +} + /* footer of the page - not-editable, provided by Smeagol */ footer { border-top: thin solid gray; @@ -52,6 +66,9 @@ footer div { padding: 0.1em; } +form { + border: thin solid silver; +} /* header for all pages in the Wiki - editable, provided by users. */ header { @@ -69,7 +86,66 @@ header img { float: right; } -/* ids generally in document order */ +input { + background-color: white; +} + +input.action { + background-color: green; +} + +input.action-dangerous { + color: white; + background-color: red; +} + +input.required:after { + content: " \*"; + color: red; +} + +ins { + color: green; +} + +label { + width: 20%; + min-width: 20em; + border-right: thin solid gray; + display: inline-block; +} + +menu li { + display: inline; +} + +menu li::before { + content: "|| "; +} + +table { + border: 2px solid black; + border-collapse: collapse; +} + +table.music-ruled tr:nth-child(odd) { + background-color: silver; +} + +th, td { + text-align: left; + vertical-align: top; + padding: 0.15em 1.5em; + border: 1px solid gray; +} + +th { + background-color: silver; +} + +/* + ## ids generally in document order + */ /* top-of-page navigation, not editable, provided by Smeagol */ #nav{ @@ -180,22 +256,22 @@ li.nav-item a:active { background: gray; color: white; } display: block; } - - .change { background-color: rgb( 223, 223, 223); border: thin solid silver; } - .error { width: 100%; background-color: red; color: white; + border: thin solid maroon; } .message { - border: thin solid red; + color: darkgreen; + background-color: silver; + border: thin solid lime; } .minor-controls { @@ -233,75 +309,3 @@ li.nav-item a:active { background: gray; color: white; } margin: 0; } -form { - border: thin solid silver; -} - -del { - color: red; -} - -div.content, form, p, pre, h1, h2, h3, h4, h5 { - padding: 0.25em 5%; -} - -dl, menu, ol, table, ul { - margin: 0.25em 5%; -} - -input { - background-color: white; -} - -input.action { - background-color: green; -} - -input.action-dangerous { - color: white; - background-color: red; -} - -input.required:after { - content: " \*"; - color: red; -} - -ins { - color: green; -} - -label { - width: 20%; - min-width: 20em; - border-right: thin solid gray; -} - -menu li { - display: inline; -} - -menu li::before { - content: "|| "; -} - -table { - border: 2px solid black; - border-collapse: collapse; -} - -table.music-ruled tr:nth-child(odd) { - background-color: silver; -} - -th, td { - text-align: left; - vertical-align: top; - padding: 0.15em 1.5em; - border: 1px solid gray; -} - -th { - background-color: silver; -} - diff --git a/resources/public/vendor/README.md b/resources/public/vendor/README.md new file mode 100644 index 0000000..c3ab41c --- /dev/null +++ b/resources/public/vendor/README.md @@ -0,0 +1 @@ +This folder must exist in order that the Bower package manager can deploy JavaScript packages to it. diff --git a/resources/templates/base.html b/resources/templates/base.html index 76f43ff..2d5c822 100644 --- a/resources/templates/base.html +++ b/resources/templates/base.html @@ -10,30 +10,27 @@
- -
- - -
+
  • + {% if user %} + Log out + {% else %} + Log in + {% endif %}
  • + +
    +

    {{title}}

    + {{header|safe}} {% if message %}

    {{message}}

    @@ -44,7 +41,12 @@

    {{error}}

    {% endif %} + + +
    {% block content %} {% endblock %}
    @@ -62,8 +64,8 @@