ReenenLaurie: I saw some stuff about macros etc. Is it possible to create a macro to create a 'thread', a bit like the user prefences page, except that the textboxes will contain the actual 'posting', and then the forum like feel will certainly take off. I have a feeling that the possibilities with the wiki is extremely powerful, and I am genuinely in awe.
ReenenLaurie: To sum up: Forum-like buttons for "New Topic" and "Reply", and let the macros do the ----- or similar posting 'organizing'.
Also, then you could lock these pages as well, and let the macro's add the newest stuff to the top etc.
NeilStevens: To be specific about what I'm planning, I'm going to look into having a macro that generates a form, which when used appends the entered text to the bottom of the page.
SoulWynd: That will need both a macro and an action. I'm looking into it and might try to code it when I have some free time.
ReenenLaurie: That would be SO cool. At the moment I think it's a little over the top to have to type [[LastChanged(page/topic)]] ["/topic"] and then click on the unrecognized link to add a page. (It looks too much like programming and too little like a layman's forum at the moment).
Then the GeneralDiscussion and IdeaArchive etc. could be immutable pages which just gets modified by the macros. So then (maybe) the topics could be sorted according to LastChanged. Then it would be very very close to true forum emulation. Is it possible to add buttons and similar things to wiki pages? (Yes I believe it is... looking at user preferences)
SoulWynd: I could make a macro that lists all subpages with their PageAge or LastChanged time. The macro NeilStevens was talking about would be just to append something to a thread (with automatic formatting of course). I think the thread creation might remain unchanged for now but I could look into creating a macro to create subpages. About the immutable thing, the problem is that it affects permissions, so they shouldn't be immutable unless you want the macro to be above permissions and allow annonymous subpage creation in the forums.
ReenenLaurie: Yes, my idea was to give the macro permissions to change the page, and not the general public. It's just my idea though, and my vision doesn't necessarily work with other's ideas.
The macro to list all subpages with PageAge/LastChanged sounds excellent! Then have another macro to create a new subpage. Throw them together and 'viola!' I don't think that it's necessary to change the actual editing of a page, as this is the idea of the wiki.
NeilStevens: The point wasn't to un-wiki the page, not at all. The point was to give an alternative to the Lock->Edit->Post cycle for pages that are meant to contain chatter. There would be no ACLs or anything. People would be free to edit pages normally. The macro-generated form would just be there to make quick comments quicker to make.
ReenenLaurie: Ok, where you're going and I is related, but not the same. My main idea was to make the creation of new threads easy and forum like. Yours was to make the answering on chatter (like we're doing here) easier. Also so you don't have to load the whole page to add something, but to edit I assume you still would).
Both I think is worth the effort, and will probably be first on wiki's world wide though I dunno. Great work so far SoulWynd!
NeilStevens: A macro-generated form easing the creation of new threads would be fine by me, too, on the same principle as the comment macro.
SoulWynd: Well, while examining the source, I found a lil problem with all that. The lock. I can't really ignore the page lock without writting a bunch of redundant code just to save the page while (partialy) ignoring the datestamp the wiki sends when you start editing a page. We could, however, create a macro to open a popup window, acquire a lock and the datestamp so you can successfully append the text to the thread without ignoring the lock. It's starting to look like more trouble than what its worth.
SoulWynd: Actualy, I've just found something interesting. Internal changes to pages use a datestamp = 0 ... That makes things easier. The action could request the raw form of the page, append changes and then savetext with a datestamp 0, since everything would happen internaly it wouldn't affect anything else. I might come up with some code for that soon.
Dryad: Some wikis have a feature where you can edit separately single sections (without having to see all sections while you edit). This is priceless for large documents, such as some "day in the life of" pages. Sections are even separate files on some wikis, which allows many people to edit many sections in the same page without being a mess.
SoulWynd: The code for the action is done, I just need to work on the macro. I might do it tonight if my headache goes away, if not, maybe tomorrow.
SoulWynd: Hopefuly this will work without problem:
macro\Append.py
"""
Usage:
[[Append]] - Creates the append form
-SoulWynd
"""
from MoinMoin import wikiutil
Dependencies = []
def execute(macro, args):
pagename = macro.formatter.page.page_name
ret = '<form method="post" action="%s/%s#preview">' % (macro.request.getScriptname(), wikiutil.quoteWikiname(pagename))
ret = ret + '<p><input type="hidden" name="action" value="addpost"><textarea wrap=soft name="savetext" rows="5" cols="80" style="width:100%"></textarea></p><p><input type="submit" name="button_save" value="Save Changes"></p></form>'
return ret
action\addpost.py
"""
addpost action
-SoulWynd
"""
import string
from MoinMoin import user
from MoinMoin.Page import Page
from MoinMoin.PageEditor import PageEditor
def execute(pagename, request):
_ = request.getText
if not request.user.may.edit(pagename):
Page(pagename).send_page(request,
msg = _('You are not allowed to edit this page.'))
return
pg = PageEditor(pagename, request)
savetext = request.form.get('savetext', [''])[0]
datestamp = '0'
comment = 'Automated thread post'
control_chars = '\x00\x01\x02\x03\x04\x05\x06\x07\x08\x0b\x0c\x0e\x0f' \
'\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f'
remap_chars = string.maketrans('\t\r\n', ' ')
comment = comment.translate(remap_chars, control_chars)
originaltext = Page(pg.page_name).get_raw_body()
x = originaltext.find('[[Append]]')
savetext = pg._normalize_text(savetext, stripspaces=0)
# Merge the original with savetext in the format the wiki threads currently use
if x > 0:
savetext = originaltext[:x] + request.user.getUserIdentification(request) + ': ' + savetext + '\n' + originaltext[x:]
else:
savetext = originaltext + request.user.getUserIdentification(request) + ': ' + savetext + '\n' + '[[Append]]' + '\n'
# Copy from do_savepage
try:
savemsg = pg.saveText(savetext, datestamp,
stripspaces=0, notify=0,
comment=comment)
except pg.EditConflict, msg:
allow_conflicts = 1
from MoinMoin.util import diff3
original_text = Page(pg.page_name, date=datestamp).get_raw_body()
saved_text = pg.get_raw_body()
verynewtext = diff3.text_merge(original_text, saved_text, savetext,
allow_conflicts,
'----- /!\ Edit conflict! Other version: -----\n',
'----- /!\ Edit conflict! Your version: -----\n',
'----- /!\ End of edit conflict -----\n')
if verynewtext:
msg = _("""Someone else saved this page while you were editing!
Please review the page and save then. Do not save this page as it is!
Have a look at the diff of %(difflink)s to see what has been changed."""
) % {'difflink':pg.link_to(request, querystr='action=diff&date=' + datestamp)}
request.form['datestamp'] = [os.path.getmtime(pg._text_filename())]
pg.sendEditor(msg=msg, comment=request.form.get('comment', [''])[0],
preview=verynewtext, staytop=1)
return
else:
savemsg = msg
except pg.SaveError, msg:
savemsg = msg
request.reset()
backto = request.form.get('backto', [None])[0]
if backto:
pg = Page(backto)
pg.send_page(request, msg=savemsg)
request.http_redirect(pg.url(request))
Note that filename capitalization is important... I have no idea if this will work, but we can try it out. Lemme know if there are bugs laying around.
NeilStevens: Any chance you could send this to me as a patch or a changeset to my Moin tree? See Wiki Development for details on that.
SoulWynd: Not really. I have no idea how, and that tutorial they have is almost like nothing.
NeilStevens: OK, at long last, I tested this action, and I get an error: AttributeError: User instance has no attribute 'getUserIdentification'
SoulWynd: My fault, I didn't notice it was outside the class. Change request.user.getUserIdentification(request) to getUserIdentification(request) ... If that fails, change it to (request.user.name or request.remote_addr) That should be it.
ToME Wiki