-
-
Save nlharri/5ce357f60b3208aa04f359bf56559474 to your computer and use it in GitHub Desktop.
Ruby Message Board App
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
# Listen on all interfaces in the development environment | |
# This is needed when we run from Cloud 9 environment | |
# source: https://gist.github.com/jhabdas/5945768 | |
set :bind, '0.0.0.0' | |
set :port, 8080 | |
get '/' do | |
t_msg = [ | |
{ nick: "Harri", msg: "Hello World!" }, | |
{ nick: "Ioana", msg: "Buna dimineata" }, | |
{ nick: "Alexandru", msg: "sunt fericit" } | |
] | |
erb :v_message, :layout => :l_main, :locals => {:t_msg => t_msg} | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang=en> | |
<head> | |
<link rel="stylesheet" type="text/css" href="/stylesheets/main.css"> | |
<link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet"> | |
<meta charset=utf-8> | |
<title>Message Board</title> | |
</head> | |
<body> | |
<div class="pageheader"> | |
<h1>Message Board</h1> | |
</div> | |
<div class="speech-bubble"> | |
<form action="/new" id="newmessage"> | |
<p class="nick"><input type="text" placeholder="Nickname" name="nickname"></p> | |
<p class="message"><textarea placeholder="Message" name="message" form="newmessage"></textarea></p> | |
<p class="submit"><button class="submit" type="submit" form="newmessage" value="Submit">I say this!</button></p> | |
</form> | |
</div> | |
<%= yield %> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% t_msg.each do |msg| %> | |
<div class="speech-bubble"> | |
<p class="nick"><%= msg[:nick] %> says:</p> | |
<p class="message"> "<%= msg[:msg] %>"</p> | |
</div> | |
<% end %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment