Signed-off-by: Adrian Hinz <adhinz@gmail.com>
This commit is contained in:
parent
ed16c6bf77
commit
8dde288784
File diff suppressed because one or more lines are too long
|
|
@ -10,7 +10,6 @@ $(function() {
|
||||||
// get values from FORM
|
// get values from FORM
|
||||||
var name = $("input#name").val();
|
var name = $("input#name").val();
|
||||||
var email = $("input#email").val();
|
var email = $("input#email").val();
|
||||||
var phone = $("input#phone").val();
|
|
||||||
var message = $("textarea#message").val();
|
var message = $("textarea#message").val();
|
||||||
var firstName = name; // For Success/Failure Message
|
var firstName = name; // For Success/Failure Message
|
||||||
// Check for white space in name for Success/Fail message
|
// Check for white space in name for Success/Fail message
|
||||||
|
|
@ -20,11 +19,11 @@ $(function() {
|
||||||
$this = $("#sendMessageButton");
|
$this = $("#sendMessageButton");
|
||||||
$this.prop("disabled", true); // Disable submit button until AJAX call is complete to prevent duplicate messages
|
$this.prop("disabled", true); // Disable submit button until AJAX call is complete to prevent duplicate messages
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "././mail/contact_me.php",
|
url: "/site/send_email",
|
||||||
type: "POST",
|
type: "POST",
|
||||||
|
beforeSend: function(xhr) {xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content'))},
|
||||||
data: {
|
data: {
|
||||||
name: name,
|
name: name,
|
||||||
phone: phone,
|
|
||||||
email: email,
|
email: email,
|
||||||
message: message
|
message: message
|
||||||
},
|
},
|
||||||
|
|
@ -35,7 +34,7 @@ $(function() {
|
||||||
$('#success > .alert-success').html("<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×")
|
$('#success > .alert-success').html("<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×")
|
||||||
.append("</button>");
|
.append("</button>");
|
||||||
$('#success > .alert-success')
|
$('#success > .alert-success')
|
||||||
.append("<strong>Your message has been sent. </strong>");
|
.append("<strong>Wiadomość została wysłąna. </strong>");
|
||||||
$('#success > .alert-success')
|
$('#success > .alert-success')
|
||||||
.append('</div>');
|
.append('</div>');
|
||||||
//clear all fields
|
//clear all fields
|
||||||
|
|
@ -46,7 +45,7 @@ $(function() {
|
||||||
$('#success').html("<div class='alert alert-danger'>");
|
$('#success').html("<div class='alert alert-danger'>");
|
||||||
$('#success > .alert-danger').html("<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×")
|
$('#success > .alert-danger').html("<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×")
|
||||||
.append("</button>");
|
.append("</button>");
|
||||||
$('#success > .alert-danger').append($("<strong>").text("Sorry " + firstName + ", it seems that my mail server is not responding. Please try again later!"));
|
$('#success > .alert-danger').append($("<strong>").text("Wygląda na to, że serwer nie odpowiada. Proszę spróbuj później."));
|
||||||
$('#success > .alert-danger').append('</div>');
|
$('#success > .alert-danger').append('</div>');
|
||||||
//clear all fields
|
//clear all fields
|
||||||
$('#contactForm').trigger("reset");
|
$('#contactForm').trigger("reset");
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -27,7 +27,10 @@ class SiteController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def send_email
|
def send_email
|
||||||
|
contact = {'name' => params[:name], 'message' => params[:message], 'email' => params[:email]}
|
||||||
|
ContactMailer.contact_email(contact).deliver_now
|
||||||
|
#return head(:bad_request)
|
||||||
|
head :ok
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,10 @@ module ApplicationHelper
|
||||||
|
|
||||||
def menu_top(pages)
|
def menu_top(pages)
|
||||||
ret = '<nav class="navbar navbar-expand-lg navbar-light fixed-top navbar-shrink" id="mainNav">'
|
ret = '<nav class="navbar navbar-expand-lg navbar-light fixed-top navbar-shrink" id="mainNav">'
|
||||||
ret += '<div class="container">'
|
ret += '<div class="container-fluid">'
|
||||||
ret += '<a class="navbar-brand" href="/">Ubezpieczenia-Należności</a>'
|
ret += '<a class="navbar-brand" href="/">Ubezpieczenie-Należności</a>'
|
||||||
|
ret += '<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button>'
|
||||||
|
ret += '<div class="collapse navbar-collapse" id="navbarResponsive">'
|
||||||
ret += '<ul class="navbar-nav ml-auto">'
|
ret += '<ul class="navbar-nav ml-auto">'
|
||||||
friendly_id = nil
|
friendly_id = nil
|
||||||
if params[:id]
|
if params[:id]
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
class ContactMailer < ApplicationMailer
|
||||||
|
default from: 'kontakt@ubezpieczenie-naleznosci.pl'
|
||||||
|
default to: 'adhinz@gmail.com'
|
||||||
|
|
||||||
|
def contact_email(contact)
|
||||||
|
@contact = contact
|
||||||
|
mail(from: @contact['email'], subject: "Kontakt od: #{@contact['name']}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1><%= @contact['name'] %> napisał(ła):</h1>
|
||||||
|
<p><%= @contact['message'] %></p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
<%= @contact['name'] %> napisał(ła):
|
||||||
|
|
||||||
|
<%= @contact['message'] %>
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Ubezpieczenia - Należności - Panel Administracyjny</title>
|
<title>Ubezpieczenie - Należności - Panel Administracyjny</title>
|
||||||
<%= csrf_meta_tags %>
|
<%= csrf_meta_tags %>
|
||||||
<%= favicon_link_tag %>
|
<%= favicon_link_tag %>
|
||||||
<%= stylesheet_link_tag 'application','bootstrap_lte' , 'font-awesome' , media: 'all', 'data-turbolinks-track': 'reload' %>
|
<%= stylesheet_link_tag 'application','bootstrap_lte' , 'font-awesome' , media: 'all', 'data-turbolinks-track': 'reload' %>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title><%= @page.blank? ? 'Ubezpieczenia - Należności' : @page.title %></title>
|
<title><%= @page.blank? ? 'Ubezpieczenie-Należności' : "Ubezpieczenie-Należności: #{@page.title}" %></title>
|
||||||
<%= csrf_meta_tags %>
|
<%= csrf_meta_tags %>
|
||||||
<%= favicon_link_tag %>
|
<%= favicon_link_tag %>
|
||||||
<%= stylesheet_link_tag 'application','bootstrap' , 'font-awesome' , media: 'all', 'data-turbolinks-track': 'reload' %>
|
<%= stylesheet_link_tag 'application','bootstrap' , 'font-awesome' , media: 'all', 'data-turbolinks-track': 'reload' %>
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-8 col-md-10 mx-auto">
|
<div class="col-lg-8 col-md-10 mx-auto">
|
||||||
<p class="copyright text-muted">Copyright © Ubezpieczenia-Należnośći 2018</p>
|
<p class="copyright text-muted">Copyright © Ubezpieczenie-Należnośći 2018</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Ubezpieczenia - Należności - Panel Administracyjny</title>
|
<title>Ubezpieczenie-Należności - Panel Administracyjny</title>
|
||||||
<%= csrf_meta_tags %>
|
<%= csrf_meta_tags %>
|
||||||
<%= favicon_link_tag %>
|
<%= favicon_link_tag %>
|
||||||
<%= stylesheet_link_tag 'application','bootstrap_lte' , 'font-awesome' , media: 'all', 'data-turbolinks-track': 'reload' %>
|
<%= stylesheet_link_tag 'application','bootstrap_lte' , 'font-awesome' , media: 'all', 'data-turbolinks-track': 'reload' %>
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-8 col-md-10 mx-auto">
|
<div class="col-lg-8 col-md-10 mx-auto">
|
||||||
<div class="page-heading">
|
<div class="page-heading">
|
||||||
<h1>Skontaktuj się</h1>
|
<h1>Napisz do mnie<br>lub zadzwoń.</h1>
|
||||||
<span class="subheading">Masz pytania? Udzielę odpowiedzi.</span>
|
<span class="subheading">Masz pytania? Udzielę odpowiedzi.</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -18,9 +18,6 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-8 col-md-10 mx-auto">
|
<div class="col-lg-8 col-md-10 mx-auto">
|
||||||
<p>Wypełnij poniższy formularz i wyślij go do mnie. Odpowiem najszybciej jak to możliwe.</p>
|
<p>Wypełnij poniższy formularz i wyślij go do mnie. Odpowiem najszybciej jak to możliwe.</p>
|
||||||
<!-- Contact Form - Enter your email address on line 19 of the mail/contact_me.php file to make this form work. -->
|
|
||||||
<!-- WARNING: Some web hosts do not allow emails to be sent through forms to common mail hosts like Gmail or Yahoo. It's recommended that you use a private domain email address! -->
|
|
||||||
<!-- To use the contact form, your site must be on a live web host with PHP! The form will not work locally! -->
|
|
||||||
<form name="sentMessage" id="contactForm" novalidate>
|
<form name="sentMessage" id="contactForm" novalidate>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<div class="form-group floating-label-form-group controls">
|
<div class="form-group floating-label-form-group controls">
|
||||||
|
|
@ -32,7 +29,7 @@
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<div class="form-group floating-label-form-group controls">
|
<div class="form-group floating-label-form-group controls">
|
||||||
<label>Adres Email</label>
|
<label>Adres Email</label>
|
||||||
<input type="email" class="form-control" placeholder="Adres Email" id="email" required data-validation-required-message="Proszę wprowadzić adres email.">
|
<input type="email" class="form-control" placeholder="Adres Email" id="email" required data-validation-required-message="Proszę wprowadzić adres email." data-validation-validemail-message="Błędny format adresu email.">
|
||||||
<p class="help-block text-danger"></p>
|
<p class="help-block text-danger"></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -52,3 +49,6 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<% content_for :footer_scripts do %>
|
||||||
|
<%= javascript_include_tag 'jqBootstrapValidation', 'contact_me' %>
|
||||||
|
<% end %>
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,10 @@ Rails.application.configure do
|
||||||
|
|
||||||
config.action_mailer.perform_caching = false
|
config.action_mailer.perform_caching = false
|
||||||
|
|
||||||
|
config.action_mailer.delivery_method = :sendmail
|
||||||
|
config.action_mailer.perform_deliveries = true
|
||||||
|
config.action_mailer.raise_delivery_errors = true
|
||||||
|
config.action_mailer.default_options = {from: 'no-reply@mini-blog.xyz'}
|
||||||
# Print deprecation notices to the Rails logger.
|
# Print deprecation notices to the Rails logger.
|
||||||
config.active_support.deprecation = :log
|
config.active_support.deprecation = :log
|
||||||
|
|
||||||
|
|
@ -45,7 +49,7 @@ Rails.application.configure do
|
||||||
# Suppress logger output for asset requests.
|
# Suppress logger output for asset requests.
|
||||||
config.assets.quiet = true
|
config.assets.quiet = true
|
||||||
|
|
||||||
config.assets.precompile += ['*.js', '*.css']
|
config.assets.precompile += ['*.js', '*.css']
|
||||||
|
|
||||||
# Raises error for missing translations
|
# Raises error for missing translations
|
||||||
# config.action_view.raise_on_missing_translations = true
|
# config.action_view.raise_on_missing_translations = true
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ Rails.application.routes.draw do
|
||||||
resources :article
|
resources :article
|
||||||
end
|
end
|
||||||
devise_for :admins
|
devise_for :admins
|
||||||
|
post 'site/send_email'
|
||||||
get 'site/kontakt'
|
get 'site/kontakt'
|
||||||
get 'site/preview/:id' => 'site#preview'
|
get 'site/preview/:id' => 'site#preview'
|
||||||
root 'site#index'
|
root 'site#index'
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class ContactMailerTest < ActionMailer::TestCase
|
||||||
|
# test "the truth" do
|
||||||
|
# assert true
|
||||||
|
# end
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
# Preview all emails at http://localhost:3000/rails/mailers/contact_mailer
|
||||||
|
class ContactMailerPreview < ActionMailer::Preview
|
||||||
|
|
||||||
|
end
|
||||||
Loading…
Reference in New Issue