Skip to content

Commit

Permalink
Merge branch 'master' into gem-updates
Browse files Browse the repository at this point in the history
# Conflicts:
#	Gemfile
#	Gemfile.lock
  • Loading branch information
fbacall committed Aug 25, 2023
2 parents 1245f61 + f8349fb commit 057150d
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 87 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ gem 'bootstrap-tab-history-rails'
gem 'country_select'
gem 'devise'
gem 'devise_invitable'
gem 'dynamic_sitemaps', github: 'lassebunk/dynamic_sitemaps', branch: 'master' # Contains a HTTPS fix that is not released
gem 'sitemap_generator'
gem 'eventbrite_sdk'
gem 'font-awesome-sass', '~> 4.7.0' # Prefer V4 icon styles
gem 'friendly_id'
Expand Down
11 changes: 3 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@ GIT
tess_rdf_extractors (0.1.0)
linkeddata (~> 3.2.0)

GIT
remote: https://github.com/lassebunk/dynamic_sitemaps.git
revision: 37beeba143e8202218ee814056231b0e6974bafb
branch: master
specs:
dynamic_sitemaps (2.0.0)

GIT
remote: https://github.com/sunspot/sunspot.git
revision: 678c5b2b57d3b06b9432307f00283ecc6c85ad4d
Expand Down Expand Up @@ -660,6 +653,8 @@ GEM
sitemap-parser (0.5.6)
nokogiri (~> 1.6)
typhoeus (>= 0.6, < 2.0)
sitemap_generator (6.3.0)
builder (~> 3.0)
slim (5.1.1)
temple (~> 0.10.0)
tilt (>= 2.1.0)
Expand Down Expand Up @@ -772,7 +767,6 @@ DEPENDENCIES
country_select
devise
devise_invitable
dynamic_sitemaps!
eventbrite_sdk
font-awesome-sass (~> 4.7.0)
friendly_id
Expand Down Expand Up @@ -829,6 +823,7 @@ DEPENDENCIES
simplecov
simplecov-lcov
sitemap-parser
sitemap_generator
slim
sunspot_rails!
terser
Expand Down
2 changes: 1 addition & 1 deletion app/views/content_providers/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
disabled: { check: events_count.zero?, message: 'No associated events' },
count: events_count) %>
<% if TeSS::Config.feature['user_source_creation'] && policy(@content_provider).update? %>
<% if TeSS::Config.feature['sources'] && policy(@content_provider).update? %>
<%= tab('Sources', icon_class_for_model('sources'), 'sources', count: sources.count, activator: activator) %>
<% end %>
</ul>
Expand Down
11 changes: 5 additions & 6 deletions app/views/search/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,17 @@
<p class="empty">No results found</p>
<% else %>
<% tabs = @results.keys.sort_by { |k| TeSS::Config.site['tab_order'].index(k.to_s) || 99 } %>
<% activator = tab_activator %>
<ul class="nav nav-tabs">
<% tabs.each_with_index do |tab, index| %>
<li class="<%= index == 0 ? 'active' : '' %>">
<a data-toggle="tab" href="#<%= tab %>"><i class="<%= icon_class_for_model(tab) %>"></i> <%= tab.to_s.humanize.capitalize %>
(<%= @results[tab].total %>)</a>
</li>
<% tabs.each do |tab| %>
<%= tab(tab.to_s.humanize.capitalize, icon_class_for_model(tab), tab, activator: activator,
disabled: { check: @results[tab].total.zero? }, count: @results[tab].total) %>
<% end %>
</ul>

<div class="tab-content">
<% @results.each do |model, results_for_model| %>
<div class="tab-pane fade in <%= 'active'.html_safe if model == tabs.first %>" id="<%= model %>">
<div class="tab-pane fade <%= 'in active'.html_safe if activator.check_pane(model) %>" id="<%= model %>">
<div class="search-results-count my-3">
Showing <%= pluralize(results_for_model.results.count, model.to_s.humanize.downcase.singularize) %>
<% if results_for_model.total > page_size %>
Expand Down
11 changes: 3 additions & 8 deletions config/schedule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,9 @@
end

# Generate a new sitemap...
if !schedules['sitemap'].nil?
every :"#{schedules['sitemap']['every']}", at: "#{schedules['sitemap']['at']}" do
rake "sitemap:generate"
end
else
every :day, at: '1am' do
rake "sitemap:generate"
end
every schedules.dig('sitemap', 'every')&.to_sym || :day,
at: schedules.dig('sitemap', 'at') || '1am' do
rake "sitemap:refresh"
end

# Process subscriptions...
Expand Down
90 changes: 27 additions & 63 deletions config/sitemap.rb
Original file line number Diff line number Diff line change
@@ -1,66 +1,30 @@
# Change this to your host. See the readme at https://github.com/lassebunk/dynamic_sitemaps
# for examples of multiple hosts and folders.
base_url = URI.parse(TeSS::Config.base_url)
host_with_port = base_url.host
if base_url.port != base_url.default_port
host_with_port += ":#{base_url.port}"
end

protocol base_url.scheme
host host_with_port

sitemap :site do
url root_url, last_mod: Time.now, change_freq: 'daily', priority: 1.0
url about_url, change_freq: 'weekly', priority: 0.4
if TeSS::Config.feature['materials']
url materials_url, last_mod: Time.now, change_freq: 'daily', priority: 0.7
end
if TeSS::Config.feature['events']
url events_url, last_mod: Time.now, change_freq: 'daily', priority: 0.7
# Set the host name for URL creation
SitemapGenerator::Sitemap.default_host = TeSS::Config.base_url

SitemapGenerator::Sitemap.create(compress: false, sitemaps_path: 'sitemaps/', include_root: false) do
types = {
materials: { resources: Material.from_verified_users, changefreq: 'daily', priority: 0.7 },
events: { resources: Event.from_verified_users, changefreq: 'daily', priority: 0.7 },
content_providers: { resources: ContentProvider, changefreq: 'weekly', priority: 0.4 },
workflows: { resources: Workflow.from_verified_users.visible_by(nil), changefreq: 'daily', priority: 0.6 },
collections: { resources: Collection.from_verified_users.visible_by(nil), changefreq: 'daily', priority: 0.6 }
}

group(filename: :site) do
add root_path, changefreq: 'daily', priority: 1.0
add about_path, priority: 0.4
types.each do |type, options|
next unless TeSS::Config.feature[type.to_s]
add polymorphic_path(type), lastmod: options[:resources].maximum(:updated_at), **options.except(:resources)
end
end
if TeSS::Config.feature['workflows']
url workflows_url, last_mod: Time.now, change_freq: 'daily', priority: 0.6
end
if TeSS::Config.feature['content_providers']
url content_providers_url, last_mod: Time.now, change_freq: 'weekly', priority: 0.4

types.each do |type, options|
next unless TeSS::Config.feature[type.to_s]
group(filename: type) do
options[:resources].find_each do |resource|
add polymorphic_path(resource), lastmod: resource.updated_at
end
end
end
end

# You can have multiple sitemaps like the above – just make sure their names are different.

# Automatically link to all pages using the routes specified
# using "resources :pages" in config/routes.rb. This will also
# automatically set <lastmod> to the date and time in page.updated_at:
#
# sitemap_for Page.scoped

sitemap_for Material.from_verified_users if TeSS::Config.feature['materials']
sitemap_for Event.from_verified_users if TeSS::Config.feature['events']
sitemap_for ContentProvider if TeSS::Config.feature['content_providers']
sitemap_for Workflow.from_verified_users.visible_by(nil) if TeSS::Config.feature['workflows']

# For products with special sitemap name and priority, and link to comments:
#
# sitemap_for Product.published, name: :published_products do |product|
# url product, last_mod: product.updated_at, priority: (product.featured? ? 1.0 : 0.7)
# url product_comments_url(product)
# end

# If you want to generate multiple sitemaps in different folders (for example if you have
# more than one domain, you can specify a folder before the sitemap definitions:
#
# Site.all.each do |site|
# folder "sitemaps/#{site.domain}"
# host site.domain
#
# sitemap :site do
# url root_url
# end
#
# sitemap_for site.products.scoped
# end

# Ping search engines after sitemap generation:
#

ping_with "#{base_url.scheme}://#{host}/sitemap.xml" if Rails.env.production?

0 comments on commit 057150d

Please sign in to comment.