Tactical commit

This commit is contained in:
Simon Brooke 2020-02-19 15:24:08 +00:00
parent 0649ecf195
commit 03c63da19e
No known key found for this signature in database
GPG key ID: A7A4F18D1D4DF987
6 changed files with 127 additions and 122 deletions

View file

@ -24,16 +24,6 @@
## html elements generally in alphabetic order ## html elements generally in alphabetic order
*/ */
a {
color: darkgray;
font-weight: bold;
}
a:hover {
color: darkgray;
background:rgba(200,200,200,0.8);
}
body { body {
margin: 0; margin: 0;
padding: 0; padding: 0;
@ -62,15 +52,14 @@ dd {
/* footer of the page - not-editable, provided by Smeagol */ /* footer of the page - not-editable, provided by Smeagol */
footer { footer {
border-top: thin solid silver; border-top: thin solid gray;
color: gray;
background:rgba(200,200,200,0.8);
clear: both; clear: both;
font-size: smaller; font-size: smaller;
text-align: center; text-align: center;
color: gray;
background: rgba(224,224,224,0.95);
width: 100%; width: 100%;
margin: 0; margin: 0;
min-height: 4px;
padding: 0.25em 0; padding: 0.25em 0;
bottom:0; bottom:0;
position:fixed; position:fixed;
@ -82,14 +71,9 @@ footer {
} }
footer div { footer div {
display: none;
padding: 0.1em; padding: 0.1em;
} }
footer:hover div {
display: block;
}
form { form {
border: thin solid silver; border: thin solid silver;
} }
@ -99,6 +83,8 @@ header {
margin-top: 0; margin-top: 0;
width:100%; width:100%;
max-width: 100%; max-width: 100%;
background-color: gray;
color: white;
} }
header h1 { header h1 {
@ -107,6 +93,7 @@ header h1 {
header a { header a {
font-weight: bold; font-weight: bold;
color: white;
} }
header a:hover { header a:hover {
@ -144,12 +131,12 @@ ins {
label { label {
width: 20%; width: 20%;
min-width: 20em; min-width: 20em;
border-right: thin solid silver; border-right: thin solid gray;
display: inline-block; display: inline-block;
} }
table { table {
border: thin solid silver; border: 2px solid black;
border-collapse: collapse; border-collapse: collapse;
} }
@ -161,7 +148,7 @@ th, td {
text-align: left; text-align: left;
vertical-align: top; vertical-align: top;
padding: 0.15em 1.5em; padding: 0.15em 1.5em;
border: 1px solid silver; border: 1px solid gray;
} }
th { th {
@ -179,7 +166,6 @@ th {
/* left bar for all pages in the Wiki - editable, provided by users. Within main-container */ /* left bar for all pages in the Wiki - editable, provided by users. Within main-container */
#side-bar { #side-bar {
display: none;
width: 17%; width: 17%;
height: 100%; height: 100%;
float: left; float: left;
@ -187,10 +173,10 @@ th {
/* cookies information box, fixed, in right margin, just above footer */ /* cookies information box, fixed, in right margin, just above footer */
#cookies { #cookies {
width: 20%; width: 30%;
float: right; float: right;
position: fixed; position: fixed;
bottom: 8px; bottom: 3.5em;
right: 0; right: 0;
z-index: 175; z-index: 175;
background: transparent; background: transparent;
@ -204,8 +190,8 @@ th {
text-align: right; text-align: right;
padding: 0.25em 2em; padding: 0.25em 2em;
border-radius: 0.25em; border-radius: 0.25em;
color: gray; color: white;
background:rgba(200,200,200,0.8); background:rgba(40,40,40,0.8);
} }
/* more-about-cookies box, normally hidden */ /* more-about-cookies box, normally hidden */
@ -213,9 +199,9 @@ th {
display: none; display: none;
padding: 0.5em 2em; padding: 0.5em 2em;
border-radius: 0.5em; border-radius: 0.5em;
color: gray; color: white;
background:rgba(200,200,200,0.8); background:rgba(40,40,40,0.8);
border-bottom: thin solid gray; border-bottom: thin solid white;
} }
/* but magically appears on mouseover */ /* but magically appears on mouseover */
@ -256,8 +242,8 @@ th {
right: 0; right: 0;
padding: 0.25em 2em; padding: 0.25em 2em;
border-radius: 0.25em; border-radius: 0.25em;
color: gray; color: white;
background:rgba(200,200,200,0.8); background:rgba(40,40,40,0.8);
font-size: 66%; font-size: 66%;
} }
@ -268,11 +254,7 @@ th {
.minor-controls a { .minor-controls a {
float: right; float: right;
padding: 0.25em 2em; padding: 0.25em 2em;
color: gray; color: white;
}
.minor-controls a:hover {
color: darkgray;
} }
.pseudo-input { .pseudo-input {
@ -321,7 +303,8 @@ th {
/* content of the current page in the Wiki - editable, provided by users. Within main-container */ /* content of the current page in the Wiki - editable, provided by users. Within main-container */
#content { #content {
border: thin solid silver; border: thin solid silver;
width: 100%; width: 80%;
float: right;
padding-bottom: 5em; padding-bottom: 5em;
} }
@ -329,29 +312,16 @@ th {
display: none; display: none;
} }
#header {
font-size: smaller;
}
/* top-of-page navigation, not editable, provided by Smeagol */ /* top-of-page navigation, not editable, provided by Smeagol */
#nav{ #nav{
margin: 0; margin: 0;
padding: 0; padding: 0;
top: 0; top: 0;
min-height: 4px; width: 100%;
_position: absolute; _position: absolute;
_top: expression(document.documentElement.scrollTop); _top: expression(document.documentElement.scrollTop);
z-index: 149; z-index: 149;
color: gray; background:rgba(40,40,40,0.8);
background:rgba(200,200,200,0.8);
}
#nav #nav-menu {
display: none;
}
#nav:hover #nav-menu {
display: block;
} }
/* only needed for fly-out menu effect on tablet and phone stylesheets */ /* only needed for fly-out menu effect on tablet and phone stylesheets */
@ -371,14 +341,14 @@ th {
} }
#nav menu li a { #nav menu li a {
color: gray; color: white;
text-decoration: none; text-decoration: none;
font-weight: bold; font-weight: bold;
padding: 0.1em 0.75em; padding: 0.1em 0.75em;
margin: 0; margin: 0;
} }
#nav menu li.active a { background: gray; color: white;} #nav menu li.active a { background: gray;}
li.nav-item a:hover { background: rgb( 240, 240, 240) } li.nav-item a:hover { background: rgb( 240, 240, 240) }
li.nav-item a:active { background: gray; color: white; } li.nav-item a:active { background: gray; color: white; }
@ -409,15 +379,17 @@ th {
padding: 0; padding: 0;
position: fixed; position: fixed;
z-index: 149; z-index: 149;
color: black; color: silver;
background:rgba(200,200,200,0.9); background:rgba(40,40,40,0.9);
} }
#nav a { #nav a {
color: white;
text-decoration: none;
font-weight: bold; font-weight: bold;
} }
#nav:hover #nav-menu, #nav:hover #phone-side-bar { #nav:hover #nav-menu {
display: block; display: block;
list-style-type: none; list-style-type: none;
width: 100%; width: 100%;
@ -483,21 +455,18 @@ th {
display: none; display: none;
} }
#header {
display: none;
}
#nav{ #nav{
margin: 0; margin: 0;
padding: 0; padding: 0;
position: fixed; position: fixed;
z-index: 149; z-index: 149;
color: black; color: silver;
background:rgba(200,200,200,0.9); background:rgba(40,40,40,0.9);
} }
#nav a { #nav a {
color: black; color: white;
text-decoration: none;
font-weight: bold; font-weight: bold;
} }
@ -522,8 +491,6 @@ th {
} }
#nav menu li a { #nav menu li a {
color: black;
font-weight: bold;
} }
#nav ul li.active a { background: silver;} #nav ul li.active a { background: silver;}

View file

@ -10,6 +10,7 @@
[smeagol.extensions.mermaid :refer [process-mermaid]] [smeagol.extensions.mermaid :refer [process-mermaid]]
[smeagol.extensions.photoswipe :refer [process-photoswipe]] [smeagol.extensions.photoswipe :refer [process-photoswipe]]
[smeagol.extensions.vega :refer [process-vega]] [smeagol.extensions.vega :refer [process-vega]]
[smeagol.local-links :refer :all]
[taoensso.timbre :as log])) [taoensso.timbre :as log]))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -44,26 +45,6 @@
;;;; ;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Error to show if text to be rendered is nil.
;; TODO: this should go through i18n
(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 (cs/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 "<a href='wiki?page=%s'>%s</a>" munged text)))
no-text-error))
(declare process-text) (declare process-text)
@ -133,26 +114,10 @@
result result
{:inclusions {inky (eval (list formatter (subs fragment (count token)) index))} {:inclusions {inky (eval (list formatter (subs fragment (count token)) index))}
:extensions {fkey (-> config :formatters fkey)}}) :extensions {fkey (-> config :formatters fkey)}})
;; (assoc-in
;; (assoc-in result [:inclusions inky] (eval (list formatter (subs fragment (count token)) index)))
;; [:extensions fkey] (-> config :formatters fkey))
(rest fragments) (rest fragments)
(cons inky processed)))) (cons inky processed))))
;; (apply-formatter
;; 3
;; {:inclusions {}}
;; '()
;; '()
;; "pswp
;; ![Frost on a gate, Laurieston](content/uploads/g1.jpg)
;; ![Feathered crystals on snow surface, Taliesin](content/uploads/g2.jpg)
;; ![Feathered snow on log, Taliesin](content/uploads/g3.jpg)
;; ![Crystaline growth on seed head, Taliesin](content/uploads/g4.jpg)"
;; "pswp"
;; smeagol.extensions.photoswipe/process-photoswipe)
(defn reassemble-text (defn reassemble-text
"Reassemble these processed strings into a complete text, and process it as "Reassemble these processed strings into a complete text, and process it as
Markdown." Markdown."

View file

@ -0,0 +1,50 @@
(ns ^{:doc "Format Semagol's local links."
:author "Simon Brooke"}
smeagol.local-links
(:require [clojure.data.json :as json]
[clojure.string :as cs]
[cemerick.url :refer (url url-encode url-decode)]))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;
;;;; 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
;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Error to show if text to be rendered is nil.
;; TODO: this should go through i18n
(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 (cs/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 "<a href='wiki?page=%s'>%s</a>" munged text)))
no-text-error))

View file

@ -11,6 +11,7 @@
[scot.weft.i18n.core :as i18n] [scot.weft.i18n.core :as i18n]
[smeagol.authenticate :as auth] [smeagol.authenticate :as auth]
[smeagol.configuration :refer [config]] [smeagol.configuration :refer [config]]
[smeagol.local-links :refer :all]
[taoensso.timbre :as log])) [taoensso.timbre :as log]))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -135,9 +136,13 @@
:admin (auth/get-admin user) :admin (auth/get-admin user)
:js-from (:js-from config) :js-from (:js-from config)
:side-bar (md/md-to-html-string :side-bar (md/md-to-html-string
(slurp (cjio/file content-dir "_side-bar.md")):heading-anchors true) (local-links
(slurp (cjio/file content-dir "_side-bar.md")))
:heading-anchors true)
:header (md/md-to-html-string :header (md/md-to-html-string
(slurp (cjio/file content-dir "_header.md")) :heading-anchors true) (local-links
(slurp (cjio/file content-dir "_header.md")))
:heading-anchors true)
:version (System/getProperty "smeagol.version")})) :version (System/getProperty "smeagol.version")}))

View file

@ -1,20 +1,24 @@
(ns smeagol.test.formatting (ns smeagol.test.formatting
(:require [clojure.test :refer :all] (:require [clojure.test :refer :all]
[smeagol.formatting :refer [local-links no-text-error]] [smeagol.formatting :refer :all]
[smeagol.extensions.test :refer :all])) [smeagol.extensions.test :refer :all]
[smeagol.local-links :refer :all]))
(deftest test-local-links (deftest test-apply-formatter
(testing "Rewriting of local links" (testing "apply-formatter"
(is (= (local-links nil) no-text-error) "Should NOT fail with a no pointer exception!") (let [actual (-> (apply-formatter
(is (= (local-links "") "") "Empty string should pass through unchanged.") 3
(is (= (local-links "[[froboz]]") "<a href='wiki?page=froboz'>froboz</a>") "Local link should be rewritten.") {:inclusions {}}
(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")))) "test
![Frost on a gate, Laurieston](content/uploads/g1.jpg)
;; (deftest test-process-text ![Feathered crystals on snow surface, Taliesin](content/uploads/g2.jpg)
;; (testing "The process-text flow" ![Feathered snow on log, Taliesin](content/uploads/g3.jpg)
;; (let [expected process-test-return-value ![Crystaline growth on seed head, Taliesin](content/uploads/g4.jpg)"
;; actual (process-text "```test "test"
;; ```")] smeagol.extensions.test/process-test)
;; (is (= actual expected))))) :inclusions
:inclusion-3)
expected "<!-- The test extension has run and this is its output -->"]
(is (= actual expected)))))

View file

@ -0,0 +1,14 @@
(ns smeagol.test.local-links
(:require [clojure.test :refer :all]
[smeagol.local-links :refer [local-links no-text-error]]
[smeagol.extensions.test :refer :all]
[smeagol.local-links :refer :all]))
(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"))))