添加了运行环境
This commit is contained in:
parent
4bcc59578a
commit
6700e0e105
1
Gemfile
1
Gemfile
|
@ -1,5 +1,4 @@
|
|||
source 'https://rubygems.org/'
|
||||
ruby '2.1.2'
|
||||
|
||||
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
||||
gem 'rails', '4.2.3'
|
||||
|
|
|
@ -18,6 +18,10 @@
|
|||
*/
|
||||
@import "bootstrap-sprockets";
|
||||
@import "bootstrap";
|
||||
body{
|
||||
background:rgba(102, 255, 255, 0.1) none repeat scroll 0 0 !important;
|
||||
}
|
||||
|
||||
.body_content {
|
||||
margin-top: 60px;
|
||||
}
|
||||
|
|
|
@ -2,19 +2,19 @@
|
|||
|
||||
= form_for @article, role: 'form' do |f|
|
||||
.form-group
|
||||
%label{for: 'article_title'} 文章标题
|
||||
= f.text_field :title, placeholder: '文章标题', class: 'form-control'
|
||||
%label{for: 'article_title'} 分享标题
|
||||
= f.text_field :title, placeholder: '分享标题', class: 'form-control'
|
||||
.form-group
|
||||
%label{for: 'article_category_id'} 文章分类
|
||||
%label{for: 'article_category_id'} 分享分类
|
||||
= select_tag "article[category_id]", options_for_select(get_categories_options, @article.category_id), include_blank: true, class: 'form-control'
|
||||
或者新建一个分类:
|
||||
= f.text_field :category_name, placeholder: '分类名称', class: 'form-control'
|
||||
.form-group
|
||||
%label{for: 'article_tags'} 标签
|
||||
= f.text_field :tags, placeholder: '文章标签,多个用英文“,”隔开', class: 'form-control'
|
||||
= f.text_field :tags, placeholder: '分享标签,多个用英文“,”隔开', class: 'form-control'
|
||||
.form-group
|
||||
%label{for: 'article_source'} 文章来源
|
||||
= f.text_field :source, placeholder: '文章来源,为空则为原创', class: 'form-control'
|
||||
%label{for: 'article_source'} 分享来源
|
||||
= f.text_field :source, placeholder: '分享来源,为空则为原创', class: 'form-control'
|
||||
.form-group
|
||||
%ul.nav.nav-tabs#preview_tab{role: "tablist"}
|
||||
%li.active
|
||||
|
@ -23,7 +23,7 @@
|
|||
= link_to '预览', '#preview', role: 'tab', 'data-toggle'=>'tab'
|
||||
.tab-content
|
||||
.tab-pane.active#edit
|
||||
= f.text_area :content, placeholder: '文章内容', class: 'form-control'
|
||||
= f.text_area :content, placeholder: '分享内容', class: 'form-control'
|
||||
.tab-pane#preview
|
||||
.form-group
|
||||
= f.submit '提交', class: 'btn btn-success btn-lg btn-block'
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
%h3 编辑博文
|
||||
%h3 编辑分享
|
||||
= render partial: 'error'
|
||||
= render partial: 'form'
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
.row.inner.edge
|
||||
.col-md-9.layout-main
|
||||
.tab-nav
|
||||
-# %h2.common-title 博文列表
|
||||
-# %h2.common-title 分享列表
|
||||
%nav.sub-tab.row
|
||||
%span.col-md-6.text-left
|
||||
%h3 文章列表
|
||||
%h3 经验列表
|
||||
%span.col-md-6.text-right.sort_navbar
|
||||
- params_hash = params.dup
|
||||
- params_hash.delete :page
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
|
||||
%h3 撰写博文
|
||||
%h3 撰写分享
|
||||
= render partial: 'error'
|
||||
= render partial: 'form'
|
||||
|
|
|
@ -14,6 +14,6 @@
|
|||
= link_to '个人信息设置', set_blogs_path
|
||||
- if current_user_is_admin?
|
||||
%li{role: 'presentation', class: "#{'active' if params[:action] == 'set_blog'}"}
|
||||
= link_to '博客设置', set_blog_blogs_path
|
||||
= link_to '空间设置', set_blog_blogs_path
|
||||
%li{role: 'presentation'}
|
||||
= link_to '修改密码', change_password_blogs_path
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
.text-left
|
||||
%p
|
||||
%h2 博主
|
||||
%h2 分享者
|
||||
= @blog ? @blog.name : '未设置'
|
||||
%p
|
||||
%h2 email
|
||||
|
|
|
@ -4,16 +4,16 @@
|
|||
.col-md-8
|
||||
= form_for @blog, as: 'blog', url: update_blog_blogs_path, method: 'post', role: 'form' do |f|
|
||||
.form-group
|
||||
%label{for: 'blog_name'} 博主
|
||||
= f.text_field :name, placeholder: '博主名称', class: 'form-control'
|
||||
%label{for: 'blog_name'} 分享者
|
||||
= f.text_field :name, placeholder: '分享者名称', class: 'form-control'
|
||||
.form-group
|
||||
%label{for: 'blog_blog_title'} 博客名字
|
||||
= f.text_field :blog_title, placeholder: '博客名称', class: 'form-control'
|
||||
%label{for: 'blog_blog_title'} 空间名字
|
||||
= f.text_field :blog_title, placeholder: '空间名称', class: 'form-control'
|
||||
.form-group
|
||||
%label{for: 'blog_email'} 联系邮箱
|
||||
= f.text_field :email, placeholder: '联系邮箱', class: 'form-control'
|
||||
.form-group
|
||||
%label{for: 'blog_description'} 关于博主
|
||||
= f.text_area :description, placeholder: '关于博主', class: 'form-control blog-description'
|
||||
%label{for: 'blog_description'} 关于分享者
|
||||
= f.text_area :description, placeholder: '关于分享者', class: 'form-control blog-description'
|
||||
.form-group
|
||||
= f.submit '修改', class: 'btn btn-primary set-btn'
|
|
@ -18,9 +18,9 @@
|
|||
.collspse.navbar-collapse.site-header
|
||||
%ul.nav.navbar-nav
|
||||
%li{class: "#{'active' if params[:controller] == 'articles' && params[:action] == 'index'}"}
|
||||
= link_to '文章列表', articles_path
|
||||
= link_to '经验列表', articles_path
|
||||
%li
|
||||
= link_to '关于博主', about_blogs_path
|
||||
= link_to '关于', about_blogs_path
|
||||
%ul.nav.navbar-nav.navbar-right
|
||||
- if is_logined?
|
||||
%li.dropdown
|
||||
|
@ -34,7 +34,7 @@
|
|||
%li
|
||||
= link_to '设置', set_blogs_path
|
||||
%li
|
||||
= link_to '写博客', new_article_path
|
||||
= link_to '写经验', new_article_path
|
||||
%li
|
||||
= link_to '退出', logout_path
|
||||
.navbar-header.navbar-avatar
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
%section.content
|
||||
.form-unit
|
||||
= link_to root_path, class: 'brand' do
|
||||
%h1 Blog
|
||||
%h1 E2S
|
||||
%h3 用户登录
|
||||
- errors = @user ? @user.errors.full_messages : []
|
||||
- if errors.any?
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
%section.content
|
||||
.form-unit
|
||||
= link_to root_path, class: 'brand' do
|
||||
%h1 Blog
|
||||
%h1 E2S
|
||||
%h3 注册账号
|
||||
- errors = @user.errors.full_messages
|
||||
- if errors.any?
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
# config/initializers/gravatar_image_tag.rb
|
||||
GravatarImageTag.configure do |config|
|
||||
config.default_image = 'https://assets.github.com/images/gravatars/gravatar-140.png' # Set this to use your own default gravatar image rather then serving up Gravatar's default image [ 'http://example.com/images/default_gravitar.jpg', :identicon, :monsterid, :wavatar, 404 ].
|
||||
config.filetype = nil # Set this if you require a specific image file format ['gif', 'jpg' or 'png']. Gravatar's default is png
|
||||
config.include_size_attributes = true # The height and width attributes of the generated img will be set to avoid page jitter as the gravatars load. Set to false to leave these attributes off.
|
||||
config.rating = nil # Set this if you change the rating of the images that will be returned ['G', 'PG', 'R', 'X']. Gravatar's default is G
|
||||
config.size = nil # Set this to globally set the size of the gravatar image returned (1..512). Gravatar's default is 80
|
||||
config.secure = false # Set this to true if you require secure images on your pages.
|
||||
end
|
|
@ -0,0 +1,66 @@
|
|||
# path to app dir
|
||||
app_dir = "/home/root/e2s/"
|
||||
worker_processes 2
|
||||
working_directory app_dir
|
||||
|
||||
# Load app into the master before forking workers for super-fast
|
||||
# worker spawn times
|
||||
preload_app true
|
||||
|
||||
# nuke workers after 30 seconds (60 is the default)
|
||||
timeout 30
|
||||
|
||||
# listen on a Unix domain socket and/or a TCP port,
|
||||
|
||||
#listen 8080 # listen to port 8080 on all TCP interfaces
|
||||
#listen "127.0.0.1:8080" # listen to port 8080 on the loopback interface
|
||||
listen "#{app_dir}/tmp/sockets/e2s.socket"
|
||||
|
||||
pid "#{app_dir}/tmp/pids/unicorn.pid"
|
||||
stderr_path "#{app_dir}/log/unicorn.stderr.log"
|
||||
stdout_path "#{app_dir}/log/unicorn.stdout.log"
|
||||
|
||||
# http://www.rubyenterpriseedition.com/faq.html#adapt_apps_for_cow
|
||||
if GC.respond_to?(:copy_on_write_friendly=)
|
||||
GC.copy_on_write_friendly = true
|
||||
end
|
||||
|
||||
|
||||
before_fork do |server, worker|
|
||||
# the following is highly recomended for Rails + "preload_app true"
|
||||
# as there's no need for the master process to hold a connection
|
||||
# defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect!
|
||||
|
||||
##
|
||||
# When sent a USR2, Unicorn will suffix its pidfile with .oldbin and
|
||||
# immediately start loading up a new version of itself (loaded with a new
|
||||
# version of our app). When this new Unicorn is completely loaded
|
||||
# it will begin spawning workers. The first worker spawned will check to
|
||||
# see if an .oldbin pidfile exists. If so, this means we've just booted up
|
||||
# a new Unicorn and need to tell the old one that it can now die. To do so
|
||||
# we send it a QUIT.
|
||||
#
|
||||
# Using this method we get 0 downtime deploys.
|
||||
|
||||
old_pid = "#{server.config[:pid]}.oldbin"
|
||||
|
||||
if File.exists?(old_pid) && server.pid != old_pid
|
||||
begin
|
||||
sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU
|
||||
Process.kill(sig, File.read(old_pid).to_i)
|
||||
rescue Errno::ENOENT, Errno::ESRCH
|
||||
# someone else did our job for us
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
after_fork do |server, worker|
|
||||
# Unicorn master loads the app then forks off workers - because of the way
|
||||
# Unix forking works, we need to make sure we aren't using any of the parent's
|
||||
# sockets, e.g. db connection
|
||||
|
||||
# defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection
|
||||
# Redis and Memcached would go here but their connections are established
|
||||
# on demand, so the master never opens a socket
|
||||
end
|
||||
|
|
@ -0,0 +1,115 @@
|
|||
### BEGIN INIT INFO
|
||||
# Provides: code
|
||||
# Required-Start: $local_fs $remote_fs $network $syslog redis-server
|
||||
# Required-Stop: $local_fs $remote_fs $network $syslog
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Code git repository management
|
||||
# Description: Code git repository management
|
||||
### END INIT INFO
|
||||
|
||||
|
||||
APP_ROOT="/home/root/e2s"
|
||||
DAEMON_OPTS="-c $APP_ROOT/config/unicorn.rb -E production"
|
||||
PID_PATH="$APP_ROOT/tmp/pids"
|
||||
UNICORN_PID="$PID_PATH/unicorn.pid"
|
||||
NAME="unicorn"
|
||||
DESC="E2S Group service"
|
||||
|
||||
check_pid(){
|
||||
if [ -f $UNICORN_PID ]; then
|
||||
PID=`cat $UNICORN_PID`
|
||||
STATUS=`ps aux | grep $PID | grep -v grep | wc -l`
|
||||
else
|
||||
STATUS=0
|
||||
PID=0
|
||||
fi
|
||||
}
|
||||
|
||||
start() {
|
||||
cd $APP_ROOT
|
||||
check_pid
|
||||
if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then
|
||||
# Program is running, exit with error code 1.
|
||||
echo "Error! $DESC $NAME is currently running!"
|
||||
exit 1
|
||||
else
|
||||
if [ `whoami` = root ]; then
|
||||
sudo -u fangxiang -H bash -l -c "nohup bundle exec unicorn $DAEMON_OPTS > /dev/null 2>&1 &"
|
||||
echo "$DESC started"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
stop() {
|
||||
cd $APP_ROOT
|
||||
check_pid
|
||||
if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then
|
||||
## Program is running, stop it.
|
||||
kill -QUIT `cat $UNICORN_PID`
|
||||
rm "$UNICORN_PID" >> /dev/null
|
||||
echo "$DESC stopped"
|
||||
else
|
||||
## Program is not running, exit with error.
|
||||
echo "Error! $DESC not started!"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
restart() {
|
||||
cd $APP_ROOT
|
||||
check_pid
|
||||
if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then
|
||||
echo "Restarting $DESC..."
|
||||
kill -USR2 `cat $UNICORN_PID`
|
||||
echo "$DESC restarted."
|
||||
else
|
||||
echo "Error, $NAME not running!"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
status() {
|
||||
cd $APP_ROOT
|
||||
check_pid
|
||||
if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then
|
||||
echo "$DESC / Unicorn with PID $PID is running."
|
||||
else
|
||||
echo "$DESC is not running."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
## Check to see if we are running as root first.
|
||||
## Found at http://www.cyberciti.biz/tips/shell-root-user-check-script.html
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
echo "This script must be run as root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart)
|
||||
restart
|
||||
;;
|
||||
reload|force-reload)
|
||||
echo -n "Reloading $NAME configuration: "
|
||||
kill -HUP `cat $PID`
|
||||
echo "done."
|
||||
;;
|
||||
status)
|
||||
status
|
||||
;;
|
||||
*)
|
||||
echo "Usage: sudo service code {start|stop|restart|reload}" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
#user nobody;
|
||||
worker_processes 1;
|
||||
|
||||
#error_log logs/error.log;
|
||||
#error_log logs/error.log notice;
|
||||
#error_log logs/error.log info;
|
||||
|
||||
#pid logs/nginx.pid;
|
||||
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
|
||||
http {
|
||||
include mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
# '$status $body_bytes_sent "$http_referer" '
|
||||
# '"$http_user_agent" "$http_x_forwarded_for"';
|
||||
|
||||
#access_log logs/access.log main;
|
||||
|
||||
sendfile on;
|
||||
#tcp_nopush on;
|
||||
|
||||
#keepalive_timeout 0;
|
||||
keepalive_timeout 65;
|
||||
|
||||
gzip on;
|
||||
gzip_types application/json;
|
||||
|
||||
upstream blog {
|
||||
server unix:/home/root/e2s/tmp/sockets/e2s.socket;
|
||||
}
|
||||
server {
|
||||
listen 80;
|
||||
#server_name blog.com;
|
||||
root /home/root/e2s/public;
|
||||
try_files $uri/index.html $uri.html $uri @user1;
|
||||
location @user1 {
|
||||
proxy_redirect off;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
proxy_set_header X-Forwarded-Server $host;
|
||||
proxy_set_header X-Real-Ip $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_buffering on;
|
||||
proxy_pass http://blog;
|
||||
}
|
||||
location ~ ^(/assets) {
|
||||
access_log off;
|
||||
expires max;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue