diff --git a/app/assets/images/campaigns.png b/app/assets/images/campaigns.png index 7865a31..d5022f8 100644 Binary files a/app/assets/images/campaigns.png and b/app/assets/images/campaigns.png differ diff --git a/app/assets/images/email-template.png b/app/assets/images/email-template.png deleted file mode 100644 index 745d2e2..0000000 Binary files a/app/assets/images/email-template.png and /dev/null differ diff --git a/app/assets/images/filter.png b/app/assets/images/filter.png new file mode 100644 index 0000000..fb51353 Binary files /dev/null and b/app/assets/images/filter.png differ diff --git a/app/assets/images/inbox.png b/app/assets/images/inbox.png new file mode 100644 index 0000000..62f5459 Binary files /dev/null and b/app/assets/images/inbox.png differ diff --git a/app/assets/images/mj.png b/app/assets/images/mj.png deleted file mode 100644 index 1f687d5..0000000 Binary files a/app/assets/images/mj.png and /dev/null differ diff --git a/app/assets/images/ss-users.png b/app/assets/images/ss-users.png deleted file mode 100644 index 42711b6..0000000 Binary files a/app/assets/images/ss-users.png and /dev/null differ diff --git a/app/assets/images/template.png b/app/assets/images/template.png new file mode 100644 index 0000000..f9faca5 Binary files /dev/null and b/app/assets/images/template.png differ diff --git a/app/assets/images/users.png b/app/assets/images/users.png new file mode 100644 index 0000000..bb9916d Binary files /dev/null and b/app/assets/images/users.png differ diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 8fe3dfa..8c61f05 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -43,5 +43,5 @@ $( document ).ready(function() { }); function reply_template_select(){ - $('#body').text($('#reply_email_template').val()); + $('#body').val($('#reply_email_template').val()); } diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index d2d610e..a0b85ed 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -29,10 +29,5 @@ height: 500px; } -.jumbotron { - padding-top: 0; - background-color: #2A3F54; - color: #ffffff; -} +.btn-info { background-color: #2b9cbd; } -.btn-info { background-color: #2b9cbd; } \ No newline at end of file diff --git a/app/assets/stylesheets/landing.scss b/app/assets/stylesheets/landing.scss new file mode 100644 index 0000000..2cd555d --- /dev/null +++ b/app/assets/stylesheets/landing.scss @@ -0,0 +1,155 @@ +@import "bootstrap-sprockets"; +@import "bootstrap"; + +.jumbotron { + padding-top: 0; + background-color: #2A3F54; + color: #ffffff; +} + +// Landing Page CSS +.topnav { + font-size: 14px; +} + +.lead { + font-size: 18px; + font-weight: 400; +} + +.intro-header { + text-align: center; + color: #f8f8f8; + background-color: #2A3F54; + background-size: cover; +} + +.intro-message { + position: relative; + padding-top: 10%; + padding-bottom: 10%; +} + +.intro-message > h1 { + margin: 0; + text-shadow: 2px 2px 3px rgba(0,0,0,0.6); + font-size: 5em; +} + +.intro-divider { + width: 400px; + border-top: 1px solid #f8f8f8; + border-bottom: 1px solid rgba(0,0,0,0.2); +} + +.intro-message > h3 { + text-shadow: 2px 2px 3px rgba(0,0,0,0.6); +} + +@media(max-width:767px) { + .intro-message { + padding-bottom: 15%; + } + + .intro-message > h1 { + font-size: 3em; + } + + ul.intro-social-buttons > li { + display: block; + margin-bottom: 20px; + padding: 0; + } + + ul.intro-social-buttons > li:last-child { + margin-bottom: 0; + } + + .intro-divider { + width: 100%; + } +} + +.network-name { + text-transform: uppercase; + font-size: 14px; + font-weight: 400; + letter-spacing: 2px; +} + +.content-section-a { + padding: 50px 0; + background-color: #f8f8f8; +} + +.content-section-b { + padding: 50px 0; + border-top: 1px solid #e7e7e7; + border-bottom: 1px solid #e7e7e7; +} + +.section-heading { + margin-bottom: 30px; +} + +.section-heading-spacer { + float: left; + width: 200px; + border-top: 3px solid #e7e7e7; +} + +.banner { + padding: 100px 0; + color: #f8f8f8; + background: url(../img/banner-bg.jpg) no-repeat center center; + background-size: cover; +} + +.banner h2 { + margin: 0; + text-shadow: 2px 2px 3px rgba(0,0,0,0.6); + font-size: 3em; +} + +.banner ul { + margin-bottom: 0; +} + +.banner-social-buttons { + float: right; + margin-top: 0; +} + +@media(max-width:1199px) { + ul.banner-social-buttons { + float: left; + margin-top: 15px; + } +} + +@media(max-width:767px) { + .banner h2 { + margin: 0; + text-shadow: 2px 2px 3px rgba(0,0,0,0.6); + font-size: 3em; + } + + ul.banner-social-buttons > li { + display: block; + margin-bottom: 20px; + padding: 0; + } + + ul.banner-social-buttons > li:last-child { + margin-bottom: 0; + } +} + +footer { + padding: 50px 0; + background-color: #f8f8f8; +} + +p.copyright { + margin: 15px 0 0; +} \ No newline at end of file diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index fb5d10d..8259f50 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,6 +1,8 @@ class ApplicationController < ActionController::Base protect_from_forgery with: :exception + before_action :authenticate_account! + def set_all_tags @all_tags = ActsAsTaggableOn::Tag.all.pluck(:name) end diff --git a/app/controllers/campaigns_controller.rb b/app/controllers/campaigns_controller.rb index d499c42..f91e750 100644 --- a/app/controllers/campaigns_controller.rb +++ b/app/controllers/campaigns_controller.rb @@ -1,8 +1,9 @@ class CampaignsController < ApplicationController - before_action :authenticate_account!, except: :event_receiver + skip_before_action :authenticate_account!, only: :event_receiver + skip_before_action :verify_authenticity_token, only: :event_receiver + before_action :set_campaign, only: [:show, :destroy, :send_emails] before_action :check_new_campaign_avaibility, :set_all_tags, only: :new - skip_before_action :verify_authenticity_token, only: :event_receiver def index @associations = [:users, :tags, :email_template, :campaign_users] @@ -57,13 +58,14 @@ def destroy def send_emails # Redirect to settings path if account doesn't have settings. - unless current_account.mail_setting.try(:all_present?) - redirect_to settings_path, notice: 'Your settings information are required!' + smtp_settings = current_account.smtp_settings.find_by(id: params[:smtp_id]) || current_account.smtp_settings.default_for_campaigns + if !smtp_settings.present? || !smtp_settings.try(:all_present?) + redirect_to smtp_settings_path, notice: 'Your SMTP settings are required!' return end # Send campaign emails in bg job - SendCampaignEmailsJob.perform_later(@campaign.id) + SendCampaignEmailsJob.perform_later(@campaign.id, smtp_settings.id) redirect_to campaign_path(@campaign), notice: 'Emails sending in background!' end diff --git a/app/controllers/email_templates_controller.rb b/app/controllers/email_templates_controller.rb index e39ef04..84a360e 100644 --- a/app/controllers/email_templates_controller.rb +++ b/app/controllers/email_templates_controller.rb @@ -1,5 +1,4 @@ class EmailTemplatesController < ApplicationController - before_action :authenticate_account! before_action :set_email_template, only: [:show, :edit, :update, :destroy] def index diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 3f00e84..501c207 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -1,23 +1,8 @@ class HomeController < ApplicationController - before_action :authenticate_account!, only: :settings - def index; end - - def settings - @settings = current_account.mail_setting - end + layout 'welcome' + skip_before_action :authenticate_account! - def update_settings - if current_account.mail_setting.update(settings_params) - redirect_to settings_path, notice: 'Settings updated successfully!' - else - redirect_to settings_path, notice: 'Error! Settings not updated!' - end - end - - private + def index; end - def settings_params - params.require(:settings).permit(:from_email, :reply_to, :address, :port, :domain, :user_name, :password, :provider, - :imap_password, :imap_port, :imap_address, :imap_username) - end + def documentation; end end diff --git a/app/controllers/imap_settings_controller.rb b/app/controllers/imap_settings_controller.rb new file mode 100644 index 0000000..e686846 --- /dev/null +++ b/app/controllers/imap_settings_controller.rb @@ -0,0 +1,62 @@ +class ImapSettingsController < ApplicationController + before_action :set_imap_setting, only: [:edit, :update, :destroy] + + # GET /imap_settings + def index + @imap_settings = current_account.imap_settings.all + end + + # GET /imap_settings/new + def new + unless current_account.smtp_settings.present? + redirect_to smtp_settings_path, notice: 'Please define at least one smtp settings to read reply emails of it.' + return + end + @imap_setting = current_account.imap_settings.new + end + + # GET /imap_settings/1/edit + def edit + end + + # POST /imap_settings + def create + @imap_setting = current_account.imap_settings.new(imap_setting_params) + + respond_to do |format| + if @imap_setting.save + format.html { redirect_to imap_settings_path, notice: 'IMAP setting was successfully created.' } + else + format.html { render :new } + end + end + end + + # PATCH/PUT /imap_settings/1 + def update + respond_to do |format| + if @imap_setting.update(imap_setting_params) + format.html { redirect_to imap_settings_path, notice: 'IMAP setting was successfully updated.' } + else + format.html { render :edit } + end + end + end + + # DELETE /imap_settings/1 + def destroy + @imap_setting.destroy + respond_to do |format| + format.html { redirect_to imap_settings_url, notice: 'IMAP setting was successfully destroyed.' } + end + end + + private + def set_imap_setting + @imap_setting = current_account.imap_settings.find(params[:id]) + end + + def imap_setting_params + params.require(:imap_setting).permit(:address, :port, :email, :password) + end +end diff --git a/app/controllers/inbox_controller.rb b/app/controllers/inbox_controller.rb index 53dac6c..f514af7 100644 --- a/app/controllers/inbox_controller.rb +++ b/app/controllers/inbox_controller.rb @@ -1,7 +1,5 @@ class InboxController < ApplicationController - before_action :authenticate_account! before_action :set_imap_settings, only: :index - before_action :set_smtp_settings, only: :reply_email def index if params[:from].present? && params[:to].present? @@ -17,6 +15,7 @@ def detail @message = params[:message] @subject = params[:subject] @email = params[:email] + @has_attach = params[:has_attachments] @user = current_account.users.find_by(email: @email) if @user.present? @@ -35,53 +34,30 @@ def reply_email mail_to = params[:mail_to] mail_body = Tilt::ERBTemplate.new { params[:body] } content = mail_body.render(current_account.users.find_by(email: params[:mail_to])) - mail_from = current_account.mail_setting.imap_username + smtp_id = current_account.smtp_settings.find_by(id: params[:smtp_id]).try(:id) || + current_account.smtp_settings.where(is_default_for_campaigns: true).first.try(:id) - Mail.deliver do - from mail_from - to mail_to - subject subject - html_part do - content_type 'text/html; charset=UTF-8' - body content - end - end + UserMailer.reply_email(mail_to, subject, content, smtp_id).deliver_now end private # To read emails def set_imap_settings - settings = current_account.mail_setting + settings = current_account.imap_settings.find_by(id: params[:imap_id]) || current_account.imap_settings.first - if !settings.imap_address.present? || !settings.imap_port.present? || !settings.imap_password.present? || !settings.imap_username.present? - redirect_to settings_path, notice: 'Please! Add your IMAP Settings to read the messages.' + if !settings.present? || !settings.address.present? || !settings.port.present? || !settings.password.present? || !settings.email.present? + redirect_to imap_settings_path, notice: 'Please! Add your IMAP Settings to read the messages.' return end Mail.defaults do retriever_method :imap, - :address => settings.imap_address, - :port => settings.imap_port, - :user_name => settings.imap_username, - :password => settings.imap_password, + :address => settings.address, + :port => settings.port, + :user_name => settings.email, + :password => settings.password, :enable_ssl => true end end - - # To send email - def set_smtp_settings - settings = current_account.mail_setting - - Mail.defaults do - delivery_method :smtp, - user_name: settings.user_name, - password: settings.password, - address: settings.address, - port: settings.port, - domain: settings.domain, - authentication: 'plain', - enable_starttls_auto: true - end - end end diff --git a/app/controllers/smtp_settings_controller.rb b/app/controllers/smtp_settings_controller.rb new file mode 100644 index 0000000..9f4a07c --- /dev/null +++ b/app/controllers/smtp_settings_controller.rb @@ -0,0 +1,71 @@ +class SmtpSettingsController < ApplicationController + before_action :set_smtp_setting, only: [:edit, :update, :destroy, :set_default_for_campaigns, :set_default_for_reply] + + # GET /smtp_settings + def index + @smtp_settings = current_account.smtp_settings.order('created_at DESC') + end + + # GET /smtp_settings/new + def new + @smtp_setting = current_account.smtp_settings.new + end + + # GET /smtp_settings/1/edit + def edit + end + + # POST /smtp_settings + def create + @smtp_setting = current_account.smtp_settings.new(smtp_setting_params) + + respond_to do |format| + if @smtp_setting.save + @smtp_setting.update(is_default_for_campaigns: true, is_default_for_reply: true) if current_account.smtp_settings.count == 1 + format.html { redirect_to smtp_settings_path, notice: 'Smtp setting was successfully created.' } + else + format.html { render :new } + end + end + end + + # PATCH/PUT /smtp_settings/1 + def update + respond_to do |format| + if @smtp_setting.update(smtp_setting_params) + format.html { redirect_to smtp_settings_path, notice: 'Smtp setting was successfully updated.' } + else + format.html { render :edit } + end + end + end + + # DELETE /smtp_settings/1 + def destroy + @smtp_setting.destroy + respond_to do |format| + format.html { redirect_to smtp_settings_url, notice: 'Smtp setting was successfully destroyed.' } + end + end + + def set_default_for_campaigns + current_account.smtp_settings.update_all(is_default_for_campaigns: false) + @smtp_setting.update(is_default_for_campaigns: true) + redirect_to smtp_settings_url + end + + def set_default_for_reply + current_account.smtp_settings.update_all(is_default_for_reply: false) + @smtp_setting.update(is_default_for_reply: true) + redirect_to smtp_settings_url + end + + private + def set_smtp_setting + @smtp_setting = current_account.smtp_settings.find(params[:id]) + end + + def smtp_setting_params + params.require(:smtp_setting).permit(:from_email, :reply_to, :provider, :address, :port, :domain, :username, :password, :is_default_for_campaigns, :is_default_for_reply) + end +end diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 1efe18c..970563d 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -1,7 +1,5 @@ class TagsController < ApplicationController helper_method :xeditable? - - before_action :authenticate_account! before_action :set_tag, only: [:update, :destroy] def index diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 699a918..b55be94 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,5 +1,4 @@ class UsersController < ApplicationController - before_action :authenticate_account! before_action :set_all_tags, only: [:new, :import] def index diff --git a/app/helpers/smtp_settings_helper.rb b/app/helpers/smtp_settings_helper.rb new file mode 100644 index 0000000..e18efd4 --- /dev/null +++ b/app/helpers/smtp_settings_helper.rb @@ -0,0 +1,2 @@ +module SmtpSettingsHelper +end diff --git a/app/jobs/send_campaign_emails_job.rb b/app/jobs/send_campaign_emails_job.rb index 56d47d0..95007f2 100644 --- a/app/jobs/send_campaign_emails_job.rb +++ b/app/jobs/send_campaign_emails_job.rb @@ -1,12 +1,12 @@ class SendCampaignEmailsJob < ApplicationJob # No retry - def perform(campaign_id) + def perform(campaign_id, smtp_id) campaign = Campaign.find campaign_id campaign.campaign_users.where(status: 'draft').find_each do |campaign_user| begin - UserMailer.campaign_email(campaign_user).deliver_now + UserMailer.campaign_email(campaign_user, smtp_id).deliver_now campaign_user.update(sent_at: Time.now, status: 'processed') rescue => ex Rails.logger.info ex diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 8dc04b3..1eebfdd 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -2,19 +2,9 @@ class ApplicationMailer < ActionMailer::Base default from: 'from@example.com' layout 'mailer' - def send_email_with_delivery_options(campaign_user, subject) + def send_email_with_delivery_options(campaign_user, subject, smtp_id) - settings = campaign_user.user.account.mail_setting - - delivery_options = { - user_name: settings.user_name, - password: settings.password, - address: settings.address, - port: settings.port, - domain: settings.domain, - authentication: 'plain', - enable_starttls_auto: true - } + settings = campaign_user.user.account.smtp_settings.find(smtp_id) # Set unique args at header headers 'X-SMTPAPI' => { unique_args: { campaign_user_id: campaign_user.id } }.to_json @@ -24,7 +14,34 @@ def send_email_with_delivery_options(campaign_user, subject) reply_to: settings.reply_to.presence || settings.try(:from_email), subject: subject, from: settings.try(:from_email), - delivery_method_options: delivery_options + delivery_method_options: get_options(settings) ) end + + def reply_email_with_delivery_options(mail_to, subject, smtp_id) + + settings = SmtpSetting.find(smtp_id) + + mail( + to: mail_to, + reply_to: settings.reply_to.presence || settings.from_email, + subject: subject, + from: settings.from_email, + delivery_method_options: get_options(settings) + ) + end + + private + + def get_options(settings) + { + user_name: settings.username, + password: settings.password, + address: settings.address, + port: settings.port, + domain: settings.domain, + authentication: 'plain', + enable_starttls_auto: true + } + end end diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index 67cad83..36c0c4e 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -1,5 +1,5 @@ class UserMailer < ApplicationMailer - def campaign_email(campaign_user) + def campaign_email(campaign_user, smtp_id) @campaign_user = campaign_user @user = campaign_user.user @@ -8,9 +8,13 @@ def campaign_email(campaign_user) body = Tilt::ERBTemplate.new { "#{template.body}" } subject = Tilt::ERBTemplate.new { "#{template.subject}" } - @subject = subject.render(@user) @content = body.render(@user) - send_email_with_delivery_options(campaign_user, @subject) + send_email_with_delivery_options(campaign_user, subject.render(@user), smtp_id) + end + + def reply_email(mail_to, subject, content, smtp_id) + @content = content + reply_email_with_delivery_options(mail_to, subject, smtp_id) end end diff --git a/app/models/account.rb b/app/models/account.rb index f3fad65..5fe88ac 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -30,8 +30,6 @@ class Account < ApplicationRecord has_many :users has_many :campaigns has_many :email_templates - - has_one :mail_setting - - after_create :create_mail_setting + has_many :smtp_settings + has_many :imap_settings end diff --git a/app/models/imap_setting.rb b/app/models/imap_setting.rb new file mode 100644 index 0000000..8779271 --- /dev/null +++ b/app/models/imap_setting.rb @@ -0,0 +1,3 @@ +class ImapSetting < ApplicationRecord + belongs_to :account +end diff --git a/app/models/smtp_setting.rb b/app/models/smtp_setting.rb new file mode 100644 index 0000000..4d1b115 --- /dev/null +++ b/app/models/smtp_setting.rb @@ -0,0 +1,16 @@ +class SmtpSetting < ApplicationRecord + belongs_to :account + + def all_present? + from_email.present? && address.present? && port.present? && + domain.present? && username.present? && password.present? + end + + def self.default_for_campaigns + where(is_default_for_campaigns: true).first + end + + def self.default_for_reply + where(is_default_for_reply: true).first + end +end diff --git a/app/views/campaigns/_template_form.html.haml b/app/views/campaigns/_template_form.html.haml index f45c94b..95c43b6 100644 --- a/app/views/campaigns/_template_form.html.haml +++ b/app/views/campaigns/_template_form.html.haml @@ -1,11 +1,20 @@ - body = Tilt::ERBTemplate.new { "#{@campaign.email_template.body}" } - subject = Tilt::ERBTemplate.new { "#{@campaign.email_template.subject}" } -%h2.text-center - = subject.render(User.first).html_safe -= body.render(User.first).html_safe +.x_panel + %h2 + .text-center + = subject.render(User.first).html_safe + .pull-right + = link_to 'Edit Template', edit_email_template_path(@campaign.email_template), class: 'btn btn-default btn-xs' + = body.render(User.first).html_safe -%hr = form_tag send_emails_campaign_path(@campaign), method: :post do .actions.text-center - = submit_tag 'Send Campaign Emails', class: 'btn btn-success', data: { confirm: 'This email will send only to email addresses in draft status. Are you sure?' } + .col-md-6 + Select SMTP Settings + = select_tag 'smtp_id', options_for_select(current_account.smtp_settings.map{|ss| [ ss.provider, ss.id ]}, current_account.smtp_settings.default_for_campaigns.try(:id)), include_blank: false, class: 'form-control' + .col-md-6 + = submit_tag 'Send Campaign Emails', class: 'btn btn-success btn-block', data: { confirm: 'This email will send only to email addresses in draft status. Are you sure?' }, style: 'margin-top: 17px;' + +%hr \ No newline at end of file diff --git a/app/views/campaigns/index.html.haml b/app/views/campaigns/index.html.haml index 6b63ffc..7a15be1 100644 --- a/app/views/campaigns/index.html.haml +++ b/app/views/campaigns/index.html.haml @@ -42,7 +42,7 @@ %span.btn.btn-info.btn-xs = tag %td= campaign.users.count - %td= CampaignUser.where.not(status: 'draft').count + %td= campaign.campaign_users.where.not(status: 'draft').count %td = link_to "##{campaign.email_template.id}", email_template_path(campaign.email_template), 'data-toggle': 'tooltip', 'data-placement': 'top', 'data-original-title': "#{campaign.email_template.subject}" %td diff --git a/app/views/campaigns/show.html.haml b/app/views/campaigns/show.html.haml index d78e62d..3c6c25a 100644 --- a/app/views/campaigns/show.html.haml +++ b/app/views/campaigns/show.html.haml @@ -8,8 +8,8 @@ %div{id: "CampaignTags-#{@campaign.id}"} = render partial: 'tags/item_tags', locals: { item: @campaign } -.x_panel - = render 'template_form' + += render 'template_form' .x_panel .x_title diff --git a/app/views/email_templates/_form.html.haml b/app/views/email_templates/_form.html.haml index 0bc6f7b..826092f 100644 --- a/app/views/email_templates/_form.html.haml +++ b/app/views/email_templates/_form.html.haml @@ -17,7 +17,7 @@ = f.text_area :body, class: 'form-control', rows: 28 %p.text-muted - To put each user name in the emails use: <%= self.name %> keyword instead of name etc... You can use ruby codes here. + To put each user name in the emails use: <%= self.try(:name) %> keyword instead of name or for any user custom data (<%= self.try(:phone) %>, <%= self.try(:city) %> etc...). You can use ruby codes here. .actions = f.submit 'Submit', class: 'btn btn-primary' diff --git a/app/views/email_templates/index.html.haml b/app/views/email_templates/index.html.haml index e5d5fbf..126d849 100644 --- a/app/views/email_templates/index.html.haml +++ b/app/views/email_templates/index.html.haml @@ -1,7 +1,7 @@ %div .page-title .title_left - %h3 Listing Users + %h3 Listing Email Templates .title_right .col-md-12.col-sm-12.col-xs-12.text-right = link_to new_email_template_path do diff --git a/app/views/home/documentation.html.erb b/app/views/home/documentation.html.erb new file mode 100644 index 0000000..e69de29 diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index 05ca1e6..4cf12d8 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -1,55 +1,85 @@ -/ Main jumbotron for a primary marketing message or call to action -.jumbotron - .container.text-center - %h1 Smart Email Marketing - %div - %h1 - %i.fa.fa-envelope-open - %p - %i.tagline A minimal email marketing tool. - %div - %a.btn.btn-primary.btn-lg{:href => new_account_session_path} Login - %a.btn.btn-success.btn-lg{:href => new_account_registration_path} Sign Up - -.section{style: 'background-color: white;margin-top: -2%;'} +.intro-header .container - .row.text-center - .col-md-5.col-xs-12 - %h1{:style => "color:#2d3e4f"} Import Users! - %br/ - %h4 You can import your users list from csv file or add them manually with additional attributes. - %br/ - %h4 Also you can add tag to users while importing to whole of the list or you can add/remove tags manually later. - %br/ - %h3 After filtering create a new campaign for filtered user. - .col-md-7.col-xs-12 - = image_tag 'ss-users.png', width: '100%', style: 'padding: 2%' - -.section - .container - .row.text-center - .col-md-7.col-xs-12 - = image_tag 'email-template.png', width: '100%', style: 'padding: 2%' - .col-md-5.col-xs-12 - %h1{:style => "color:#2d3e4f"} Email Templates! - %br/ - %h4 Create a new email template as html for your campaign email. - %h4 You can select your template and you can add tags to campaign while creating the campaign. - -.section{style: 'background-color: white;'} + .row + .col-lg-12 + .intro-message + %h1 Smart Email Marketing + %h4 A simple dockerized rails app to manage your emails and campaigns with taggings. + %h4 You can find brief explanation as following or all features below. + %hr.intro-divider/ + %ul.list-inline.intro-social-buttons + %li + %a.btn.btn-success.btn-lg{:href => new_account_session_path } + %span.network-name Login + %li + %a.btn.btn-info.btn-lg{:href => new_account_registration_path } + %span.network-name Sign Up + %li + %a.btn.btn-default.btn-lg{:href => 'https://github.com/svtek/smart-emailing', target: '_blank'} + %i.fa.fa-github.fa-fw + %span.network-name Github + +.content-section-a .container - .row.text-center - .col-md-5.col-xs-12 - %h1{:style => "color:#2d3e4f"} Sending Campaign Email! - %br/ - %h4 You should set your email provider settings to sending campaign emails. - %br/ - %h4 If your provider is sendgrid, you can also add Sendgrid Event Notification to recieve emails statuses. - %p Go to: https://app.sendgrid.com/settings/mail_settings -> Event Notification - %p Then set this app domain to with receiver path. Example: smartemailmarketing-domain.com/campaigns/event_receiver + .row + .col-lg-5.col-sm-6 + %h3.section-heading About %p - Click - %a{href: 'https://sendgrid.com/docs/API_Reference/Webhooks/event.html'} here - for more info. - .col-md-7.col-xs-12 - = image_tag 'campaigns.png', width: '100%', style: 'padding: 2%' \ No newline at end of file + Using the app, you can easily add your users, tag and categorize them, set campaigns separately or combined while creating email templates. Then, you will be managing your campaigns with adding tags to every campaign-user records or whole campaign. Finally, you can get replied emails, categorized them or reply with template responses directly from inbox. + .col-lg-5.col-lg-offset-2.col-sm-6 + -#%img.img-responsive{:alt => "", :src => "img/ipad.png"}/ + = image_tag 'users.png', class: 'img-responsive' + +.content-section-b + .container + .row + .col-lg-5.col-lg-offset-1.col-sm-push-6.col-sm-6 + %h3.section-heading CRM + %ul + %li Import users manually or from csv (any column name will become custom data) + %li Add tags or custom data as key-value pairs to users + %li Filter users with simple and advanced search using tags, previous campaign,campaign status, email open status etc. + %li Create a campaign from filtered user results or add filtered users to an existing campaign. + .col-lg-5.col-sm-pull-6.col-sm-6 + = image_tag 'filter.png', class: 'img-responsive' + +.content-section-a + .container + .row + .col-lg-5.col-sm-6 + %h3.section-heading Campaign Managment + %ul + %li Select an created email template + %li Add tags to campaigns + %li Send emails from any email provider to all campaign users + %li Add tags to campaign-user (mutated record from the Campaign and User) + %li Create a new campaign with filtering from the existing campaign + %li Get email statistics if you choose sendgrid as a provider + + .col-lg-5.col-lg-offset-2.col-sm-6 + = image_tag 'campaigns.png', class: 'img-responsive' + +.content-section-b + .container + .row + .col-lg-5.col-lg-offset-1.col-sm-push-6.col-sm-6 + %h3.section-heading Inbox + %ul + %li Email inbox parsing and email matching for replied emails + %li Add tags, and campaign-user tags directly from inbox + %li Quick template responses directly from inbox + + .col-lg-5.col-sm-pull-6.col-sm-6 + = image_tag 'inbox.png', class: 'img-responsive' + +.content-section-a + .container + .row + .col-lg-5.col-sm-6 + %h3.section-heading Email Template + %p Create email templates with writing any ruby code for using users custom data in the content + .col-lg-5.col-lg-offset-2.col-sm-6 + -#%img.img-responsive{:alt => "", :src => "img/ipad.png"}/ + = image_tag 'template.png', class: 'img-responsive' + + diff --git a/app/views/home/settings.html.haml b/app/views/home/settings.html.haml deleted file mode 100644 index 862992a..0000000 --- a/app/views/home/settings.html.haml +++ /dev/null @@ -1,74 +0,0 @@ -.x_panel - / Nav tabs - .card - %ul.nav.nav-tabs{:role => "tablist"} - %li.active{:role => "presentation"} - %a{"aria-controls" => "home", "data-toggle" => "tab", :href => "#smtp", :role => "tab"} SMTP Settings - %li{:role => "presentation"} - %a{"aria-controls" => "profile", "data-toggle" => "tab", :href => "#reply", :role => "tab"} Reply Settings - %li{:role => "presentation"} - %a{"aria-controls" => "profile", "data-toggle" => "tab", :href => "#imap", :role => "tab"} IMAP Settings - / Tab panes - .tab-content - #smtp.tab-pane.active{:role => "tabpanel"} - %p Add your settings for sending campaign emails. - - = form_tag update_settings_path, method: :post do - = label_tag 'Send emails from email:' - = text_field_tag 'settings[from_email]', @settings.from_email, class: 'form-control', placeholder: 'example@yourdomain.com' - - %hr - %h4.text-muted SMTP Settings - - = label_tag 'Set smtp provider:' - = text_field_tag 'settings[provider]', @settings.provider, class: 'form-control', placeholder: 'sendgrid' - %hr - - = label_tag 'smtp address' - = text_field_tag 'settings[address]', @settings.address, class: 'form-control', placeholder: 'smtp.examplemailserver.com' - - = label_tag 'smtp port' - = text_field_tag 'settings[port]', @settings.port, class: 'form-control', placeholder: '587' - - = label_tag 'Your verified domain' - = text_field_tag 'settings[domain]', @settings.domain, class: 'form-control', placeholder: 'example.com' - - = label_tag 'username' - = text_field_tag 'settings[user_name]', @settings.user_name, class: 'form-control', placeholder: 'username' - - = label_tag 'password' - = password_field_tag 'settings[password]', @settings.password, class: 'form-control', placeholder: '*********' - - .actions - = submit_tag 'Update Settings', class: 'btn btn-primary' - - #reply.tab-pane{:role => "tabpanel"} - %p Add an email address the campaign users can reply to. - = form_tag update_settings_path, method: :post do - = label_tag 'Reply to email:' - = text_field_tag 'settings[reply_to]', @settings.reply_to, class: 'form-control', placeholder: 'example@yourdomain.com' - - .actions - = submit_tag 'Update Settings', class: 'btn btn-primary' - - #imap.tab-pane{:role => "tabpanel"} - %p Add IMAP settings to read replied emails. - = form_tag update_settings_path, method: :post do - - %hr - %h4.text-muted IMAP Settings - - = label_tag 'imap address' - = text_field_tag 'settings[imap_address]', @settings.imap_address, class: 'form-control', placeholder: 'outlook.office365.com' - - = label_tag 'imap port' - = text_field_tag 'settings[imap_port]', @settings.imap_port, class: 'form-control', placeholder: '993' - - = label_tag 'IMAP email' - = text_field_tag 'settings[imap_username]', @settings.imap_username, class: 'form-control', placeholder: 'example@yourdomain.com' - - = label_tag 'password' - = password_field_tag 'settings[imap_password]', @settings.imap_password, class: 'form-control', placeholder: '********' - - .actions - = submit_tag 'Update Settings', class: 'btn btn-primary' diff --git a/app/views/imap_settings/_form.html.haml b/app/views/imap_settings/_form.html.haml new file mode 100644 index 0000000..63ff0cd --- /dev/null +++ b/app/views/imap_settings/_form.html.haml @@ -0,0 +1,25 @@ +.col-md-6 + .x_panel + = form_for @imap_setting do |f| + - if @imap_setting.errors.any? + #error_explanation + %h2= "#{pluralize(@imap_setting.errors.count, "error")} prohibited this SMTP Setting from being saved:" + %ul + - @imap_setting.errors.full_messages.each do |msg| + %li= msg + + .field + = f.label 'IMAP address' + = f.text_field :address, class: 'form-control' + .field + = f.label :port + = f.text_field :port, class: 'form-control', required: true + .field + = f.label :email + = f.select :email, options_for_select(current_account.smtp_settings.pluck(:reply_to).uniq), { include_blank: false }, { class: 'form-control' } + .field + = f.label :password + = f.password_field :password, class: 'form-control', required: true + .actions + = f.submit 'Save', class: 'btn btn-primary' +.col-sm-6 diff --git a/app/views/imap_settings/edit.html.haml b/app/views/imap_settings/edit.html.haml new file mode 100644 index 0000000..8b6f9b7 --- /dev/null +++ b/app/views/imap_settings/edit.html.haml @@ -0,0 +1,6 @@ +%h1 Editing IMAP Setting + += render 'form' + +.col-md-12 + = link_to 'Back', imap_settings_path, class: 'btn btn-default btn-xs' diff --git a/app/views/imap_settings/index.html.haml b/app/views/imap_settings/index.html.haml new file mode 100644 index 0000000..bfb96c9 --- /dev/null +++ b/app/views/imap_settings/index.html.haml @@ -0,0 +1,28 @@ +%div + .page-title + .title_left + %h3 Listing IMAP Settings + .title_right + .col-md-12.col-sm-12.col-xs-12.text-right + = link_to new_imap_setting_path do + %button.btn.btn-primary New IMAP Settings +.clearfix +.x_panel + %p Add IMAP settings to read replied emails. + %table.table.table-striped.projects + %thead + %tr + %th Address + %th Port + %th Email + %th.text-center{width: '200px'} # + %tbody + - @imap_settings.each do |imap_setting| + %tr + %td= imap_setting.address + %td= imap_setting.port + %td= imap_setting.email + %td + = link_to 'Edit', edit_imap_setting_path(imap_setting), class: 'btn btn-xs btn-warning' + = link_to 'Destroy', imap_setting, :method => :delete, :data => { :confirm => 'Are you sure?' }, class: 'btn btn-xs btn-danger' + diff --git a/app/views/imap_settings/new.html.haml b/app/views/imap_settings/new.html.haml new file mode 100644 index 0000000..50576c2 --- /dev/null +++ b/app/views/imap_settings/new.html.haml @@ -0,0 +1,6 @@ +%h1 New IMAP Setting + += render 'form' + +.col-md-12 + = link_to 'Back', imap_settings_path, class: 'btn btn-default btn-xs' diff --git a/app/views/inbox/_detail.html.haml b/app/views/inbox/_detail.html.haml index 410698d..f28c541 100644 --- a/app/views/inbox/_detail.html.haml +++ b/app/views/inbox/_detail.html.haml @@ -4,7 +4,9 @@ .panel.panel-default .panel-heading User & Campaign User Details - .panel-body + %span.pull-right + %i.fa.fa-angle-down.fa-2x{'data-toggle': 'collapse', 'data-target': "#UserInfo-#{user.id}"} + .panel-body{id: "UserInfo-#{user.id}", class: 'collapse'} .row .col-lg-6 .panel.panel-default @@ -27,6 +29,23 @@ - if campaign_users.count < 1 %p.text-center.text-danger Campaign User Not Found! + .row + .panel.panel-default + .panel-heading + User Attributes + .panel-body + %table.table-bordered.table-condensed + %thead + %tr + %td Attribute + %td Value + %tbody + - user.user_attributes.each do |attr| + %tr + %td= attr.key + %td= attr.value + + .row .col-sm-12 @@ -35,6 +54,11 @@ = @subject %strong= @email .panel-body + - if @has_attach == 'true' + %p.text-warning + %i.fa.fa-exclamation-triangle + This email has an attachment. + = simple_format(@message, {}, :sanitize => false) @@ -46,8 +70,12 @@ .col-md-12 .col-md-8 - Select an email template: - = select_tag 'reply_email_template', options_for_select(current_account.email_templates.map{|et| [ et.subject, et.body.html_safe ]}), onchange: 'reply_template_select()', include_blank: '- select -', class: 'form-control' + .col-md-6 + Select an email template: + = select_tag 'reply_email_template', options_for_select(current_account.email_templates.map{|et| [ et.subject, et.body.html_safe ]}), onchange: 'reply_template_select()', include_blank: '- select -', class: 'form-control' + .col-md-6 + Select SMTP Settings + = select_tag 'smtp_id', options_for_select(current_account.smtp_settings.map{|ss| [ ss.provider, ss.id ]}, current_account.smtp_settings.default_for_reply.try(:id)), include_blank: false, class: 'form-control' .col-md-4.text-right = submit_tag 'Send Message', id: 'reply-submit', class: 'btn btn-success', style: 'margin-top: 8%;' .col-md-12 diff --git a/app/views/inbox/detail.js.erb b/app/views/inbox/detail.js.erb index 64f4b0d..609379b 100644 --- a/app/views/inbox/detail.js.erb +++ b/app/views/inbox/detail.js.erb @@ -1 +1,2 @@ -$("#email-detail").html("<%= escape_javascript render(partial: 'inbox/detail', locals: { user: @user, campaign_users: @campaign_users, message: @message, subject: @subject, email: @email }) %>"); \ No newline at end of file +$("#email-detail").html("<%= escape_javascript render(partial: 'inbox/detail', locals: { user: @user, campaign_users: @campaign_users, message: @message, subject: @subject, email: @email, has_attach: @has_attach }) %>"); +$(window).scrollTop(0); \ No newline at end of file diff --git a/app/views/inbox/index.html.haml b/app/views/inbox/index.html.haml index 58feb46..1988596 100644 --- a/app/views/inbox/index.html.haml +++ b/app/views/inbox/index.html.haml @@ -8,23 +8,25 @@ Inbox %small User Replies .clearfix - .title_right - .input-group - = form_for(inbox_index_path, method: :get) do - .col-md-4 - = label_tag 'Date From' - = text_field_tag 'from', params[:from], 'data-provide': 'datepicker', class: 'form-control', id: 'dt1' - .col-md-4 - = label_tag 'Date To' - = text_field_tag 'to', params[:to], 'data-provide': 'datepicker', class: 'form-control', id: 'dt2' - .col-md-4{style: 'margin-top: 4%;'} - = button_tag :submit, class: 'btn btn-success' do - %span.glyphicon.glyphicon.glyphicon-filter - Filter Emails + .input-group + = form_for(inbox_index_path, method: :get) do + .col-md-4 + = label_tag 'IMAP Email' + = select_tag 'imap_id', options_for_select(current_account.imap_settings.map{|ss| [ ss.email, ss.id ]}, current_account.imap_settings.first.try(:id)), include_blank: false, class: 'form-control' + .col-md-3 + = label_tag 'Date From' + = text_field_tag 'from', params[:from], 'data-provide': 'datepicker', class: 'form-control', id: 'dt1' + .col-md-3 + = label_tag 'Date To' + = text_field_tag 'to', params[:to], 'data-provide': 'datepicker', class: 'form-control', id: 'dt2' + .col-md-2{style: 'margin-top: 4%;'} + = button_tag :submit, class: 'btn btn-success' do + %i.glyphicon.glyphicon.glyphicon-filter{color: 'white'} + Filter .x_content .row - .col-sm-4 + .col-sm-4{style: "max-height: 700px; overflow: scroll;"} .row - @emails.each do |message| .col-sm-12 @@ -33,7 +35,7 @@ .panel.panel-default .panel-body{style: "width: 100%"} %p{style: 'word-wrap: break-word;'} - = message.from.try(:first) + = current_account.users.find_by(email: message.from.try(:first)).try(:name) || message.from.try(:first) %p = message.date.strftime("%d-%m-%y %H:%M") %p= message.subject @@ -43,5 +45,6 @@ = hidden_field_tag 'message', display_part.force_encoding("UTF-8") = hidden_field_tag 'email', email = hidden_field_tag 'subject', message.subject + = hidden_field_tag 'has_attachments', message.attachments.present? = hidden_field_tag 'cu_id', campaign_user_id .col-sm-8#email-detail \ No newline at end of file diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 3f97ede..6881b11 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -59,13 +59,22 @@ %i.fa.fa-tags Tag Managment %li - %a{:href => settings_path} + %a %i.fa.fa-cog Settings + %span.fa.fa-chevron-down + %ul.nav.child_menu + %li + %a{:href => smtp_settings_path } SMTP Settings + %li + %a{:href => imap_settings_path } IMAP Settings %li %a{:href => '/sidekiq', :target => '_blank'} %i.fa.fa-bar-chart Sidekiq + %li + %a{:href => 'https://github.com/svtek/smart-emailing', :target => '_blank'} + %img{:alt => "Known Vulnerabilities", "data-canonical-src" => "https://snyk.io/test/github/svtek/smart-emailing", :src => "http://github-release-version.herokuapp.com/github/svtek/smart-emailing/release.svg?style=flat", :style => "max-width:100%;"}/ / top navigation .top_nav diff --git a/app/views/layouts/welcome.html.haml b/app/views/layouts/welcome.html.haml new file mode 100644 index 0000000..6997a0c --- /dev/null +++ b/app/views/layouts/welcome.html.haml @@ -0,0 +1,41 @@ +!!! +%html{:lang => "en"} + %head + %meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/ + %meta{:charset => "utf-8"}/ + %meta{:content => "IE=edge", "http-equiv" => "X-UA-Compatible"}/ + %meta{:content => "width=device-width, initial-scale=1", :name => "viewport"}/ + %title Email Marketing + = csrf_meta_tags + = stylesheet_link_tag 'landing', media: 'all', 'data-turbolinks-track': 'reload' + = javascript_include_tag 'application', 'data-turbolinks-track': true + + %link{href: "https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css", rel: "stylesheet", integrity: "sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN", crossorigin: "anonymous"} + %body + %nav.navbar.navbar-default.navbar-fixed-top.topnav{:role => "navigation"} + .container.topnav + / Brand and toggle get grouped for better mobile display + .navbar-header + %button.navbar-toggle{"data-target" => "#bs-example-navbar-collapse-1", "data-toggle" => "collapse", :type => "button"} + %span.sr-only Toggle navigation + %span.icon-bar + %span.icon-bar + %span.icon-bar + %a.navbar-brand.topnav{:href => "/"} Smart Email Marketing + / Collect the nav links, forms, and other content for toggling + #bs-example-navbar-collapse-1.collapse.navbar-collapse + %ul.nav.navbar-nav.navbar-right + %li + %a{:href => "/documentation"} Documentation + + = yield + + / Footer + %footer{style: 'background-color: white'} + .container + .row + .col-lg-12 + .col-md-6.text-left + %img{:alt => "Known Vulnerabilities", "data-canonical-src" => "https://snyk.io/test/github/svtek/smart-emailing", :src => "http://github-release-version.herokuapp.com/github/svtek/smart-emailing/release.svg?style=flat", :style => "max-width:100%;"}/ + .col-md-6.text-right + %p.copyright.text-muted.small Copyright © 2017. All Rights Reserved diff --git a/app/views/smtp_settings/_form.html.haml b/app/views/smtp_settings/_form.html.haml new file mode 100644 index 0000000..55a582a --- /dev/null +++ b/app/views/smtp_settings/_form.html.haml @@ -0,0 +1,42 @@ +.row + .col-md-12 + .x_panel + .col-md-6 + .x_panel + .x_content + = form_for @smtp_setting do |f| + - if @smtp_setting.errors.any? + #error_explanation + %h2= "#{pluralize(@smtp_setting.errors.count, "error")} prohibited this SMTP Setting from being saved:" + %ul + - @smtp_setting.errors.full_messages.each do |msg| + %li= msg + + .field + = f.label :from_email + = f.text_field :from_email, class: 'form-control', required: true + .field + = f.label :reply_to + = f.text_field :reply_to, class: 'form-control', required: true + .field + = f.label :provider + = f.text_field :provider, class: 'form-control', required: true + .field + = f.label :address + = f.text_field :address, class: 'form-control', required: true + .field + = f.label :port + = f.text_field :port, class: 'form-control', required: true + .field + = f.label :domain + = f.text_field :domain, class: 'form-control', required: true + .field + = f.label :username + = f.text_field :username, class: 'form-control', required: true + .field + = f.label :password + = f.password_field :password, class: 'form-control', required: true + .actions + = f.submit 'Save', class: 'btn btn-primary' + = link_to 'Cancel', smtp_settings_path, class: 'btn btn-default pull-right' + .clearfix diff --git a/app/views/smtp_settings/edit.html.haml b/app/views/smtp_settings/edit.html.haml new file mode 100644 index 0000000..2ff0d64 --- /dev/null +++ b/app/views/smtp_settings/edit.html.haml @@ -0,0 +1,4 @@ +%h1 Editing SMTP Setting + += render 'form' + diff --git a/app/views/smtp_settings/index.html.haml b/app/views/smtp_settings/index.html.haml new file mode 100644 index 0000000..be2e97f --- /dev/null +++ b/app/views/smtp_settings/index.html.haml @@ -0,0 +1,46 @@ +%div + .page-title + .title_left + %h3 Listing SMTP Settings + .title_right + .col-md-12.col-sm-12.col-xs-12.text-right + = link_to new_smtp_setting_path do + %button.btn.btn-primary New SMTP Settings +.clearfix +.x_panel + %p Add SMTP settings to send campaign emails and reply users from dashboard. + %table.table.table-striped.projects + %thead + %tr + %th From email + %th Reply to + %th Provider + %th Address + %th Username + %th Port + %th Domain + %th.text-center{width: '200px'} # + %tbody + - @smtp_settings.each do |smtp_setting| + %tr + %td= smtp_setting.from_email + %td= smtp_setting.reply_to + %td= smtp_setting.provider + %td= smtp_setting.address + %td= smtp_setting.port + %td= smtp_setting.domain + %td= smtp_setting.username + %td + = link_to 'Edit', edit_smtp_setting_path(smtp_setting), class: 'btn btn-xs btn-warning' + - if !smtp_setting.is_default_for_campaigns && !smtp_setting.is_default_for_reply + = link_to 'Destroy', smtp_setting, :method => :delete, :data => { :confirm => 'Are you sure?' }, class: 'btn btn-xs btn-danger' + %br + - if smtp_setting.is_default_for_campaigns + %span.label.label-default Default For Campaign Emails + - else + = link_to 'Set As Default For Campaign Emails', set_default_for_campaigns_smtp_setting_path(smtp_setting), method: :post, class: 'btn btn-xs btn-default' + - if smtp_setting.is_default_for_reply + %span.label.label-default Default For Reply Emails + - else + = link_to 'Set As Default For Reply Emails', set_default_for_reply_smtp_setting_path(smtp_setting), method: :post, class: 'btn btn-xs btn-default' + diff --git a/app/views/smtp_settings/new.html.haml b/app/views/smtp_settings/new.html.haml new file mode 100644 index 0000000..9f26038 --- /dev/null +++ b/app/views/smtp_settings/new.html.haml @@ -0,0 +1,3 @@ +%h1 New SMTP Setting + += render 'form' diff --git a/app/views/user_mailer/reply_email.html.haml b/app/views/user_mailer/reply_email.html.haml new file mode 100644 index 0000000..af6f8f3 --- /dev/null +++ b/app/views/user_mailer/reply_email.html.haml @@ -0,0 +1 @@ += @content.html_safe \ No newline at end of file diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 01ef3e6..e791197 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -8,4 +8,4 @@ # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. -# Rails.application.config.assets.precompile += %w( search.js ) +Rails.application.config.assets.precompile += %w( landing.css ) diff --git a/config/routes.rb b/config/routes.rb index 1cf2ff6..b9a6480 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -28,6 +28,14 @@ end end + resources :smtp_settings do + member do + post :set_default_for_campaigns + post :set_default_for_reply + end + end + resources :imap_settings + resources :email_templates resources :inbox do @@ -44,8 +52,7 @@ end end - get 'settings', to: 'home#settings' - post 'update_settings', to: 'home#update_settings' + get 'documentation', to: 'home#documentation' # config/routes.rb diff --git a/db/migrate/20170703113927_drop_mail_settings.rb b/db/migrate/20170703113927_drop_mail_settings.rb new file mode 100644 index 0000000..a191bb4 --- /dev/null +++ b/db/migrate/20170703113927_drop_mail_settings.rb @@ -0,0 +1,5 @@ +class DropMailSettings < ActiveRecord::Migration[5.0] + def change + drop_table :mail_settings + end +end diff --git a/db/migrate/20170703114542_create_smtp_settings.rb b/db/migrate/20170703114542_create_smtp_settings.rb new file mode 100644 index 0000000..e8964a9 --- /dev/null +++ b/db/migrate/20170703114542_create_smtp_settings.rb @@ -0,0 +1,19 @@ +class CreateSmtpSettings < ActiveRecord::Migration[5.0] + def change + create_table :smtp_settings do |t| + t.references :account, foreign_key: true + t.string :from_email + t.string :reply_to + t.string :provider + t.string :address + t.string :port + t.string :domain + t.string :username + t.string :password + t.boolean :is_default_for_campaigns, default: false + t.boolean :is_default_for_reply, default: false + + t.timestamps + end + end +end diff --git a/db/migrate/20170703122535_create_imap_settings.rb b/db/migrate/20170703122535_create_imap_settings.rb new file mode 100644 index 0000000..c7a96cd --- /dev/null +++ b/db/migrate/20170703122535_create_imap_settings.rb @@ -0,0 +1,13 @@ +class CreateImapSettings < ActiveRecord::Migration[5.0] + def change + create_table :imap_settings do |t| + t.references :account, foreign_key: true + t.string :address + t.string :port + t.string :email + t.string :password + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 625ff86..b8c25ea 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: 20170525191634) do +ActiveRecord::Schema.define(version: 20170703122535) do create_table "accounts", force: :cascade do |t| t.string "email", default: "", null: false @@ -63,23 +63,32 @@ t.index ["account_id"], name: "index_email_templates_on_account_id" end - create_table "mail_settings", force: :cascade do |t| + create_table "imap_settings", force: :cascade do |t| + t.integer "account_id" + t.string "address" + t.string "port" + t.string "email" + t.string "password" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["account_id"], name: "index_imap_settings_on_account_id" + end + + create_table "smtp_settings", force: :cascade do |t| t.integer "account_id" t.string "from_email" + t.string "reply_to" + t.string "provider" t.string "address" t.string "port" t.string "domain" - t.string "user_name" + t.string "username" t.string "password" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.string "provider" - t.string "reply_to" - t.string "imap_address" - t.string "imap_port" - t.string "imap_password" - t.string "imap_username" - t.index ["account_id"], name: "index_mail_settings_on_account_id" + t.boolean "is_default_for_campaigns", default: false + t.boolean "is_default_for_reply", default: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["account_id"], name: "index_smtp_settings_on_account_id" end create_table "taggings", force: :cascade do |t| diff --git a/spec/factories/mail_settings.rb b/spec/factories/mail_settings.rb deleted file mode 100644 index c0041bb..0000000 --- a/spec/factories/mail_settings.rb +++ /dev/null @@ -1,5 +0,0 @@ -FactoryGirl.define do - factory :mail_setting do - account nil - end -end diff --git a/spec/models/mail_setting_spec.rb b/spec/models/mail_setting_spec.rb deleted file mode 100644 index 6672943..0000000 --- a/spec/models/mail_setting_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'rails_helper' - -RSpec.describe MailSetting, type: :model do - # pending "add some examples to (or delete) #{__FILE__}" -end