mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 01:32:36 +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
|
current_site.get_file filename
|
||||||
end
|
end
|
||||||
|
|
||||||
get '/site_files/text_editor/:filename' do |filename|
|
get %r{\/site_files\/text_editor\/(.+)} do
|
||||||
require_login
|
require_login
|
||||||
|
@filename = params[:captures].first
|
||||||
begin
|
begin
|
||||||
@file_data = current_site.get_file filename
|
@file_data = current_site.get_file @filename
|
||||||
rescue Errno::ENOENT
|
rescue Errno::ENOENT
|
||||||
flash[:error] = 'We could not find the requested file.'
|
flash[:error] = 'We could not find the requested file.'
|
||||||
redirect '/dashboard'
|
redirect '/dashboard'
|
||||||
|
@ -732,8 +733,9 @@ get '/site_files/text_editor/:filename' do |filename|
|
||||||
erb :'site_files/text_editor'
|
erb :'site_files/text_editor'
|
||||||
end
|
end
|
||||||
|
|
||||||
post '/site_files/save/:filename' do |filename|
|
post %r{\/site_files\/save\/(.+)} do
|
||||||
require_login_ajax
|
require_login_ajax
|
||||||
|
filename = params[:captures].first
|
||||||
|
|
||||||
tempfile = Tempfile.new 'neocities_saving_file'
|
tempfile = Tempfile.new 'neocities_saving_file'
|
||||||
|
|
||||||
|
@ -1001,7 +1003,7 @@ post '/api/delete' do
|
||||||
|
|
||||||
paths = []
|
paths = []
|
||||||
params[:filenames].each do |path|
|
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"
|
api_error 400, 'bad_filename', "#{path} is not a valid filename, canceled deleting"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -294,11 +294,6 @@ class Site < Sequel::Model
|
||||||
!@blockings.select {|b| b.site_id == site.id}.empty?
|
!@blockings.select {|b| b.site_id == site.id}.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.valid_path?(path)
|
|
||||||
puts 'ditto restrictions scrub'
|
|
||||||
true
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.valid_username?(username)
|
def self.valid_username?(username)
|
||||||
!username.empty? && username.match(/^[a-zA-Z0-9_\-]+$/i)
|
!username.empty? && username.match(/^[a-zA-Z0-9_\-]+$/i)
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
<div class="header-Outro">
|
<div class="header-Outro">
|
||||||
<div class="row content">
|
<div class="row content">
|
||||||
<h1>Editing <%= params[:filename] %></h1>
|
<h1>Editing <%= @filename %></h1>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -120,11 +120,14 @@
|
||||||
|
|
||||||
function saveTextFile(quit) {
|
function saveTextFile(quit) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/site_files/save/<%= params[:filename] %>?csrf_token=<%= csrf_token %>',
|
url: '/site_files/save/<%= @filename %>?csrf_token=<%= csrf_token %>',
|
||||||
data: editor.getValue(),
|
data: editor.getValue(),
|
||||||
processData: false,
|
processData: false,
|
||||||
contentType: false,
|
contentType: false,
|
||||||
type: 'POST',
|
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){
|
success: function(response){
|
||||||
if(response == 'ok') {
|
if(response == 'ok') {
|
||||||
if(quit === true) {
|
if(quit === true) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue