[cmsiki-svn] SF.net SVN: cmsiki: [25] trunk/cmsiki
Status: Pre-Alpha
Brought to you by:
cnu
From: <cn...@us...> - 2007-04-15 16:59:52
|
Revision: 25 http://cmsiki.svn.sourceforge.net/cmsiki/?rev=25&view=rev Author: cnu Date: 2007-04-15 09:59:49 -0700 (Sun, 15 Apr 2007) Log Message: ----------- Implemented getPageVersion, getPageInfoVersion, getPageHTMLVersion to cmsikireplace. Moved ordering of sites app in admin page. Modified Paths: -------------- trunk/cmsiki/cmsikireplace.py trunk/cmsiki/settings.py Modified: trunk/cmsiki/cmsikireplace.py =================================================================== --- trunk/cmsiki/cmsikireplace.py 2007-04-04 17:57:21 UTC (rev 24) +++ trunk/cmsiki/cmsikireplace.py 2007-04-15 16:59:49 UTC (rev 25) @@ -58,9 +58,36 @@ page_html_content = '' page_html_content = page_html_content.replace('<a class="nonexistent" href="/','<a class="nonexistent" href="%s' %(wiki['url'])) return page_html_content.replace('<a href="/','<a href="%s' %(wiki['url'])) - + +def getPageHTMLVersion(tag): + '''Returns the page contents as rendered HTML during that particular version. + + tag is of the following format [getPageHTMLVersion:PageName,version@WikiName].''' + page_pattern = re.compile(r':\w+,\d+@') + wiki_pattern = re.compile('@[a-zA-Z]+\]') + page_match = page_pattern.findall(tag)[0] + page_version_name = page_match[1:-1] + page_name = page_version_name.split(',')[0] + version = int(page_version_name.split(',')[1]) + wiki_match = wiki_pattern.findall(tag)[0] + wiki_name = wiki_match[1:-1] + try: + wiki = wikirpc(wiki_name) + except WikiNameError: + return '' + srcwiki = xmlrpclib.ServerProxy(wiki['xmlrpc']) + try: + page_html_content = srcwiki.getPageHTMLVersion(page_name,version) + except httplib.socket.error: + page_html_content = '' + page_html_content = page_html_content.replace('<a class="nonexistent" href="/','<a class="nonexistent" href="%s' %(wiki['url'])) + return page_html_content.replace('<a href="/','<a href="%s' %(wiki['url'])) + + def getPage(tag): - '''Returns the page contents from the wiki as WikiText.''' + '''Returns the page contents from the wiki as WikiText. + + tag is of the following format [getPage:PageName@WikiName].''' page_pattern = re.compile(':\w+@') wiki_pattern = re.compile('@[a-zA-Z]+\]') page_match = page_pattern.findall(tag)[0] @@ -78,6 +105,33 @@ page_content = '' return page_content.replace('\n','<br/>') + +def getPageVersion(tag): + '''Returns the page contents as raw text during that particular version. + + tag is of the following format [getPageVersion:PageName,version@WikiName].''' + page_pattern = re.compile(r':\w+,\d+@') + wiki_pattern = re.compile('@[a-zA-Z]+\]') + page_match = page_pattern.findall(tag)[0] + page_version_name = page_match[1:-1] + page_name = page_version_name.split(',')[0] + version = int(page_version_name.split(',')[1]) + wiki_match = wiki_pattern.findall(tag)[0] + wiki_name = wiki_match[1:-1] + try: + wiki = wikirpc(wiki_name) + except WikiNameError: + return '' + srcwiki = xmlrpclib.ServerProxy(wiki['xmlrpc']) + try: + page_content = srcwiki.getPageVersion(page_name,version) + except httplib.socket.error: + page_content = '' + return page_content.replace('\n','<br/>') + + + + def getPageInfo(tag): '''Return the page contents from the wiki as WikiText.''' page_pattern = re.compile(':\w+@') @@ -100,6 +154,33 @@ %(page_info['name'], page_info['author'], page_info['version']) return str(page_string_info) +def getPageInfoVersion(tag): + '''Returns the page info during that particular version. + + tag is of the following format [getPageInfoVersion:PageName,version@WikiName].''' + page_pattern = re.compile(r':\w+,\d+@') + wiki_pattern = re.compile('@[a-zA-Z]+\]') + page_match = page_pattern.findall(tag)[0] + page_version_name = page_match[1:-1] + page_name = page_version_name.split(',')[0] + version = int(page_version_name.split(',')[1]) + wiki_match = wiki_pattern.findall(tag)[0] + wiki_name = wiki_match[1:-1] + try: + wiki = wikirpc(wiki_name) + except WikiNameError: + return '' + srcwiki = xmlrpclib.ServerProxy(wiki['xmlrpc']) + try: + page_info = srcwiki.getPageInfoVersion(page_name,version) + except httplib.socket.error: + page_info = '' + # return the wiki page info in a string format + page_string_info = 'PageName: %s <br/>\nAuthor: %s <br/>\nVersion: %s \n' \ + %(page_info['name'], page_info['author'], page_info['version']) + return str(page_string_info) + + def getLink(tag): '''Returns the URL of the page in a particular wiki.''' page_pattern = re.compile(':\w+@') @@ -117,16 +198,20 @@ dict_func = {'getPage':getPage, - 'getPageHTML':getPageHTML, - 'getPageInfo':getPageInfo, - 'getLink':getLink, + 'getPageHTML':getPageHTML, + 'getPageInfo':getPageInfo, + 'getLink':getLink, + 'getPageVersion':getPageVersion, + 'getPageInfoVersion':getPageInfoVersion, + 'getPageHTMLVersion':getPageHTMLVersion, + } def tagreplace(originaltext): '''Replace the originaltext with text from wiki.''' wikireplacelist = [] - tagpattern = re.compile('\[[a-zA-Z]+:\w+@[a-zA-Z]+\]') + tagpattern = re.compile(r'\[[a-zA-Z]+:\w+@[a-zA-Z]+\]|\[[a-zA-Z]+:\w+,\d+@[a-zA-Z]+\]') tagmatches = tagpattern.findall(originaltext) # find list of all import tags methodpattern = re.compile('\[[a-zA-Z]+') for tag in tagmatches: Modified: trunk/cmsiki/settings.py =================================================================== --- trunk/cmsiki/settings.py 2007-04-04 17:57:21 UTC (rev 24) +++ trunk/cmsiki/settings.py 2007-04-15 16:59:49 UTC (rev 25) @@ -69,12 +69,12 @@ 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', - 'django.contrib.sites', 'django.contrib.admin', 'cmsiki.apps.page', 'cmsiki.apps.story', 'django.contrib.comments', 'cmsiki.apps.blogroll', + 'django.contrib.sites', ) # Comments: to get the URL of the current page a template variable This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |