Changeset 4831
- Timestamp:
- 06/28/08 16:17:40 (6 months ago)
- Files:
-
- trunk/docs/project_code/Wiki-20/wiki20/controllers/root.py (modified) (1 diff)
- trunk/docs/project_code/Wiki-20/wiki20/model/__init__.py (modified) (1 diff)
- trunk/docs/project_code/Wiki-20/wiki20/templates/edit.html (modified) (3 diffs)
- trunk/docs/project_code/Wiki-20/wiki20/templates/page.html (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/docs/project_code/Wiki-20/wiki20/controllers/root.py
r4806 r4831 3 3 from tg import expose, flash 4 4 from pylons.i18n import ugettext as _ 5 import tg 6 from tg import redirect, validate 7 from wiki20.model import DBSession, metadata 5 #from tg import redirect, validate 6 #from wiki20.model import DBSession, metadata 8 7 #from dbsprockets.dbmechanic.frameworks.tg2 import DBMechanic 9 8 #from dbsprockets.saprovider import SAProvider 10 from wiki20.model.page import Page11 import re12 from docutils.core import publish_parts13 from sqlalchemy.exceptions import InvalidRequestError14 15 wikiwords = re.compile(r"\b([A-Z]\w+[A-Z]+\w+)")16 9 17 10 class RootController(BaseController): 18 11 #admin = DBMechanic(SAProvider(metadata), '/admin') 19 12 20 @expose('wiki20.templates.page') 21 def default(self, pagename="FrontPage"): 22 try: 23 page = DBSession.query(Page).filter_by(pagename=pagename).one() 24 except InvalidRequestError: 25 raise redirect("notfound", pagename=pagename) 26 content = publish_parts(page.data, writer_name="html")["html_body"] 27 root = tg.url('/') 28 content = wikiwords.sub(r'<a href="%s\1">\1</a>' % root, content) 29 return dict(content=content, wikipage=page) 30 31 @expose('wiki20.templates.edit') 32 def edit(self, pagename): 33 page = DBSession.query(Page).filter_by(pagename=pagename).one() 34 return dict(wikipage=page) 13 @expose('wiki20.templates.index') 14 def index(self): 15 return dict(page='index') 35 16 36 17 @expose('wiki20.templates.about') 37 18 def about(self): 38 19 return dict() 39 40 @expose()41 def save(self, pagename, data, submit):42 page = DBSession.query(Page).filter_by(pagename=pagename).one()43 page.data = data44 DBSession.commit() # Tells database to commit changes permanently45 redirect("/" + pagename)46 47 @expose('wiki20.templates.edit')48 def notfound(self, pagename):49 page = Page(pagename=pagename, data="")50 DBSession.save(page)51 DBSession.commit()52 return dict(wikipage=page)53 54 @expose('wiki20.templates.pagelist')55 def pagelist(self):56 pages = [page.pagename for page in DBSession.query(Page)]57 return dict(pages=pages)58 trunk/docs/project_code/Wiki-20/wiki20/model/__init__.py
r4806 r4831 40 40 41 41 # Import your model modules here. 42 ##{ModelModules} 42 43 from wiki20.model.page import Page, pages_table 43 44 ## trunk/docs/project_code/Wiki-20/wiki20/templates/edit.html
r4806 r4831 9 9 <xi:include href="footer.html" /> 10 10 <xi:include href="master.html" /> 11 11 <!-- ##{Head} --> 12 12 <head> 13 13 <meta content="text/html; charset=UTF-8" http-equiv="content-type" py:replace="''"/> 14 14 <title>Editing: ${wikipage.pagename}</title> 15 15 </head> 16 16 <!-- ## --> 17 17 <body> 18 18 … … 22 22 You can return to the <a href="/">FrontPage</a>. 23 23 </div> 24 24 <!-- ##{Form}--> 25 25 <div> 26 26 <form action="/save" method="post"> … … 31 31 </div> 32 32 </div> 33 33 <!-- ##--> 34 34 </body> 35 35 </html> trunk/docs/project_code/Wiki-20/wiki20/templates/page.html
r4806 r4831 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 3 <html xmlns="http://www.w3.org/1999/xhtml" 4 xmlns:py="http://genshi.edgewall.org/" 5 xmlns:xi="http://www.w3.org/2001/XInclude"> 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 3 <html 4 xmlns="http://www.w3.org/1999/xhtml" 5 xmlns:py="http://genshi.edgewall.org/" 6 xmlns:xi="http://www.w3.org/2001/XInclude"> 6 7 7 <xi:include href="header.html" /> 8 <xi:include href="sidebars.html" />9 <xi:include href="footer.html" />10 <xi:include href="master.html" />8 9 <xi:include href="header.html" /> 10 <xi:include href="footer.html" /> 11 <xi:include href="master.html" /> 11 12 12 13 <head> 13 <meta content="text/html; charset=UTF-8" http-equiv="content-type" py:replace="''"/>14 <title>${wikipage.pagename} - The TurboGears 2 Wiki</title>14 <meta content="text/html; charset=utf-8" http-equiv="Content-Type" py:replace="''"/> 15 <title>${wikipage.pagename} - The TurboGears 2 Wiki</title> 15 16 </head> 16 17 … … 18 19 19 20 <div class="main_content"> 20 <div style="float:right; width: 10em;"> Viewing 21 <span py:replace="wikipage.pagename">Page Name Goes Here</span> <br/> 21 <div style="float:right; width: 10em;"> Viewing 22 <!-- ##{PageName} --> 23 <span py:replace="wikipage.pagename">Page Name Goes Here</span> 24 <!-- ## --> 25 <br/> 22 26 You can return to the <a href="/">FrontPage</a>. 23 </div>24 25 <div py:replace="XML(content)">Formatted content goes here.</div>26 <a href="/edit/${wikipage.pagename}">Edit this page</a>27 <a href="/pagelist">View the page list</a>27 </div> 28 <!-- ##{PageContent} --> 29 <div py:replace="wikipage.data">Page text goes here.</div> 30 <!-- ## --> 31 <a href="/edit/${wikipage.pagename}">Edit this page</a> 28 32 </div> 29 33