Skip to content

Commit

Permalink
[#30] Add about page
Browse files Browse the repository at this point in the history
  • Loading branch information
jfacorro committed Oct 17, 2017
1 parent 8b5f913 commit e9f61e5
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 17 deletions.
24 changes: 20 additions & 4 deletions priv/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ body {
text-align: center;
color: white;
font-family: Arial, sans-serif;
font-size: 14px;
font-size: 0.9em;
text-shadow: 0px 0px 5px #FFF;
}

#footer a {
Expand All @@ -35,21 +36,36 @@ a:hover, a:visited, a:link, a:active {
text-decoration: none;
}

a:hover {
text-shadow: 0px 0px 5px #333;
}

#ribbon {
position: absolute;
top: 0;
right: 0;
border: 0;
}

#terminal {
#terminal, #about {
background:rgba(0, 0, 0, 0.85);
border-radius: 5px;
padding: 10px;
}

#about {
background:rgba(0, 0, 0, 0.7);
font-family: Arial, sans-serif;
font-size: 1em;
color: white;
text-align: justify;
}

#terminal {
color: #CCC;
height: 500px;
font-size: 14px;
font-family:monospace;
padding: 10px;
height: 500px;
}

#terminal div.jquery-console-inner {
Expand Down
5 changes: 3 additions & 2 deletions src/try_clojerl/app.clje
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
(->list (map into-tuple m)))

(def routes
{:_ [["/" :try-clojerl.index nil]
["/repl" :try-clojerl.repl nil]
{:_ [["/" :try-clojerl.layout :index]
["/about" :try-clojerl.layout :about]
["/repl" :try-clojerl.repl nil]
["/css/[...]" :cowboy_static #erl[:priv_dir :try_clojerl "css"]]
["/img/[...]" :cowboy_static #erl[:priv_dir :try_clojerl "img"]]
["/js/[...]" :cowboy_static #erl[:priv_dir :try_clojerl "js"]]]})
Expand Down
8 changes: 0 additions & 8 deletions src/try_clojerl/index.clje

This file was deleted.

38 changes: 35 additions & 3 deletions src/try_clojerl/layout.clje
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
(def header [:div#header [:h1 "Try Clojerl"]])

(def footer [:div#footer
[:a {:href "https://github.com/jfacorro/clojerl"} "Clojerl"]
[:a {:href "https://jfacorro.github.io/clojerl/"} "Docs"]])
[:a {:href "/"} "Home"]
[:a {:href "/about"} "About"]
[:a {:href "https://github.com/jfacorro/clojerl"} "Clojerl"]])

(def ribbon-img
"https://s3.amazonaws.com/github/ribbons/forkme_right_white_ffffff.png")
Expand All @@ -22,9 +23,40 @@
[:img#ribbon {:src ribbon-img
:alt "Fork me on GitHub"}]])

(defn index [title content]
(def index [:div#terminal])

(def about
[:div#about
[:h3 "About"]
[:p "This website is currently being hosted on a Raspberry PI 3 and running
on a docker container. The user inside the docker container which runs the
Erlang VM process is not root and is not a sudoer."]
[:p "There's currently no sandboxing, so you can do almost anything that you
would be able to do in a local REPL."]
[:p " If the Erlang VM gets killed somehow (e.g. by calling "
[:code "(erlang/halt)"] ") the docker container will restart on its own. All
connected clients will see their connections closed and each will try to open a
new connection."]
[:p "It would be pretty nice testing the limit of how many clients this setup
can handle at the same."]
[:p "Enjoy!"]])

(def pages
{:index {:title "Try Clojerl"
:content index}
:about {:title "Try Clojerl - About"
:content about}})

(defn page [title content]
(html5
(head title)
[:body
ribbon
[:div#content header content footer]]))

(defn init
[req page-id]
(let* [data (pages page-id)
html (page (:title data) (:content data))
req (cowboy_req/reply.e 200 #erl{} html req)]
#erl[:ok req page-id]))

0 comments on commit e9f61e5

Please sign in to comment.