From 0704521d4a5194277241230c6d335ccfd57be990 Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Tue, 26 Mar 2024 21:03:26 -0500 Subject: [PATCH 1/6] fixes for tutorial --- views/tutorial/html/6.erb | 4 ++-- views/tutorial/html/9.erb | 33 +++++++++++++++++++++++++-------- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/views/tutorial/html/6.erb b/views/tutorial/html/6.erb index ea978cca..a70148f7 100644 --- a/views/tutorial/html/6.erb +++ b/views/tutorial/html/6.erb @@ -7,8 +7,8 @@
Your Neocities web directory already includes an image called neocities.png.
-
- Add it to your page like so:
<img src="/neocities.png">
+
+ Add it to your page:
<img src="/neocities.png">
That's it! No closing tag needed for images. diff --git a/views/tutorial/html/9.erb b/views/tutorial/html/9.erb index d6928d71..289713f7 100644 --- a/views/tutorial/html/9.erb +++ b/views/tutorial/html/9.erb @@ -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 }) - }) From 2831d2fd77ab70440bb89ee31d9c8b8b74cadc61 Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Wed, 27 Mar 2024 02:03:59 +0000 Subject: [PATCH 2/6] fixes for mime type changes --- models/site.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/models/site.rb b/models/site.rb index 0874fbe1..c76c29c4 100644 --- a/models/site.rb +++ b/models/site.rb @@ -10,8 +10,6 @@ class Site < Sequel::Model VALID_MIME_TYPES = %w{ application/epub application/epub+zip - application/font-sfnt - application/javascript application/json application/octet-stream application/opensearchdescription+xml @@ -21,10 +19,13 @@ class Site < Sequel::Model application/rss+xml application/vnd.ms-fontobject application/vnd.ms-opentype - application/x-elc - application/x-font-ttf application/xml audio/midi + font/otf + font/sfnt + font/ttf + font/woff + font/woff2 image/apng image/avif image/gif @@ -38,10 +39,10 @@ class Site < Sequel::Model image/x-xcf message/rfc822 text/cache-manifest - text/cache-manifest text/css text/csv text/html + text/javascript text/plain text/tsv text/xml From f7314663172944269b683f87d1eaf893558dcafe Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Wed, 27 Mar 2024 14:01:28 +0000 Subject: [PATCH 3/6] increase max follows to 2000 --- models/site.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/models/site.rb b/models/site.rb index c76c29c4..dbe2829c 100644 --- a/models/site.rb +++ b/models/site.rb @@ -78,8 +78,8 @@ class Site < Sequel::Model INDEX_HTML_REGEX = /\/?index.html$/ ROOT_INDEX_HTML_REGEX = /^\/?index.html$/ MAX_COMMENT_SIZE = 420 # Used to be the limit for Facebook.. no comment (PUN NOT INTENDED). - MAX_FOLLOWS = 1000 - + MAX_FOLLOWS = 2000 + BROWSE_MINIMUM_VIEWS = 100 BROWSE_MINIMUM_FOLLOWER_VIEWS = 10_000 From c090392b413f3a60c98956387b99073eeb16a21f Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Wed, 27 Mar 2024 10:02:02 -0500 Subject: [PATCH 4/6] limit how many follows are shown --- views/_follows.erb | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/views/_follows.erb b/views/_follows.erb index 851257e7..05b1e5dc 100644 --- a/views/_follows.erb +++ b/views/_follows.erb @@ -1,22 +1,26 @@ -<% site_followings = site.followings_dataset.count %> -<% if (!is_current_site && site_followings > 0) || is_current_site %> +<% site_followings_count = site.followings_dataset.count %> +<% if (!is_current_site && site_followings_count > 0) || is_current_site %>

<%= is_current_site ? 'Sites you follow' : 'This site follows' %>

- <% if site_followings == 0 %> + <% if site_followings_count == 0 %>

You are not following any sites yet. Add some by browsing sites or looking at your tags. <% else %> - <% site.followings_dataset.select(:site_id).all.each do |following| %> + <% site.followings_dataset.select(:site_id).limit(Site::MAX_DISPLAY_FOLLOWS).each do |following| %> <% end %> + + <% if Site::MAX_DISPLAY_FOLLOWS < site_followings_count %> + see more + <% end %> <% end %>

<% end %> -<% site_follows = site.follows_dataset.count %> -<% if (!is_current_site && site_follows > 0) || is_current_site %> +<% site_follows_count = site.follows_dataset.count %> +<% if (!is_current_site && site_follows_count > 0) || is_current_site %>

Followers

- <% if site_follows == 0 %> + <% if site_follows_count == 0 %> No followers yet. <% else %> <% site_profile_follows_actioning_ids = site.profile_follows_actioning_ids %> From 8fdc30a88cfac582958107da0bba7c217c790f3d Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Wed, 27 Mar 2024 10:17:29 -0500 Subject: [PATCH 5/6] missing atom mime type --- models/site.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/models/site.rb b/models/site.rb index dbe2829c..7366eafa 100644 --- a/models/site.rb +++ b/models/site.rb @@ -8,6 +8,7 @@ class Site < Sequel::Model include Sequel::ParanoidDelete VALID_MIME_TYPES = %w{ + application/atom+xml application/epub application/epub+zip application/json From d850559f36a7abf5e5fe13cca63f1a3e78365e70 Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Thu, 28 Mar 2024 00:29:57 -0500 Subject: [PATCH 6/6] site views, hits needs bigint --- migrations/125_sites_stats_bigint.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 migrations/125_sites_stats_bigint.rb diff --git a/migrations/125_sites_stats_bigint.rb b/migrations/125_sites_stats_bigint.rb new file mode 100644 index 00000000..efb229ed --- /dev/null +++ b/migrations/125_sites_stats_bigint.rb @@ -0,0 +1,15 @@ +Sequel.migration do + up { + alter_table(:sites) do + set_column_type :hits, :bigint + set_column_type :views, :bigint + end + } + + down { + alter_table(:sites) do + set_column_type :hits, Integer + set_column_type :views, Integer + end + } +end