Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
361b15e398 | ||
|
|
0972181e75 |
Binary file not shown.
@@ -51,4 +51,4 @@ $(function(){
|
|||||||
return time + " " + unit + tail;
|
return time + " " + unit + tail;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -14,5 +14,4 @@
|
|||||||
//= require app
|
//= require app
|
||||||
//= require editor
|
//= require editor
|
||||||
//= require highlight
|
//= require highlight
|
||||||
//= require jquery-textcomplete
|
//= require jquery-textcomplete
|
||||||
//= require memory
|
|
||||||
@@ -89,4 +89,4 @@ $(function() {
|
|||||||
debounce: 300
|
debounce: 300
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
$(function() {
|
|
||||||
$('td').focus(function() {
|
|
||||||
if (this.id.split("-")[0] == "memory") {
|
|
||||||
$(this).css("background-color", "lightblue")
|
|
||||||
}
|
|
||||||
});
|
|
||||||
var data = [];
|
|
||||||
$('td').keydown(function() {
|
|
||||||
data.push(this.id, $(this).html().substr(0, 2)); //position, value
|
|
||||||
})
|
|
||||||
$('td').blur(function() {
|
|
||||||
$(this).css("background", "none");
|
|
||||||
if ((id_i = data.indexOf(this.id) != -1) && data[id_i+1] != $(this).html().substr(0, 2)) {
|
|
||||||
$(this).css("color", "darkgreen");
|
|
||||||
var int_id = this.id.split("-")[1]
|
|
||||||
$.post("/memory/update_memory?project="+$(this).closest("table").data("project")+"&file="+Math.floor((int_id/2048)+1)+"&mem_id="+int_id%2048+"&value="+$(this).html().substr(0, 2));
|
|
||||||
data.splice(id_i, 2);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
$('select').change(function() {
|
|
||||||
$.get("/memory/table?project="+$(this).data("project")+"&file="+$(this).find("option:selected").text()+".hex")
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1026,13 +1026,4 @@ nav.pagination {
|
|||||||
padding: 0.1em 0.2em;
|
padding: 0.1em 0.2em;
|
||||||
border-radius: 0.2em;
|
border-radius: 0.2em;
|
||||||
text-shadow: none;
|
text-shadow: none;
|
||||||
}
|
}
|
||||||
.memory-table {
|
|
||||||
width: 980px;
|
|
||||||
margin: auto;
|
|
||||||
text-align: center;
|
|
||||||
th, td {
|
|
||||||
height: 20px;
|
|
||||||
border: 1px solid black;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -5,7 +5,12 @@ class ForumgroupsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def show
|
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
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@@ -77,4 +82,4 @@ class ForumgroupsController < ApplicationController
|
|||||||
params.require(:forumgroup).permit(a)
|
params.require(:forumgroup).permit(a)
|
||||||
end
|
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]
|
[t.sticky ? 0 : 1, -(t.replies.last.try(:created_at) || t.created_at).to_i]
|
||||||
end
|
end
|
||||||
@threads = Kaminari.paginate_array(@threads).page(params[:page])
|
@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
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@@ -92,4 +97,4 @@ class ForumsController < ApplicationController
|
|||||||
a = [:name, :position, :role_read_id, :role_write_id] + add
|
a = [:name, :position, :role_read_id, :role_write_id] + add
|
||||||
params.require(:forum).permit(a)
|
params.require(:forum).permit(a)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,7 +7,12 @@ class ForumthreadsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def show
|
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
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@@ -92,4 +97,4 @@ class ForumthreadsController < ApplicationController
|
|||||||
a += add
|
a += add
|
||||||
params.require(:forumthread).permit(a)
|
params.require(:forumthread).permit(a)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,54 +0,0 @@
|
|||||||
class MemoryController < ApplicationController
|
|
||||||
|
|
||||||
before_filter :logged_in
|
|
||||||
|
|
||||||
def index
|
|
||||||
current_uuid = current_user.uuid.gsub("-", "")
|
|
||||||
Dir.chdir("/etc/minecraft/redstoner/plugins/JavaUtils/memory/players/#{current_uuid}")
|
|
||||||
psjson = JSON.parse(File.read("projects.json"))
|
|
||||||
@projects = psjson["owns"] + psjson["read"] + psjson["write"]
|
|
||||||
@project_names = @projects.collect{|p| (data = JSON.parse(File.read(File.expand_path("../..")+"/projects/#{p}/project.json")))["name"] + " | #{"own" if data["owner"] == current_uuid}#{"write" if data["write"].include? current_uuid}#{"read" if data["read"].include? current_uuid}"}
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def list
|
|
||||||
render :index
|
|
||||||
end
|
|
||||||
|
|
||||||
def table
|
|
||||||
Dir.chdir("/etc/minecraft/redstoner/plugins/JavaUtils/memory/projects/#{params[:project].gsub(/[^a-zA-Z0-9-]/,"")[0..35]}")
|
|
||||||
@data = []
|
|
||||||
Dir.glob('*').reverse.each do |f|
|
|
||||||
File.open(Dir.pwd+"/#{f}") do |file|
|
|
||||||
@data.concat(file.read.unpack("C*").map{|h| h.to_s(16)})
|
|
||||||
unless (parse = JSON.parse((jf = File.open(Dir.pwd+"/project.json")).read))["read"].include? current_user.uuid.gsub("-","")
|
|
||||||
@can_edit = true
|
|
||||||
end
|
|
||||||
@name = parse["name"]
|
|
||||||
jf.close
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def update_memory
|
|
||||||
Dir.chdir("/etc/minecraft/redstoner/plugins/JavaUtils/memory/projects/#{params[:project].gsub(/[^a-zA-Z0-9-]/,"")[0..35]}")
|
|
||||||
unless params[:mem_id].to_i > JSON.parse(File.read("project.json"))["size"] || (/[^A-Fa-f0-9]/.match params[:value])
|
|
||||||
new_text = ""
|
|
||||||
File.open("#{params[:file]}.hex"){|f| new_text = f.read.unpack("C*").collect{|h| h.to_s(16)}}
|
|
||||||
new_text[params[:mem_id].to_i] = params[:value]
|
|
||||||
File.open("#{params[:file]}.hex", "w") do |f|
|
|
||||||
f.write((new_text.collect{|h| h.to_s.to_i(16)}).pack("C*").force_encoding("UTF-8"))
|
|
||||||
end
|
|
||||||
render nothing: true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def logged_in
|
|
||||||
unless current_user
|
|
||||||
flash[:alert] = "Please log in before viewing memory files."
|
|
||||||
redirect_to home_statics_path
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -4,7 +4,7 @@ class UsersController < ApplicationController
|
|||||||
include MailerHelper
|
include MailerHelper
|
||||||
include ERB::Util
|
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
|
def index
|
||||||
if params[:role]
|
if params[:role]
|
||||||
@@ -327,6 +327,26 @@ class UsersController < ApplicationController
|
|||||||
end
|
end
|
||||||
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
|
private
|
||||||
|
|
||||||
def validate_token(uuid, email, token)
|
def validate_token(uuid, email, token)
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
module MemoryHelper
|
|
||||||
end
|
|
||||||
@@ -173,4 +173,4 @@ class User < ActiveRecord::Base
|
|||||||
def set_email_token
|
def set_email_token
|
||||||
self.email_token ||= SecureRandom.hex(16)
|
self.email_token ||= SecureRandom.hex(16)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -51,4 +51,4 @@
|
|||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= paginate @threads %>
|
<%= paginate @threads %>
|
||||||
</div>
|
</div>
|
||||||
@@ -25,4 +25,4 @@
|
|||||||
</div>
|
</div>
|
||||||
<%= render partial: "/layouts/footer" %>
|
<%= render partial: "/layouts/footer" %>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
<%= form_tag url_for(controller: "memory", action: "table"), method: :get do %>
|
|
||||||
<%= select_tag "project", options_for_select(@projects.collect.with_index{|p, i| [@project_names[i], p]}) %>
|
|
||||||
<br><br>
|
|
||||||
<%= submit_tag "Load table", name: nil, class: "btn blue" %>
|
|
||||||
<% end %>
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
<h1 style="text-align:center"><%= title @name + (" (read-only)" if !@can_edit).to_s %></h1>
|
|
||||||
<table class="memory-table", data-project="<%=params[:project]%>">
|
|
||||||
<tr>
|
|
||||||
<% ["Address","0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"].each do |i| %>
|
|
||||||
<th><b><%=i%></b></th>
|
|
||||||
<% end %>
|
|
||||||
</tr>
|
|
||||||
<% @data.in_groups_of(16).each_with_index do |row, rindex| %>
|
|
||||||
<tr>
|
|
||||||
<td><b><%=(rindex*16).to_s(16).upcase.rjust(6, "0")%></b></td>
|
|
||||||
<% row.each_with_index do |hex, hindex| %>
|
|
||||||
<td contenteditable="<%=!!@can_edit%>" id="memory-<%=(16*rindex)+hindex%>"><%=hex.to_s.upcase.rjust(2, "0")%></td>
|
|
||||||
<% end %>
|
|
||||||
</tr>
|
|
||||||
<% end %>
|
|
||||||
</table>
|
|
||||||
<br>
|
|
||||||
@@ -30,4 +30,4 @@
|
|||||||
<span>for those who just want to mine some ore</span>
|
<span>for those who just want to mine some ore</span>
|
||||||
<span>and we have a freebuild world for large projects.</span>
|
<span>and we have a freebuild world for large projects.</span>
|
||||||
</p>
|
</p>
|
||||||
<p>Join us now!</p>
|
<p>Join us now!</p>
|
||||||
@@ -19,4 +19,4 @@
|
|||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= paginate @users %>
|
<%= paginate @users %>
|
||||||
</div>
|
</div>
|
||||||
@@ -10,7 +10,7 @@ default: &default
|
|||||||
development:
|
development:
|
||||||
<<: *default
|
<<: *default
|
||||||
database: redstoner-web
|
database: redstoner-web
|
||||||
username: web
|
username: root
|
||||||
|
|
||||||
production:
|
production:
|
||||||
<<: *default
|
<<: *default
|
||||||
@@ -24,4 +24,4 @@ test:
|
|||||||
adapter: sqlite3
|
adapter: sqlite3
|
||||||
database: db/test.sqlite3
|
database: db/test.sqlite3
|
||||||
pool: 5
|
pool: 5
|
||||||
timeout: 5000
|
timeout: 5000
|
||||||
@@ -43,4 +43,4 @@ Redstoner::Application.configure do
|
|||||||
password: ENV["GMAIL_PASSWORD"],
|
password: ENV["GMAIL_PASSWORD"],
|
||||||
}
|
}
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -29,15 +29,6 @@ Redstoner::Application.routes.draw do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :memory do
|
|
||||||
collection do
|
|
||||||
get 'list'
|
|
||||||
get 'table'
|
|
||||||
post 'update_memory'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
resources :forumgroups, path: '/forums/groups'
|
resources :forumgroups, path: '/forums/groups'
|
||||||
resources :forums, path: '/forums'
|
resources :forums, path: '/forums'
|
||||||
resources :forumthreads, path: '/forums/threads' do
|
resources :forumthreads, path: '/forums/threads' do
|
||||||
|
|||||||
@@ -38,4 +38,4 @@ User.create!(
|
|||||||
password: "123456789", # high seructity!
|
password: "123456789", # high seructity!
|
||||||
password_confirmation: "123456789",
|
password_confirmation: "123456789",
|
||||||
role: Role.get(:superadmin)
|
role: Role.get(:superadmin)
|
||||||
)
|
)
|
||||||
Reference in New Issue
Block a user