Merge branch 'master' of github.com:neocities/neocities

This commit is contained in:
Victoria Wang 2015-02-26 00:24:30 -06:00
commit 122c9eeb89
7 changed files with 40 additions and 8 deletions

View file

@ -18,6 +18,9 @@ GEM
bcrypt (3.1.7)
blankslate (3.1.3)
builder (3.2.2)
byebug (2.7.0)
columnize (~> 0.3)
debugger-linecache (~> 1.2)
capybara (2.4.1)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
@ -35,6 +38,7 @@ GEM
cocaine (0.5.4)
climate_control (>= 0.0.3, < 1.0)
coderay (1.1.0)
columnize (0.8.9)
connection_pool (2.0.0)
crack (0.4.2)
safe_yaml (~> 1.0.0)
@ -43,6 +47,7 @@ GEM
nokogiri (>= 1.4.2)
rack (>= 1.1.0)
uuidtools (~> 2.1.1)
debugger-linecache (1.2.0)
docile (1.1.3)
erubis (2.7.0)
extlib (0.9.16)
@ -118,6 +123,9 @@ GEM
coderay (~> 1.0)
method_source (~> 0.8)
slop (~> 3.4)
pry-byebug (1.3.2)
byebug (~> 2.7)
pry (~> 0.9.12)
puma (2.8.1)
rack (>= 1.1, < 2.0)
rack (1.5.2)

View file

@ -110,6 +110,17 @@ end
get %r{\/site_files\/text_editor\/(.+)} do
require_login
@filename = params[:captures].first
extname = File.extname @filename
@ace_mode = case extname
when /htm|html/ then 'html'
when /js/ then 'javascript'
when /md/ then 'markdown'
when /css/ then 'css'
else
nil
end
begin
@file_data = current_site.get_file @filename
rescue Errno::ENOENT

View file

@ -493,7 +493,7 @@ class Site < Sequel::Model
# extname = uploaded_file[:filename]
#end
unless (Site::VALID_MIME_TYPES.include?(mime_type) || mime_type =~ /text/) &&
unless (Site::VALID_MIME_TYPES.include?(mime_type) || mime_type =~ /text/ || mime_type =~ /inode\/x-empty/) &&
Site::VALID_EXTENSIONS.include?(extname.sub(/^./, '').downcase)
return false
end

0
tests/files/empty.js Normal file
View file

View file

@ -48,6 +48,11 @@ describe 'site_files' do
end
describe 'upload' do
it 'works with empty files' do
upload 'files[]' => Rack::Test::UploadedFile.new('./tests/files/empty.js', 'text/javascript')
File.exists?(@site.files_path('empty.js')).must_equal true
end
it 'manages files with invalid UTF8' do
upload 'files[]' => Rack::Test::UploadedFile.new('./tests/files/invalidutf8.html', 'text/html')
File.exists?(@site.files_path('invalidutf8.html')).must_equal true

View file

@ -227,6 +227,8 @@
$('#uploadingOverlay').css('display', 'none')
}
allUploadsComplete = false
Dropzone.options.uploads = {
paramName: 'files',
maxFilesize: <%= current_site.remaining_space.to_mb %>,
@ -235,7 +237,8 @@
dictDefaultMessage: '',
uploadMultiple: true,
init: function() {
this.on("successmultiple", function(file) {
this.on("completemultiple", function(file) {
if(allUploadsComplete == true)
location.reload()
})
@ -246,6 +249,9 @@
})
this.on("totaluploadprogress", function(progress, totalBytes, totalBytesSent) {
if(progress == 100)
allUploadsComplete = true
showUploadProgress()
$('#progressBar').css('display', 'block')
$('#uploadingProgress').css('width', progress+'%')

View file

@ -150,7 +150,9 @@
$(document).ready(function() {
editor = ace.edit("editor")
setTheme()
editor.getSession().setMode("ace/mode/html")
<% if @ace_mode %>
editor.getSession().setMode("ace/mode/<%= @ace_mode %>")
<% end %>
editor.getSession().setTabSize(2)
editor.getSession().setUseWrapMode(true)
editor.setFontSize(14)