From 68eebb8989ab3e21e9a161b977c2e97a8f41fcfc Mon Sep 17 00:00:00 2001 From: yafeilee Date: Tue, 1 Apr 2014 17:09:35 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4ENV=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E7=BB=86=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admin/sessions_controller.rb | 2 +- app/controllers/blogs_controller.rb | 1 + app/models/post.rb | 2 +- app/views/blogs/index.html.slim | 11 ++++++----- app/views/layouts/_google_analytics.html.slim | 2 +- config/application.rb | 1 - config/application.yml.example | 14 ++++++++++---- 7 files changed, 20 insertions(+), 13 deletions(-) diff --git a/app/controllers/admin/sessions_controller.rb b/app/controllers/admin/sessions_controller.rb index 44e1159..b90767e 100644 --- a/app/controllers/admin/sessions_controller.rb +++ b/app/controllers/admin/sessions_controller.rb @@ -5,7 +5,7 @@ class Admin::SessionsController < ApplicationController end def create - if ! ENV['ADMIN_USER'] + if ENV['ADMIN_USER'].blank? render :json=> { success: false, message: '系统未配置管理员账户, 无法登录' } elsif ENV['ADMIN_USER'] != params[:username] render :json=> { success: false, message: '管理员账户错误' } diff --git a/app/controllers/blogs_controller.rb b/app/controllers/blogs_controller.rb index b152a53..391bc12 100644 --- a/app/controllers/blogs_controller.rb +++ b/app/controllers/blogs_controller.rb @@ -1,5 +1,6 @@ # encoding : utf-8 class BlogsController < ApplicationController + def index @newest = Post.desc(:created_at).first @recent = Post.desc(:created_at).to_a[1..5] diff --git a/app/models/post.rb b/app/models/post.rb index 2e47256..7a88fbe 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -23,7 +23,7 @@ class Post validates :type, :presence=>true, :inclusion => { :in => [ TECH, LIFE, CREATOR ] } after_create do - unless ENV['SENDCLOUD_USER'] + if ENV['SENDCLOUD_USER'].present? NewPostWorker.perform_async(self.title, Subscribe.subscribe_list) end end diff --git a/app/views/blogs/index.html.slim b/app/views/blogs/index.html.slim index 7de2aa3..19c6c2c 100644 --- a/app/views/blogs/index.html.slim +++ b/app/views/blogs/index.html.slim @@ -30,11 +30,12 @@ p = link_to '关于我', about_path h4 SUBSCRIBE ul.subscribe-ul - li - = link_to '邮件订阅 ', '', "ng-click"=>"click('email')" - p - .email-subscribe ng-show="type == 'email'" - = text_field_tag 'email', nil, placeholder: 'your@email.com' + - if ENV['SENDCLOUD_USER'].present? + li + = link_to '邮件订阅 ', '', "ng-click"=>"click('email')" + p + .email-subscribe ng-show="type == 'email'" + = text_field_tag 'email', nil, placeholder: 'your@email.com' li = link_to '微信扫一扫', '', "ng-click"=>"click('weixin')" p diff --git a/app/views/layouts/_google_analytics.html.slim b/app/views/layouts/_google_analytics.html.slim index 208424f..31028d7 100644 --- a/app/views/layouts/_google_analytics.html.slim +++ b/app/views/layouts/_google_analytics.html.slim @@ -1,4 +1,4 @@ -- if ENV['GOOGLE'] +- if ENV['GOOGLE'].present? javascript: var _gaq = _gaq || []; _gaq.push(['_setAccount', '#{ENV['GOOGLE']}']); diff --git a/config/application.rb b/config/application.rb index 512e159..3e6039b 100644 --- a/config/application.rb +++ b/config/application.rb @@ -2,7 +2,6 @@ require File.expand_path('../boot', __FILE__) # Pick the frameworks you want: require "active_model/railtie" -# require "active_record/railtie" require "action_controller/railtie" require "action_mailer/railtie" require "action_view/railtie" diff --git a/config/application.yml.example b/config/application.yml.example index d4d739e..7351552 100644 --- a/config/application.yml.example +++ b/config/application.yml.example @@ -1,11 +1,17 @@ -# Add application configuration variables here, as shown below. -# - - +# 必须配置的 SITE_NAME: "WinDy's Blog" # 后台登录的用户名与密码, 不填的话无法管理后台 ADMIN_USER: 'admin' ADMIN_PASSWORD: 'admin' +# 可选的 # google analytics, 如果不需要可以留空 GOOGLE: 'UA-32883596-1' + +# SENDCLOUD 邮件订阅功能, 留空用户名表示不需要创建博客后发送订阅邮件 +# 更多参数细节请查阅: /app/workers/new_post_worker.rb +SENDCLOUD_USER: '' +SENDCLOUD_PASSWORD: '' +SENDCLOUD_FROM: '' +SENDCLOUD_FROMNAME: '' +SENDCLOUD_SITE_ADDRESS: ''