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

challenge completed #87

Open
wants to merge 5 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
72 changes: 39 additions & 33 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,47 +1,50 @@
GEM
remote: https://rubygems.org/
specs:
coderay (1.0.9)
diff-lcs (1.2.5)
faraday (0.9.0)
coderay (1.1.1)
diff-lcs (1.3)
faraday (0.11.0)
multipart-post (>= 1.2, < 3)
httparty (0.8.3)
multi_json (~> 1.0)
multi_xml
json (1.8.1)
jwt (0.1.11)
multi_json (>= 1.5)
httparty (0.14.0)
multi_xml (>= 0.5.2)
json (2.0.3)
jwt (1.5.6)
method_source (0.8.2)
multi_json (1.8.4)
multi_xml (0.5.5)
multi_json (1.12.1)
multi_xml (0.6.0)
multipart-post (2.0.0)
oauth2 (0.9.3)
faraday (>= 0.8, < 0.10)
jwt (~> 0.1.8)
oauth2 (1.3.1)
faraday (>= 0.8, < 0.12)
jwt (~> 1.0)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (~> 1.2)
pry (0.9.12.2)
coderay (~> 1.0.5)
method_source (~> 0.8)
rack (>= 1.2, < 3)
pry (0.10.4)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
rack (1.5.2)
rack-protection (1.5.2)
rack (1.6.5)
rack-protection (1.5.3)
rack
rspec (2.14.1)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
rspec-core (2.14.7)
rspec-expectations (2.14.5)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.14.5)
sinatra (1.4.4)
rack (~> 1.4)
rspec (3.5.0)
rspec-core (~> 3.5.0)
rspec-expectations (~> 3.5.0)
rspec-mocks (~> 3.5.0)
rspec-core (3.5.4)
rspec-support (~> 3.5.0)
rspec-expectations (3.5.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.5.0)
rspec-mocks (3.5.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.5.0)
rspec-support (3.5.0)
sinatra (1.4.8)
rack (~> 1.5)
rack-protection (~> 1.4)
tilt (~> 1.3, >= 1.3.4)
slop (3.4.6)
tilt (1.4.1)
tilt (>= 1.3, < 3)
slop (3.6.0)
tilt (2.0.7)

PLATFORMS
ruby
Expand All @@ -53,3 +56,6 @@ DEPENDENCIES
pry
rspec
sinatra

BUNDLED WITH
1.14.6
35 changes: 0 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,41 +30,6 @@ in the terminal, and re-run ```ruby app.rb```.

## TODO

Attempt the following tasks. The list is meant to be progressively more
difficult and open-ended; the aim is to demonstrate your approach when dealing with programming issues and to test your initiative. Complete as much as you can within the time limit; you will not be penalised for not finishing the list. We are looking for self-motivated effort and to see how much of the groundwork you have grasped.

Don't forget to ```git add .``` and ```git commit``` after each step, if you have made any changes to your code!

* You should see a list of the profile data that you submitted to us when you
applied to We Got Coders. Use your knowledge of HTML / CSS to redesign and
layout the page in a presentable way. Show us what you can do with:

* Headings
* Lists
* Backgrounds / Gradients
* Multiple columns

* Add an image of yourself to your profile. Add CSS where necessary to ensure that it looks presentable.

* Observe how the about field works. What makes it bound to the data from your profile? Add more fields so that you can edit your profile.

* Add a field to the form so that you can add your Codecademy account to
your profile. You will need an input text box, with the appropriate ```name``` attribute.

* Add some Javascript to the provided ```<script>``` tag in the views/index.erb file, that counts the number of words in each section. You ought to have at least twenty words for each of the questions.

* Add code to the primes.rb file, that finds the sum of all prime numbers less than one hundred. Can you refactor the implementation so that you can pass in higher numbers to act as the limit? Test your implementation by running the rspec command ```rspec```. Find the sum of all prime numbers up to two million. Add a field to your profile named ```trainees[primes_sum]``` and enter in your answer.

* Over to you! Make any adjustments that you see fit, and add a feature that you are interested in attempting. Perhaps you might:

* Attempt a programming puzzle in Ruby, see http://projecteuler.net
* Experiment with using JavaScript to respond to user events
* Add some more pages and link them together

* Once you are done, submit a pull request. We will use this to review your work once you are done.

* Get buzzing! Mention @wegotcoders and tell the world why you decided to join the course and become a web developer.

## FAQs / Troubleshooting

* If you see this message, then you haven't set your application id and secret correctly.
Expand Down
14 changes: 11 additions & 3 deletions app.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require 'sinatra'
require './lib/profile'

set :application_id, 'EDIT_ME'
set :secret, 'EDIT_ME'
set :application_id, '2a9626cc51c05d18e778edd71aea5143865403bf26231f95063256732c7ba35a'
set :secret, '45184ae9271f6df0feb10b2f8387b79e5ef5056fccdc71e8317b871500012641'
set :redirect_uri, 'http://localhost:4567/callback'
set :site_url, 'https://wegotcoders.com'
set :session_secret, 'secret'
Expand All @@ -17,13 +17,21 @@

erb :primes, :layout => :main
end
get '/edit' do
if signed_in?
@profile = trainee.get_profile
end
erb :edit, :layout => :main
end

get '/' do
if signed_in?
@profile = trainee.get_profile

end

erb :index, :layout => :main
erb :index1, :layout => :main

end

post '/update' do
Expand Down
14 changes: 13 additions & 1 deletion primes.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
class Primes
def self.sum_to(limit = 100)
# TODO - add your prime number solution here...
prime_num = Array.new
"I'm working on it!"

for i in (2..limit) do
for j in (2..i) do
break if i%j == 0
end

# p "#{i} is a prime number." if i == j
prime_num[i] = i if i == j;

end
return prime_num
end
end
end
Binary file added public/images/email.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/facebook.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/github.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/line.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/phone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/profile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/twitter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
108 changes: 108 additions & 0 deletions public/stylesheets/main.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@


body {
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
font-size: 14px;
Expand Down Expand Up @@ -37,3 +39,109 @@ h3 {
}

/* TODO - Add your own styles here */
.clear{
clear: both;
}
.main-container{
margin: 0 auto;
width: 90%;
border: 2px solid blue;
background-color: lightgreen;
}
.header{
width: 100%;

}
.right-section{
margin-top: 10px;
border: 2px solid yellow;
width: 60%;
height: 760px;
float: right;
border-radius: 10px;
}
.left-section{
border: 2px solid red;
width: 40%;
height: 760px;
float: left;
border-radius: 10px;
}
/* -------------------------------- */
.container-main {
background: #fff;
margin-top: 80px;
padding: 0 30px 30px 30px;
}

header {
min-height: 100px;
overflow: auto;
}

header h1 {
margin: 0;
padding: 20px 0 0 0;
font-size: 2.2em;
font-weight: 700;
text-transform: uppercase;
letter-spacing: -1px;
text-align: center;
line-height: 1.4em;
}

.row {
margin-bottom: 20px;
}

.profile-img {
width: 160px;
display: block;
margin: auto;
margin-top: -80px;
}

.line {
max-width: 100%;
}

.contact-list {
padding: 0;
margin: 0;
}

.contact-list li {
list-style: none;
font-weight: bold;
line-height: 3.2em;
}

.contact-list span {
display: block;
margin: 0;
padding: 0;
line-height: 0.1em;
margin-left: 37px;
font-size: 15px;
color: #ccc;
}

.media {
background: #ededed;
padding: 10px;
}

.work-list li {
list-style: none;
float: left;
padding: 0 10px 0 10px;
margin-bottom: 30px;
}

footer {
background: #3b5a76;
color: #fff;
text-align: center;
padding-top: 20px;
padding-bottom: 20px;
}
79 changes: 79 additions & 0 deletions views/edit.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@

<div >
<h3>Edit Profile</h3>

<form action="/update" method="POST">
<fieldset>
<legend>Your Details :</legend>
<div class="form-group">
<label for="trainee[first_name]">First Name</label>
<input type="text" name="trainee[first_name]" value="<%= @profile["first_name"] %>"/>
</div>

<div class="form-group">
<label for="trainee[last_name]">Last Name</label>
<input type="text" name="trainee[last_name]" value="<%= @profile["last_name"] %>"/>
</div>
<div class="form-group">
<label for="trainee[dob]">Date of Birth</label>
<input type="text" name="trainee[dob]" value="<%= @profile["dob"] %>"/>
</div>
<div class="form-group">
<label for="trainee[gender]">Gender</label>
<input type="text" name="trainee[gender]" value="<%= @profile["gender"] %>"/>
</div>
<div class="form-group">
<label for="trainee[codecademy]">CodeCademy</label>
<input type="text" name="trainee[codecademy]" value="<%= @profile["codecademy"] %>"/>
</div>

</fieldset>

<fieldset>
<legend>
General Information
</legend

<div class="form-group">
<label for="trainee[about]">About</label>
<textarea rows="4" cols="70" name="trainee[about]" id="trainee_about">
<%= @profile["about"] %>
</textarea>
</div>
<div class="form-group">
<label for="trainee[ambition]">Ambition</label>
<textarea rows="4" cols="70" name="trainee[ambition]" id="trainee_ambition">
<%= @profile["ambition"] %>
</textarea>
</div>

<div class="form-group">
<label for="trainee[learning_experience]">Learning Experience</label>
<textarea rows="4" cols="70" name="trainee[learning_experience]" id="trainee_learning_experience">
<%= @profile["learning_experience"] %>
</textarea>
</div>

<div class="form-group">
<label for="trainee[projects]">Projects</label>
<textarea rows="4" cols="70" name="trainee[projects]" id="trainee_projects">
<%= @profile["projects"] %>
</textarea>
</div>

<div class="form-group">
<label for="trainee[rationale]">Rationale</label>
<textarea rows="4" cols="70" name="trainee[rationale]" id="trainee_rationale">
<%= @profile["rationale"] %>
</textarea>
</div>


<!-- TODO - Add more fields so that your profile can be edited -->

<input type="submit" value="Update Profile" class="btn btn-primary" />
<a href="/" class="btn btn-primary" role="button">Cancel</a>

</fieldset>
</form>
</div>
Loading