Compare commits
2 Commits
permission
...
api
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
361b15e398 | ||
|
|
0972181e75 |
@@ -8,8 +8,16 @@ class BlogpostsController < ApplicationController
|
||||
end
|
||||
|
||||
def show
|
||||
@comment = Comment.new(blogpost: @post)
|
||||
@comments = @post.comments.page(params[:page])
|
||||
if @post
|
||||
@comment = Comment.new(blogpost: @post)
|
||||
@comments = @post.comments.page(params[:page])
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.json {render json: @post.attributes.merge(replies: Comment.where(blogpost: @post).ids).to_json}
|
||||
end
|
||||
else
|
||||
respond_to {|format| format.json {render json: Comment.find_by(id: params[:id][1..-1]).try(:attributes).to_json}}
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
@@ -64,7 +72,9 @@ class BlogpostsController < ApplicationController
|
||||
|
||||
def set_post
|
||||
if params[:id]
|
||||
@post = Blogpost.find(params[:id])
|
||||
unless action_name == "show" && params[:id][0].downcase == "c"
|
||||
@post = Blogpost.find(params[:id])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -75,4 +85,4 @@ class BlogpostsController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,6 +2,12 @@ class CommentsController < ApplicationController
|
||||
|
||||
include MailerHelper
|
||||
|
||||
def show
|
||||
respond_to do |format|
|
||||
format.json {render json: @comment.attributes.to_json}
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@comment = Comment.find(params[:id])
|
||||
if mod? || @comment.author.is?(current_user)
|
||||
@@ -72,4 +78,4 @@ class CommentsController < ApplicationController
|
||||
def comment_params
|
||||
params.require(:comment).permit(:content)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -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]
|
||||
@@ -30,6 +30,10 @@ class UsersController < ApplicationController
|
||||
end
|
||||
|
||||
def show
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.json {render json: @user.attributes.slice("id", "uuid", "ign", "name", "about", "donor", "confirmed", "last_seen", "created_at").to_json}
|
||||
end
|
||||
end
|
||||
|
||||
# SIGNUP
|
||||
@@ -323,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