##// END OF EJS Templates
helpers: use WebHelpers2 as much as possible - it supports Python3, and WebHelpers is dead...
Mads Kiilerich -
r7712:b077cf7e default
parent child Browse files
Show More
@@ -34,7 +34,7 b' from tg import request, config, tmpl_con'
34 from whoosh.index import open_dir, exists_in, EmptyIndexError
34 from whoosh.index import open_dir, exists_in, EmptyIndexError
35 from whoosh.qparser import QueryParser, QueryParserError
35 from whoosh.qparser import QueryParser, QueryParserError
36 from whoosh.query import Phrase, Prefix
36 from whoosh.query import Phrase, Prefix
37 from webhelpers.util import update_params
37 from webhelpers2.html.tools import update_params
38
38
39 from kallithea.lib.auth import LoginRequired
39 from kallithea.lib.auth import LoginRequired
40 from kallithea.lib.base import BaseRepoController, render
40 from kallithea.lib.base import BaseRepoController, render
@@ -120,8 +120,7 b' class SearchController(BaseRepoControlle'
120
120
121 def url_generator(**kw):
121 def url_generator(**kw):
122 q = urllib.quote(safe_str(c.cur_query))
122 q = urllib.quote(safe_str(c.cur_query))
123 return update_params("?q=%s&type=%s" \
123 return update_params("?q=%s&type=%s" % (q, safe_str(c.cur_type)), **kw)
124 % (q, safe_str(c.cur_type)), **kw)
125 repo_location = RepoModel().repos_path
124 repo_location = RepoModel().repos_path
126 c.formated_results = Page(
125 c.formated_results = Page(
127 WhooshResultWrapper(search_type, searcher, matcher,
126 WhooshResultWrapper(search_type, searcher, matcher,
@@ -31,14 +31,14 b' from pygments.formatters.html import Htm'
31 from pygments import highlight as code_highlight
31 from pygments import highlight as code_highlight
32 from tg.i18n import ugettext as _
32 from tg.i18n import ugettext as _
33
33
34 from webhelpers.html import literal, HTML, escape
34 from webhelpers2.html import literal, HTML, escape
35 from webhelpers.html.tags import checkbox, end_form, hidden, link_to, \
35 from webhelpers2.html.tags import checkbox, end_form, hidden, link_to, \
36 select, submit, text, password, textarea, radio, form as insecure_form
36 select as webhelpers2_select, Option, Options, \
37 from webhelpers.number import format_byte_size
37 submit, text, password, textarea, radio, form as insecure_form
38 from webhelpers2.number import format_byte_size
38 from webhelpers.pylonslib import Flash as _Flash
39 from webhelpers.pylonslib import Flash as _Flash
39 from webhelpers.text import chop_at, truncate, wrap_paragraphs
40 from webhelpers2.text import chop_at, truncate, wrap_paragraphs
40 from webhelpers.html.tags import _set_input_attrs, _set_id_attr, \
41 from webhelpers2.html.tags import _input, NotGiven, _make_safe_id_component
41 convert_boolean_attrs, NotGiven, _make_safe_id_component
42
42
43 from kallithea.config.routing import url
43 from kallithea.config.routing import url
44 from kallithea.lib.annotate import annotate_highlight
44 from kallithea.lib.annotate import annotate_highlight
@@ -144,17 +144,29 b' def shorter(s, size=20, firstline=False,'
144 return s
144 return s
145
145
146
146
147 def _reset(name, value=None, id=NotGiven, type="reset", **attrs):
147 def reset(name, value, id=NotGiven, **attrs):
148 """
148 """Create a reset button, similar to webhelpers2.html.tags.submit ."""
149 Reset button
149 return _input("reset", name, value, id, attrs)
150 """
151 _set_input_attrs(attrs, type, name, value)
152 _set_id_attr(attrs, id, name)
153 convert_boolean_attrs(attrs, ["disabled"])
154 return HTML.input(**attrs)
155
150
156
151
157 reset = _reset
152 def select(name, selected_values, options, id=NotGiven, **attrs):
153 """Convenient wrapper of webhelpers2 to let it accept options as a tuple list"""
154 if isinstance(options, list):
155 l = []
156 for x in options:
157 try:
158 value, label = x
159 except ValueError: # too many values to unpack
160 if isinstance(x, basestring):
161 value = label = x
162 else:
163 log.error('invalid select option %r', x)
164 raise
165 l.append(Option(label, value))
166 options = Options(l)
167 return webhelpers2_select(name, selected_values, options, id=id, **attrs)
168
169
158 safeid = _make_safe_id_component
170 safeid = _make_safe_id_component
159
171
160
172
@@ -18,7 +18,7 b' import logging'
18 import math
18 import math
19 import re
19 import re
20 from kallithea.config.routing import url
20 from kallithea.config.routing import url
21 from webhelpers.html import literal, HTML
21 from webhelpers2.html import literal, HTML
22 from webhelpers.paginate import Page as _Page
22 from webhelpers.paginate import Page as _Page
23
23
24 log = logging.getLogger(__name__)
24 log = logging.getLogger(__name__)
@@ -40,7 +40,7 b' import pwd'
40
40
41 import webob
41 import webob
42 import urlobject
42 import urlobject
43 from webhelpers.text import collapse, remove_formatting, strip_tags
43 from webhelpers2.text import collapse, remove_formatting, strip_tags
44
44
45 from tg.i18n import ugettext as _, ungettext
45 from tg.i18n import ugettext as _, ungettext
46 from kallithea.lib.vcs.utils.lazy import LazyProperty
46 from kallithea.lib.vcs.utils.lazy import LazyProperty
@@ -1495,7 +1495,7 b' class RepoGroup(Base, BaseDbModel):'
1495 @classmethod
1495 @classmethod
1496 def _generate_choice(cls, repo_group):
1496 def _generate_choice(cls, repo_group):
1497 """Return tuple with group_id and name as html literal"""
1497 """Return tuple with group_id and name as html literal"""
1498 from webhelpers.html import literal
1498 from webhelpers2.html import literal
1499 if repo_group is None:
1499 if repo_group is None:
1500 return (-1, u'-- %s --' % _('top level'))
1500 return (-1, u'-- %s --' % _('top level'))
1501 return repo_group.group_id, literal(cls.SEP.join(repo_group.full_path_splitted))
1501 return repo_group.group_id, literal(cls.SEP.join(repo_group.full_path_splitted))
@@ -44,6 +44,7 b' requirements = ['
44 "tgext.routes >= 0.2.0, < 1",
44 "tgext.routes >= 0.2.0, < 1",
45 "Beaker >= 1.7.0, < 2",
45 "Beaker >= 1.7.0, < 2",
46 "WebHelpers >= 1.3, < 1.4",
46 "WebHelpers >= 1.3, < 1.4",
47 "WebHelpers2 >= 2.0, < 2.1",
47 "FormEncode >= 1.3.0, < 1.4",
48 "FormEncode >= 1.3.0, < 1.4",
48 "SQLAlchemy >= 1.1, < 1.4",
49 "SQLAlchemy >= 1.1, < 1.4",
49 "Mako >= 0.9.0, < 1.1",
50 "Mako >= 0.9.0, < 1.1",
General Comments 0
You need to be logged in to leave comments. Login now