Seems all to be working now. You can't actually delete users through the user

interface, but you can add and edit them.
This commit is contained in:
simon 2016-09-11 16:01:51 +01:00
parent de7a553a86
commit 09fe67a26e
13 changed files with 351 additions and 193 deletions

View file

@ -1 +1 @@
{:admin {:password "admin", :email "admin@localhost"}}
{:admin {:admin true, :email "info@weft.scot", password "admin"}}

View file

@ -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:

View file

@ -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.

View file

@ -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;
}

1
resources/public/vendor/README.md vendored Normal file
View file

@ -0,0 +1 @@
This folder must exist in order that the Bower package manager can deploy JavaScript packages to it.

View file

@ -10,30 +10,27 @@
</head>
<body>
<header class="wiki">
<!-- navbar -->
<div id="nav">
{% if user %}
<p class="user" id="user">You are logged in as {{user}} | <a href="passwd">change password</a></p>
<!-- navbar -->
<div id="nav">
{% if user %}
<p class="user" id="user">You are logged in as {{user}} | <a href="passwd">change password</a></p>
{% endif %}
<img id="nav-icon" src="{{servlet-context}}/img/threelines.png" alt="Menu"/>
<ul id="nav-menu" class="nav">
<li class="{{wiki-selected}}"><a href="{{servlet-context}}/">Home</a></li>
{% if admin %}
<li class="{{admin-selected}}"><a href="{{servlet-context}}/edit-users">Edit users</a></li>
{% endif %}
<img id="nav-icon" src="{{servlet-context}}/img/threelines.png" alt="Menu"/>
<ul id="nav-menu" class="nav">
<li class="{{wiki-selected}}"><a href="{{servlet-context}}/">Home</a></li>
<li class="{{auth-selected}}"><a href="{{servlet-context}}/auth">
{% if user %}
Log out
{% else %}
Log in
{% endif %}</a></li>
</ul>
</div>
<h1>{{title}}</h1>
{{header|safe}}
</header>
<div id="side-bar" class="wiki">
{{side-bar|safe}}
</div>
<div id="main-container" class="container">
<li class="{{auth-selected}}"><a href="{{servlet-context}}/auth">
{% if user %}
Log out
{% else %}
Log in
{% endif %}</a></li>
</ul>
</div>
<h1>{{title}}</h1>
{{header|safe}}
{% if message %}
<div id="message">
<p class="message">{{message}}</p>
@ -44,7 +41,12 @@
<p class="error">{{error}}</p>
</div>
{% endif %}
</header>
<div id="side-bar" class="wiki">
{{side-bar|safe}}
</div>
<div id="main-container" class="container">
{% block content %}
{% endblock %}
</div>
@ -62,8 +64,8 @@
<footer>
<div id="credits">
<div>
One Wiki to rule them all ||
<img height="16" width="16" alt="one wiki to rule them all" src="img/smeagol.png"/>Smeagol wiki engine {{version}} ||
<img height="16" width="16" alt="one wiki to rule them all" src="img/smeagol.png"/>One Wiki to rule them all ||
Smeagol wiki engine {{version}} ||
<img height="16" width="16" alt="The Web Engineering Factory &amp; Toolworks" src="http://www.weft.scot/images/weft.logo.64.png"> Developed by <a href="http://www.weft.scot/">WEFT</a>
</div>
<div>

View file

@ -0,0 +1,32 @@
{% extends "templates/base.html" %}
{% block content %}
<div id="content" class="edit">
<form action="{{servlet-context}}/edit-user" method="POST">
<p class="widget">
<label for="target">Username</label>
<input type="text" name="target" id="target" value="{{target}}" required/>
</p>
<p class="widget">
<label for="pass1">New password</label>
<input name="pass1" id="pass1" type="password"/>
</p>
<p class="widget">
<label for="pass2">And again</label>
<input name="pass2" id="pass2" type="password"/>
</p>
<p class="widget">
<label for="email">Email address</label>
<input name="email" id="email" type="text" value="{{details.email}}" required/>
</p>
<p class="widget">
<label for="admin">Is administrator?</label>
<input name="admin" id="admin" type="checkbox" {% if details.admin %}checked{% endif %}/>
</p>
<p class="widget">
<label for="submit">When you have finished editing</label>
<input name="submit" id="submit" type="submit" class="action" value="Save!"/>
</p>
</form>
</div>
{% endblock %}

View file

@ -0,0 +1,12 @@
{% extends "templates/base.html" %}
{% block content %}
<div id="content">
<ul>
{% for user in users %}
<li><a href="edit-user?target={{user}}">{{user}}</a></li>
{% endfor %}
<li><a href="edit-user">Add new user</a></li>
</ul>
</div>
{% endblock %}

View file

@ -3,20 +3,20 @@
<div id="content" class="auth">
<form action="{{servlet-context}}/passwd" method="POST">
<p class="widget">
<label for="password">Your password</label>
<label for="oldpass">Your password</label>
<input name="oldpass" id="oldpass" type="password" required/>
</p>
<p class="widget">
<label for="password">New password</label>
<label for="pass1">New password</label>
<input name="pass1" id="pass1" type="password" required/>
</p>
<p class="widget">
<label for="password">And again</label>
<label for="pass2">And again</label>
<input name="pass2" id="pass2" type="password" required/>
</p>
<p class="widget">
<label for="submit">To edit this wiki</label>
<input name="action" id="action" type="submit" class="action" value="Login!"/>
<input name="action" id="action" type="submit" class="action" value="Change password!"/>
</p>
</form>
</div>

View file

@ -2,10 +2,12 @@
{% block content %}
<div id="content" class="wiki">
{% if editable %}
<ul class="minor-controls">
<li><a href="{{servlet-context}}/edit?page={{title}}">Edit this page</a></li>
<li><a href="history?page={{page}}">History</a></li>
</ul>
{{content|safe}}
{% endif %}
{{content|safe}}
</div>
{% endblock %}