Created
September 6, 2012 10:56
-
-
Save migane/3654789 to your computer and use it in GitHub Desktop.
Reverse world in sentence with rackup
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
# config.ru | |
require './my_app_bis.rb' | |
run MyAppBis.new | |
# my_app_bis.rb | |
class MyAppBis | |
def initialize() | |
@str = "Is not rackup fun, is it?" | |
end | |
def reverse_word(str) | |
str.split(" ").reverse.join(" ") | |
end | |
def call(env) | |
[200, {"Content-Type" => "text/html"}, [ | |
"<head>", | |
"<style type=\"text/css\">", | |
"h1 {color: #8B4513;}", | |
"h2 {margin-left: 45px;color: #5F9EA0;}", | |
"b.foo {padding-left: 20px;}", | |
"b.bar {padding-left: 95px;}", | |
"</style>", | |
"</head", | |
"<body>", | |
"<h1>Reverse Word Order in Sentence Service</h1>", | |
"<p>The initial sentence was: <b class=\"foo\">#{@str}</b></p>", | |
"<p>The result is: <b class=\"bar\">" + reverse_word(@str)+ "</b></p>", | |
"<h2>And the coder is doubled up with laughter.</h2>", | |
"</body>"]] | |
end | |
end | |
# Comments | |
# Would have preferred to use linked stylesheet, but don't know how to tell rackup | |
# to serve it. |
I think if you treat it just like a sinatra app and make a public folder with your stylesheets in a stylesheets folder, you might give that a try.
I'm getting h1 and h2 to work but the color is not
Be sure to use single quotes
"",
"",
["",]
I can't seem to figure out the markdown here. But you know what I mean.
What I tried to let you know was that I don't get any syntax errors with a line like this
link rel='stylesheet' href='/public/stylesheets/style.css'/
however you're right it just won't link. I tried the folders like stated previously.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Have you got this one bookmarked? http://cyrildavid.com/articles/2012/01/03/understanding-rack