mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
FEATURE: permalinks lookup table can redirect to any arbitrary url
This commit is contained in:
parent
dcd4956ea4
commit
8a88e71b3c
2 changed files with 24 additions and 0 deletions
|
@ -13,9 +13,28 @@ class Permalink < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def target_url
|
||||
return external_url if external_url
|
||||
return post.url if post
|
||||
return topic.relative_url if topic
|
||||
return category.url if category
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: permalinks
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# url :string(1000) not null
|
||||
# topic_id :integer
|
||||
# post_id :integer
|
||||
# category_id :integer
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# external_url :string(1000)
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_permalinks_on_url (url) UNIQUE
|
||||
#
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddExernalUrlToPermalinks < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :permalinks, :external_url, :string, limit: 1000
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue