mirror of
https://github.com/journeyman-cc/smeagol.git
synced 2026-04-12 18:05:06 +00:00
Merge branch 'develop'
This commit is contained in:
commit
5745eb12c7
28 changed files with 644 additions and 221 deletions
6
.gitignore
vendored
6
.gitignore
vendored
|
|
@ -7,9 +7,13 @@ pom.xml.asc
|
|||
/target/
|
||||
/checkouts/
|
||||
/resources/public/content/.git
|
||||
/resources/public/vendor
|
||||
.lein-deps-sum
|
||||
.lein-repl-history
|
||||
.lein-plugins/
|
||||
.lein-failures
|
||||
.lein-env
|
||||
|
||||
.nrepl-port
|
||||
smeagol.log*
|
||||
/node_modules/
|
||||
.DS_Store
|
||||
|
|
|
|||
3
Dockerfile
Normal file
3
Dockerfile
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
FROM tomcat:alpine
|
||||
COPY target/smeagol-*-standalone.war $CATALINA_HOME/webapps/smeagol.war
|
||||
|
||||
24
README.md
24
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
|
||||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@
|
|||
[lein-ancient "0.5.5" :exclusions [org.clojure/clojure org.clojure/data.xml]]
|
||||
[lein-marginalia "0.7.1" :exclusions [org.clojure/clojure]]]
|
||||
: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}
|
||||
|
|
|
|||
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,14 +1,15 @@
|
|||

|
||||
|
||||
# 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.
|
||||
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. Here's an example [[Internal Link]].
|
||||
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:
|
||||
|
|
@ -23,11 +24,8 @@ Smeagol does not currently have any mechanism to upload images. You can, however
|
|||
|
||||

|
||||
|
||||
## 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 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
|
||||
|
|
@ -66,6 +64,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
|
||||
|
||||
## Editing the framing content
|
||||
You can edit the [stylesheet](/edit-css?page=stylesheet), the [[\_left-bar]], the [[\_edit-left-bar]], and the [[\_header]].
|
||||
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.
|
||||
|
|
|
|||
|
|
@ -82,8 +82,10 @@ header h1 {
|
|||
margin-top: 0;
|
||||
}
|
||||
|
||||
header img {
|
||||
float: right;
|
||||
img {
|
||||
border: 0;
|
||||
padding: 0;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
input {
|
||||
|
|
@ -115,14 +117,6 @@ label {
|
|||
display: inline-block;
|
||||
}
|
||||
|
||||
menu li {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
menu li::before {
|
||||
content: "|| ";
|
||||
}
|
||||
|
||||
table {
|
||||
border: 2px solid black;
|
||||
border-collapse: collapse;
|
||||
|
|
@ -147,58 +141,6 @@ th {
|
|||
## ids generally in document order
|
||||
*/
|
||||
|
||||
/* top-of-page navigation, not editable, provided by Smeagol */
|
||||
#nav{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
_position: absolute;
|
||||
_top: expression(document.documentElement.scrollTop);
|
||||
z-index: 149;
|
||||
background:rgba(40,40,40,0.8);
|
||||
}
|
||||
|
||||
#user {
|
||||
font-height: 66%;
|
||||
float: right;
|
||||
padding: 0.1em 0.75em;
|
||||
margin: 0;
|
||||
color: white;
|
||||
}
|
||||
|
||||
#user a {
|
||||
color: silver;
|
||||
}
|
||||
|
||||
/* only needed for fly-out menu effect on tablet and phone stylesheets */
|
||||
#nav-icon {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#nav-menu {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#nav ul li {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
display: inline;
|
||||
}
|
||||
|
||||
#nav ul li a {
|
||||
color: white;
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
padding: 0.1em 0.75em;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#nav ul li.active a { background: silver;}
|
||||
li.nav-item a:hover { background: rgb( 240, 240, 240) }
|
||||
li.nav-item a:active { background: gray; color: white; }
|
||||
|
||||
/* Overall container div, holds all content of page. Yes, I know it shouldn't have fixed width */
|
||||
#main-container{
|
||||
}
|
||||
|
|
@ -211,33 +153,25 @@ li.nav-item a:active { background: gray; color: white; }
|
|||
float: left;
|
||||
}
|
||||
|
||||
/* content of the current in the Wiki - editable, provided by users. Within main-container */
|
||||
#content {
|
||||
border: thin solid silver;
|
||||
width: 80%;
|
||||
float: right;
|
||||
padding-bottom: 5em;
|
||||
}
|
||||
|
||||
/* cookies information box, fixed, in right margin, just above footer */
|
||||
#cookies {
|
||||
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 +179,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 +212,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%;
|
||||
|
|
@ -309,3 +246,212 @@ li.nav-item a:active { background: gray; color: white; }
|
|||
margin: 0;
|
||||
}
|
||||
|
||||
/* desktops and laptops, primarily. Adapted to mouse; targets may be small */
|
||||
@media all and (min-device-width: 1025px) {
|
||||
/* content of the current page in the Wiki - editable, provided by users. Within main-container */
|
||||
#content {
|
||||
border: thin solid silver;
|
||||
width: 80%;
|
||||
float: right;
|
||||
padding-bottom: 5em;
|
||||
}
|
||||
|
||||
#phone-side-bar, #phone-credits {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* top-of-page navigation, not editable, provided by Smeagol */
|
||||
#nav{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
_position: absolute;
|
||||
_top: expression(document.documentElement.scrollTop);
|
||||
z-index: 149;
|
||||
background:rgba(40,40,40,0.8);
|
||||
}
|
||||
|
||||
/* only needed for fly-out menu effect on tablet and phone stylesheets */
|
||||
#nav-icon {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#nav-menu {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#nav menu li {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
display: inline;
|
||||
}
|
||||
|
||||
#nav menu li a {
|
||||
color: white;
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
padding: 0.1em 0.75em;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#nav menu li.active a { background: gray;}
|
||||
li.nav-item a:hover { background: rgb( 240, 240, 240) }
|
||||
li.nav-item a:active { background: gray; color: white; }
|
||||
|
||||
#nav menu li#user {
|
||||
padding: 0 1em;
|
||||
float: right;
|
||||
}
|
||||
}
|
||||
|
||||
/* tablets, primarily. Adapted to touch; targets are larger */
|
||||
@media all and (min-device-width: 769px) and (max-device-width: 1024px) {
|
||||
h1 {
|
||||
/* I wouldn't normally use a px value, but the menu icon is 49px wide */
|
||||
padding: 0.25em 5%;
|
||||
padding-left: 100px;
|
||||
}
|
||||
|
||||
/* content of the current page in the Wiki - editable, provided by users. Within main-container */
|
||||
#content {
|
||||
border: thin solid silver;
|
||||
width: 80%;
|
||||
float: right;
|
||||
padding-bottom: 5em;
|
||||
}
|
||||
|
||||
#nav{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
position: fixed;
|
||||
z-index: 149;
|
||||
color: silver;
|
||||
background:rgba(40,40,40,0.9);
|
||||
}
|
||||
|
||||
#nav a {
|
||||
color: white;
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#nav:hover #nav-menu {
|
||||
display: block;
|
||||
list-style-type: none;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#nav-icon {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#nav-menu, #phone-side-bar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#nav menu li {
|
||||
padding: 0.5em;
|
||||
margin: 0.5 em;
|
||||
font-size: 150%;
|
||||
}
|
||||
|
||||
#nav menu li a {
|
||||
}
|
||||
|
||||
#nav ul li.active a { background: silver;}
|
||||
li.nav-item a:hover { background: rgb( 240, 240, 240) }
|
||||
li.nav-item a:active { background: gray; color: white; }
|
||||
|
||||
#nav menu #user {
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* phones, and, indeed, smaller phones. Adapted to touch; display radically
|
||||
* decluttered */
|
||||
@media all and (max-device-width: 768px) {
|
||||
footer {
|
||||
display: none;
|
||||
}
|
||||
|
||||
h1 {
|
||||
/* I wouldn't normally use a px value, but the menu icon is 49px wide */
|
||||
padding: 0.25em 5%;
|
||||
padding-left: 100px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
/* content of the current in the Wiki - editable, provided by users. Within main-container */
|
||||
#content {
|
||||
border: thin solid silver;
|
||||
width: 100%;
|
||||
padding-bottom: 2em;
|
||||
}
|
||||
|
||||
#main-container {
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
|
||||
#cookies {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#nav{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
position: fixed;
|
||||
z-index: 149;
|
||||
color: silver;
|
||||
background:rgba(40,40,40,0.9);
|
||||
}
|
||||
|
||||
#nav a {
|
||||
color: white;
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#nav:hover #nav-menu, #nav:hover #phone-side-bar {
|
||||
display: block;
|
||||
list-style-type: none;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#nav-icon {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#nav-menu, #phone-side-bar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#nav menu li {
|
||||
padding: 0.5em;
|
||||
margin: 0.5 em;
|
||||
font-size: 150%;
|
||||
}
|
||||
|
||||
#nav menu li a {
|
||||
}
|
||||
|
||||
#nav ul li.active a { background: silver;}
|
||||
li.nav-item a:hover { background: rgb( 240, 240, 240) }
|
||||
li.nav-item a:active { background: gray; color: white; }
|
||||
|
||||
#nav menu #user {
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#side-bar {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,13 +42,13 @@ body {
|
|||
display: none;
|
||||
}
|
||||
|
||||
#nav ul li {
|
||||
#nav menu li {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
display: inline;
|
||||
}
|
||||
|
||||
#nav ul li a {
|
||||
#nav menu li a {
|
||||
color: white;
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
|
|
|
|||
BIN
resources/public/img/three-lines.png
Normal file
BIN
resources/public/img/three-lines.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 665 B |
88
resources/public/img/three-lines.svg
Normal file
88
resources/public/img/three-lines.svg
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="210mm"
|
||||
height="297mm"
|
||||
viewBox="0 0 744.09448819 1052.3622047"
|
||||
id="svg2"
|
||||
version="1.1"
|
||||
inkscape:version="0.91 r13725"
|
||||
sodipodi:docname="three-lines.svg">
|
||||
<defs
|
||||
id="defs4" />
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="0.7"
|
||||
inkscape:cx="16.791691"
|
||||
inkscape:cy="509.7116"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="true"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="996"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="28"
|
||||
inkscape:window-maximized="1">
|
||||
<inkscape:grid
|
||||
type="xygrid"
|
||||
id="grid4136" />
|
||||
</sodipodi:namedview>
|
||||
<metadata
|
||||
id="metadata7">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1">
|
||||
<rect
|
||||
style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:#060000;stroke-width:1.324;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.51906158"
|
||||
id="rect4172"
|
||||
width="580"
|
||||
height="440"
|
||||
x="40"
|
||||
y="72.362206" />
|
||||
<rect
|
||||
style="opacity:1;fill:#000000;fill-opacity:1;stroke:#060000;stroke-width:1.324;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.51906158"
|
||||
id="rect4138"
|
||||
width="540"
|
||||
height="80"
|
||||
x="60"
|
||||
y="92.362206" />
|
||||
<rect
|
||||
y="252.36221"
|
||||
x="60"
|
||||
height="80"
|
||||
width="540"
|
||||
id="rect4149"
|
||||
style="opacity:1;fill:#000000;fill-opacity:1;stroke:#060000;stroke-width:1.324;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.51906158" />
|
||||
<rect
|
||||
style="opacity:1;fill:#000000;fill-opacity:1;stroke:#060000;stroke-width:1.324;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.51906158"
|
||||
id="rect4151"
|
||||
width="540"
|
||||
height="80"
|
||||
x="60"
|
||||
y="412.36221" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.7 KiB |
BIN
resources/public/img/three-lines.xcf
Normal file
BIN
resources/public/img/three-lines.xcf
Normal file
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 260 B |
|
|
@ -2,24 +2,25 @@
|
|||
{% block content %}
|
||||
<div id="content" class="auth">
|
||||
<form action="{{servlet-context}}/auth" method="POST">
|
||||
{% csrf-field %}
|
||||
<input type="hidden" name="redirect-to" value="{{redirect-to}}"/>
|
||||
{% if user %}
|
||||
<p class="widget">
|
||||
<label for="submit">To finish editing</label>
|
||||
<input name="action" id="action" type="submit" class="action-dangerous" value="Logout!"/>
|
||||
<label for="submit">{{config.save-prompt}}</label>
|
||||
<input name="action" id="action" type="submit" class="action-dangerous" value="{{config.logout-label}}"/>
|
||||
</p>
|
||||
{% else %}
|
||||
<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/>
|
||||
</p>
|
||||
<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/>
|
||||
</p>
|
||||
<p class="widget">
|
||||
<label for="submit">To edit this wiki</label>
|
||||
<input name="action" id="action" type="submit" class="action" value="Login!"/>
|
||||
<label for="submit">{{config.login-prompt}}</label>
|
||||
<input name="action" id="action" type="submit" class="action" value="{{config.login-label}}"/>
|
||||
</p>
|
||||
{% endif %}
|
||||
</form>
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>{{title}}</title>
|
||||
<title>{{config.site-title}}: {{title}}</title>
|
||||
<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" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link href="{{servlet-context}}/content/stylesheet.css" media="screen" rel="stylesheet" type="text/css" />
|
||||
<link href="{{servlet-context}}/css/print.css" media="print" rel="stylesheet" type="text/css" />
|
||||
{% block extra-headers %}
|
||||
{% endblock %}
|
||||
|
|
@ -12,24 +14,38 @@
|
|||
<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>
|
||||
{% 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>
|
||||
<img id="nav-icon" src="{{servlet-context}}/img/three-lines.png" alt="Menu"/>
|
||||
<menu id="nav-menu">
|
||||
<li class="{{wiki-selected}}"><a href="{{servlet-context}}/">{{config.home-link}}</a></li>
|
||||
{% if admin %}
|
||||
<li class="{{admin-selected}}"><a href="{{servlet-context}}/edit-users">Edit users</a></li>
|
||||
<li class="{{edit-users-selected}}"><a href="{{servlet-context}}/edit-users">{{config.edit-users-link}}</a></li>
|
||||
{% endif %}
|
||||
<li class="{{auth-selected}}"><a href="{{servlet-context}}/auth">
|
||||
{% if user %}
|
||||
Log out
|
||||
<li class="{{passwd-selected}}"><a href="passwd">{{config.change-pass-link}}</a></li>
|
||||
<li class="user" id="user">{{config.logged-in-as}} {{user}}</li>
|
||||
<li class="{{auth-selected}}"><a href="{{servlet-context}}/auth">
|
||||
{{config.logout-link}}</a></li>
|
||||
{% else %}
|
||||
Log in
|
||||
{% endif %}</a></li>
|
||||
</ul>
|
||||
<li class="{{auth-selected}}"><a href="{{servlet-context}}/auth">
|
||||
{{config.login-link}}</a></li>
|
||||
{% endif %}
|
||||
</menu>
|
||||
<div id="phone-side-bar" class="wiki">
|
||||
{{side-bar|safe}}
|
||||
<div id="phone-credits">
|
||||
<p>
|
||||
<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 & Toolworks"
|
||||
src="http://www.weft.scot/images/weft.logo.64.png">
|
||||
Developed by <a href="http://www.weft.scot/">WEFT</a>
|
||||
</p>
|
||||
</div>
|
||||
<h1>{{title}}</h1>
|
||||
</div>
|
||||
</div>
|
||||
<h1>{{config.site-title}}: {{title}}</h1>
|
||||
{{header|safe}}
|
||||
{% if message %}
|
||||
<div id="message">
|
||||
|
|
@ -52,13 +68,10 @@
|
|||
</div>
|
||||
<div id="cookies">
|
||||
<div id="more-about-cookies">
|
||||
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}}
|
||||
</div>
|
||||
<div id="about-cookies">
|
||||
About cookies
|
||||
{{config.cookies-about}}
|
||||
</div>
|
||||
</div>
|
||||
<footer>
|
||||
|
|
|
|||
|
|
@ -6,17 +6,14 @@
|
|||
<input type="hidden" name="page" value="{{page}}"/>
|
||||
<textarea name="src" id="src" rows="25" cols="80">{{content}}</textarea>
|
||||
<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"
|
||||
value="{%if exists%}{%else%}New file {{title}}{%endif%}" required/>
|
||||
</p>
|
||||
<p class="widget">
|
||||
<label for="submit">When you have finished editing</label>
|
||||
<input name="submit" id="submit" type="submit" class="action" value="Save!"/>
|
||||
<label for="submit">{{config.save-prompt}}</label>
|
||||
<input name="submit" id="submit" type="submit" class="action" value="{{config.save-label}}"/>
|
||||
</p>
|
||||
</form>
|
||||
</div>
|
||||
<script>
|
||||
var simplemde = new SimpleMDE();
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
|
|
|||
|
|
@ -4,28 +4,28 @@
|
|||
<div id="content" class="edit">
|
||||
<form action="{{servlet-context}}/edit-user" method="POST">
|
||||
<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/>
|
||||
</p>
|
||||
<p class="widget">
|
||||
<label for="pass1">New password</label>
|
||||
<label for="pass1">{{config.new-pass-prompt}}</label>
|
||||
<input name="pass1" id="pass1" type="password"/>
|
||||
</p>
|
||||
<p class="widget">
|
||||
<label for="pass2">And again</label>
|
||||
<label for="pass2">{{config.rpt-pass-prompt}}</label>
|
||||
<input name="pass2" id="pass2" type="password"/>
|
||||
</p>
|
||||
<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/>
|
||||
</p>
|
||||
<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 %}/>
|
||||
</p>
|
||||
<p class="widget">
|
||||
<label for="submit">When you have finished editing</label>
|
||||
<input name="submit" id="submit" type="submit" class="action" value="Save!"/>
|
||||
<label for="submit">{{config.save-prompt}}</label>
|
||||
<input name="submit" id="submit" type="submit" class="action" value="{{config.save-label}}"/>
|
||||
</p>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -4,16 +4,16 @@
|
|||
<div id="content">
|
||||
<table>
|
||||
<tr>
|
||||
<th>Edit</th><th>Delete</th>
|
||||
<th>{{config.edit-col-hdr}}</th><th>{{config.del-col-hdr}}</th>
|
||||
</tr>
|
||||
{% for user in users %}
|
||||
<tr>
|
||||
<td><a href="edit-user?target={{user}}">Edit {{user}}</a></td>
|
||||
<td><a href="delete-user?target={{user}}">Delete {{user}}</a></td>
|
||||
<td><a href="edit-user?target={{user}}">{{config.edit-col-hdr}} {{user}}</a></td>
|
||||
<td><a href="delete-user?target={{user}}">{{config.del-col-hdr}} {{user}}</a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
<tr>
|
||||
<td><a href="edit-user">Add new user</a></td>
|
||||
<td><a href="edit-user">{{config.add-user-label}}</a></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
|
|||
|
|
@ -10,13 +10,13 @@
|
|||
<input type="hidden" name="page" value="{{page}}"/>
|
||||
<textarea name="src" id="src" rows="25" cols="80">{{content}}</textarea>
|
||||
<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"
|
||||
value="{%if exists%}{%else%}New file {{title}}{%endif%}" required/>
|
||||
</p>
|
||||
<p class="widget">
|
||||
<label for="submit">When you have finished editing</label>
|
||||
<input name="submit" id="submit" type="submit" class="action" value="Save!"/>
|
||||
<label for="submit">{{config.save-prompt}}</label>
|
||||
<input name="submit" id="submit" type="submit" class="action" value="{{config.save-label}}"/>
|
||||
</p>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,15 +1,13 @@
|
|||
{% extends "templates/base.html" %}
|
||||
{% block content %}
|
||||
<div id="content" class="history">
|
||||
<table>
|
||||
<table class="music-ruled">
|
||||
<tr>
|
||||
<th>When</th><th>What</th><th>Version</th><th>Changes</th>
|
||||
<th>{{config.when-col-hdr}}</th>
|
||||
<th>{{config.what-col-hdr}}</th>
|
||||
<th>{{config.vers-col-hdr}}</th>
|
||||
<th>{{config.change-col-hdr}}</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Now</td><td></td>
|
||||
<td><a href="wiki?content={{page}}">[current]</a></td>
|
||||
<td>[no changes]</td>
|
||||
<tr>
|
||||
{% for entry in history %}
|
||||
<tr>
|
||||
<td>S
|
||||
|
|
@ -22,7 +20,7 @@
|
|||
<a href="version?page={{page}}&version={{entry.id}}">Show version</a>
|
||||
</td>
|
||||
<td>
|
||||
<a href="changes?page={{page}}&version={{entry.id}}">What's changed?</a>
|
||||
<a href="changes?page={{page}}&version={{entry.id}}">What's changed since?</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
|
|
|||
|
|
@ -3,20 +3,20 @@
|
|||
<div id="content" class="auth">
|
||||
<form action="{{servlet-context}}/passwd" method="POST">
|
||||
<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/>
|
||||
</p>
|
||||
<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/>
|
||||
</p>
|
||||
<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/>
|
||||
</p>
|
||||
<p class="widget">
|
||||
<label for="submit">To edit this wiki</label>
|
||||
<input name="action" id="action" type="submit" class="action" value="Change password!"/>
|
||||
<label for="submit">{{config.change-pass-prompt}}</label>
|
||||
<input name="action" id="action" type="submit" class="action" value="{{config.change-pass-link}}!"/>
|
||||
</p>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
<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>
|
||||
<li><a href="{{servlet-context}}/edit?page={{title}}">{{config.edit-page-link}}</a></li>
|
||||
<li><a href="history?page={{page}}">{{config.history-link}}</a></li>
|
||||
</ul>
|
||||
{% endif %}
|
||||
{{content|safe}}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
smeagol.layout
|
||||
(:require [selmer.parser :as parser]
|
||||
[clojure.string :as s]
|
||||
[noir.io :as io]
|
||||
[ring.util.response :refer [content-type response]]
|
||||
[compojure.response :refer [Renderable]]
|
||||
[environ.core :refer [env]]))
|
||||
|
|
@ -33,6 +34,10 @@
|
|||
|
||||
(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]
|
||||
Renderable
|
||||
|
|
@ -40,6 +45,7 @@
|
|||
(content-type
|
||||
(->> (assoc params
|
||||
(keyword (s/replace template #".html" "-selected")) "active"
|
||||
:config config
|
||||
:dev (env :dev)
|
||||
:servlet-context
|
||||
(if-let [context (:servlet-context request)]
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
user (session/get :user)]
|
||||
(layout/render "edit-users.html"
|
||||
(merge (util/standard-params request)
|
||||
{:title "Select user to edit"
|
||||
{:title (:edit-users-title layout/config)
|
||||
:users (auth/list-users)}))))
|
||||
|
||||
(defn delete-user
|
||||
|
|
@ -48,11 +48,11 @@
|
|||
(let [params (keywordize-keys (:params request))
|
||||
target (:target params)
|
||||
deleted (auth/delete-user target)
|
||||
message (if deleted (str "Successfully deleted user " target))
|
||||
error (if (not deleted) (str "Could not delete user " target))]
|
||||
message (if deleted (str (:del-user-success layout/config) " " target "."))
|
||||
error (if (not deleted) (str (:del-user-fail layout/config) " " target "."))]
|
||||
(layout/render "edit-users.html"
|
||||
(merge (util/standard-params request)
|
||||
{:title "Select user to edit"
|
||||
{:title (:edit-users-title layout/config)
|
||||
:message message
|
||||
:error error
|
||||
:users (auth/list-users)}))))
|
||||
|
|
@ -67,9 +67,9 @@
|
|||
password (if (and pass1 (auth/evaluate-password pass1 (:pass2 params))) pass1)
|
||||
stored (if (:email 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))
|
||||
(str "User " target " was not stored."))
|
||||
(str (:save-user-fail layout/config) " " target "."))
|
||||
details (auth/fetch-user-details target)]
|
||||
(if message
|
||||
(timbre/info message))
|
||||
|
|
@ -77,7 +77,7 @@
|
|||
(timbre/warn error))
|
||||
(layout/render "edit-user.html"
|
||||
(merge (util/standard-params request)
|
||||
{:title (str "Edit user " target)
|
||||
{:title (str (:edit-title-prefix layout/config) " " target)
|
||||
:message message
|
||||
:error error
|
||||
:target target
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -74,14 +74,14 @@
|
|||
(if
|
||||
(= suffix ".md")
|
||||
(url-encode page)
|
||||
"Introduction")))))
|
||||
(:default-page-title layout/config))))))
|
||||
|
||||
|
||||
(defn edit-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."
|
||||
([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]
|
||||
(let [params (keywordize-keys (:params request))
|
||||
src-text (:src params)
|
||||
|
|
@ -96,7 +96,7 @@
|
|||
true
|
||||
(layout/render template
|
||||
(merge (util/standard-params request)
|
||||
{:title (str "Edit " page)
|
||||
{:title (str (:edit-title-prefix layout/config) " " page)
|
||||
:page page
|
||||
:side-bar (util/local-links (util/md->html side-bar))
|
||||
:content (if exists? (io/slurp-resource (str "/content/" page suffix)) "")
|
||||
|
|
@ -113,7 +113,7 @@
|
|||
"Render the markdown page specified in this `request`, if any. If none found, redirect to edit-page"
|
||||
[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-path (str (io/resource-path) file-name)
|
||||
exists? (.exists (clojure.java.io/as-file file-path))]
|
||||
|
|
@ -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)))))
|
||||
|
|
@ -134,7 +135,7 @@
|
|||
if any. If none, error?"
|
||||
[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")
|
||||
repo-path (str (io/resource-path) "/content/")]
|
||||
(layout/render "history.html"
|
||||
|
|
@ -148,13 +149,13 @@
|
|||
"Render a specific historical version of a page"
|
||||
[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)
|
||||
file-name (str page ".md")
|
||||
repo-path (str (io/resource-path) "/content/")]
|
||||
(layout/render "wiki.html"
|
||||
(merge (util/standard-params request)
|
||||
{:title (str "Version " version " of " page)
|
||||
{:title (str (:vers-col-hdr layout/config) " " version " of " page)
|
||||
:page page
|
||||
:content (util/local-links
|
||||
(md/md-to-html-string
|
||||
|
|
@ -166,13 +167,13 @@
|
|||
"Render a diff between two versions of a page"
|
||||
[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)
|
||||
file-name (str page ".md")
|
||||
repo-path (str (io/resource-path) "/content/")]
|
||||
(layout/render "wiki.html"
|
||||
(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
|
||||
:content (d2h/diff2html (hist/diff repo-path file-name version))}))))
|
||||
|
||||
|
|
@ -187,7 +188,7 @@
|
|||
user (session/get :user)
|
||||
redirect-to (or (:redirect-to params) "/wiki")]
|
||||
(cond
|
||||
(= action "Logout!")
|
||||
(= action (:logout-label layout/config))
|
||||
(do
|
||||
(timbre/info (str "User " user " logging out"))
|
||||
(session/remove! :user)
|
||||
|
|
@ -199,7 +200,7 @@
|
|||
true
|
||||
(layout/render "auth.html"
|
||||
(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")
|
||||
:side-bar (util/local-links (util/md->html "/content/_side-bar.md"))
|
||||
:header (util/local-links (util/md->html "/content/_header.md"))
|
||||
|
|
@ -214,19 +215,21 @@
|
|||
pass1 (:pass1 params)
|
||||
pass2 (:pass2 params)
|
||||
user (session/get :user)
|
||||
message (cond
|
||||
(nil? oldpass) nil
|
||||
(and (auth/evaluate-password pass1 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...
|
||||
changed? (and
|
||||
(auth/evaluate-password pass1 pass2)
|
||||
(auth/change-pass user oldpass pass2))]
|
||||
(layout/render "passwd.html"
|
||||
(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"))
|
||||
:header (util/local-links (util/md->html "/content/_header.md"))
|
||||
:message message}))))
|
||||
:message (if changed? (:chpass-success layout/config))
|
||||
:error (cond
|
||||
(nil? oldpass) nil
|
||||
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
|
||||
|
|
|
|||
|
|
@ -37,9 +37,14 @@
|
|||
(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]
|
||||
(if html-src
|
||||
(cs/replace html-src #"\[\[[^\[\]]*\]\]"
|
||||
#(let [text (clojure.string/replace %1 #"[\[\]]" "")
|
||||
encoded (url-encode text)
|
||||
|
|
@ -47,7 +52,8 @@
|
|||
;; '_' is meaningful in Markdown. However, this needs to
|
||||
;; be stripped out when interpreting local links.
|
||||
munged (cs/replace encoded #"%26%2395%3B" "_")]
|
||||
(format "<a href='wiki?page=%s'>%s</a>" munged text))))
|
||||
(format "<a href='wiki?page=%s'>%s</a>" munged text)))
|
||||
no-text-error))
|
||||
|
||||
|
||||
(defn standard-params
|
||||
|
|
|
|||
13
test/smeagol/test/util.clj
Normal file
13
test/smeagol/test/util.clj
Normal file
|
|
@ -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]]") "<a href='wiki?page=froboz'>froboz</a>") "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"))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue