diff options
Diffstat (limited to 'app/models/node_action.rb')
| -rw-r--r-- | app/models/node_action.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/app/models/node_action.rb b/app/models/node_action.rb index f1e4eaea..1e64861e 100644 --- a/app/models/node_action.rb +++ b/app/models/node_action.rb | |||
| @@ -35,6 +35,7 @@ class NodeAction < ApplicationRecord | |||
| 35 | # "title" -- pair, always; "from" null on first publish | 35 | # "title" -- pair, always; "from" null on first publish |
| 36 | # "author" -- pair, when the byline changed (incl. first publish) | 36 | # "author" -- pair, when the byline changed (incl. first publish) |
| 37 | # "tags" -- pair of arrays, when changed | 37 | # "tags" -- pair of arrays, when changed |
| 38 | # "external_url" -- pair, when a chapter's homepage changed | ||
| 38 | # "assets" -- {"added" => [asset names], "removed" => [asset names]}, | 39 | # "assets" -- {"added" => [asset names], "removed" => [asset names]}, |
| 39 | # keys only when any; a delta, not a pair. The event IS | 40 | # keys only when any; a delta, not a pair. The event IS |
| 40 | # the delta, full sets would bloat every entry. Changed | 41 | # the delta, full sets would bloat every entry. Changed |
| @@ -134,7 +135,6 @@ class NodeAction < ApplicationRecord | |||
| 134 | # from the node verbs' "tags", which is a pair, | 135 | # from the node verbs' "tags", which is a pair, |
| 135 | # so one renderer cannot mistake the other. | 136 | # so one renderer cannot mistake the other. |
| 136 | # "path" -- the node's unique_name, when it has a node | 137 | # "path" -- the node's unique_name, when it has a node |
| 137 | # "external_url" -- pair | ||
| 138 | # | 138 | # |
| 139 | # On "event_update" only, and only when something changed -- an | 139 | # On "event_update" only, and only when something changed -- an |
| 140 | # update that changes nothing records no entry at all: | 140 | # update that changes nothing records no entry at all: |
| @@ -199,12 +199,16 @@ class NodeAction < ApplicationRecord | |||
| 199 | "to" => title_of.call(new_page) } } | 199 | "to" => title_of.call(new_page) } } |
| 200 | unless old_page | 200 | unless old_page |
| 201 | diff[:author] = { "from" => nil, "to" => new_page.user&.login } if new_page.user | 201 | diff[:author] = { "from" => nil, "to" => new_page.user&.login } if new_page.user |
| 202 | diff[:external_url] = { "from" => nil, "to" => new_page.external_url } if new_page.external_url.present? | ||
| 202 | return diff | 203 | return diff |
| 203 | end | 204 | end |
| 204 | 205 | ||
| 205 | old_author, new_author = old_page.user&.login, new_page.user&.login | 206 | old_author, new_author = old_page.user&.login, new_page.user&.login |
| 206 | diff[:author] = { "from" => old_author, "to" => new_author } if old_author != new_author | 207 | diff[:author] = { "from" => old_author, "to" => new_author } if old_author != new_author |
| 207 | 208 | ||
| 209 | old_url, new_url = old_page.external_url, new_page.external_url | ||
| 210 | diff[:external_url] = { "from" => old_url, "to" => new_url } if old_url != new_url | ||
| 211 | |||
| 208 | old_tags, new_tags = old_page.tag_list.sort, new_page.tag_list.sort | 212 | old_tags, new_tags = old_page.tag_list.sort, new_page.tag_list.sort |
| 209 | diff[:tags] = { "from" => old_tags, "to" => new_tags } if old_tags != new_tags | 213 | diff[:tags] = { "from" => old_tags, "to" => new_tags } if old_tags != new_tags |
| 210 | 214 | ||
