diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-10 00:35:24 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-10 00:35:24 +0200 |
| commit | a25d90335ad3738b6831288190132c2f7498465c (patch) | |
| tree | 5aa7083d9f8c8701644fe60bc7d28542775694b8 /app/views/revisions/index.html.erb | |
| parent | da0b79a7c1f3116e2b450ecbe50efdf31cf23414 (diff) | |
Retire vendored cacycle_diff.js for a diff-lcs-based diff view
Revisions#diff now computes an inline or side-by-side word diff
server-side (Page#diff_against, lib/html_word_diff.rb) instead of
shipping raw/escaped content to the browser for a 2008-era vendored
JS differ to mangle. View mode is picked via a `view` param, settable
either on the diff page itself or directly from the revisions#index
sticky bar next to "Diff revisions".
Also fixes a pre-existing bug in RevisionsController#diff's single-
revision branch, which set params[:start]/params[:end] instead of
params[:start_revision]/params[:end_revision].
Diffstat (limited to 'app/views/revisions/index.html.erb')
| -rw-r--r-- | app/views/revisions/index.html.erb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/app/views/revisions/index.html.erb b/app/views/revisions/index.html.erb index a6a981af..58c08b70 100644 --- a/app/views/revisions/index.html.erb +++ b/app/views/revisions/index.html.erb | |||
| @@ -19,6 +19,8 @@ | |||
| 19 | form: { id: 'diff_form', class: 'button_to computation' }, | 19 | form: { id: 'diff_form', class: 'button_to computation' }, |
| 20 | disabled: true %> | 20 | disabled: true %> |
| 21 | <span id="diff_selection_label"></span> | 21 | <span id="diff_selection_label"></span> |
| 22 | <label><%= radio_button_tag :view, 'inline', true %> Inline</label> | ||
| 23 | <label><%= radio_button_tag :view, 'side_by_side', false %> Side by side</label> | ||
| 22 | </td> | 24 | </td> |
| 23 | </tr> | 25 | </tr> |
| 24 | </thead> | 26 | </thead> |
| @@ -68,6 +70,7 @@ | |||
| 68 | document.getElementById('diff_form').addEventListener('submit', function(e) { | 70 | document.getElementById('diff_form').addEventListener('submit', function(e) { |
| 69 | var start = document.querySelector('input[name="start_revision"]:checked'); | 71 | var start = document.querySelector('input[name="start_revision"]:checked'); |
| 70 | var end = document.querySelector('input[name="end_revision"]:checked'); | 72 | var end = document.querySelector('input[name="end_revision"]:checked'); |
| 73 | var view = document.querySelector('input[name="view"]:checked'); | ||
| 71 | if (start) { | 74 | if (start) { |
| 72 | var s = document.createElement('input'); | 75 | var s = document.createElement('input'); |
| 73 | s.type = 'hidden'; s.name = 'start_revision'; s.value = start.value; | 76 | s.type = 'hidden'; s.name = 'start_revision'; s.value = start.value; |
| @@ -78,5 +81,10 @@ | |||
| 78 | en.type = 'hidden'; en.name = 'end_revision'; en.value = end.value; | 81 | en.type = 'hidden'; en.name = 'end_revision'; en.value = end.value; |
| 79 | this.appendChild(en); | 82 | this.appendChild(en); |
| 80 | } | 83 | } |
| 84 | if (view) { | ||
| 85 | var v = document.createElement('input'); | ||
| 86 | v.type = 'hidden'; v.name = 'view'; v.value = view.value; | ||
| 87 | this.appendChild(v); | ||
| 88 | } | ||
| 81 | }); | 89 | }); |
| 82 | </script> | 90 | </script> |
