Commit 0fa1803b authored by 神楽坂玲奈's avatar 神楽坂玲奈

论坛附件yrp ydk deck播放, 换行符

parent da8298ea
...@@ -21,7 +21,9 @@ group :assets do ...@@ -21,7 +21,9 @@ group :assets do
gem 'coffee-rails' gem 'coffee-rails'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes # See https://github.com/sstephenson/execjs#readme for more supported runtimes
unless RUBY_PLATFORM["mswin"] or RUBY_PLATFORM["ming"] if RUBY_PLATFORM["mswin"] or RUBY_PLATFORM["ming"]
gem 'therubyrhino'
else
gem 'therubyracer' gem 'therubyracer'
end end
......
...@@ -136,6 +136,7 @@ GEM ...@@ -136,6 +136,7 @@ GEM
hike (~> 1.2) hike (~> 1.2)
rack (~> 1.0) rack (~> 1.0)
tilt (~> 1.1, != 1.3.0) tilt (~> 1.1, != 1.3.0)
therubyrhino (1.73.4)
thor (0.14.6) thor (0.14.6)
tilt (1.3.3) tilt (1.3.3)
treetop (1.4.10) treetop (1.4.10)
...@@ -165,4 +166,5 @@ DEPENDENCIES ...@@ -165,4 +166,5 @@ DEPENDENCIES
rails rails
rails_admin rails_admin
sass-rails sass-rails
therubyrhino
uglifier uglifier
...@@ -22,7 +22,7 @@ class UsersController < ApplicationController ...@@ -22,7 +22,7 @@ class UsersController < ApplicationController
respond_to do |format| respond_to do |format|
format.html # show.html.erb format.html # show.html.erb
format.json { render :json => {id: @user.id, name: @user.name, nickname: @user.nickname} } format.json { render :json => {id: @user.id, name: @user.name, nickname: @user.nickname} }
format.png {redirect_to @user.avatar.url(:middle)} format.png { redirect_to @user.avatar.url(:middle) }
end end
end end
...@@ -45,12 +45,12 @@ class UsersController < ApplicationController ...@@ -45,12 +45,12 @@ class UsersController < ApplicationController
@actions = [@user, "修改头像"] @actions = [@user, "修改头像"]
if @current_user != @user if @current_user != @user
respond_to do |format| respond_to do |format|
format.html {redirect_to(edit_user_path(@current_user), :notice => '请先登录.')} format.html { redirect_to(edit_user_path(@current_user), :notice => '请先登录.') }
end end
end end
else else
respond_to do |format| respond_to do |format|
format.html {redirect_to(:login, :notice => '请先登录.')} format.html { redirect_to(:login, :notice => '请先登录.') }
end end
end end
...@@ -67,10 +67,16 @@ class UsersController < ApplicationController ...@@ -67,10 +67,16 @@ class UsersController < ApplicationController
@continue = params[:continue] @continue = params[:continue]
@from = params[:from].to_s.to_sym @from = params[:from].to_s.to_sym
respond_to do |format| respond_to do |format|
if @user.save open("http://ygopro-ocg.com/mycard.php?key=zh99998&username=#{CGI.escape @user.name}&password=#{CGI.escape @user.password}&email=#{CGI.escape @user.email}") do |f|
result = f.read
if result.to_i <= 0
@user.errors[:base] << "发生系统错误 (#{result}) 请联系zh99998@gmail.com"
end
end rescue @user.errors[:base] << "发生系统错误 (#{$!.inspect}) 请联系zh99998@gmail.com"
if !@user.errors.any? and @user.save
boardcast_user(@user, :"ygopro-ocg") boardcast_user(@user, :"ygopro-ocg")
session[:user_id] = @user.id session[:user_id] = @user.id
format.html { redirect_to(params[:continue] ? URI.escape(params[:continue]) : @user, :notice => '注册成功') } format.html { redirect_to(params[:continue].blank? ? @user : URI.escape(params[:continue]) , :notice => '注册成功') }
format.xml { render :xml => @user, :status => :created, :location => @user } format.xml { render :xml => @user, :status => :created, :location => @user }
else else
format.html { render :action => "new" } format.html { render :action => "new" }
...@@ -78,6 +84,7 @@ class UsersController < ApplicationController ...@@ -78,6 +84,7 @@ class UsersController < ApplicationController
end end
end end
end end
# PUT /users/1 # PUT /users/1
# PUT /users/1.xml # PUT /users/1.xml
def update def update
...@@ -113,6 +120,7 @@ class UsersController < ApplicationController ...@@ -113,6 +120,7 @@ class UsersController < ApplicationController
format.xml { head :ok } format.xml { head :ok }
end end
end end
def login def login
@actions = [User.human_attribute_name(:login)] @actions = [User.human_attribute_name(:login)]
return @user = User.new if params[:user].blank? return @user = User.new if params[:user].blank?
...@@ -140,7 +148,7 @@ class UsersController < ApplicationController ...@@ -140,7 +148,7 @@ class UsersController < ApplicationController
session[:user_id] = @user.id session[:user_id] = @user.id
@user.update_attribute(:lastloginip, request.remote_ip) @user.update_attribute(:lastloginip, request.remote_ip)
boardcast_user(@user) boardcast_user(@user)
format.html { redirect_to(params[:continue] ? URI.escape(params[:continue]) : @user, :notice => 'Login Successfully.') } format.html { redirect_to(params[:continue].blank? ? @user : URI.escape(params[:continue]), :notice => 'Login Successfully.') }
format.json { render json: @user } format.json { render json: @user }
else else
@user = User.new(params[:user]) @user = User.new(params[:user])
...@@ -149,6 +157,7 @@ class UsersController < ApplicationController ...@@ -149,6 +157,7 @@ class UsersController < ApplicationController
end end
end end
end end
def logout def logout
session[:user_id] = nil session[:user_id] = nil
respond_to do |format| respond_to do |format|
...@@ -156,6 +165,7 @@ class UsersController < ApplicationController ...@@ -156,6 +165,7 @@ class UsersController < ApplicationController
format.xml { head :ok } format.xml { head :ok }
end end
end end
def theme def theme
#p params[:theme], @site[:themes].has_key?(params[:theme]) #p params[:theme], @site[:themes].has_key?(params[:theme])
if params[:theme].blank? if params[:theme].blank?
...@@ -170,20 +180,23 @@ class UsersController < ApplicationController ...@@ -170,20 +180,23 @@ class UsersController < ApplicationController
format.xml { head :ok } format.xml { head :ok }
end end
end end
def boardcast_user(user, wait=nil)
def boardcast_user(user, from=nil)
Server.find_each do |server| Server.find_each do |server|
url = "http://#{server.ip}:#{server.http_port}/?pass=#{server.password}&operation=forceuserpass&username=#{CGI.escape user.name}&password=#{CGI.escape user.password}" url = "http://#{server.ip}:#{server.http_port}/?pass=#{server.password}&operation=forceuserpass&username=#{CGI.escape user.name}&password=#{CGI.escape user.password}"
if RUBY_PLATFORM["win"] || RUBY_PLATFORM["ming"] if RUBY_PLATFORM["win"] || RUBY_PLATFORM["ming"]
open(url){} rescue nil open(url) {} rescue nil
else else
Process.spawn('curl', url) Process.spawn('curl', url)
end end
end end
if from != :"ygopro-ocg"
url = "http://ygopro-ocg.com/mycard.php?key=zh99998&username=#{CGI.escape user.name}&password=#{CGI.escape user.password}&email=#{CGI.escape user.email}" url = "http://ygopro-ocg.com/mycard.php?key=zh99998&username=#{CGI.escape user.name}&password=#{CGI.escape user.password}&email=#{CGI.escape user.email}"
if wait == :"ygopro-ocg" or RUBY_PLATFORM["win"] || RUBY_PLATFORM["ming"] if RUBY_PLATFORM["win"] || RUBY_PLATFORM["ming"]
open(url){} open(url) {}
else else
Process.spawn('curl', url) Process.spawn('curl', url)
end end
end end
end
end end
\ No newline at end of file
<li>
<%= link_to attachment.data.original_filename, attachment.data.url %>
<% case %>
<% when attachment.data.content_type[0, 5] == "image" %>
<div><%= image_tag attachment.data.url %></div>
<% else %>
<% case File.extname attachment.data.original_filename %>
<% when ".yrp" %>
<span><%= link_to "播放", 'mycard://' + request.env['HTTP_HOST'] + URI.escape(URI.escape(attachment.data.url nil, timestamp: false )) %></span>
<% when ".ydk" %>
<span><%= link_to "编辑", 'mycard://' + request.env['HTTP_HOST'] + URI.escape(URI.escape(attachment.data.url nil, timestamp: false )) %></span>
<% when ".deck" %>
<span><%= link_to "编辑", 'mycard://' + request.env['HTTP_HOST'] + URI.escape(URI.escape(attachment.data.url nil, timestamp: false )) %></span>
<% end %>
<% end %>
</li>
\ No newline at end of file
...@@ -56,12 +56,7 @@ ...@@ -56,12 +56,7 @@
<p> <p>
<b><%= post.attachments.size %> 个附件:</b> <b><%= post.attachments.size %> 个附件:</b>
<ul> <ul>
<% post.attachments.each do |attachment| %> <%=render post.attachments %>
<li><%= link_to attachment.data.original_filename, attachment.data.url %></li>
<% if attachment.data.content_type[0,5] == "image" %>
<%= image_tag attachment.data.url %>
<% end %>
<% end %>
</ul> </ul>
</p> </p>
<% end %> <% end %>
......
...@@ -374,6 +374,3 @@ zh-CN: ...@@ -374,6 +374,3 @@ zh-CN:
submit: "提交" submit: "提交"
private: "仅楼主可见" private: "仅楼主可见"
anonymous: "匿名发帖" anonymous: "匿名发帖"
tournament:
location:
qun: "QQ群"
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment