mirror of
https://github.com/neocities/neocities.git
synced 2025-04-26 18:22:38 +02:00
Merge branch 'master' of github.com:neocities/neocities
This commit is contained in:
commit
122c9eeb89
7 changed files with 40 additions and 8 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
@ -148,4 +159,4 @@ end
|
|||
|
||||
get '/site_files/mount_info' do
|
||||
erb :'site_files/mount_info'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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
0
tests/files/empty.js
Normal 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
|
||||
|
|
|
@ -227,6 +227,8 @@
|
|||
$('#uploadingOverlay').css('display', 'none')
|
||||
}
|
||||
|
||||
allUploadsComplete = false
|
||||
|
||||
Dropzone.options.uploads = {
|
||||
paramName: 'files',
|
||||
maxFilesize: <%= current_site.remaining_space.to_mb %>,
|
||||
|
@ -235,8 +237,9 @@
|
|||
dictDefaultMessage: '',
|
||||
uploadMultiple: true,
|
||||
init: function() {
|
||||
this.on("successmultiple", function(file) {
|
||||
location.reload()
|
||||
this.on("completemultiple", function(file) {
|
||||
if(allUploadsComplete == true)
|
||||
location.reload()
|
||||
})
|
||||
|
||||
this.on("error", function(file, errorMessage) {
|
||||
|
@ -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+'%')
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
html {
|
||||
overflow-y: hidden;
|
||||
}
|
||||
#editor {
|
||||
#editor {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
|
@ -133,14 +133,14 @@
|
|||
$('#editorUpdates').fadeOut(); //.addClass('hidden');
|
||||
}, 2000)
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
$('#saveButton').tooltip('show')
|
||||
$('#editorUpdates span').text(response)
|
||||
}
|
||||
$('#editorUpdates').fadeIn()
|
||||
$('#editorUpdates').removeClass('hidden')
|
||||
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue