diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-08-08 02:46:06 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-08-08 02:46:06 +0200 |
| commit | 1a037ac6fab34c5f65ed0f37ed603b88e7b02fd1 (patch) | |
| tree | 48af0eab79ea64c9ca92833d415483773e665305 /app/models/node.rb | |
| parent | 5699572861085bfb0b375f44e2f35ee8eee3f8c6 (diff) | |
Move the external homepage onto the draft
Diffstat (limited to 'app/models/node.rb')
| -rw-r--r-- | app/models/node.rb | 22 |
1 files changed, 2 insertions, 20 deletions
diff --git a/app/models/node.rb b/app/models/node.rb index 5c28a786..f5b76b45 100644 --- a/app/models/node.rb +++ b/app/models/node.rb | |||
| @@ -42,9 +42,6 @@ class Node < ApplicationRecord | |||
| 42 | :inclusion => { :in => ->(_) { Page.custom_templates } }, | 42 | :inclusion => { :in => ->(_) { Page.custom_templates } }, |
| 43 | :allow_blank => true, | 43 | :allow_blank => true, |
| 44 | :if => :default_template_name_changed? | 44 | :if => :default_template_name_changed? |
| 45 | validates :external_url, :format => { :with => %r{\Ahttps?://}i, | ||
| 46 | :allow_blank => true, | ||
| 47 | :message => :must_be_http } | ||
| 48 | 45 | ||
| 49 | # Everything outside the Trash subtree, the Trash node included. | 46 | # Everything outside the Trash subtree, the Trash node included. |
| 50 | # Relies on unique_name being authoritative for tree position -- | 47 | # Relies on unique_name being authoritative for tree position -- |
| @@ -260,6 +257,8 @@ class Node < ApplicationRecord | |||
| 260 | self.slug = self.head.slug | 257 | self.slug = self.head.slug |
| 261 | end | 258 | end |
| 262 | 259 | ||
| 260 | self.external_url = self.head.external_url | ||
| 261 | |||
| 263 | if self.head.parent_node_id && self.head.parent_node_id != parent_id | 262 | if self.head.parent_node_id && self.head.parent_node_id != parent_id |
| 264 | new_parent = Node.find_by(:id => self.head.parent_node_id) | 263 | new_parent = Node.find_by(:id => self.head.parent_node_id) |
| 265 | 264 | ||
| @@ -604,23 +603,6 @@ class Node < ApplicationRecord | |||
| 604 | self.created_at < new_id_format_date ? unique_path : id | 603 | self.created_at < new_id_format_date ? unique_path : id |
| 605 | end | 604 | end |
| 606 | 605 | ||
| 607 | def update_external_url!(url, current_user = nil) | ||
| 608 | normalised = url.presence | ||
| 609 | return false if normalised == external_url | ||
| 610 | |||
| 611 | guard_live_change!(current_user) | ||
| 612 | previous = external_url | ||
| 613 | |||
| 614 | transaction do | ||
| 615 | update!(:external_url => normalised) | ||
| 616 | NodeAction.record!(:node => self, :user => current_user, | ||
| 617 | :action => "node_external_url", | ||
| 618 | :path => unique_name, | ||
| 619 | :external_url => { "from" => previous, "to" => normalised }) | ||
| 620 | end | ||
| 621 | true | ||
| 622 | end | ||
| 623 | |||
| 624 | # Full-text search across all locale translations using PostgreSQL tsvector. | 606 | # Full-text search across all locale translations using PostgreSQL tsvector. |
| 625 | # Uses 'simple' dictionary (no stemming, no stopwords) so queries work | 607 | # Uses 'simple' dictionary (no stemming, no stopwords) so queries work |
| 626 | # across German and English content without language detection. | 608 | # across German and English content without language detection. |
