Section Edit feature helps users be able to edit a section instead of the whole page. It is still missing in the MoinMoin although the other wiki engines provide it. See FeatureRequests/SectionEditing for more information.
See also the bounty for this feature.
Here I tried to add this feature with the following patches. But they may have many of bugs and have not been confirmed with the other actions. I hope the moin developers consider this feature to be stable and deployed.
Contents
Internal
The details about the internal are:
- the section editing option can be configured in wikiconfig.py or with #pragma PI.
- the formatter counts the line number of a heading text in the raw text as the starting line number of the section.
- the section ends at the end of the page or right before the next section whose depth is equal or less than itself
the ending line number is handled by javascript at text_html.heading() call of the next section
- the section-editing querystring passes revision number to the page editor and if it's different from the current one, it cancels section-editing, because it may not be the target section anymore in the updated revision.
- it locks all of the editing page including the other sections. it's the one of very wanted feature but so complicated
- if users save or preview the section, the editor shows the preview of the section only
- at saving or previewing, the input section is merged to the rest of the text and makes a backup of the merged text
- if conflicts, it cancels the section-editing and shows the conflicts in the entire text of the page
(deprecated: 2005-11-24 01:11:52)
- the formatter counts and remembers the occurrence of the heading without regarding the depth
the order of the occurrence is stored as sectionindex and is passed to the link to the section-editing
right after closing the heading, insert the edit icon with sectionindex
- in the page editor, it parses the specified section out of the raw body of the page using regular expression
this will not work for other kinds of markup. Better use the parser and formatter to find sections, not regex that works only for wiki markup.
It is deprecated. Now it use line numbers of raw text.
- the specified section block starts at the heading marker ('='),
Known Problem
Please report your experiences.
It does not work with Include macro.
It swallows the whitespace characters in the front of the content one by one. Is it intended in moin?
- In order to remove the section, I've clicked the 'save changes' with blank text, then the editor redirects to the unmodifed one! Is it also intended in moin or a bug?
If the heading title is in preformatted block, it mis-counts this as a normal heading: it malfunctions.
It does not work if the page is modified in between, it may even result in data loss (imagine someone adding a new section) Through checking revision number
Won't raise conflict at saving? Here cannot update different revision even if they are different sections.
The regular expressions are copied and pasted into various files.
It doesn't work with pages that contain non-wiki parsers.
Because of the above problems, I suggest to add a new formatter call that collects the section data dynamically. -- AlexanderSchremmer 2005-11-22 12:54:07
Could give me a hint for that please?
- It is simple - add a new function to the formatter which records the byte position or line number etc. Then you need to call it from the formatter. The heading call in the formatter would then read the internal line no. stat and generate correct links which point to a revision number and a line number range. Lateron, merging can be done by knowing the revision number and the line number range. It is important to have it in the formatter to support all kinds of parsers.
- Thanks for your comment. I've updated my patch for section editing, and marked resolved items.
- It is simple - add a new function to the formatter which records the byte position or line number etc. Then you need to call it from the formatter. The heading call in the formatter would then read the internal line no. stat and generate correct links which point to a revision number and a line number range. Lateron, merging can be done by knowing the revision number and the line number range. It is important to have it in the formatter to support all kinds of parsers.
- It does not work with Include macro if it includes a part of a page using from, to parameters. Since the Include macro sets the partical content as raw body of the page, the parser starts to count line number from 0 at the start of the partial content. In order to fix it, the Include macro should inform a parser the correct line number at which the partial content starts in an original page content.
If the text contains comments e.g., ## it's a comment the wiki parser does not increment line number when parsing. Thus the section editing cannot handle this properly.
Editing different sections results in a conflict. It would be nice if sections would be independent, both in locking and conflict resolution. -- TheAnarcat 2007-02-13 22:02:27
Using editmoin no longer works
Can someone please clarify what the marks mean? 'Solved' or just 'confirmed'? -- AndreasKloeckner
Sample
Try the following:
The CSS in the example Moin is to be broken for Opera (9.21 on Linux), rendering the text-editing field unusuable. A screenshot is attached, but not embedded since this is not a bug in this patch I think. With other Themes (i.e. monomoin) it works perfectly.
The example wiki does not work - section edit links lead to standard full page editor instead of the selected section.
It was a cache-related problem. At the previous patch, it used text_html.endContent() call for specifying the start/end line of the sections using javascript, but (though it's not confirmd yet; IMHO) the output javascript codes of this method is not included at the cached result. Thus I've moved the line-calculating procedure to the text_html.heading() call from the text_html.endContent().
Patches
The patches are following. they are based on 1.5b2 and 1.35 but they may not be very different from the other versions IMHO.
These patches are NOT confirmed by moin developers. Use them at your own risk.
1.9
section-edit-1.9-v1.2.patch -- AndreasKloeckner 2010-01-22 15:01:27 section-edit-1.9-v1.4.patch -- -- AndreasKloeckner 2010-10-11 19:07:12
1.7.1
I adapted SectionEditing-1.5.7.patch for 1.7.1 -- Pento 2008-09-19 11:01:45
1.5.8
The 1.5.7 patch applies fine (with some fuzz). -- TheAnarcat 2007-07-26 00:26:45
1.5.7
SectionEditing-1.5.7.patch is a new version of the 1.5.4 patch, with some corrections on whitespace that were breaking the GUI editor. -- TheAnarcat 2007-04-18 19:04:44
1.5.6
1.5.4
SectionEditing-1.5.4.patch is a repackaging of the .zip above that:
actually works
- is a single .patch file that can be more easily applied, without completely overwriting the existing files which might have already been patched.
- also applies on 1.5.7
- ... but breaks the GUI editor because of whitespace issues in the diff, try the 1.5.7 diff above instead
-- TheAnarcat 2007-02-13 22:01:17
1.5b2
1.35
- may work with wiki parser only
Discussion
good idea!
it seems to work properly.
however the URL of this section i am editing is rather error prone: it contains the string action=edit&srev=40&startline=7&endline=22. It would be better to have an ID which does not change when there is some text been added above these lines - KAESTNER
It checks the revision number of the page. Thus if it is modified during editing, it shows conflict messages. -- SeungikLee 2006-01-18 06:10:36
Thanks for the patch! I managed to get it to apply to 1.5.2 release. I had to make minor modifications to the patch to get it to apply cleanly to the latest release. The patch contains filenames relative to $PYTHONROOT/Lib/site-patckages. This makes it easier to apply than the original patch which contained no path information, so that you had to manually specify file names. This is the modified patch. --SrinathAvadhanula
Is there any movement on getting this into the code base? This would be incredibly helpful! --NGilmore
Hello, I am trying to get this going on an install of MMDE 1.5.5a-1, but things are not going so good. I don't actually have a wikiaction.py, and some of the preceding lines in the diff are slightly different. Can someone point me in the right direction? Thanks. --NVA
Does anybody have patch for 1.7.1? --Pento
Has anybody tried this for 1.8? What is the plan of the developers for implementing this function as a stable feature? I think section editing is a useful and almost indispensable function for a wiki, as it is quite painful and inefficient to work on long text without this function. I sincerely wish this issue gets higher priority in moin development. Thanks. -- TakeoKatsuki 2009-08-08 15:31:34
- This feature could be sane implemented after domtree refactoring was merged with 2.0-storage.
Great. Until then I will use the patch. The patch for 1.7.1 can be adapted to 1.8.3 by adding one modification to MoinMoin/config/multiconfig.py. -- TakeoKatsuki 2009-08-09 01:55:19
For 1.7.1: show_section_numbers = 0 # enumerate sections (headlines) by default? + allow_section_edit = 1 show_timings = False # show some timing stats (usually in the footer)
For 1.8.3 ('show_section_numbers', False, 'show section numbers in headings by default'), + ('allow_section_edit', 1, "allow section edit"), ('show_timings', False, "show some timing values at bottom of a page"),
Could we somehow add a "hide/show section" option to this feature? See TaskPlanner for how a hide/show option looks like. -- TakeoKatsuki 2010-01-22 09:38:54
That's a separate feature, IMO. -- 72.221.120.106 2010-01-22 13:14:55
Hmm, you are right. This feature does not necessarily depend on SectionEditing. Maybe I should ask this as a separate FeatureRequest. Thanks. -- TakeoKatsuki 2010-01-22 15:45:51