Changeset 3524
- Timestamp:
- 04/17/08 05:12:23 (9 months ago)
- Files:
-
- zoomquiettranslation/plugins/KSTracTicketTemplate/0.10/En/tickettemplate/changelog.txt (modified) (1 diff)
- zoomquiettranslation/plugins/KSTracTicketTemplate/0.10/En/tickettemplate/description.tmpl (added)
- zoomquiettranslation/plugins/KSTracTicketTemplate/0.10/En/tickettemplate/readme.txt (modified) (2 diffs)
- zoomquiettranslation/plugins/KSTracTicketTemplate/0.10/En/tickettemplate/templates/admin_tickettemplate.cs (modified) (2 diffs)
- zoomquiettranslation/plugins/KSTracTicketTemplate/0.10/En/tickettemplate/ttadmin.py (modified) (5 diffs)
- zoomquiettranslation/plugins/KSTracTicketTemplate/0.10/En/tickettemplate/version.txt (modified) (1 diff)
- zoomquiettranslation/plugins/KSTracTicketTemplate/0.10/Zh/tickettemplate/changelog.txt (modified) (1 diff)
- zoomquiettranslation/plugins/KSTracTicketTemplate/0.10/Zh/tickettemplate/description.tmpl (added)
- zoomquiettranslation/plugins/KSTracTicketTemplate/0.10/Zh/tickettemplate/readme.txt (modified) (2 diffs)
- zoomquiettranslation/plugins/KSTracTicketTemplate/0.10/Zh/tickettemplate/templates/admin_tickettemplate.cs (modified) (2 diffs)
- zoomquiettranslation/plugins/KSTracTicketTemplate/0.10/Zh/tickettemplate/ttadmin.py (modified) (5 diffs)
- zoomquiettranslation/plugins/KSTracTicketTemplate/0.10/Zh/tickettemplate/version.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
zoomquiettranslation/plugins/KSTracTicketTemplate/0.10/En/tickettemplate/changelog.txt
r3138 r3524 1 TicketTemplate 0.4 (Mar 25, 2008) 2 3 * add preview to admin page 4 * use one persistence file to store all template texts 5 * fixed bug: leading space in template text is not stripped now 6 * add some default template text for trac's default install: 7 * defect 8 * enhancement 9 * task 10 * default 11 1 12 TicketTemplate 0.3 (Jan 2, 2008) 2 13 zoomquiettranslation/plugins/KSTracTicketTemplate/0.10/En/tickettemplate/readme.txt
r3273 r3524 8 8 9 9 = Install = 10 11 '''IMPORTANT''': Please BACKUP you ticket templates if you are upgrading this plugin. 12 10 13 You can install this software as normal Trac plugin. 11 14 … … 30 33 }}} 31 34 35 6. If you are installing this plugin first time, you can copy description.tmpl to your/trac/environment/templates to utilize some default ticket templates. 32 36 33 37 = Prerequisite = zoomquiettranslation/plugins/KSTracTicketTemplate/0.10/En/tickettemplate/templates/admin_tickettemplate.cs
r3138 r3524 2 2 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 3 3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 4 <html xmlns="http://www.w3.org/1999/xhtml" lang=" cn" xml:lang="cn" charset="utf-8">4 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en" charset="utf-8"> 5 5 <head><title>Available Projects</title></head> 6 6 <body> … … 20 20 21 21 <div class="field"> 22 <label for="description">Full description (you may use <a tabindex="42" href="<?cs 22 <label for="description">Full description (you may use <a tabindex="42" href="<?cs 23 23 var:$trac.href.wiki ?>/WikiFormatting">WikiFormatting</a> here):</label><br /> 24 <textarea id="description" name="description" class="wikitext" rows="20" style="width:63%" name="tt_text"><?cs var:tt_text ?></textarea> 24 <textarea id="description" name="description" class="wikitext" rows="20" cols="66" name="tt_text"><?cs var:tt_text ?></textarea> 25 <?cs 26 if:description_preview ?> 27 <fieldset id="preview"> 28 <legend>preview</legend> 29 <?cs var:description_preview ?> 30 </fieldset><?cs 31 /if ?> 25 32 </div> 26 27 </form> 33 28 34 29 35 <script type="text/javascript" src="<?cs 30 36 var:htdocs_location ?>js/wikitoolbar.js"></script> 31 37 38 <div class="buttons"> 39 <input type="submit" name="preview" value="preview" accesskey="r" /> 40 <input type="submit" value="submit" /> 41 </div> 42 43 </form> 44 45 46 32 47 </html> zoomquiettranslation/plugins/KSTracTicketTemplate/0.10/En/tickettemplate/ttadmin.py
r3523 r3524 13 13 from trac.web.chrome import INavigationContributor 14 14 from trac.web.chrome import * 15 from trac.wiki import wiki_to_html, wiki_to_oneliner 15 16 16 17 from trac.ticket import Milestone, Ticket, TicketSystem, ITicketManipulator … … 23 24 24 25 import os 25 import base6426 import pickle 26 27 27 28 __all__ = ['TicketTemplateModule'] … … 120 121 121 122 if req.method == 'POST': 122 tt_file_name = "description_%s.tmpl" % req.args.get('type')123 tt_file_name_default = "description_%s.tmpl" % "default"124 125 tt_file = os.path.join(self.env.path, "templates", tt_file_name)126 tt_file_default = os.path.join(self.env.path, "templates", tt_file_name_default)123 # tt_file_name = "description_%s.tmpl" % req.args.get('type') 124 # tt_file_name_default = "description_%s.tmpl" % "default" 125 # 126 # tt_file = os.path.join(self.env.path, "templates", tt_file_name) 127 # tt_file_default = os.path.join(self.env.path, "templates", tt_file_name_default) 127 128 128 129 # Load … … 134 135 # Save 135 136 elif req.args.get('savetickettemplate'): 136 tt_text = req.args.get('description'). strip().replace('\r', '')137 tt_text = req.args.get('description').replace('\r', '') 137 138 tt_name = req.args.get('type') 138 139 139 140 self._saveTemplateText(tt_name, tt_text) 140 141 req.hdf['tt_text'] = tt_text 142 143 # Save 144 elif req.args.get('preview'): 145 tt_text = req.args.get('description').replace('\r', '') 146 tt_name = req.args.get('type') 147 148 description_preview = self._previewTemplateText(tt_name, tt_text, req) 149 req.hdf['tt_text'] = tt_text 150 req.hdf['description_preview'] = description_preview 141 151 142 152 return 'admin_tickettemplate.cs', None 153 154 def _previewTemplateText(self, tt_name, tt_text, req): 155 """ preview ticket template 156 """ 157 db = self.env.get_db_cnx() 158 description_preview = wiki_to_html(tt_text, self.env, req, db) 159 return description_preview 160 143 161 144 162 # ITemplateProvider … … 165 183 166 184 # private methods 167 def _getTTFilePath(self , tt_name):185 def _getTTFilePath(self): 168 186 """ get ticket template file path 169 187 """ 170 tt_file_name = "description_%s.tmpl" % base64.encodestring(tt_name.encode("utf-8")) 171 tt_file = os.path.join(self.env.path, "templates", tt_file_name) 172 return tt_file 173 174 def _loadTemplateText(self, tt_name): 175 """ load ticket template text from file. 176 """ 177 tt_file = self._getTTFilePath(tt_name) 178 tt_file_default = self._getTTFilePath(u"default") 188 return os.path.join(self.env.path, "templates", "description.tmpl") 189 190 def _loadTTDict(self): 191 """ load ticket template dict from file. 192 """ 193 tt_file = self._getTTFilePath() 179 194 180 195 try: 181 fp = open(tt_file,'r ')182 tt_ text= fp.read()196 fp = open(tt_file,'rb') 197 tt_stream = fp.read() 183 198 fp.close() 184 199 except: 185 try: 186 fp = open(tt_file_default, 'r') 187 tt_text = fp.read() 188 fp.close() 189 except: 190 tt_text = "" 191 192 return tt_text 193 200 tt_stream = "" 201 202 try: 203 tt_dict = pickle.loads(tt_stream) 204 except: 205 tt_dict = {} 206 207 return tt_dict 208 209 def _loadTemplateText(self, tt_name): 210 """ get tempate text from tt_dict. 211 return tt_text if found in tt_dict 212 or default tt_text if exists 213 or empty string if default not exists. 214 """ 215 tt_dict = self._loadTTDict() 216 return tt_dict.get(tt_name, tt_dict.get("default", "")) 217 194 218 def _saveTemplateText(self, tt_name, tt_text): 195 219 """ save ticket template text to file. 196 220 """ 197 tt_file = self._getTTFilePath(tt_name) 198 221 # dump tt_dict 222 tt_dict = self._loadTTDict() 223 tt_dict[tt_name] = tt_text 224 tt_stream = pickle.dumps(tt_dict) 225 226 tt_file = self._getTTFilePath() 199 227 try: 200 fp = open(tt_file,'w ')201 except Exception, e:228 fp = open(tt_file,'wb') 229 except: 202 230 raise TracError("Can't write ticket template file %s" % tt_file) 203 231 else: 204 fp.write(tt_ text.encode("utf-8"))232 fp.write(tt_stream) 205 233 fp.close() 206 234 zoomquiettranslation/plugins/KSTracTicketTemplate/0.10/En/tickettemplate/version.txt
r3523 r3524 1 0. 31 0.4 zoomquiettranslation/plugins/KSTracTicketTemplate/0.10/Zh/tickettemplate/changelog.txt
r3138 r3524 1 TicketTemplate 0.4 (Mar 25, 2008) 2 3 * add preview to admin page 4 * use one persistence file to store all template texts 5 * fixed bug: leading space in template text is not stripped now 6 * add some default template text for trac's default install: 7 * defect 8 * enhancement 9 * task 10 * default 11 1 12 TicketTemplate 0.3 (Jan 2, 2008) 2 13 zoomquiettranslation/plugins/KSTracTicketTemplate/0.10/Zh/tickettemplate/readme.txt
r3273 r3524 8 8 9 9 = Install = 10 11 '''IMPORTANT''': Please BACKUP you ticket templates if you are upgrading this plugin. 12 10 13 You can install this software as normal Trac plugin. 11 14 … … 30 33 }}} 31 34 35 6. If you are installing this plugin first time, you can copy description.tmpl to your/trac/environment/templates to utilize some default ticket templates. 32 36 33 37 = Prerequisite = zoomquiettranslation/plugins/KSTracTicketTemplate/0.10/Zh/tickettemplate/templates/admin_tickettemplate.cs
r3138 r3524 10 10 11 11 12 <form id="savetickettemplate" method="post">12 <form id="savetickettemplate" action="tickettemplate" method="post"> 13 13 14 14 <div class="field"><label for="type">ç§ç±»:</label> <?cs … … 22 22 <div class="field"> 23 23 <label for="description">å®æŽæè¿° (<a tabindex="42" href="<?cs var:$trac.href.wiki ?>/WikiFormatting">Wikiæ ŒåŒ</a> åž®å©):</label><br /> 24 <textarea id="description" name="description" class="wikitext" rows="20" style="width:63%" name="tt_text"><?cs var:tt_text ?></textarea> 24 <textarea id="description" name="description" class="wikitext" rows="20" cols="66" name="tt_text"><?cs var:tt_text ?></textarea> 25 <?cs 26 if:description_preview ?> 27 <fieldset id="preview"> 28 <legend>æè¿°é¢è§</legend> 29 <?cs var:description_preview ?> 30 </fieldset><?cs 31 /if ?> 25 32 </div> 26 27 </form> 33 28 34 29 35 <script type="text/javascript" src="<?cs 30 36 var:htdocs_location ?>js/wikitoolbar.js"></script> 31 37 38 <div class="buttons"> 39 <input type="submit" name="preview" value="é¢è§" accesskey="r" /> 40 <input type="submit" value="åé" /> 41 </div> 42 43 </form> 44 45 46 32 47 </html> zoomquiettranslation/plugins/KSTracTicketTemplate/0.10/Zh/tickettemplate/ttadmin.py
r3523 r3524 13 13 from trac.web.chrome import INavigationContributor 14 14 from trac.web.chrome import * 15 from trac.wiki import wiki_to_html, wiki_to_oneliner 15 16 16 17 from trac.ticket import Milestone, Ticket, TicketSystem, ITicketManipulator … … 23 24 24 25 import os 25 import base6426 import pickle 26 27 27 28 __all__ = ['TicketTemplateModule'] … … 121 122 122 123 if req.method == 'POST': 123 tt_file_name = "description_%s.tmpl" % req.args.get('type')124 tt_file_name_default = "description_%s.tmpl" % "default"125 126 tt_file = os.path.join(self.env.path, "templates", tt_file_name)127 tt_file_default = os.path.join(self.env.path, "templates", tt_file_name_default)124 # tt_file_name = "description_%s.tmpl" % req.args.get('type') 125 # tt_file_name_default = "description_%s.tmpl" % "default" 126 # 127 # tt_file = os.path.join(self.env.path, "templates", tt_file_name) 128 # tt_file_default = os.path.join(self.env.path, "templates", tt_file_name_default) 128 129 129 130 # Load … … 135 136 # Save 136 137 elif req.args.get('savetickettemplate'): 137 tt_text = req.args.get('description'). strip().replace('\r', '')138 tt_text = req.args.get('description').replace('\r', '') 138 139 tt_name = req.args.get('type') 139 140 140 141 self._saveTemplateText(tt_name, tt_text) 141 142 req.hdf['tt_text'] = tt_text 143 144 # Save 145 elif req.args.get('preview'): 146 tt_text = req.args.get('description').replace('\r', '') 147 tt_name = req.args.get('type') 148 149 description_preview = self._previewTemplateText(tt_name, tt_text, req) 150 req.hdf['tt_text'] = tt_text 151 req.hdf['description_preview'] = description_preview 142 152 143 153 return 'admin_tickettemplate.cs', None 154 155 def _previewTemplateText(self, tt_name, tt_text, req): 156 """ preview ticket template 157 """ 158 db = self.env.get_db_cnx() 159 description_preview = wiki_to_html(tt_text, self.env, req, db) 160 return description_preview 161 144 162 145 163 # ITemplateProvider … … 166 184 167 185 # private methods 168 def _getTTFilePath(self , tt_name):186 def _getTTFilePath(self): 169 187 """ get ticket template file path 170 188 """ 171 tt_file_name = "description_%s.tmpl" % base64.encodestring(tt_name.encode("utf-8")) 172 tt_file = os.path.join(self.env.path, "templates", tt_file_name) 173 return tt_file 174 175 def _loadTemplateText(self, tt_name): 176 """ load ticket template text from file. 177 """ 178 tt_file = self._getTTFilePath(tt_name) 179 tt_file_default = self._getTTFilePath(u"default") 189 return os.path.join(self.env.path, "templates", "description.tmpl") 190 191 def _loadTTDict(self): 192 """ load ticket template dict from file. 193 """ 194 tt_file = self._getTTFilePath() 180 195 181 196 try: 182 fp = open(tt_file,'r ')183 tt_ text= fp.read()197 fp = open(tt_file,'rb') 198 tt_stream = fp.read() 184 199 fp.close() 185 200 except: 186 try: 187 fp = open(tt_file_default, 'r') 188 tt_text = fp.read() 189 fp.close() 190 except: 191 tt_text = "" 192 193 return tt_text 194 201 tt_stream = "" 202 203 try: 204 tt_dict = pickle.loads(tt_stream) 205 except: 206 tt_dict = {} 207 208 return tt_dict 209 210 def _loadTemplateText(self, tt_name): 211 """ get tempate text from tt_dict. 212 return tt_text if found in tt_dict 213 or default tt_text if exists 214 or empty string if default not exists. 215 """ 216 tt_dict = self._loadTTDict() 217 return tt_dict.get(tt_name, tt_dict.get("default", "")) 218 195 219 def _saveTemplateText(self, tt_name, tt_text): 196 220 """ save ticket template text to file. 197 221 """ 198 tt_file = self._getTTFilePath(tt_name) 199 222 # dump tt_dict 223 tt_dict = self._loadTTDict() 224 tt_dict[tt_name] = tt_text 225 tt_stream = pickle.dumps(tt_dict) 226 227 tt_file = self._getTTFilePath() 200 228 try: 201 fp = open(tt_file,'w ')202 except Exception, e:229 fp = open(tt_file,'wb') 230 except: 203 231 raise TracError("Can't write ticket template file %s" % tt_file) 204 232 else: 205 fp.write(tt_ text.encode("utf-8"))233 fp.write(tt_stream) 206 234 fp.close() 207 235 zoomquiettranslation/plugins/KSTracTicketTemplate/0.10/Zh/tickettemplate/version.txt
r3523 r3524 1 0. 31 0.4
