| 145 | | def send_project_index(req, mpr, dir): |
| 146 | | req.content_type = 'text/html' |
| 147 | | req.write('<html><head><title>Available Projects</title></head>') |
| 148 | | req.write('<body><h1>Available Projects</h1><ul>') |
| 149 | | for project in os.listdir(dir): |
| 150 | | req.write('<li><a href="%s">%s</a></li>' |
| 151 | | % (href_join(mpr.idx_location, project), project)) |
| 152 | | req.write('</ul></body><html>') |
| | 145 | def send_project_index(req, mpr, dir, options): |
| | 146 | if options.has_key('TracEnvIndexTemplate'): |
| | 147 | try: |
| | 148 | tmpl_path,tmpl_idx = os.path.split(options['TracEnvIndexTemplate']) |
| | 149 | |
| | 150 | from trac.web.clearsilver import HDFWrapper |
| | 151 | mpr.hdf = HDFWrapper(loadpaths=[tmpl_path]) |
| | 153 | tmpl_vars = {} |
| | 154 | if options.has_key('TracTemplateVars'): |
| | 155 | pairs = options['TracTemplateVars'].split(',') |
| | 156 | for pair in pairs: |
| | 157 | key,val = pair.split('=') |
| | 158 | tmpl_vars[key] = val |
| | 159 | mpr.hdf['template'] = tmpl_vars |
| | 160 | |
| | 161 | projs = [] |
| | 162 | for project in os.listdir(dir): |
| | 163 | env = open_environment(os.path.join(dir, project)) |
| | 164 | descr = env.get_config('project', 'descr', '') |
| | 165 | name = env.get_config('project', 'name', '') |
| | 166 | uri = href_join(mpr.idx_location, project) |
| | 167 | projs.append({'name': name, 'descr': descr, 'uri':uri}) |
| | 168 | mpr.hdf['projects'] = projs |
| | 169 | mpr.display(tmpl_idx, response=200) |
| | 170 | except RequestDone: |
| | 171 | pass |
| | 172 | else: |
| | 173 | req.content_type = 'text/html' |
| | 174 | req.write('<html><head><title>Available Projects</title></head>') |
| | 175 | req.write('<body><h1>Available Projects</h1><ul>') |
| | 176 | for project in os.listdir(dir): |
| | 177 | req.write('<li><a href="%s">%s</a></li>' |
| | 178 | % (href_join(mpr.idx_location, project), project)) |
| | 179 | req.write('</ul></body><html>') |
| | 180 | |