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

View file

@ -18,23 +18,40 @@
$('h3#sitePreview').css('display', 'none') $('h3#sitePreview').css('display', 'none')
$('.preview').css('margin-top', '20px') $('.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({ $.ajax({
url: '/site_files/upload?csrf_token=<%= Rack::Utils.escape csrf_token %>&filename=<%= Rack::Utils.escape 'index.html' %>&site_id=<%= current_site.id %>', url: '/api/upload',
data: sessionStorage.getItem('tutorialHtml'), data: formData,
processData: false, processData: false,
contentType: false, contentType: false,
type: 'POST', type: 'POST',
error: function(jqXHR, textStatus, errorThrown) { 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' window.location = '/tutorial/html/10'
} }
}) })
return false
}) })
}) })
</script> </script>