Ticket #962: wiki_page_templates-r3886.patch
| File wiki_page_templates-r3886.patch, 4.9 kB (added by cboos, 23 months ago) |
|---|
-
htdocs/css/wiki.css
16 16 margin: 1em 0 2em; 17 17 overflow: auto; 18 18 } 19 #template {vertical-align: middle; padding-top: 1em;} 19 20 20 21 /* Diff view */ 21 22 #overview .multi { color: #999 } -
trac/wiki/web_ui.py
316 316 317 317 if 'text' in req.args: 318 318 page.text = req.args.get('text') 319 elif 'template' in req.args: 320 template = req.args.get('template') 321 template_page = WikiPage(self.env, template, db=db) 322 if template_page.exists: 323 page.text = template_page.text 319 324 if action == 'preview': 320 325 page.readonly = 'readonly' in req.args 321 326 … … 404 409 if req.perm.has_permission('WIKI_MODIFY'): 405 410 attach_href = req.href.attachment('wiki', page.name) 406 411 412 413 templates = [t for t in WikiPage.select_names(self.env, 414 'PageTemplates/%', db)] 407 415 data.update({'action': 'view', 408 416 'page_html': page_html, 409 417 'comment_html': comment_html, … … 412 420 'attach_href': attach_href, 413 421 # Ask web spiders to not index old versions 414 422 'norobots': bool(version), 415 })423 'templates': templates}) 416 424 return 'wiki_view.html', data, None 417 425 418 426 # ITimelineEventProvider methods -
trac/wiki/model.py
155 155 "ORDER BY version DESC", (self.name, self.version)) 156 156 for version,time,author,comment,ipnr in cursor: 157 157 yield version,time,author,comment,ipnr 158 159 def select_names(cls, env, prefix=None, db=None): 160 if not db: 161 db = env.get_db_cnx() 162 cursor = db.cursor() 163 if prefix: 164 cursor.execute("SELECT name FROM wiki WHERE name LIKE %s" 165 " ORDER BY name", (prefix,)) 166 else: 167 cursor.execute("SELECT name FROM wiki ORDER BY name") 168 for name, in cursor: 169 yield name 170 171 select_names = classmethod(select_names) 172 -
templates/wiki_edit.html
62 62 </select> 63 63 </div> 64 64 <p><textarea id="text" class="wikitext" name="text" cols="80" rows="$edit_rows"> 65 $page.text 66 </textarea> 65 $page.text</textarea> 67 66 </p> 68 67 <script type="text/javascript"> 69 68 var scrollBarPos = document.getElementById("scroll_bar_pos"); -
templates/wiki_view.html
19 19 <li><a href="${href.wiki('RecentChanges')}">Index by Date</a></li> 20 20 <li class="last"> 21 21 <a href="${req.href.wiki(page.name, action='diff', version=page.version)}">Last Change</a> 22 </li> 22 </li> 23 23 </ul> 24 24 <hr /> 25 25 </div> 26 26 27 27 <div id="content" class="wiki"> 28 28 29 29 <py:if test="comment_html"> 30 30 <table id="info" summary="Revision info"> 31 31 <tbody> … … 50 50 <form method="get" action="${href.wiki(page.name)}"> 51 51 <div> 52 52 <input type="hidden" name="action" value="edit" /> 53 <input type="submit" value="${page.exists and 'Edit' or 'Create'} this page" accesskey="e" /> 53 <py:choose> 54 <py:when test="page.exists"> 55 <input type="submit" value="Edit this page" accesskey="e" /> 56 </py:when> 57 <py:otherwise> 58 <input type="submit" value="Create this page" accesskey="e" /> 59 <div py:if="templates" id="template"> 60 <label for="template">Using the template:</label> 61 <select name="template"> 62 <option selected="${not 'PageTemplates/Default' in templates and 'selected' or None}" value="">(blank page)</option> 63 <option py:for="t in templates" py:attrs="form_attrs(selected=t=='PageTemplates/Default')">$t</option> 64 </select> 65 </div> 66 </py:otherwise> 67 </py:choose> 54 68 </div> 55 69 </form> 56 70 <py:if test="page.exists">
