+ <% end %>
+
+
+ <% if submission.explanation.present? %>
+
+
+ "<%= submission.explanation %>"
+
+
+
+ <% end %>
+
+
+
+
+ See full page
+ arrow_forward
+
+
+
+
+
+
+
+
+
+ <% end %>
+
\ No newline at end of file
diff --git a/app/views/page_collections/show.html.erb b/app/views/page_collections/show.html.erb
index e272cc5a..d5304174 100644
--- a/app/views/page_collections/show.html.erb
+++ b/app/views/page_collections/show.html.erb
@@ -412,7 +412,7 @@
- Loading more articles...
+ Loading more pages...
@@ -978,19 +978,29 @@ document.addEventListener('DOMContentLoaded', function() {
loadingIndicator.classList.remove('hidden');
try {
- // Simulate loading more articles (in production, this would be an AJAX request)
- await new Promise(resolve => setTimeout(resolve, 1000));
+ // Make an AJAX request to get more pages
+ const response = await fetch(`/page_collections/${window.location.pathname.split('/').pop()}/pages?page=${currentPage + 1}`);
+ const data = await response.json();
// Hide loading indicator
loadingIndicator.classList.add('hidden');
isLoading = false;
- // In a real implementation, you'd append new articles to the container
- console.log('Loaded page', ++currentPage);
+ // Append the new pages to the container
+ if (data.pages && data.pages.length > 0) {
+ data.pages.forEach(page => {
+ // Create and append new article HTML
+ articlesContainer.insertAdjacentHTML('beforeend', page.html);
+ });
+ currentPage++;
+ } else {
+ // No more pages to load, remove the scroll observer
+ scrollObserver.unobserve(scrollTrigger);
+ }
} catch (error) {
loadingIndicator.classList.add('hidden');
isLoading = false;
- console.error('Error loading more articles:', error);
+ console.error('Error loading more pages:', error);
}
}
diff --git a/config/routes.rb b/config/routes.rb
index e77143aa..bbca2163 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -74,6 +74,7 @@ Rails.application.routes.draw do
get 'report', on: :member
get 'rss', on: :member, defaults: { format: 'rss' }
get 'feed', on: :member, to: 'page_collections#rss', defaults: { format: 'rss' }, as: 'feed'
+ get 'pages', on: :member, to: 'page_collections#pages', defaults: { format: 'json' }
get 'by/:user_id', to: 'page_collections#by_user', as: :submissions_by_user