diff --git a/.gitignore b/.gitignore index b510bc5..41eb940 100644 --- a/.gitignore +++ b/.gitignore @@ -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 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..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 @@ -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 40eeea6..84a2537 100644 --- a/project.clj +++ b/project.clj @@ -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} 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..fe61aaf 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 "admin"}} diff --git a/resources/public/content/Introduction.md b/resources/public/content/Introduction.md index ae4b565..18df529 100644 --- a/resources/public/content/Introduction.md +++ b/resources/public/content/Introduction.md @@ -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. diff --git a/resources/public/content/stylesheet.css b/resources/public/content/stylesheet.css index c19d52b..a9d64f9 100644 --- a/resources/public/content/stylesheet.css +++ b/resources/public/content/stylesheet.css @@ -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; + } +} diff --git a/resources/public/css/tablet.css b/resources/public/css/tablet.css index 714c179..78d736a 100644 --- a/resources/public/css/tablet.css +++ b/resources/public/css/tablet.css @@ -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; diff --git a/resources/public/img/three-lines.png b/resources/public/img/three-lines.png new file mode 100644 index 0000000..c7895a9 Binary files /dev/null and b/resources/public/img/three-lines.png differ diff --git a/resources/public/img/three-lines.svg b/resources/public/img/three-lines.svg new file mode 100644 index 0000000..c97c8c9 --- /dev/null +++ b/resources/public/img/three-lines.svg @@ -0,0 +1,88 @@ + + + + diff --git a/resources/public/img/three-lines.xcf b/resources/public/img/three-lines.xcf new file mode 100644 index 0000000..23b8a42 Binary files /dev/null and b/resources/public/img/three-lines.xcf differ diff --git a/resources/public/img/threelines.png b/resources/public/img/threelines.png deleted file mode 100644 index f26babb..0000000 Binary files a/resources/public/img/threelines.png and /dev/null differ diff --git a/resources/templates/auth.html b/resources/templates/auth.html index 4eb63b0..87ffbe2 100644 --- a/resources/templates/auth.html +++ b/resources/templates/auth.html @@ -1,27 +1,28 @@ {% extends "templates/base.html" %} {% block content %}