Small, mainly cosmetic tweaks, but including enabling links in the left bar

which were formerly broken.
This commit is contained in:
simon 2015-01-08 22:48:38 +00:00
parent 8edd392ba9
commit 941b7b54ff
3 changed files with 20 additions and 18 deletions

View file

@ -7,7 +7,7 @@
+ \!\[image alt text\]\(http://url.of.image\) + \!\[image alt text\]\(http://url.of.image\)
+ \+ (at start of line) ordinary bulleted lists + \+ (at start of line) ordinary bulleted lists
+ \1\. (at start of line) numbered lists + \1\. (at start of line) numbered lists
+ \**bold*\* + \*\***bold**\*\*
+ \__italic_\_ + \__italic_\_
More documentation [here](http://daringfireball.net/projects/markdown/syntax) More documentation [here](http://daringfireball.net/projects/markdown/syntax)

View file

@ -42,7 +42,8 @@ body {
font-height: 66%; font-height: 66%;
float: right; float: right;
padding: 0.1em 0.75em; padding: 0.1em 0.75em;
margin: 0; margin: 0;
color: silver;
} }
/* only needed for fly-out menu effect on tablet and phone stylesheets */ /* only needed for fly-out menu effect on tablet and phone stylesheets */
@ -94,6 +95,7 @@ li.nav-item a:active { background: gray; color: white; }
border: thin solid silver; border: thin solid silver;
width: 80%; width: 80%;
float: right; float: right;
padding-bottom: 5em;
} }

View file

@ -27,6 +27,14 @@
[smeagol.layout :as layout] [smeagol.layout :as layout]
[smeagol.util :as util])) [smeagol.util :as util]))
(defn local-links
"Rewrite text in `html-src` surrounded by double square brackets as a local link into this wiki."
[html-src]
(clojure.string/replace html-src #"\[\[[^\[\]]*\]\]"
#(let [text (clojure.string/replace %1 #"[\[\]]" "")]
(str "<a href='wiki?content=" text "'>" text "</a>"))))
(defn process-source (defn process-source
"Process `source-text` and save it to the specified `file-path`, committing it "Process `source-text` and save it to the specified `file-path`, committing it
to Git and finally redirecting to wiki-page." to Git and finally redirecting to wiki-page."
@ -60,19 +68,12 @@
true true
(layout/render "edit.html" (layout/render "edit.html"
{:title content {:title content
:left-bar (util/md->html "/content/_edit-left-bar.md") :left-bar (local-links (util/md->html "/content/_edit-left-bar.md"))
:header (util/md->html "/content/_header.md") :header (local-links (util/md->html "/content/_header.md"))
:content (if exists? (io/slurp-resource file-name) "") :content (if exists? (io/slurp-resource file-name) "")
:user (session/get :user) :user (session/get :user)
:exists exists?})))) :exists exists?}))))
(defn local-links
"Rewrite text in `html-src` surrounded by double square brackets as a local link into this wiki."
[html-src]
(clojure.string/replace html-src #"\[\[[^\[\]]*\]\]"
#(let [text (clojure.string/replace %1 #"[\[\]]" "")]
(str "<a href='wiki?content=" text "'>" text "</a>"))))
(defn wiki-page (defn wiki-page
"Render the markdown page specified in this `request`, if any. If none found, redirect to edit-page" "Render the markdown page specified in this `request`, if any. If none found, redirect to edit-page"
[request] [request]
@ -98,7 +99,6 @@
password (:password params) password (:password params)
action (:action params) action (:action params)
user (session/get :user)] user (session/get :user)]
(println (str "Action = " action))
(cond (cond
(= action "Logout!") (= action "Logout!")
(do (do
@ -111,8 +111,8 @@
true true
(layout/render "auth.html" (layout/render "auth.html"
{:title (if user (str "Logout " user) "Log in") {:title (if user (str "Logout " user) "Log in")
:left-bar (util/md->html "/content/_left-bar.md") :left-bar (local-links (util/md->html "/content/_left-bar.md"))
:header (util/md->html "/content/_header.md") :header (local-links (util/md->html "/content/_header.md"))
:user user})))) :user user}))))
(defn about-page [] (defn about-page []