Closed Eiji7 closed 8 years ago
Two ways to do this. 1. calculate and store on each change. 2. Generate from database on each request. The latter would be easier, but has performance implications.
I won't have time to work on this for a while. I've some ex_admin features I need to complete first.
A PR is welcome.
Yes, these two ways can be configurable too. First when installing, second as a separated module.
defmodule MyProject.Post do
use Whatwasit
use Whatwasit.Diff # normal diffs when calling with two strings
use Whatwasit.Version.Diff # diffs for versions
# ...
end
I want to easily generate diff for
%MyProject.User
(admin and/or editor role) to preview multi lineString
e.g%MyProject.Post
body
field. This should be method that accepttype
argument (Atom
orString
) and optionallylines
(Integer
).Lines argument is to limit diff response for X lines around change (not need when type is json).
Type argument may be:
patch
command)Format for normal: We have Enum of lines. Each line have
String
(s) and/orTuple
(s).String
(s) are not affected text.Tuple
is info about affected text, where:["delete", "insert"]
When side-by-side we have tuple:
{left_column, right_column}
where each column is array of lines (see format for nomal). For example:[ ["same text 1", {"insert", "text inserted in first line"}, "same text 2"], ["same text for second line ..."] ]
JSON API: Returns json with two fields:
source
- original textchanges
- array of changes where each element hastype
,line
,column
,change_length
. For example:{"source": "First line\nSecondd line\nThird line", "changes":[{"change_length": 1, "column": 7, "line": 2, "type": "delete"}]}
API says: "remove 7th character of 2nd column for given source".Generating diff should be available for one and all versions (
Version
) for same model and model id.Diff support can be optional when installing.