diff --git a/app/assets/stylesheets/e_paper/emailer.scss b/app/assets/stylesheets/e_paper/emailer.scss new file mode 100644 index 0000000..89ce09e --- /dev/null +++ b/app/assets/stylesheets/e_paper/emailer.scss @@ -0,0 +1,157 @@ +.epaper-show { + .epaper-show-title { + border-bottom: 2px solid #ddd; + padding: 0 0 10px; + margin: 10px 0 20px; + color: #881f05; + } + + .ep-info { + background: #fff; + border-radius: 3px; + padding: 10px; + margin: 0 0 15px; + } + + .ep-info-title { + border-bottom: 1px solid #eee; + padding: 0 0 5px; + margin: 0 0 8px; + font-size: 18px; + } + + .ep-info-date { + float: left; + width: 50%; + margin: 0 0 5px; + color: #888; + } + + .ep-info-period { + float: right; + width: 50%; + margin: 0 0 5px; + text-align: right; + padding: 0 10px 0 0; + color: #888; + } + + .ep-info-description { + clear: both; + padding: 10px 0 0; + overflow: hidden; + border-top: 1px solid #eee; + } + + .ep-info-description span { + float: right; + width: calc(100% - 90px); + line-height: 1.5; + } + + .ep-content-item { + float: left; + width: calc(50% - 20px); + border: 1px solid #ccc; + vertical-align: top; + min-height: 200px; + padding: 20px; + margin: 10px; + } + + .ep-content-title { + color: #881f05; + font-size: 20px; + border-left: 4px solid #881f05; + display: block; + padding: 0 0 0 10px; + margin: 0 0 10px; + } + + p.ep-content-text { + color: #666; + font-size: 15px; + } + a.ep-content-more { + background: #881f05; + color: #fff; + padding: 2px 10px; + border-radius: 5px; + font-size: 12px; + } +} +.ep-topic-show { + .ep-topic-title { + margin: 10px 0; + color: #881f05; + } + + .ep-topic-date { + background: #fff; + padding: 10px; + border-radius: 3px; + margin: 0 0 10px; + } + + .ep-topic-content { + font-size: 15px; + line-height: 2; + } +} + +//widget +.epaper-form { + background: #fff; + padding: 20px; + width: 100%; + max-width: 300px; + margin: auto; + border-radius: 5px; + box-shadow: 0 0 30px rgba(0,0,0,0.05); + + input.input-mail { + display: block; + width: 100%; + margin: 0 0 20px; + padding: 5px 10px; + border: 1px solid #ccc; + border-radius: 5px; + color: #333; + } + + .btn-primary { + width: 50%; + float: left; + display: block; + } + + .btn-white { + background: none; + width: 50%; + outline: none; + float: right; + color: #888; + } + + .btn-white:active { + outline: none; + box-shadow: none; + } + + .btn-white:hover { + text-decoration: underline; + } + + .ep-form-title { + font-size: 20px; + margin: 0 0 15px; + } + + h3.ep-form-title .en { + display: none; + } + + form { + overflow: hidden; + } +} \ No newline at end of file diff --git a/app/controllers/admin/e_papers_controller.rb b/app/controllers/admin/e_papers_controller.rb index 8239a26..472527b 100644 --- a/app/controllers/admin/e_papers_controller.rb +++ b/app/controllers/admin/e_papers_controller.rb @@ -62,6 +62,31 @@ class Admin::EPapersController < OrbitAdminController redirect_to admin_e_papers_path(:page => params[:page]) end + def subscribers + @table_fields = [:email, :actions] + @subscribers = Subscriber.all.desc(:created_at) + @filter_fields = {} + @subscribers = search_data(@subscribers, [:email]).page(params[:page]).per(10) + if request.xhr? + render :partial => "subscriber_index" + end + end + + def delete_subscriber + subscriber = Subscriber.find(params[:id]) + subscriber.destroy + redirect_to subscribers_admin_e_papers_path(:page => params[:page]) + end + + def send_test_email + paper = Paper.find(params[:id]) + page = Page.where(:module_app => "e_paper").first.url rescue "" + email = Email.new(:mail_subject => paper.title, :mail_lang => :zh_tw, :template => "admin/e_papers/emailer", :template_data => {"paper" => paper, "page" => "http://" + request.host_with_port + page}, :mail_to => params[:email]) + email.deliver + + render :json => {"success" => true}.to_json + end + private diff --git a/app/models/paper.rb b/app/models/paper.rb index b51b4e4..8c90db9 100644 --- a/app/models/paper.rb +++ b/app/models/paper.rb @@ -7,7 +7,7 @@ class Paper include Slug field :title,as: :slug_title, localize: true - field :period, localize: true + field :period, type: DateTime field :description, localize: true field :mailed, type: Boolean, default: false field :ready_to_send, type: Boolean, default: false diff --git a/app/views/admin/e_papers/_form.html.erb b/app/views/admin/e_papers/_form.html.erb index d953a7c..e3758e8 100644 --- a/app/views/admin/e_papers/_form.html.erb +++ b/app/views/admin/e_papers/_form.html.erb @@ -61,17 +61,13 @@ -
+ <%= sub.email %> + | ++ <%= t(:delete_) %> + | +
<%= t[0..100] %>
+ " target="_blank">more +