(no commit message)
[ikiwiki.git] / doc / todo / applydiff_plugin.mdwn
1 [[!tag wishlist done]]
2
3 [[!toc ]]
4
5 Summary
6 =======
7
8 Allow a user to apply an arbitrary diff, in order to modify a given
9 page (or, even better, a given set of pages).
10
11 Rationale
12 =========
13
14 To edit intensively an ikiwiki-powered website can quickly get
15 annoying for anybody meeting enough of the following conditions:
16
17 * living mainly offline
18 * having no commit access to the RCS backing up the site (BTW, please
19   note I can send my ssh public key to anyone who asks for, free of
20   charges)
21 * hating web-browsers and despising textareas
22 * loving in his/her own preferred `$EDITOR`
23
24 ... and when one gathers all of these defaults, she/he is on her/his
25 way to get mad. Soon.
26
27 Before it's too late, some dareful ones dream of the following
28 playflow:
29
30 1. Go online.
31 1. Update local working copy.
32 1. Go offline.
33 1. `$EDITOR` : write, report, answer, propose
34 1. Go online.
35 1. Update local working copy (and optionally fix conflicts between
36    local changes and remote ones).
37 1. Generate a diff.
38 1. Use a web-browser to paste the diffs (or better, upload them into
39    a form) somewhere on the wiki, and click "Apply".
40 1. git pull (to reflect locally the fact that the diff has been
41    applied to the remote repo)
42 1. Go offline.
43
44 (This is for sure a bit theoretical: the ones who dream of this would
45 actually insert various steps about branching, merging and rebasing
46 random stuff.)
47
48 Design
49 ======
50
51 This has to be thought very carefully, to avoid one to apply diffs to
52 pages he/she is not allowed to edit. Restricting a given diff to
53 modify only *one* page may be easier.
54
55 Implementation
56 ==============
57
58 Also see [[joey]]'s idea on [[users/xma/discussion]], to allow (filtered) anonymous push to this wiki's repository.
59
60 > Ideally the filtering should apply the same constraints on what's pushed
61 > as are applied to web edits. So locked pages can't be changed, etc.
62
63 > That could be accomplished by making the git pre-receive hook be a
64 > ikiwiki wrapper. A new `git_receive_wrapper` config setting could cause
65 > the wrapper to be generated, with `$config{receive}` set to true.
66
67 > When run that way, ikiwiki would call `rcs_receive`. In the case of git,
68 > that would look at the received changes as fed into the hook on stdin,
69 > and use `parse_diff_tree` to get a list of the files changed. Then it
70 > could determine if the changes were allowed.
71
72 > To do that, it should first look at what unix user received the
73 > commit.  That could be mapped directly to an ikiwiki user. This would
74 > typically be an unprivelidged user (that was set up just to allow
75 > anonymous pushes), but you might also want to set up
76 > separate users who have fewer limits on what they can push. And, of
77 > course, pushes from the main user, who owns the wiki, would not be
78 > checked at all. So, let's say `$config{usermap}` is a hash, something
79 > like `{usera => "wikiusera", userb => "wikiuserb"}`, and pushes from
80 > users not in the hash are not checked.
81
82 > Then it seems like it would want to call `check_canedit` to test if an
83 > edit to each changed page is allowed. Might also want to call
84 > `check_canattach` and `check_canremove` if the attach and remove plugins
85 > are enabled. All three expect to be passed a CGI and a CGI::Session
86 > object, which is a bit problimatic here. So dummy the objects up? (To call
87 > `check_canattach` the changed attachment would need to be extracted to a
88 > temp file for it to check..)
89
90 > If a change is disallowed, it would print out what was disallowed, and
91 > exit nonzero. I think that git then discards the pushed objects (or maybe
92 > they remain in the database until `git-gc` .. if so, that could be used
93 > to DOS by uploading junk, so need to check this point).
94
95 > Also, I've not verified that the objects have been recieved already when
96 > whe pre-receive hook is called. Although the docs seem to say that is the
97 > case. --[[Joey]]
98
99 >> Update: The git pre-receive hook stuff is written, and seems to work.
100 >> I think it makes more sense than using diffs, and so think this todo
101 >> could probably be closed.
102 >> --[[Joey]]
103
104 >>> I agree, closing this. I really prefer this solution to the one I was
105 >>> initially proposing.
106 >>> Is this pre-receive hook already enabled on ikiwiki.info?
107 >>> If not, do you plan to enable it at some point?
108 >>> --[[intrigeri]]
109
110 >>>> [[news/git_push_to_this_wiki]] gave me the answer. Well done! --[[intrigeri]]