mirror of
https://github.com/neocities/neocities.git
synced 2025-04-24 17:22:35 +02:00
Merge branch 'master' of github.com:neocities/neocities
This commit is contained in:
commit
6925c21d2b
2 changed files with 38 additions and 33 deletions
|
@ -163,42 +163,47 @@
|
||||||
|
|
||||||
var editor = {}
|
var editor = {}
|
||||||
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$.get("/site_files/download/<%= Addressable::URI.parse(@filename).normalized_path.to_s %>", function(resp) {
|
$.ajax({
|
||||||
editor = ace.edit("editor")
|
url: "/site_files/download/<%= Addressable::URI.parse(@filename).normalized_path.to_s %>",
|
||||||
setTheme()
|
cache: false,
|
||||||
<% if @ace_mode %>
|
success: function(resp) {
|
||||||
editor.getSession().setMode("ace/mode/<%= @ace_mode %>")
|
editor = ace.edit("editor")
|
||||||
<% end %>
|
setTheme()
|
||||||
editor.getSession().setTabSize(2)
|
<% if @ace_mode %>
|
||||||
editor.getSession().setUseWrapMode(true)
|
editor.getSession().setMode("ace/mode/<%= @ace_mode %>")
|
||||||
editor.setFontSize(14)
|
<% end %>
|
||||||
editor.setShowPrintMargin(false)
|
editor.getSession().setTabSize(2)
|
||||||
editor.setOptions({
|
editor.getSession().setUseWrapMode(true)
|
||||||
maxLines: Infinity,
|
editor.setFontSize(14)
|
||||||
autoScrollEditorIntoView: true
|
editor.setShowPrintMargin(false)
|
||||||
})
|
editor.setOptions({
|
||||||
|
maxLines: Infinity,
|
||||||
|
autoScrollEditorIntoView: true
|
||||||
|
})
|
||||||
|
|
||||||
// Disable autocomplete
|
// Disable autocomplete
|
||||||
editor.setBehavioursEnabled(false)
|
editor.setBehavioursEnabled(false)
|
||||||
|
|
||||||
editor.setValue(resp, -1)
|
editor.setValue(resp, -1)
|
||||||
editor.getSession().setUndoManager(new ace.UndoManager())
|
editor.getSession().setUndoManager(new ace.UndoManager())
|
||||||
|
|
||||||
editor.on('change', function(obj) {
|
editor.on('change', function(obj) {
|
||||||
$('a#saveButton,a#saveAndExitButton').css('opacity', 1)
|
$('a#saveButton,a#saveAndExitButton').css('opacity', 1)
|
||||||
unsavedChanges = true
|
unsavedChanges = true
|
||||||
})
|
})
|
||||||
|
|
||||||
editor.commands.addCommand({
|
editor.commands.addCommand({
|
||||||
name: 'saveCommand',
|
name: 'saveCommand',
|
||||||
bindKey: {win: 'Ctrl-S', mac: 'Command-S'},
|
bindKey: {win: 'Ctrl-S', mac: 'Command-S'},
|
||||||
exec: function(editor) {
|
exec: function(editor) {
|
||||||
saveTextFile(false)
|
saveTextFile(false)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
}
|
||||||
})
|
});
|
||||||
|
});
|
||||||
|
|
||||||
window.onbeforeunload = function() {
|
window.onbeforeunload = function() {
|
||||||
if(unsavedChanges == true)
|
if(unsavedChanges == true)
|
||||||
|
|
|
@ -47,7 +47,7 @@ class ScreenshotWorker
|
||||||
base_image_tmpfile_path = "/tmp/#{SecureRandom.uuid}.png"
|
base_image_tmpfile_path = "/tmp/#{SecureRandom.uuid}.png"
|
||||||
|
|
||||||
http_resp = HTTP.basic_auth(user: api_user, pass: api_password).get(uri)
|
http_resp = HTTP.basic_auth(user: api_user, pass: api_password).get(uri)
|
||||||
BlackBox.new(site, path).check_uri(http_resp.headers['X-URL'])
|
BlackBox.new(site, path).check_uri(http_resp.headers['X-URL']) if defined?(BlackBox)
|
||||||
File.write base_image_tmpfile_path, http_resp.to_s
|
File.write base_image_tmpfile_path, http_resp.to_s
|
||||||
|
|
||||||
user_screenshots_path = File.join SCREENSHOTS_PATH, Site.sharding_dir(username), username
|
user_screenshots_path = File.join SCREENSHOTS_PATH, Site.sharding_dir(username), username
|
||||||
|
@ -72,7 +72,7 @@ class ScreenshotWorker
|
||||||
rescue => e
|
rescue => e
|
||||||
raise e
|
raise e
|
||||||
ensure
|
ensure
|
||||||
FileUtils.rm base_image_tmpfile_path
|
FileUtils.rm base_image_tmpfile_path if File.exist?(base_image_tmpfile_path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue