diff --git a/Gemfile b/Gemfile index 502cba1..91c54c4 100644 --- a/Gemfile +++ b/Gemfile @@ -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] diff --git a/Gemfile.lock b/Gemfile.lock index 35ce7e7..f5eb857 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) @@ -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) @@ -193,4 +196,4 @@ DEPENDENCIES web-console (>= 3.3.0) BUNDLED WITH - 1.16.1 + 1.16.2 diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 9166753..0cb7950 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -16,14 +16,14 @@ //= 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 @@ -31,4 +31,3 @@ $(function() { $('body').addClass('fadeIn') }) }); - diff --git a/app/assets/javascripts/site.js b/app/assets/javascripts/site.js index c22b599..0e6f275 100644 --- a/app/assets/javascripts/site.js +++ b/app/assets/javascripts/site.js @@ -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.'); + } }) -}) \ No newline at end of file +}) + +function isEmail(email) { + var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; + return regex.test(email); +} diff --git a/app/controllers/contacts_controller.rb b/app/controllers/contacts_controller.rb new file mode 100644 index 0000000..a08f3ac --- /dev/null +++ b/app/controllers/contacts_controller.rb @@ -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 diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb new file mode 100644 index 0000000..ba2c900 --- /dev/null +++ b/app/controllers/home_controller.rb @@ -0,0 +1,14 @@ +class HomeController < ApplicationController + + def index + end + + def about_us + end + + def what_we_do + end + + def our_team + end +end diff --git a/app/controllers/sites_controller.rb b/app/controllers/sites_controller.rb deleted file mode 100644 index c917cc4..0000000 --- a/app/controllers/sites_controller.rb +++ /dev/null @@ -1,10 +0,0 @@ -class SitesController < ApplicationController - - def show - @site = Site.find_by_slug(params[:slug] || 'home') - - respond_to do |format| - format.html - end - end -end diff --git a/app/controllers/subscribe_users_controller.rb b/app/controllers/subscribe_users_controller.rb deleted file mode 100644 index 9ba0b62..0000000 --- a/app/controllers/subscribe_users_controller.rb +++ /dev/null @@ -1,26 +0,0 @@ -class SubscribeUsersController < ApplicationController - - def create - build_subscribe_user - respond_to do |format| - format.json { render json: { is_success: @subscribe_user.save! } } - end - end - - private - - def subscribe_user_params - params.fetch(:subscribe_user, {}) - .permit(:first_name, :last_name, :email) - end - - def build_subscribe_user - @subscribe_user ||= subscribe_user_scope - @subscribe_user.attributes = subscribe_user_params - end - - def subscribe_user_scope - @subscribe_user = SubscribeUser.new - end - -end diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 286b223..774d0d9 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -1,4 +1,4 @@ class ApplicationMailer < ActionMailer::Base - default from: 'from@example.com' + default from: ENV['FROM_EMAIL'] layout 'mailer' end diff --git a/app/mailers/contact_mailer.rb b/app/mailers/contact_mailer.rb new file mode 100644 index 0000000..3527d92 --- /dev/null +++ b/app/mailers/contact_mailer.rb @@ -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 diff --git a/app/models/subscribe_user.rb b/app/models/subscribe_user.rb deleted file mode 100644 index a732548..0000000 --- a/app/models/subscribe_user.rb +++ /dev/null @@ -1,10 +0,0 @@ -class SubscribeUser < ApplicationRecord - EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i - - validates :email, presence: true, uniqueness: true - validates_format_of :email, :with => EMAIL_REGEX, :on => :create - - scope :active, -> { where(status: 'A') } - - has_many :page_stats, as: :page_stateable -end diff --git a/app/views/application/_footer.html.erb b/app/views/application/_footer.html.erb index 0fb19ce..86b6fe6 100644 --- a/app/views/application/_footer.html.erb +++ b/app/views/application/_footer.html.erb @@ -2,57 +2,7 @@ - diff --git a/app/views/application/_nav_list.html.erb b/app/views/application/_nav_list.html.erb index db234fb..f32b318 100644 --- a/app/views/application/_nav_list.html.erb +++ b/app/views/application/_nav_list.html.erb @@ -1,16 +1,16 @@ <% current_item = "current-menu-item" %> -
  • - 01. Home +
  • + 01. Home
  • -
  • - 02. About Us +
  • + 02. About Us
  • -
  • - 03. What We Do +
  • + 03. What We Do
  • -
  • - 04. Our Team +
  • + 04. Our Team +
  • +
  • + 05. Contact Us
  • -
  • - 05. Contact Us -
  • \ No newline at end of file diff --git a/app/views/application/_navbar.html.erb b/app/views/application/_navbar.html.erb index d2fb9aa..da9b8f9 100644 --- a/app/views/application/_navbar.html.erb +++ b/app/views/application/_navbar.html.erb @@ -2,11 +2,11 @@ -
    +
    -
    \ No newline at end of file +
    diff --git a/app/views/contact_mailer/contact_send.html.erb b/app/views/contact_mailer/contact_send.html.erb new file mode 100644 index 0000000..0d173da --- /dev/null +++ b/app/views/contact_mailer/contact_send.html.erb @@ -0,0 +1,9 @@ + + + + + + +

    <%= "#{@contact[:email]} has filled out request form." %>

    + + diff --git a/app/views/contact_mailer/user_send.html.erb b/app/views/contact_mailer/user_send.html.erb new file mode 100644 index 0000000..efa6ed2 --- /dev/null +++ b/app/views/contact_mailer/user_send.html.erb @@ -0,0 +1,10 @@ + + + + + + +

    Welcome to Bushido Lab

    +

    Thank You!

    + + diff --git a/app/views/contacts/index.html.erb b/app/views/contacts/index.html.erb new file mode 100644 index 0000000..606f247 --- /dev/null +++ b/app/views/contacts/index.html.erb @@ -0,0 +1,44 @@ +
    +
    + +
    +
    + contact us +
    +
    + <%= form_tag(contacts_path, class: 'contact-form form-black') do %> +
    + <%= text_field_tag :first_name, nil, class: 'contact-form-name', placeholder: 'First Name...', required: true %> +
    +
    +
    +
    + <%= text_field_tag :last_name, nil, class: 'contact-form-message', placeholder: 'Last Name...', required: true %> +
    +
    +
    +
    + <%= email_field_tag :email, nil, class: 'contact-form-email', placeholder: 'Email...', required: true %> +
    +
    + +
    +
    +
    +
    +

     

    +
    +
    + <% end %> + +
    + +
    +
    + + +
    +
    diff --git a/app/views/home/about_us.html.erb b/app/views/home/about_us.html.erb new file mode 100644 index 0000000..c76223f --- /dev/null +++ b/app/views/home/about_us.html.erb @@ -0,0 +1,38 @@ +
    +
    + +
    +
    + The Intellectual and Technological Powerhouse Creating Tomorrow. +
    +
    +
    + <%= image_tag 'diagram_bushi.png' %> +
    +
    +
    +

    Research & Planning +
    +

    +

    We apply the rigor of the scientific method to the nascent space of cryptocurrency and blockchain, developing the infrastructure of the Web 3.0.

    + +
    +
    +

    Agile Development +
    +

    +

    Speed is our main tenant. We apply Agile methodologies to a novel environment to achieve project deliverables while creating the infrastructure on which they sit.

    +
    +
    +

    Product Launch +
    +

    +

    We are the intersection of a think tank and a products company. We ideate, we innovate and then we create.

    +
    +
    +
    +
    + + +
    +
    diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb new file mode 100644 index 0000000..24eaea8 --- /dev/null +++ b/app/views/home/index.html.erb @@ -0,0 +1,43 @@ +
    + +
    + + +
    + +
    +

    We are +   +

    +

    We are entering a world that is fundamentally different than the one we know. +
    + Economics and governance is changing. Institutions are shifting. People are listening. +
    + The next phase is here. +

    + +
    +
    +

    We leverage several technologies

    +
    + <%= image_tag 'bitcoin.png' %> +
    +
    + <%= image_tag 'lightning.png' %> +
    +
    + <%= image_tag 'ether.png' %> +
    +
    + <%= image_tag 'rsk.png' %> +
    +
    +
    + + +
    diff --git a/app/views/home/our_team.html.erb b/app/views/home/our_team.html.erb new file mode 100644 index 0000000..82e2ca2 --- /dev/null +++ b/app/views/home/our_team.html.erb @@ -0,0 +1,261 @@ +
    +
    + +
    + +
    +

    meet our team

    + +
    +
    +

    We're a small, agile, coherent team of software developers with a unified obsession with Blockchain. Ask us what get's us out of bed in the morning, you guessed it, Blockchain.

    +
    +
    + +
    +
    + + +
    +
    +
    +
    +
    + <%= image_tag 'sam.jpg' %> + + + + +
    + + + +
    + +
    + +
    + +
    +
    + <%= image_tag 'chris.jpg' %> + + +
    + + + +
    + +
    +
    + +
    +
    + <%= image_tag 'kevin.jpg' %> + + +
    + + + +
    + +
    +
    +
    +
    + +
    +
    + <%= image_tag 'luis.jpg' %> + + +
    + + +
    + +
    +
    + +
    +
    + <%= image_tag 'nicolas.jpg' %> + + +
    + + + +
    + +
    + +
    + +
    +
    + <%= image_tag 'andres.jpg' %> + + +
    + + + +
    + +
    + +
    + +
    +
    + <%= image_tag 'ariel.jpg' %> + + + +
    + + + +
    + +
    + +
    + +
    +
    + <%= image_tag 'katya.jpg' %> + + +
    + + + +
    + +
    + + +
    +
    + + +
    +
    diff --git a/app/views/home/what_we_do.html.erb b/app/views/home/what_we_do.html.erb new file mode 100644 index 0000000..b9da35c --- /dev/null +++ b/app/views/home/what_we_do.html.erb @@ -0,0 +1,108 @@ +
    +
    +
    +
    + +
    +
    What We Do
    + +
    +
    + We are ‘blockchain agnostic’. We leverage several different platforms for different use-cases. The bulk of our experience lies in the Bitcoin, Ethereum, and Hyperledger blockchain infrastructures. +
    +
    + +
    +
    + + +
    +
    +
    + +
    +
    + <%= image_tag 'digital_currency.jpg' %> +
    +
    +

    01. Digital Currency +
    +

    +

    We use and build open source protocols that leverage the power of blockchain and smart contracts to create cheap, fast and private transactions. These include consensus mechanisms, wallet development and ancillary functionality. +

    + + + +
    +
    + + +
    +
    + <%= image_tag 'financial_networks.jpg' %> +
    +
    +

    02. Blockchain Applications +
    +

    + +

    User adoption and application innovations is driving the need for more secure and robust infrastructures. Blockchain provides robust security, transparency, and increases shareholder value all around. +

    + + + +
    +
    + + +
    +
    + <%= image_tag 'blockchain_applications.jpg' %> +
    +
    +

    03. Financial Networks +
    +

    + +

    We are researching Layer 2 and Sidechain applications to support Layer 1 scalability. These protocols will afford users and institutions the ability to leverage the power of digital assets across blockchains to provide liquidity through the bridging of disparate markets. +

    + + + +
    +
    + + +
    + + +
    +
    + +
    + +
    + + +
    + +
    + +
    + + + + +
    diff --git a/app/views/sites/pages/_contact_us.html.erb b/app/views/sites/pages/_contact_us.html.erb index 32a2de9..ac1adab 100644 --- a/app/views/sites/pages/_contact_us.html.erb +++ b/app/views/sites/pages/_contact_us.html.erb @@ -102,7 +102,7 @@
    - <%= form_tag(subscribe_users_path), class: 'contact-form form-black' do %> + <%= form_tag(contacts_path), class: 'contact-form form-black' do %>
    <%= text_field_tag :first_name, nil, class: 'contact-form-name', placeholder: 'First Name...', required: true %> @@ -124,7 +124,7 @@ <% end %>
    - @@ -167,4 +167,4 @@ - adapter: postgresql encoding: unicode - # For details on connection pooling, see Rails configuration guide - # http://guides.rubyonrails.org/configuring.html#database-pooling - pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + pool: 5 + username: admin_user + password: root + host: localhost development: <<: *default diff --git a/config/environments/development.rb b/config/environments/development.rb index 5187e22..d825277 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -51,4 +51,18 @@ # Use an evented file watcher to asynchronously detect changes in source code, # routes, locales, etc. This feature depends on the listen gem. config.file_watcher = ActiveSupport::EventedFileUpdateChecker + + ## SMTP Credentials + config.action_mailer.default_url_options = { host: ENV['SMTP_HOST'] } + config.action_mailer.delivery_method = :smtp + + config.action_mailer.smtp_settings = { + address: ENV['SMTP_ADDRESS'], + port: ENV['SMTP_PORT'], + domain: ENV['SMTP_DOMAIN'], + user_name: ENV['SMTP_USER_NAME'], + password: ENV['SMTP_PASSWORD'], + authentication: :plain, + enable_starttls_auto: true + } end diff --git a/config/environments/production.rb b/config/environments/production.rb index 54ecbae..8889770 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -64,7 +64,7 @@ # Ignore bad email addresses and do not raise email delivery errors. # Set this to true and configure the email server for immediate delivery to raise delivery errors. - # config.action_mailer.raise_delivery_errors = false + config.action_mailer.raise_delivery_errors = true # Enable locale fallbacks for I18n (makes lookups for any locale fall back to # the I18n.default_locale when a translation cannot be found). @@ -86,6 +86,21 @@ config.logger = ActiveSupport::TaggedLogging.new(logger) end + ## SMTP Credentials + config.action_mailer.perform_deliveries = true + config.action_mailer.default_url_options = { host: ENV['SMTP_HOST'] } + config.action_mailer.delivery_method = :smtp + + config.action_mailer.smtp_settings = { + address: ENV['SMTP_ADDRESS'], + port: ENV['SMTP_PORT'], + domain: ENV['SMTP_DOMAIN'], + user_name: ENV['SMTP_USER_NAME'], + password: ENV['SMTP_PASSWORD'], + authentication: :plain, + enable_starttls_auto: true + } + # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false end diff --git a/config/routes.rb b/config/routes.rb index 9611d20..552deb3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,6 +1,9 @@ Rails.application.routes.draw do - root "sites#show" - resources :subscribe_users, only: [:create] + resources :contacts, only: :create + get 'about-us', to: 'home#about_us', as: :about_us + get 'what-we-do', to: 'home#what_we_do', as: :what_we_do + get 'our-team', to: 'home#our_team', as: :our_team + get 'contact-us', to: 'contacts#index', as: :contact_us - get "/:slug", to: "sites#show" + root "home#index" end diff --git a/db/migrate/20180404232602_create_subscribe_users.rb b/db/migrate/20180404232602_create_subscribe_users.rb deleted file mode 100644 index cf91c4a..0000000 --- a/db/migrate/20180404232602_create_subscribe_users.rb +++ /dev/null @@ -1,13 +0,0 @@ -class CreateSubscribeUsers < ActiveRecord::Migration[5.1] - def change - create_table :subscribe_users do |t| - t.string :first_name, limit: 100 - t.string :last_name, limit: 100 - t.string :email, limit: 100, null: false - - t.timestamps - end - add_idx = %Q(CREATE INDEX subscribe_users_email_idx ON subscribe_users using btree(email)) - execute add_idx - end -end diff --git a/db/schema.rb b/db/schema.rb index fa592a0..26c0742 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20180404232602) do +ActiveRecord::Schema.define(version: 20180404232601) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -25,13 +25,4 @@ t.datetime "updated_at", null: false end - create_table "subscribe_users", force: :cascade do |t| - t.string "first_name", limit: 100 - t.string "last_name", limit: 100 - t.string "email", limit: 100, null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.index ["email"], name: "subscribe_users_email_idx" - end - end diff --git a/test/mailers/contact_mailer_test.rb b/test/mailers/contact_mailer_test.rb new file mode 100644 index 0000000..af056da --- /dev/null +++ b/test/mailers/contact_mailer_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class ContactMailerTest < ActionMailer::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/mailers/previews/contact_mailer_preview.rb b/test/mailers/previews/contact_mailer_preview.rb new file mode 100644 index 0000000..cd6ac4a --- /dev/null +++ b/test/mailers/previews/contact_mailer_preview.rb @@ -0,0 +1,4 @@ +# Preview all emails at http://localhost:3000/rails/mailers/contact_mailer +class ContactMailerPreview < ActionMailer::Preview + +end