-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2146 from tf/permalink-redirect
Redirect after permalink change
- Loading branch information
Showing
16 changed files
with
484 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module Pageflow | ||
# @api private | ||
class PermalinkRedirect < ApplicationRecord | ||
belongs_to :entry | ||
belongs_to :directory, class_name: 'PermalinkDirectory' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
<%= form.input(:permalink, | ||
as: :pageflow_permalink, | ||
base_url: pretty_site_url(entry.site), | ||
base_url: entry.site.canonical_entry_url_prefix.presence || | ||
pretty_site_url(entry.site), | ||
site: entry.site, | ||
slug_placeholder: entry.default_permalink_slug) %> | ||
slug_placeholder: entry.default_permalink_slug, | ||
hint: entry.new_record? ? nil : t('pageflow.admin.entries.permalink_hint'))%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
de: | ||
pageflow: | ||
admin: | ||
entries: | ||
permalink_hint: |- | ||
Wenn der Permalink geändert wird, nachdem der Beitrag | ||
bereits veröffentlicht wurde, wird automatisch eine | ||
Weiterleitung von der alten URL zur neuen URL eingerichtet. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
en: | ||
pageflow: | ||
admin: | ||
entries: | ||
permalink_hint: |- | ||
Changing the permalink after the story has already been | ||
published automatically creates a redirect from the old URL | ||
to the new URL |
13 changes: 13 additions & 0 deletions
13
db/migrate/20240918084059_create_pageflow_permalink_redirects.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class CreatePageflowPermalinkRedirects < ActiveRecord::Migration[5.2] | ||
def change | ||
create_table :pageflow_permalink_redirects do |t| | ||
t.belongs_to :entry, index: true | ||
t.string :slug | ||
t.belongs_to :directory, index: true | ||
|
||
t.timestamps | ||
|
||
t.index ['slug', 'directory_id'], name: 'index_pageflow_permalink_redirects_on_slug_and_dir', unique: true | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.