Added more json support
This commit is contained in:
@@ -5,7 +5,12 @@ class ForumgroupsController < ApplicationController
|
||||
end
|
||||
|
||||
def show
|
||||
redirect_to forums_path + "#group-#{params[:id].to_i}"
|
||||
if request.format.html?
|
||||
redirect_to forums_path + "#group-#{params[:id].to_i}"
|
||||
else
|
||||
fg = Forumgroup.find_by(id: params[:id])
|
||||
respond_to {|format| format.json {render json: (fg.attributes.to_json if fg.try(:can_read?, :current_user))}}
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@@ -77,4 +82,4 @@ class ForumgroupsController < ApplicationController
|
||||
params.require(:forumgroup).permit(a)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -13,6 +13,11 @@ class ForumsController < ApplicationController
|
||||
[t.sticky ? 0 : 1, -(t.replies.last.try(:created_at) || t.created_at).to_i]
|
||||
end
|
||||
@threads = Kaminari.paginate_array(@threads).page(params[:page])
|
||||
respond_to do |format|
|
||||
format.html
|
||||
f = Forum.find_by(id: params[:id])
|
||||
format.json {render json: f.attributes.to_json}
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@@ -92,4 +97,4 @@ class ForumsController < ApplicationController
|
||||
a = [:name, :position, :role_read_id, :role_write_id] + add
|
||||
params.require(:forum).permit(a)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -7,7 +7,12 @@ class ForumthreadsController < ApplicationController
|
||||
end
|
||||
|
||||
def show
|
||||
@replies = @thread.replies.page(params[:page])
|
||||
if @thread
|
||||
@replies = @thread.replies.page(params[:page])
|
||||
else
|
||||
respond_to {|format| format.json {render json: Comment.find_by(id: params[:id][1..-1]).try(:attributes).to_json}}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def edit
|
||||
@@ -92,4 +97,4 @@ class ForumthreadsController < ApplicationController
|
||||
a += add
|
||||
params.require(:forumthread).permit(a)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@ class UsersController < ApplicationController
|
||||
include MailerHelper
|
||||
include ERB::Util
|
||||
|
||||
before_filter :set_user, except: [:index, :new, :create, :lost_password, :reset_password, :suggestions]
|
||||
before_filter :set_user, except: [:index, :new, :create, :lost_password, :reset_password, :suggestions, :update_memory]
|
||||
|
||||
def index
|
||||
if params[:role]
|
||||
@@ -327,6 +327,26 @@ class UsersController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
def memory
|
||||
params[:page] ||= (page ||= 1)
|
||||
file = File.open("/etc/minecraft/redstoner/plugins/JavaUtils/memory/hexfile.hex")
|
||||
@hex_a = file.read.unpack("C*").map {|h| h.to_s(16)}
|
||||
@hex_a = Kaminari.paginate_array(@hex_a).page(params[:page]).per(2048)
|
||||
file.close
|
||||
end
|
||||
|
||||
def update_memory
|
||||
file = File.open("/etc/minecraft/redstoner/plugins/JavaUtils/memory/hexfile.hex")
|
||||
new_text = file.read
|
||||
file.close
|
||||
new_text = new_text.unpack("C*").collect{|h| h.to_s(16)}
|
||||
new_text[params[:mem_id].split("-")[1].to_i] = params[:value]
|
||||
file = File.open("/etc/minecraft/redstoner/plugins/JavaUtils/memory/hexfile.hex", "w")
|
||||
file.write((new_text.collect{|h| h.to_s.to_i(16)}).pack("C*").force_encoding("UTF-8"))
|
||||
file.close
|
||||
render nothing: true
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def validate_token(uuid, email, token)
|
||||
|
||||
Reference in New Issue
Block a user