Skip to content
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
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ gem 'jbuilder', '~> 2.5'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

## For env variables
gem 'figaro'

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
Expand Down
5 changes: 4 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ GEM
erubi (1.7.1)
execjs (2.7.0)
ffi (1.9.23)
figaro (1.1.1)
thor (~> 0.14)
globalid (0.4.1)
activesupport (>= 4.2.0)
i18n (1.0.0)
Expand Down Expand Up @@ -178,6 +180,7 @@ DEPENDENCIES
byebug
capybara (~> 2.13)
coffee-rails (~> 4.2)
figaro
jbuilder (~> 2.5)
listen (>= 3.0.5, < 3.2)
pg (>= 0.18, < 2.0)
Expand All @@ -193,4 +196,4 @@ DEPENDENCIES
web-console (>= 3.3.0)

BUNDLED WITH
1.16.1
1.16.2
17 changes: 8 additions & 9 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,18 @@
//= require_tree .

$(function() {
$(window).scroll(function () {
if ($(this).scrollTop() > 820) {
$('.crazy-navbar').addClass('changeColor')
}
if ($(this).scrollTop() < 820) {
$('.crazy-navbar').removeClass('changeColor')
}
});
// $(window).scroll(function () {
// if ($(this).scrollTop() > 820) {
// $('.crazy-navbar').addClass('changeColor')
// }
// if ($(this).scrollTop() < 820) {
// $('.crazy-navbar').removeClass('changeColor')
// }
// });

$('a').click(function(){
debugger
$('body').removeClass('fadeOut')
$('body').addClass('fadeIn')
})
});

56 changes: 35 additions & 21 deletions app/assets/javascripts/site.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,41 @@
$(function(){
$(document).on('click', "#subscribe-user", function(e){
$(document).on('click', "#contact_user", function(e){
e.preventDefault();
var self = $(this);

$.ajax({
method: "POST",
url: self.data('url'),
dataType: 'JSON',
data: {
subscribe_user: {
first_name: $("#first_name").val(),
last_name: $("#last_name").val(),
email: $("#email").val(),
}
if ($("#first_name").val() != "" && $("#last_name").val() != "" && $("#email").val() != "") {
if (isEmail($("#email").val())) {
$('.return-msg').html('');
$.ajax({
method: "POST",
url: self.data('url'),
dataType: 'JSON',
data: {
contact: {
first_name: $("#first_name").val(),
last_name: $("#last_name").val(),
email: $("#email").val(),
}
}
}).done(function(data){
$("#first_name").val("")
$("#last_name").val("")
$("#email").val("")
$("#first_name").focus()
}).fail(function(error){
var data = error;
console.log("==data", data)
})
} else {
$('.return-msg').html('Email is invalid.');
}
}).done(function(data){
$("#first_name").val("")
$("#last_name").val("")
$("#email").val("")
$("#first_name").focus()
}).fail(function(error){
var data = error;
console.log("==data", data)
})
} else {
$('.return-msg').html('Please fill all the fields.');
}
})
})
})

function isEmail(email) {
var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
return regex.test(email);
}
15 changes: 15 additions & 0 deletions app/controllers/contacts_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class ContactsController < ApplicationController
def index
end

def create
ContactMailer.contact_send(contact_params).deliver_now
ContactMailer.user_send(contact_params).deliver_now
end

private

def contact_params
params.require(:contact).permit(:first_name, :last_name, :email)
end
end
14 changes: 14 additions & 0 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class HomeController < ApplicationController

def index
end

def about_us
end

def what_we_do
end

def our_team
end
end
10 changes: 0 additions & 10 deletions app/controllers/sites_controller.rb

This file was deleted.

26 changes: 0 additions & 26 deletions app/controllers/subscribe_users_controller.rb

This file was deleted.

2 changes: 1 addition & 1 deletion app/mailers/application_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class ApplicationMailer < ActionMailer::Base
default from: 'from@example.com'
default from: ENV['FROM_EMAIL']
layout 'mailer'
end
11 changes: 11 additions & 0 deletions app/mailers/contact_mailer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class ContactMailer < ApplicationMailer

def contact_send(contact)
@contact = contact
mail(to: ENV['TO_EMAILS'], subject: 'Contact', from: @contact['email'])
end

def user_send(contact)
mail(to: contact['email'], subject: 'Contact')
end
end
10 changes: 0 additions & 10 deletions app/models/subscribe_user.rb

This file was deleted.

54 changes: 2 additions & 52 deletions app/views/application/_footer.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,7 @@
<!-- FOOTER -->
<!-- ************************ -->

<footer class="<%= @site.slug != 'contact_us' && 'pt150'%>" id="contact_us">
<% unless @site.slug == 'contact_us' %>
<div class="container" >

<div class="title">contact us</div>

<div class="col-sm-8 col-sm-offset-2 pt80 pb80" data-sr="wait .2s">
<div class="row">

<%= form_tag(subscribe_users_path,class: 'contact-form form-black') do %>

<div class="form-control">
<%= text_field_tag :first_name, nil, class: 'contact-form-name', placeholder: 'First Name...', required: true %>
<div class="line-input"></div>
</div>
<div class="spacer-half"></div>
<div class="form-control">
<%= text_field_tag :last_name, nil, class: 'contact-form-message', placeholder: 'Last Name...', required: true %>
<div class="line-input"></div>
</div>
<div class="spacer-half"></div>
<div class="form-control">
<%= email_field_tag :email, nil, class: 'contact-form-email', placeholder: 'Email...', required: true %>
<div class="line-input"></div>
<div class="ui left corner label">
<i class="asterisk icon"></i>
</div>
</div>

<!-- End -->
<div class="col-sm-12">
<div class="text-center">
<p class="return-msg">&nbsp;</p>
</div>

</div>

<% end %>

<div class="spacer-half"></div>
<button class="btn line-hor" id="subscribe-user" data-url="<%= subscribe_users_path %>">
<i class="mail icon"></i>
<span>Submit</span>
</button>
<!-- End contact-form -->
</div>
</div>
</div>
<!-- End container -->
<% end %>

<footer>
<div class="footer-inner clearfix">
<div class="container">

Expand Down Expand Up @@ -98,4 +48,4 @@
<!-- End container -->
</div>

</footer>
</footer>
22 changes: 11 additions & 11 deletions app/views/application/_nav_list.html.erb
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<% current_item = "current-menu-item" %>
<li class="<%= @site.slug == 'home' && current_item %>">
<a href="/" class="">01. Home</a>
<li class="<%= controller_name == 'home' && action_name == 'index' && current_item %>">
<a href="<%= root_path %>" class="">01. Home</a>
</li>
<li class="<%= @site.slug == 'about_us' && current_item %>">
<a href="#about_us">02. About Us</a>
<li class="<%= controller_name == 'home' && action_name == 'about_us' && current_item %>">
<a href="<%= about_us_path %>">02. About Us</a>
</li>
<li class="<%= @site.slug == 'our_work' && current_item %>">
<a href="#what_we_do" class="">03. What We Do</a>
<li class="<%= controller_name == 'home' && action_name == 'what_we_do' && current_item %>">
<a href="<%= what_we_do_path %>" class="">03. What We Do</a>
</li>
<li class="<%= @site.slug == 'contact_us' && current_item %>">
<a href="#our_team" class="">04. Our Team</a>
<li class="<%= controller_name == 'home' && action_name == 'our_team' && current_item %>">
<a href="<%= our_team_path %>" class="">04. Our Team</a>
</li>
<li class="<%= controller_name == 'contacts' && action_name == 'index' && current_item %>">
<a href="<%= contact_us_path %>" class="">05. Contact Us</a>
</li>
<li class="<%= @site.slug == 'contact_us' && current_item %>">
<a href="#contact_us" class="">05. Contact Us</a>
</li>
6 changes: 3 additions & 3 deletions app/views/application/_navbar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
<!-- NAVBAR -->
<!-- ************************ -->

<div class="crazy-navbar">
<div class="crazy-navbar <%= controller_name == 'home' && action_name == 'index' ? '' : 'changeColor' %>">
<div class="container">

<div class="crazy-logo">
<a href="/">
<a href="<%= root_path %>">
<%= image_tag 'bushilogo.png' %>
</a>
</div>
Expand Down Expand Up @@ -39,4 +39,4 @@
</div>
<!-- End container -->

</div>
</div>
9 changes: 9 additions & 0 deletions app/views/contact_mailer/contact_send.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
</head>
<body>
<p><%= "#{@contact[:email]} has filled out request form." %></p>
</body>
</html>
10 changes: 10 additions & 0 deletions app/views/contact_mailer/user_send.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
</head>
<body>
<h1>Welcome to Bushido Lab</h1>
<p>Thank You!</p>
</body>
</html>
Loading