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

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

parent da8298ea
......@@ -21,7 +21,9 @@ group :assets do
gem 'coffee-rails'
# 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'
end
......
......@@ -136,6 +136,7 @@ GEM
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
therubyrhino (1.73.4)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
......@@ -165,4 +166,5 @@ DEPENDENCIES
rails
rails_admin
sass-rails
therubyrhino
uglifier
......@@ -22,7 +22,7 @@ class UsersController < ApplicationController
respond_to do |format|
format.html # show.html.erb
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
......@@ -45,12 +45,12 @@ class UsersController < ApplicationController
@actions = [@user, "修改头像"]
if @current_user != @user
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
else
respond_to do |format|
format.html {redirect_to(:login, :notice => '请先登录.')}
format.html { redirect_to(:login, :notice => '请先登录.') }
end
end
......@@ -67,10 +67,16 @@ class UsersController < ApplicationController
@continue = params[:continue]
@from = params[:from].to_s.to_sym
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")
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 }
else
format.html { render :action => "new" }
......@@ -78,6 +84,7 @@ class UsersController < ApplicationController
end
end
end
# PUT /users/1
# PUT /users/1.xml
def update
......@@ -113,6 +120,7 @@ class UsersController < ApplicationController
format.xml { head :ok }
end
end
def login
@actions = [User.human_attribute_name(:login)]
return @user = User.new if params[:user].blank?
......@@ -140,7 +148,7 @@ class UsersController < ApplicationController
session[:user_id] = @user.id
@user.update_attribute(:lastloginip, request.remote_ip)
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 }
else
@user = User.new(params[:user])
......@@ -149,6 +157,7 @@ class UsersController < ApplicationController
end
end
end
def logout
session[:user_id] = nil
respond_to do |format|
......@@ -156,6 +165,7 @@ class UsersController < ApplicationController
format.xml { head :ok }
end
end
def theme
#p params[:theme], @site[:themes].has_key?(params[:theme])
if params[:theme].blank?
......@@ -170,20 +180,23 @@ class UsersController < ApplicationController
format.xml { head :ok }
end
end
def boardcast_user(user, wait=nil)
def boardcast_user(user, from=nil)
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}"
if RUBY_PLATFORM["win"] || RUBY_PLATFORM["ming"]
open(url){} rescue nil
open(url) {} rescue nil
else
Process.spawn('curl', url)
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}"
if wait == :"ygopro-ocg" or RUBY_PLATFORM["win"] || RUBY_PLATFORM["ming"]
open(url){}
if RUBY_PLATFORM["win"] || RUBY_PLATFORM["ming"]
open(url) {}
else
Process.spawn('curl', url)
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 @@
<p>
<b><%= post.attachments.size %> 个附件:</b>
<ul>
<% post.attachments.each do |attachment| %>
<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 %>
<%=render post.attachments %>
</ul>
</p>
<% end %>
......
......@@ -374,6 +374,3 @@ zh-CN:
submit: "提交"
private: "仅楼主可见"
anonymous: "匿名发帖"
\ No newline at end of file
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