diff --git a/app/assets/javascripts/initializers/initScrolling.js.erb b/app/assets/javascripts/initializers/initScrolling.js.erb index a018c760f..b46144491 100644 --- a/app/assets/javascripts/initializers/initScrolling.js.erb +++ b/app/assets/javascripts/initializers/initScrolling.js.erb @@ -179,40 +179,46 @@ function fetchNextPodcastPage(el) { fetchNext(el, "/api/podcast_episodes", insertArticles) } -function paginate(tag, requiresApproval) { - var tagFilters = []; - if (tag && tag.length > 0) { - tagFilters.push(tag); - } +function paginate(tag, params, requiresApproval) { + const searchHash = { ...{ per_page: 15, page: nextPage }, ...JSON.parse(params) }; - var searchObj = { - hitsPerPage: 15, - page: nextPage, - attributesToHighlight: [], - tagFilters, - filters: (requiresApproval === 'true') ? 'approved:true' : '' + if (tag && tag.length > 0) { + searchHash.tag_names = searchHash.tag_names || []; + searchHash.tag_names.push(tag); } + searchHash.approved = (requiresApproval === 'true') ? 'true' : ''; var homeEl = document.getElementById("index-container"); - var paginationArticlesIndex; if (homeEl.dataset.feed === "base-feed") { - paginationArticlesIndex = client.initIndex('ordered_articles_<%= Rails.env %>'); + searchHash.class_name = "Article"; } else if (homeEl.dataset.feed === "latest") { - paginationArticlesIndex = client.initIndex('ordered_articles_by_published_at_<%= Rails.env %>'); + searchHash.class_name = "Article"; + searchHash.sort_by = "published_at"; } else { - var preamble = (requiresApproval === 'true') ? ' AND ' : '' - searchObj.filters += ( preamble +'published_at_int > ' + homeEl.dataset.articlesSince); - paginationArticlesIndex = client.initIndex('ordered_articles_by_positive_reactions_count_<%= Rails.env %>'); + searchHash.class_name = "Article"; + searchHash["published_at[gte]"] = homeEl.dataset.articlesSince; + searchHash.sort_by = "positive_reactions_count"; } - paginationArticlesIndex.search("*", searchObj) - .then(function searchDone(content) { + const searchParams = new URLSearchParams(searchHash).toString(); + + fetch(`/search/feed_content?${searchParams}`, { + method: 'GET', + headers: { + Accept: 'application/json', + 'X-CSRF-Token': window.csrfToken, + 'Content-Type': 'application/json', + }, + credentials: 'same-origin', + }) + .then(response => response.json()) + .then((content) => { nextPage += 1; - insertArticles(content.hits); + insertArticles(content.result); const checkBlockedContentEvent = new CustomEvent('checkBlockedContent') window.dispatchEvent(checkBlockedContentEvent); initializeReadingListIcons(); - if (content.hits.length === 0) { + if (content.result.length === 0) { document.getElementById("loading-articles").style.display = "none" done = true; } @@ -253,7 +259,11 @@ function fetchNextPageIfNearBottom() { } else { scrollableElemId = "articles-list"; fetchCallback = function fetch() { - paginate(indexContainer.dataset.tag, indexContainer.dataset.requiresApproval); + paginate( + indexContainer.dataset.tag, + indexContainer.dataset.params, + indexContainer.dataset.requiresApproval + ); }; } @@ -266,9 +276,6 @@ function fetchNextPageIfNearBottom() { } function checkIfNearBottomOfPage() { - var publicSearchKey = '<%= ALGOLIASEARCH_PUBLIC_SEARCH_ONLY_KEY %>'; - client = algoliasearch('<%= ApplicationConfig["ALGOLIASEARCH_APPLICATION_ID"] %>', publicSearchKey); - if (document.getElementsByClassName("single-article").length < 2 || window.location.search.indexOf("q=") > -1 ) { document.getElementById("loading-articles").style.display = "none"; done = true; diff --git a/app/assets/javascripts/utilities/buildArticleHTML.js.erb b/app/assets/javascripts/utilities/buildArticleHTML.js.erb index 55d8cf2e5..c08bdb767 100644 --- a/app/assets/javascripts/utilities/buildArticleHTML.js.erb +++ b/app/assets/javascripts/utilities/buildArticleHTML.js.erb @@ -1,5 +1,5 @@ function buildArticleHTML(article) { - if (article && article.type_of == "podcast_episodes") { + if (article && article.class_name == "PodcastEpisode") { return '
\
\ \ @@ -37,42 +37,44 @@ function buildArticleHTML(article) { if (article.class_name == "PodcastEpisode"){ flareTag = "podcast" } + if (article.class_name == "Comment"){ + flareTag = "comment" + } if (article.class_name == "User"){ flareTag = "person" } - var rc = article.positive_reactions_count || article.reactions_count + var rc = article.positive_reactions_count var reactionsCountHTML = '' if ((rc || '0') > 0 && article.class_name != "User") { var reactionsCountHTML = '
" alt="heart" />
' } - var picUrl = article.user.profile_image_90 - var profileUsername = article.user.username + var picUrl; + var profileUsername; + var userName; + if (article.class_name == "PodcastEpisode"){ + picUrl = article.main_image; + profileUsername = article.slug; + userName = article.title; + } else { + picUrl = article.user.profile_image_90; + profileUsername = article.user.username; + userName = article.user.name; + } var orgHeadline = ""; if (article.organization && !document.getElementById("organization-article-index")) { orgHeadline = '
'+article.organization.name+' logo'+article.organization.name+'
' } var bodyTextSnippet = ""; - var commentsBlobSnippet = ""; var searchSnippetHTML = ""; - if (article._snippetResult && article._snippetResult.body_text){ - if (article._snippetResult.body_text.matchLevel != "none"){ - var firstSnippetChar = article._snippetResult.body_text.value[0]; - var startingEllipsis = "" - if (firstSnippetChar.toLowerCase() != firstSnippetChar.toUpperCase()){ - startingEllipsis = "…" - } - bodyTextSnippet = startingEllipsis+article._snippetResult.body_text.value + "…" + if (article.highlight && article.highlight.body_text.length > 0){ + var firstSnippetChar = article.highlight.body_text[0]; + var startingEllipsis = "" + if (firstSnippetChar.toLowerCase() != firstSnippetChar.toUpperCase()){ + startingEllipsis = "…" } - if (article._snippetResult.comments_blob.matchLevel != "none" && bodyTextSnippet === ""){ - var firstSnippetChar = article._snippetResult.comments_blob.value[0]; - var startingEllipsis = "" - if (firstSnippetChar.toLowerCase() != firstSnippetChar.toUpperCase()){ - startingEllipsis = "…" - } - commentsBlobSnippet = startingEllipsis+article._snippetResult.comments_blob.value + "… (comments)" - } - if ((bodyTextSnippet.length > 0 || commentsBlobSnippet.length > 0) && article.class_name == "Article"){ - searchSnippetHTML = '
'+bodyTextSnippet+commentsBlobSnippet+'
' + bodyTextSnippet = startingEllipsis + article.highlight.body_text.join("...") + "…"; + if (bodyTextSnippet.length > 0){ + searchSnippetHTML = '
' + bodyTextSnippet + '
' } } var saveButton = ''; @@ -127,7 +129,7 @@ function buildArticleHTML(article) { '+searchSnippetHTML+'\
\ \ -

'+filterXSS(article.user.name)+publishDate+timeAgoInWords+'

\ +

'+filterXSS(userName)+publishDate+timeAgoInWords+'

\
'+tagString+'
\ '+commentsCountHTML+reactionsCountHTML+readingTimeHTML+'\ '+saveButton+'
'; diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 7043b4b7e..564033788 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -80,7 +80,7 @@ class SearchController < ApplicationController # No need to check for articles or podcast episodes if we know we only want users user_search else - # if params[:class_name] == PodcastEpisode or Article then skip user lookup + # if params[:class_name] == PodcastEpisode, Article, or Comment then skip user lookup feed_content_search end diff --git a/app/javascript/article-form/__tests__/articleForm.test.jsx b/app/javascript/article-form/__tests__/articleForm.test.jsx index cb3a2a776..809b3c1be 100644 --- a/app/javascript/article-form/__tests__/articleForm.test.jsx +++ b/app/javascript/article-form/__tests__/articleForm.test.jsx @@ -3,7 +3,6 @@ import render from 'preact-render-to-json'; import { shallow, deep } from 'preact-render-spy'; import { JSDOM } from 'jsdom'; import ArticleForm from '../articleForm'; -import algoliasearch from '../elements/__mocks__/algoliasearch'; const dummyArticleUpdatedAt = new Date(); const getArticleForm = () => ( @@ -38,8 +37,6 @@ describe('', () => { global.document.body.innerHTML = "
"; - global.window.algoliasearch = algoliasearch; - localStorage.clear(); /* eslint-disable-next-line no-underscore-dangle */ localStorage.__STORE__ = {}; diff --git a/app/javascript/articles/Article.jsx b/app/javascript/articles/Article.jsx index 79dfe6a24..5f54be8e4 100644 --- a/app/javascript/articles/Article.jsx +++ b/app/javascript/articles/Article.jsx @@ -31,8 +31,8 @@ export const Article = ({ const timeAgoIndicator = timeAgo({ oldTimeInSeconds: article.published_at_int, - formatter: x => x, - }) + formatter: (x) => x, + }); return (
{article.class_name === 'Article' && ( // eslint-disable-next-line no-underscore-dangle - + )}
@@ -94,7 +94,7 @@ export const Article = ({ )} {article.published_at_int ? ( - {timeAgoIndicator.length > 0 ? `(${timeAgoIndicator})`: '' } + {timeAgoIndicator.length > 0 ? `(${timeAgoIndicator})` : ''} ) : null} diff --git a/app/javascript/articles/__tests__/__snapshots__/Article.test.jsx.snap b/app/javascript/articles/__tests__/__snapshots__/Article.test.jsx.snap index dd67e9b5a..869069b7b 100644 --- a/app/javascript/articles/__tests__/__snapshots__/Article.test.jsx.snap +++ b/app/javascript/articles/__tests__/__snapshots__/Article.test.jsx.snap @@ -1101,7 +1101,7 @@ exports[`
component should render with a snippet result 1`] = ` class="search-snippet" > - …copying Rest withdrawal Handcrafted multi-state Pre-emptive e-markets feed overriding RSS Fantastic Plastic Gloves invoice productize systemic Monaco… + …copying Rest withdrawal Handcrafted multi-state Pre-emptive e-markets feed...overriding RSS Fantastic Plastic Gloves invoice productize systemic Monaco… diff --git a/app/javascript/articles/__tests__/utilities/articleUtilities.js b/app/javascript/articles/__tests__/utilities/articleUtilities.js index 3f8ee1dd9..9bf99d54a 100644 --- a/app/javascript/articles/__tests__/utilities/articleUtilities.js +++ b/app/javascript/articles/__tests__/utilities/articleUtilities.js @@ -1,4 +1,4 @@ -export const assetPath = relativeUrl => `/images/${relativeUrl}`; +export const assetPath = (relativeUrl) => `/images/${relativeUrl}`; export const article = { id: 62407, @@ -24,6 +24,7 @@ export const article = { }, published_at_int: 1582037964819, published_timestamp: 'Tue, 18 Feb 2020 14:59:24 GMT', + published_at: '2020-02-18T14:59:24Z', readable_publish_date: 'February 18', }; @@ -84,18 +85,13 @@ export const articleWithSnippetResult = { }, published_at_int: 1582037964819, published_timestamp: 'Tue, 18 Feb 2020 14:59:24 GMT', + published_at: '2020-02-18T14:59:24Z', readable_publish_date: 'February 18', - _snippetResult: { - body_text: { - matchLevel: 'full', - value: - 'copying Rest withdrawal Handcrafted multi-state Pre-emptive e-markets feed overriding RSS Fantastic Plastic Gloves invoice productize systemic Monaco', - }, - comments_blob: { - matchLevel: 'none', - value: - 'virtual index Global mindshare Malagasy Ariary back up Handmade green Interactions violet bandwidth Chief e-commerce front-end neural', - }, + highlight: { + body_text: [ + 'copying Rest withdrawal Handcrafted multi-state Pre-emptive e-markets feed', + 'overriding RSS Fantastic Plastic Gloves invoice productize systemic Monaco', + ], }, }; @@ -123,6 +119,7 @@ export const articleWithReactions = { }, published_at_int: 1582037964819, published_timestamp: 'Tue, 18 Feb 2020 14:59:24 GMT', + published_at: '2020-03-19T10:04:15-05:00', readable_publish_date: 'February 18', positive_reactions_count: 232, }; @@ -151,6 +148,7 @@ export const articleWithComments = { }, published_at_int: 1582037964819, published_timestamp: 'Tue, 18 Feb 2020 14:59:24 GMT', + published_at: '2020-03-19T10:04:15-05:00', readable_publish_date: 'February 18', positive_reactions_count: 428, comments_count: 213, @@ -180,6 +178,7 @@ export const articleWithReadingTimeGreaterThan1 = { }, published_at_int: 1582037964819, published_timestamp: 'Tue, 18 Feb 2020 14:59:24 GMT', + published_at: '2020-02-18T14:59:24Z', readable_publish_date: 'February 18', reading_time: 8, }; @@ -208,6 +207,7 @@ export const videoArticle = { }, published_at_int: 1582038662478, published_timestamp: 'Tue, 18 Feb 2020 15:11:02 GMT', + published_at: '2020-02-18T14:59:24Z', readable_publish_date: 'February 18', cloudinary_video_url: '/images/onboarding-background.png', video_duration_in_minutes: 10, @@ -237,6 +237,7 @@ export const podcastArticle = { }, published_at_int: 1582038662478, published_timestamp: 'Tue, 18 Feb 2020 15:11:02 GMT', + published_at: '2020-02-18T15:11:02Z', readable_publish_date: 'February 18', podcast: { slug: 'monitor-recontextualize', @@ -270,6 +271,7 @@ export const podcastEpisodeArticle = { }, published_at_int: 1582038662478, published_timestamp: 'Tue, 18 Feb 2020 15:11:02 GMT', + published_at: '2020-02-18T15:11:02Z', readable_publish_date: 'February 18', }; diff --git a/app/javascript/articles/components/SearchSnippet.jsx b/app/javascript/articles/components/SearchSnippet.jsx index 22aaa79ba..6b7a0901c 100644 --- a/app/javascript/articles/components/SearchSnippet.jsx +++ b/app/javascript/articles/components/SearchSnippet.jsx @@ -1,45 +1,25 @@ import { h } from 'preact'; import { articleSnippetResultPropTypes } from '../../src/components/common-prop-types'; -export const SearchSnippet = ({ snippetResult }) => { - if (snippetResult && snippetResult.body_text) { +export const SearchSnippet = ({ highlightText }) => { + if (highlightText && highlightText.body_text.length > 0) { + const hitHighlights = highlightText.body_text; let bodyTextSnippet = ''; - if (snippetResult.body_text.matchLevel !== 'none') { - const firstSnippetChar = snippetResult.body_text.value[0]; + if (hitHighlights[0]) { + const firstSnippetChar = hitHighlights[0]; let startingEllipsis = ''; if (firstSnippetChar.toLowerCase() !== firstSnippetChar.toUpperCase()) { startingEllipsis = '…'; } - - bodyTextSnippet = `${startingEllipsis + snippetResult.body_text.value}…`; + bodyTextSnippet = `${startingEllipsis + hitHighlights.join('...')}…`; } - let commentsBlobSnippet = ''; - - if ( - snippetResult.comments_blob.matchLevel !== 'none' && - bodyTextSnippet === '' - ) { - const firstSnippetChar = snippetResult.comments_blob.value[0]; - let startingEllipsis = ''; - - if (firstSnippetChar.toLowerCase() !== firstSnippetChar.toUpperCase()) { - startingEllipsis = '…'; - } - - commentsBlobSnippet = `${startingEllipsis + - snippetResult.comments_blob.value}… (comments)`; - } - - if (bodyTextSnippet.length > 0 || commentsBlobSnippet.length > 0) { + if (bodyTextSnippet.length > 0) { return (
- - {bodyTextSnippet} - {commentsBlobSnippet} - + {bodyTextSnippet}
); } @@ -50,7 +30,7 @@ export const SearchSnippet = ({ snippetResult }) => { SearchSnippet.propTypes = { // eslint-disable-next-line no-underscore-dangle - snippetResult: articleSnippetResultPropTypes.isRequired, + highlightText: articleSnippetResultPropTypes.isRequired, }; SearchSnippet.displayName = 'SearchSnippet'; diff --git a/app/javascript/src/components/common-prop-types/article-prop-types.js b/app/javascript/src/components/common-prop-types/article-prop-types.js index 45f30e5aa..480a7c410 100644 --- a/app/javascript/src/components/common-prop-types/article-prop-types.js +++ b/app/javascript/src/components/common-prop-types/article-prop-types.js @@ -3,14 +3,7 @@ import { tagPropTypes } from './tag-prop-types'; import { organizationPropType } from './organization-prop-type'; export const articleSnippetResultPropTypes = PropTypes.shape({ - body_text: PropTypes.shape({ - matchLevel: PropTypes.oneOf(['full', 'none']), - value: PropTypes.string.isRequired, - }), - comments_blob: PropTypes.shape({ - matchLevel: PropTypes.oneOf(['full', 'none']), - value: PropTypes.string.isRequired, - }), + body_text: PropTypes.arrayOf(PropTypes.string), }); export const articlePropTypes = PropTypes.shape({ @@ -35,7 +28,7 @@ export const articlePropTypes = PropTypes.shape({ name: PropTypes.string.isRequired, }), organization: organizationPropType, - _snippetResult: articleSnippetResultPropTypes, + highlight: articleSnippetResultPropTypes, positive_reactions_count: PropTypes.number, reactions_count: PropTypes.number, comments_count: PropTypes.number, diff --git a/app/services/search/query_builders/feed_content.rb b/app/services/search/query_builders/feed_content.rb index f6ea1da96..062287581 100644 --- a/app/services/search/query_builders/feed_content.rb +++ b/app/services/search/query_builders/feed_content.rb @@ -140,7 +140,7 @@ module Search def query_hash(key, fields) { simple_query_string: { - query: key, + query: key.downcase, fields: fields, lenient: true, analyze_wildcard: true, diff --git a/app/views/articles/_search.html.erb b/app/views/articles/_search.html.erb index 242bae4cd..7a437eff8 100644 --- a/app/views/articles/_search.html.erb +++ b/app/views/articles/_search.html.erb @@ -16,16 +16,13 @@ var params = getQueryParams(document.location.search); - // var query = escape(params.q); function searchMain() { var query = filterXSS(params.q); var filters = filterXSS(params.filters || ""); document.getElementById("substories").innerHTML = '

' - var client = algoliasearch('<%= ApplicationConfig["ALGOLIASEARCH_APPLICATION_ID"] %>', '<%= ALGOLIASEARCH_PUBLIC_SEARCH_ONLY_KEY %>'); - var index = client.initIndex('searchables_<%= Rails.env %>'); if (document.getElementById("query-wrapper")) { - search(query, index, filters); - initializeFilters(query, index, filters); + search(query, filters); + initializeFilters(query, filters); } } @@ -33,7 +30,7 @@ return String(str).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"'); } - function initializeFilters(query, index, filters) { + function initializeFilters(query, filters) { var filterButts = document.getElementsByClassName("query-filter-button"); for (var i = 0; i < filterButts.length; i++) { if (filters == filterButts[i].dataset.filter) { @@ -53,67 +50,70 @@ if (className.indexOf("selected") == -1) { e.target.classList.add("selected"); window.history.replaceState(null, null, "/search?q=" + query + "&filters=" + filters); - search(query, index, filters); + search(query, filters); } else { window.history.replaceState(null, null, "/search?q=" + query); - search(query, index, ""); + search(query, ""); } } } } - function search(query, index, filters) { - var hashtags = query.match(/#\w+/g) - var searchObj = { - hitsPerPage: 60, - page: "0", - queryType: "prefixNone", - attributesToRetrieve: [ - 'id', - 'title', - 'path', - 'class_name', - 'comments_count', - 'tag_list', - 'readable_publish_date', - 'positive_reactions_count', - 'flare_tag', - 'user', - 'reading_time' - ], - attributesToHighlight: [], - exactOnSingleWordQuery: "none", - attributesToSnippet: ['body_text:19', 'comments_blob:8'], - } + function search(query, filters) { + var hashtags = query.match(/#\w+/g); + var searchTerm = query.replace(/#/g, '').trim(); + var searchHash = { per_page: 60, page: 0 }; if (filters === "MY_POSTS" && userData()) { - searchObj["tagFilters"] = [['user_' + userData()['id']]] - } else if (hashtags != null && hashtags.length > 0) { - for(var i = 0; i < hashtags.length; i++){ - hashtags[i] = hashtags[i].replace(/#/,'') - } - searchObj["tagFilters"] = hashtags - } else { - searchObj["filters"] = filters + searchHash.user_id = userData()['id']; + searchHash.class_name = "Article"; } - index.search(query, searchObj) - .then(function searchDone(content) { + + if (hashtags && hashtags.length > 0) { + for(var i = 0; i < hashtags.length; i++){ + hashtags[i] = hashtags[i].replace(/#/,''); + } + searchHash.tag_names = hashtags; + } + + if (filters) { + filters.split('&').forEach((filter) => { + const [key, value] = filter.split(':'); + searchHash[key] = value; + }); + } + + if (searchTerm) { searchHash.search_fields = searchTerm; } + + const searchParams = new URLSearchParams(searchHash).toString(); + + fetch(`/search/feed_content?${searchParams}`, { + method: 'GET', + headers: { + Accept: 'application/json', + 'X-CSRF-Token': window.csrfToken, + 'Content-Type': 'application/json', + }, + credentials: 'same-origin', + }) + .then(response => response.json()) + .then((content) => { var resultDivs = [] - content.hits.forEach(function (story, i) { + content.result.forEach(function (story, i) { resultDivs.push(buildArticleHTML(story)); }) document.getElementById("substories").innerHTML = resultDivs.join(""); initializeReadingListIcons(); initializeAllFollowButts(); document.getElementById("substories").classList.add("search-results-loaded"); - if (content.hits.length == 0) { + if (content.result.length == 0) { document.getElementById("substories").innerHTML = '
No results match that query
' } }); } var waitingOnSearch = setInterval(function () { - if (typeof algoliasearch == 'function' && typeof filterXSS == 'function' && typeof buildArticleHTML == 'function') { + if (typeof search == 'function' && typeof filterXSS == 'function' && typeof buildArticleHTML == 'function') { clearInterval(waitingOnSearch); if (document.querySelectorAll('.search-results-loaded').length == 0) { searchMain(); diff --git a/app/views/articles/index.html.erb b/app/views/articles/index.html.erb index 0aa71aa5a..e89cf2deb 100644 --- a/app/views/articles/index.html.erb +++ b/app/views/articles/index.html.erb @@ -30,7 +30,7 @@ data-params="<%= params.to_json(only: %i[tag username q]) %>" data-which="<%= @list_of %>" data-tag="" data-feed="<%= params[:timeframe] || "base-feed" %>" - data-articles-since="<%= Timeframer.new(params[:timeframe]).datetime.to_i %>"> + data-articles-since="<%= Timeframer.new(params[:timeframe]).datetime&.iso8601 %>"> <%= render "articles/sidebar" %> diff --git a/app/views/articles/search.html.erb b/app/views/articles/search.html.erb index 24fba2304..057966357 100644 --- a/app/views/articles/search.html.erb +++ b/app/views/articles/search.html.erb @@ -6,7 +6,7 @@ data-params="<%= params.to_json(only: %i[tag username q]) %>" data-which="<%= @list_of %>" data-tag="" data-feed="<%= params[:timeframe] || "base-feed" %>" - data-articles-since="<%= Timeframer.new(params[:timeframe]).datetime.to_i %>"> + data-articles-since="<%= Timeframer.new(params[:timeframe]).datetime&.iso8601 %>"> <%= render "articles/search/sidebar" %>
diff --git a/app/views/articles/search/_sidebar.html.erb b/app/views/articles/search/_sidebar.html.erb index 0f6654454..88ff55081 100644 --- a/app/views/articles/search/_sidebar.html.erb +++ b/app/views/articles/search/_sidebar.html.erb @@ -9,6 +9,7 @@ POSTS PODCASTS PEOPLE + COMMENTS
ONLY MY POSTS
diff --git a/app/views/articles/tag_index.html.erb b/app/views/articles/tag_index.html.erb index 7f5379607..eb5a805fb 100644 --- a/app/views/articles/tag_index.html.erb +++ b/app/views/articles/tag_index.html.erb @@ -34,7 +34,7 @@ data-tag="<%= @tag %>" data-feed="<%= params[:timeframe] || "base-feed" %>" data-requires-approval="<%= @tag_model.requires_approval %>" - data-articles-since="<%= Timeframer.new(params[:timeframe]).datetime.to_i %>"> + data-articles-since="<%= Timeframer.new(params[:timeframe]).datetime&.iso8601 %>"> <%= render "articles/tags/sidebar" %>
<% if @tag_model && @tag_model.supported %> diff --git a/app/views/organizations/show.html.erb b/app/views/organizations/show.html.erb index 438573854..eb5bbd3fb 100644 --- a/app/views/organizations/show.html.erb +++ b/app/views/organizations/show.html.erb @@ -8,7 +8,7 @@ data-params="<%= params.to_json(only: %i[tag username q]) %>" data-which="<%= @list_of %>" data-tag="<%= "organization_#{@organization.id}" %>" data-feed="<%= params[:timeframe] || "base-feed" %>" - data-articles-since="<%= Timeframer.new(params[:timeframe]).datetime.to_i %>"> + data-articles-since="<%= Timeframer.new(params[:timeframe]).datetime&.iso8601 %>"> <%= render "organizations/sidebar" %>
diff --git a/app/views/podcast_episodes/index.html.erb b/app/views/podcast_episodes/index.html.erb index 7243f4585..27672b0b7 100644 --- a/app/views/podcast_episodes/index.html.erb +++ b/app/views/podcast_episodes/index.html.erb @@ -30,7 +30,7 @@ data-params="<%= params.to_json(only: %i[tag username q]) %>" data-which="<%= @list_of %>" data-tag="" data-feed="<%= params[:timeframe] || "base-feed" %>" - data-articles-since="<%= Timeframer.new(params[:timeframe]).datetime.to_i %>"> + data-articles-since="<%= Timeframer.new(params[:timeframe]).datetime&.iso8601 %>"> <%= render "podcast_episodes/sidebar" %>
diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index cbc94565c..b33bde0fd 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -176,8 +176,8 @@ <% end %>
" + data-params="<%= params.merge(user_id: @user.id, class_name: "Article").to_json(only: %i[tag user_id q class_name]) %>" data-which="<%= @list_of %>" + data-tag="" data-feed="<%= params[:timeframe] || "base-feed" %>" data-articles-since="0"> <%= render "users/sidebar" %>