fixes for tutorial

This commit is contained in:
Kyle Drake 2024-03-26 21:03:26 -05:00
parent 8f6a85d81d
commit 0704521d4a
2 changed files with 27 additions and 10 deletions

View file

@ -7,8 +7,8 @@
<div class="dialogue" style="top: 20px; left: 360px">
Your Neocities web directory already includes an image called <strong>neocities.png</strong>.
</div>
<div class="dialogue" style="top: 145px; left: 390px; width:200px">
Add it to your page like so: <pre><code class="html">&lt;img src="/neocities.png"&gt;</code></pre>
<div class="dialogue" style="top: 145px; left: 360px; width:250px">
Add it to your page: <pre><code class="html">&lt;img src="/neocities.png"&gt;</code></pre>
</div>
<div class="dialogue" style="top: 230px; left: 420px">
That's it! No closing tag needed for images.

View file

@ -18,23 +18,40 @@
$('h3#sitePreview').css('display', 'none')
$('.preview').css('margin-top', '20px')
$('#saveToSite').on('click', function() {
$('#saveToSite').on('click', function(event) {
event.preventDefault()
var formData = new FormData()
var fileContent = sessionStorage.getItem('tutorialHtml')
formData.append('index.html', new File([fileContent], 'index.html', { type: 'text/html' }))
formData.append('csrf_token', '<%= escape_javascript csrf_token %>')
formData.append('username', '<%= escape_javascript current_site.username %>')
$.ajax({
url: '/site_files/upload?csrf_token=<%= Rack::Utils.escape csrf_token %>&filename=<%= Rack::Utils.escape 'index.html' %>&site_id=<%= current_site.id %>',
data: sessionStorage.getItem('tutorialHtml'),
url: '/api/upload',
data: formData,
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!')
var errorMessage = '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!'
if(jqXHR.responseText) {
try {
// Attempt to parse the JSON responseText to get the error message
var parsedResponse = JSON.parse(jqXHR.responseText);
errorMessage += ' ERROR MESSAGE: ' + parsedResponse.message;
alert(errorMessage)
} catch (error) {
}
}
alert(errorMessage)
},
success: function(response){
success: function(response, textStatus, xhr){
window.location = '/tutorial/html/10'
}
})
return false
})
})
</script>