Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Superhero Name App: https://super-me.herokuapp.com/ #12

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
source 'https://rubygems.org'

group :development, :test do
gem 'rubocop'
end
gem 'sinatra'
26 changes: 9 additions & 17 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
GEM
remote: https://rubygems.org/
specs:
ast (2.0.0)
astrolabe (1.3.0)
parser (>= 2.2.0.pre.3, < 3.0)
parser (2.2.0.pre.5)
ast (>= 1.1, < 3.0)
slop (~> 3.4, >= 3.4.5)
powerpack (0.0.9)
rainbow (2.0.0)
rubocop (0.26.1)
astrolabe (~> 1.3)
parser (>= 2.2.0.pre.4, < 3.0)
powerpack (~> 0.0.6)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.4)
ruby-progressbar (1.6.0)
slop (3.6.0)
rack (1.5.2)
rack-protection (1.5.3)
rack
sinatra (1.4.5)
rack (~> 1.4)
rack-protection (~> 1.4)
tilt (~> 1.3, >= 1.3.4)
tilt (1.4.1)

PLATFORMS
ruby

DEPENDENCIES
rubocop
sinatra
28 changes: 10 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
# Single-Purpose Site

Create a single-purpose website using [Sinatra](http://www.sinatrarb.com/) that tells the user one thing, a la [isitchristmas.com](https://isitchristmas.com/). Surprise and delight us – creativity is encouraged. Example inputs:

* The current date
* The time
* The weather
* Whether Kanye West's most recent tweets mention Kanye West
* *etc*

**Deploy the application to Heroku**, and **submit a pull request** to this repository. Include:

* All the necessary files
* In the README:
* Setup instructions
* A link to the live app on Heroku

Check out the "Hello World" Sinatra app [here](https://github.com/cuny-nytech/sinatra-example).
superhero-name
==============
* Enter your full name into the textbox.
* If you use only your first name, your super hero first and last name will be based on your first name only.
* This app takes the first letter of your first and last name and produces a superhero name.
* Please only use letters in the first letter of your first and last name. If you use any other character,
you will get a message asking you to try again.
* If you accidently click "super me!" without putting in any information, you will get a message saying, "no entry detected"

Enjoy! https://super-me.herokuapp.com/
6 changes: 6 additions & 0 deletions config.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
require './supername'
require 'erb'
require 'sinatra'


run Sinatra::Application
92 changes: 92 additions & 0 deletions public/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*this block add the border to the entire app*/
html{

padding-left:10px;
}
/*end of style block------------------------*/

/*This block styles the welcome page*/
#welcome_page{
position:relative;top:85px;height:320px;width:587px;
background-color: white;
background-repeat: no-repeat;
text-align:center;
float:left;
}
#other{
position:relative;;height:499px;width:652px;
background-image:url('http://fc01.deviantart.net/fs70/i/2012/127/6/a/ultimate_spider_man_and_piter_parker_by_krosi-d4ytifj.png');
background-repeat:no-repeat;
background-size:114%;
float:left;
background-color:white;
}

#welcome_message{
height:120px;
color:white;
background-size:120px 587px;
background-color:blue;
font-size:2em;
line-height:120px;vertical-align:middle;
}
#enter_name{
height:90px;
line-height:90px;vertical-align:text-bottom;
font-size:2em;
}
#welcome_page_form{
vertical-align:text-top;
color:gray;
text-align:left;
height:110px;
}
/*end of style block------------------------*/

/*This block styles the results after a user enters in their name*/
#superhero_name_parent_div{/*for the whole div*/
position:relative;top:85px;height:320px;width:587px;
background-color: white;
background-repeat: no-repeat;
text-align:center;
float:left;
}

#supername_header{/*for the header message: "Your superhero name is:"*/
height:120px;
color:white;
background-size:120px 447px;
background-color:blue;
font-size:2em;
line-height:120px;vertical-align:middle;
}

#supername{/*for the resulting message: "superhero name"*/
height:52px;
line-height:52px;vertical-align:middle;
font-size:2.4em;color:red;
}
#play_again{/*for the play again button*/
height:110px;
}
#other2{
position:relative;;height:499px;width:652px;
background-image:url('http://i1161.photobucket.com/albums/q503/Diego_Timido/spiderman.png');
background-repeat:no-repeat;
background-size:119%;
float:left;
}
/*end of style block------------------------------------------*/
#footer{
height:77px;width:1225px;
background-color:red;
position: absolute; bottom: 45px; left: 100;
font-size:1.3em;
line-height:127px;
color:white;
padding-left:15px;
}




16 changes: 16 additions & 0 deletions supername.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require 'rubygems'
require 'sinatra'


get '/' do
erb :index
end


post '/name' do
if params[:message] == ""
params[:message] = "_no_entry"
end
erb :name
end

13 changes: 13 additions & 0 deletions views/index.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<div id="welcome_page"> <!--this is the div for the entire welcome page: size[320x447]px -->
<div id="welcome_message">Superhero Name Converter<br></div><!--this is the div for welcome message -->
<div id="enter_name">Enter Your Real Name</div><!--this is the div for enter name message -->
<div id="welcome_page_form" style="display: inline-block"><!--this is the div for the form -->
(first & last)
<form action="/name" method="post">
<input type="text" name="message" value = "">
<input type="submit" value="Super Me!">
</form>
</div>
</div>
<div id="other"></div>

13 changes: 13 additions & 0 deletions views/layout.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<% title="Superhero Name" %>
<!doctype html>
<html lang="en">
<head>
<link rel="stylesheet" href="styles.css">
<title><%= title %></title>
<meta charset="utf-8">
</head>
<body>
<%= yield %>
</body>
<div id="footer">Cuny/NYTech Project by Daryl Shy
</html>
48 changes: 48 additions & 0 deletions views/name.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

<%
@super_first_name = {A: :Almighty, B: :Beastly, C: :Cosmic, D: :Dynamic, E: :Ecto, F: :Ferocious, G: :Giant,H: :Harrowing,
I: :Invisible, J: :Jumping, K: :Killer, L: :Leaping, M: :Mad, N: :Nocturnal, O: :Optimus, P: :Psychic, Q: :Quick,
R: :Reaping, S: :Stunning, T: :Torching, U: :Ulitimate, V: :Venomous, W: :Weeping, X: :Extraordinary,
Y: :Young, Z: :Zapping}
@super_last_name = {A: :Anaconda, B: :Bee, C: :Cosmo, D: :Dingo, E: :Enferno, F: :Firefly, G: :Gangsta,H: :Hammer,
I: :Indigo, J: :Jupiter, K: :KO, L: :Lizard, M: :Maniac, N: :Neptune, O: :Octopus, P: :Psycho, Q: :Quicksilver,
R: :Reaper, S: :Salamander, T: :Tyrannasaurus, U: :Undertaker, V: :Virus, W: :Wonder, X: :Xray,
Y: :Yeoman, Z: :Zebra}
@super_first_initials = @super_first_name.keys
@super_last_initials = @super_last_name.keys

ufi = params[:message]
uli = params[:message]
user_first_initial = ufi.split(' ').first.upcase
user_last_initial = uli.split(' ').last.upcase

if params[:message] == "_no_entry"
error_message = "Error!"
the = ""
super_first_name = " No Entry Detected "
super_last_name = ""
exc = ""
elsif !@super_first_name.has_key?(user_first_initial[0].to_sym) || !@super_last_name.has_key?(user_last_initial[0].to_sym)
error_message = "Error!"
the = ""
super_first_name = " Use Letters Only "
super_last_name = ""
exc = ""
else
error_message = "Your Superhero Name"
the = "The "
exc = "!"
end

if @super_first_name.has_key?(user_first_initial[0].to_sym)
super_first_name = @super_first_name.values_at(user_first_initial[0].to_sym)
end
if @super_last_name.has_key?(user_last_initial[0].to_sym)
super_last_name = @super_last_name.values_at(user_last_initial[0].to_sym)
end %>
<div id="superhero_name_parent_div">
<div id="supername_header"> <%= error_message %> </div><br>
<div id="supername"><%= the %><%= super_first_name.inspect[2..super_first_name.length-3] %> <%= super_last_name.inspect[2..super_last_name.length-3] %><%= exc %></div><br>
<div id="play_again"><a href ="/"><img src="http://www.primarygames.com/holidays/chinese/games/my_sign/images/tryagain_button.png" height="100" width="300"></a></div>
</div>
<div id="other2"></div>