[PatchDiscussion] darcs patch: 1347 - summary() not quoted + cleanup.
[email protected] (betabug.darcs)
| Newsgroups | gmane.comp.web.zope.zwiki |
|---|---|
| Message-ID | <20071215144259.2AC911CCE22__25166.1737020642$1197729888$gmane$org@briareus.betabug.ch> |
Tue Nov 27 08:24:51 EET 2007 [email protected] * 1347 - summary() not quoted + cleanup. Original issue was about summary() being quoted, which isn't always desirable. Looking at it I noticed that docstrings for summary() and renderedSummary() do not reflect actual output, e.g. summary() returns RST markup, not just plain text. Added a wikilinkedSummary() method too, which is plaintext, but with active links - this could also have been done with an optional parameter to renderedSummary(). New patches: [1347 - summary() not quoted + cleanup. [email protected]**20071127062451 Original issue was about summary() being quoted, which isn't always desirable. Looking at it I noticed that docstrings for summary() and renderedSummary() do not reflect actual output, e.g. summary() returns RST markup, not just plain text. Added a wikilinkedSummary() method too, which is plaintext, but with active links - this could also have been done with an optional parameter to renderedSummary(). ] { hunk ./Utils.py 136 - def summary(self,size=200,paragraphs=1,charset="utf-8"): + def summary(self,size=200,paragraphs=1,charset="utf-8",striphtml=True): hunk ./Utils.py 146 - t = self.documentPart() + t = self.preRendered() # gets us html hunk ./Utils.py 148 - t = re.sub(r'<(?=\S)[^>]+>','',t).strip() # strip html tags - if paragraphs: t = join(split(t,'\n\n')[:paragraphs],'\n\n') + if paragraphs: t = join(split(t,'</p>')[:paragraphs],'</p>') + if striphtml: + t = re.sub(r'<(?=\S)[^>]+>','',t).strip() # strip html tags hunk ./Utils.py 155 - return html_quote(t) + if "ZWIKIMIDSECTION" in t: + t = t.split("ZWIKIMIDSECTION")[0] + return t hunk ./Utils.py 168 - self.pageType().format( - self.summary(size=size, paragraphs=paragraphs)))) + self.summary(size=size, paragraphs=paragraphs, striphtml=False))) + + def wikilinkedSummary(self,size=500,paragraphs=1): + """ + Give a summary of this page's content, as plaintext with links. + + Similar to summary(), but this one tries to do wiki linking and + leaves other links intact if possible. We remove any html though. + """ + return re.sub(r'(?si)^<p>(.*)</p>\n?$', r'\1', + self.renderLinksIn( + self.summary(size=size, paragraphs=paragraphs, striphtml=True))) } Context: [more coding style notes Simon Michael <[email protected]>**20071104173259] [directory overview & more style notes Simon Michael <[email protected]>**20071104164649] [add a doc file overview to README Simon Michael <[email protected]>**20071104163944] [move/update some old style docs Simon Michael <[email protected]>**20071104154420] [start a developer style guide, with some documentation guidelines Simon Michael <[email protected]>**20071102174859] [clarify that handleEditText permissions check Simon Michael <[email protected]>**20071028080428] [a little whitespace [email protected]**20071028062937] [make linecounts [email protected]**20071028062925] [Recorded rating change. [email protected]**20071030110512 We want to update CHANGES incrementally. Attempting to find a form for that here, which at the release could be changed quickly to the final release CHANGES. ] [Update only rating related indexes in catalog. [email protected]**20071030085420 We're saving some bytes by updating only the indexes actually related to voting. All metadata will unfortunately be updated anyway. ] [Switched to OOBTree for recording ratings. [email protected]**20071030083921 Dictionaries on persistant objects in the ZODB can only be saved by writing all of the object to the ZODB again. Inefficient. We're using a BTree now, which will save us some kB writing to disk and also reduces the likelyhood of ConflictErrors on the page. On accessting the "votes" we check for old votes still being dictionaries, moving them to BTrees on-the-fly. The overhead for this is counterbalanced by easier recording of votes, just set the entry in the BTree. ] [Remove mentions of purple numbers in comments. [email protected]**20071029174114] [oops! not running tests enough. Two typos and one bugfix [email protected]**20071028022406] [create cleanup. All significant methods in Editing have now been reviewed/tightened up. Simon Michael <[email protected]>**20071028020234] [move methods Simon Michael <[email protected]>**20071028014132] [comment cleanup [email protected]**20071028014019] [autoSubscriptionEnabled cleanup Simon Michael <[email protected]>**20071028011715] [append, edit cleanup [email protected]**20071028011427] [handleSubtopicsProperty cleanup Simon Michael <[email protected]>**20071028010818] [handleEditText cleanup Simon Michael <[email protected]>**20071028010617] [delete cleanup, drop unused updatebacklinks argument Simon Michael <[email protected]>**20071028010321] [handleRename cleanup Simon Michael <[email protected]>**20071028005220] [handleEditPageType cleanup [email protected]**20071028005122] [move a method [email protected]**20071028004655] [revert cleanup [email protected]**20071026162019] [setCreatorLike, setLastEditorLike [email protected]**20071026162005] [tests for new expunge methods [email protected]**20071026160319] [clarification [email protected]**20071026160308] [handy new manager methods expungeLastEditor, expungeLastEditorEverywhere; expunge, expungeEditsEverywhereBy cleanup [email protected]**20071026150936] [#1393 Catch ValueError too on importing unknown pagetypes. [email protected]**20071022074304] [PUT cleanup Simon Michael <[email protected]>**20071019053515] [file upload code cleanup [email protected]**20071018022343] [rename cleanup [email protected]**20071017125051] [cleanupText cleanup [email protected]**20071017123631] [clean up subtopicsEnabled [email protected]**20071016174006] [make bare page rendering at the debug prompt work again, cleanup [email protected]**20071016172335] [removed some unused code in ZWikiPage.py Simon Michael <[email protected]>**20071013190549] [Catch only AttributeError for self.DestinationURL(). [email protected]**20071013191137] [os.mkdir will raise OSError, removed bare except. [email protected]**20071013184205] [Zope version path changed in >=2.9, bare except removed. [email protected]**20071013171756] [notes update [email protected]**20071010163932] [Change content-type of the SomePage/text (or /src) methods to UTF-8. [email protected]**20071009085748 Makes the /text view of wiki pages much more usefull for non-ascii languages. ] [wording [email protected]**20071010150624] [Catch only AttributeError instead of bare except clause (in old fix for #1137). [email protected]**20071003184029] [Fix test_setupDtmlMethods for sitemap.xml.dtml. [email protected]**20071003183255] [a google sitemap.xml, installed by setupDtmlMethod.. may reduce load from search bots [email protected]**20070927201735] [remove the anti-spam 24 hour indexing delay introduced in 0.41, for better Simon Michael <[email protected]>**20070925161611 indexing of actively-edited pages (#1387) ] [feedUrl Simon Michael <[email protected]>**20070924165908] [upgrade notes Simon Michael <[email protected]>**20070920192543] [more upgrade notes Simon Michael <[email protected]>**20070920190255] [clean up and add summary & upgrade notes for 0.60 [email protected]**20070920185128] [convert recent relnote headings to definition lists like the rest [email protected]**20070920182235] [merge rc notes, add headings [email protected]**20070920181617] [mailin test comment [email protected]**20070919175328] [rename changes_rss to edits_rss (with a backwards compatibility alias) and [email protected]**20070918152135 update the docstring. Also, test forwarding to the PatchDiscussion page. ] [keep any text/x-darcs-patch part, as well as the first text/plain part of a mailin [email protected]**20070919060849] [fix darcs patch mailin test [email protected]**20070919055056] [test mailin of a darcs patch [email protected]**20070918164333] [1272 - create PageBrain only for Zwiki Pages. [email protected]**20070917193709 Since we are now ensuring that there is always a catalog in a Zwiki, the method metadataFor() shouldn't be needed any more. But I'm still adding this patch (credits and thanks to koegler), in case some code hits on it in the time between an upgrade and running the /upgradeAll method. ] [TAG release-0-60-0 [email protected]**20070915222130] Patch bundle hash: b7d97b7c6a6d5ccdb7531984f44dea859459bdee -- forwarded from http://zwiki.org/PatchDiscussion#[email protected]