Improved article slug generation (#2218)
* Improved article slug generation Ruby on Rails has a built-in slug generator since Rails 2.2 This generator fix the slug generation when non english characters are used on title improving SEO. For example: https://dev.to/lito_ordes/redimensionando-imgenes-en-tiempo-de-ejecucin-con-packer-57c6 * Ruby on Rails has a built-in slug generator since Rails 2.2 This generator fix the slug generation when non english characters are used on title improving SEO. For example: https://dev.to/lito_ordes/redimensionando-imgenes-en-tiempo-de-ejecucin-con-packer-57c6 * Ruby on Rails has a built-in slug generator since Rails 2.2 This generator fix the slug generation when non english characters are used on title improving SEO. For example: https://dev.to/lito_ordes/redimensionando-imgenes-en-tiempo-de-ejecucin-con-packer-57c6 * Ruby on Rails has a built-in slug generator since Rails 2.2 This generator fix the slug generation when non english characters are used on title improving SEO. For example: https://dev.to/lito_ordes/redimensionando-imgenes-en-tiempo-de-ejecucin-con-packer-57c6 * Ruby on Rails has a built-in slug generator since Rails 2.2 This generator fix the slug generation when non english characters are used on title improving SEO. For example: https://dev.to/lito_ordes/redimensionando-imgenes-en-tiempo-de-ejecucin-con-packer-57c6 * Fix downcase transform on event model
This commit is contained in:
parent
d1e73dceba
commit
2ebd37aba2
5 changed files with 6 additions and 6 deletions
|
|
@ -27,7 +27,7 @@ class PodcastFeed
|
|||
ep = PodcastEpisode.new
|
||||
ep.title = item.title
|
||||
ep.podcast_id = podcast.id
|
||||
ep.slug = item.title.downcase.gsub(/[^0-9a-z ]/i, "").tr(" ", "-")
|
||||
ep.slug = item.title.parameterize
|
||||
ep.subtitle = item.itunes_subtitle
|
||||
ep.summary = item.itunes_summary
|
||||
ep.website_url = item.link
|
||||
|
|
|
|||
|
|
@ -537,7 +537,7 @@ class Article < ApplicationRecord
|
|||
end
|
||||
|
||||
def title_to_slug
|
||||
title.to_s.downcase.tr(" ", "-").gsub(/[^\w-]/, "").tr("_", "") + "-" + rand(100_000).to_s(26)
|
||||
title.to_s.downcase.parameterize + "-" + rand(100_000).to_s(26)
|
||||
end
|
||||
|
||||
def bust_cache
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class Badge < ApplicationRecord
|
|||
private
|
||||
|
||||
def generate_slug
|
||||
self.slug = title.to_s.downcase.tr(" ", "-").gsub(/[^\w-]/, "").tr("_", "")
|
||||
self.slug = title.to_s.parameterize
|
||||
end
|
||||
|
||||
def bust_path
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ class ChatChannel < ApplicationRecord
|
|||
contrived_name = "Direct chat between " + usernames.join(" and ")
|
||||
slug = usernames.join("/")
|
||||
else
|
||||
slug = contrived_name.to_s.downcase.tr(" ", "-").gsub(/[^\w-]/, "").tr("_", "") + "-" + rand(100_000).to_s(26)
|
||||
slug = contrived_name.to_s.parameterize + "-" + rand(100_000).to_s(26)
|
||||
end
|
||||
|
||||
channel = ChatChannel.find_by_slug(slug)
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@ class Event < ApplicationRecord
|
|||
end
|
||||
|
||||
def title_to_slug
|
||||
downcase = (id.to_s + "-" + category + "-" + title).to_s.downcase
|
||||
downcase.tr(" ", "-").gsub(/[^\w-]/, "").tr("_", "") + "-" + starts_at.strftime("%m-%d-%Y")
|
||||
downcase = (id.to_s + "-" + category + "-" + title).to_s
|
||||
downcase.parameterize + "-" + starts_at.strftime("%m-%d-%Y")
|
||||
end
|
||||
|
||||
def bust_cache
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue