mirror of
https://github.com/neocities/neocities.git
synced 2025-04-24 17:22:35 +02:00
fix text editor
This commit is contained in:
parent
2743e02cc1
commit
e200eb47c6
3 changed files with 11 additions and 11 deletions
10
app.rb
10
app.rb
|
@ -721,10 +721,11 @@ get '/site_files/download/:filename' do |filename|
|
|||
current_site.get_file filename
|
||||
end
|
||||
|
||||
get '/site_files/text_editor/:filename' do |filename|
|
||||
get %r{\/site_files\/text_editor\/(.+)} do
|
||||
require_login
|
||||
@filename = params[:captures].first
|
||||
begin
|
||||
@file_data = current_site.get_file filename
|
||||
@file_data = current_site.get_file @filename
|
||||
rescue Errno::ENOENT
|
||||
flash[:error] = 'We could not find the requested file.'
|
||||
redirect '/dashboard'
|
||||
|
@ -732,8 +733,9 @@ get '/site_files/text_editor/:filename' do |filename|
|
|||
erb :'site_files/text_editor'
|
||||
end
|
||||
|
||||
post '/site_files/save/:filename' do |filename|
|
||||
post %r{\/site_files\/save\/(.+)} do
|
||||
require_login_ajax
|
||||
filename = params[:captures].first
|
||||
|
||||
tempfile = Tempfile.new 'neocities_saving_file'
|
||||
|
||||
|
@ -1001,7 +1003,7 @@ post '/api/delete' do
|
|||
|
||||
paths = []
|
||||
params[:filenames].each do |path|
|
||||
unless path.is_a?(String) && Site.valid_path?(path)
|
||||
unless path.is_a?(String)
|
||||
api_error 400, 'bad_filename', "#{path} is not a valid filename, canceled deleting"
|
||||
end
|
||||
|
||||
|
|
|
@ -294,11 +294,6 @@ class Site < Sequel::Model
|
|||
!@blockings.select {|b| b.site_id == site.id}.empty?
|
||||
end
|
||||
|
||||
def self.valid_path?(path)
|
||||
puts 'ditto restrictions scrub'
|
||||
true
|
||||
end
|
||||
|
||||
def self.valid_username?(username)
|
||||
!username.empty? && username.match(/^[a-zA-Z0-9_\-]+$/i)
|
||||
end
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
<div class="header-Outro">
|
||||
<div class="row content">
|
||||
<h1>Editing <%= params[:filename] %></h1>
|
||||
<h1>Editing <%= @filename %></h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -120,11 +120,14 @@
|
|||
|
||||
function saveTextFile(quit) {
|
||||
$.ajax({
|
||||
url: '/site_files/save/<%= params[:filename] %>?csrf_token=<%= csrf_token %>',
|
||||
url: '/site_files/save/<%= @filename %>?csrf_token=<%= csrf_token %>',
|
||||
data: editor.getValue(),
|
||||
processData: false,
|
||||
contentType: false,
|
||||
type: 'POST',
|
||||
error: function(jqXHR, textStatus, errorThrown) {
|
||||
alert('There has been an error saving your file, please try again. If it continues to fail, make a copy of the file locally so you don\'t lose your changes!')
|
||||
},
|
||||
success: function(response){
|
||||
if(response == 'ok') {
|
||||
if(quit === true) {
|
||||
|
|
Loading…
Add table
Reference in a new issue