##// END OF EJS Templates
meta-tags: cleanup support for metatags....
marcink -
r2091:90bf6103 default
parent child Browse files
Show More
@@ -928,52 +928,67 b' def gravatar_with_user(request, author, '
928 return _render('gravatar_with_user', author, show_disabled=show_disabled)
928 return _render('gravatar_with_user', author, show_disabled=show_disabled)
929
929
930
930
931 def desc_stylize(value):
931 tags_paterns = OrderedDict((
932 ('lang', (re.compile(r'\[(lang|language)\ \=\>\ *([a-zA-Z\-\/\#\+\.]*)\]'),
933 '<div class="metatag" tag="lang">\\2</div>')),
934
935 ('see', (re.compile(r'\[see\ \=\&gt;\ *([a-zA-Z0-9\/\=\?\&amp;\ \:\/\.\-]*)\]'),
936 '<div class="metatag" tag="see">see =&gt; \\1 </div>')),
937
938 ('url', (re.compile(r'\[url\ \=\&gt;\ \[([a-zA-Z0-9\ \.\-\_]+)\]\((.*?)\)\]'),
939 '<div class="metatag" tag="url"> <a href="\\2">\\1</a> </div>')),
940
941 ('license', (re.compile(r'\[license\ \=\&gt;\ *([a-zA-Z0-9\/\=\?\&amp;\ \:\/\.\-]*)\]'),
942 '<div class="metatag" tag="license"><a href="http:\/\/www.opensource.org/licenses/\\1">\\1</a></div>')),
943
944 ('ref', (re.compile(r'\[(requires|recommends|conflicts|base)\ \=\&gt;\ *([a-zA-Z0-9\-\/]*)\]'),
945 '<div class="metatag" tag="ref \\1">\\1 =&gt; <a href="/\\2">\\2</a></div>')),
946
947 ('state', (re.compile(r'\[(stable|featured|stale|dead|dev)\]'),
948 '<div class="metatag" tag="state \\1">\\1</div>')),
949
950 # label in grey
951 ('label', (re.compile(r'\[([a-z]+)\]'),
952 '<div class="metatag" tag="label">\\1</div>')),
953
954 # generic catch all in grey
955 ('generic', (re.compile(r'\[([a-zA-Z0-9\.\-\_]+)\]'),
956 '<div class="metatag" tag="generic">\\1</div>')),
957 ))
958
959
960 def extract_metatags(value):
932 """
961 """
933 converts tags from value into html equivalent
962 Extract supported meta-tags from given text value
934
935 :param value:
936 """
963 """
937 if not value:
964 if not value:
938 return ''
965 return ''
939
966
940 value = re.sub(r'\[see\ \=\>\ *([a-zA-Z0-9\/\=\?\&\ \:\/\.\-]*)\]',
967 tags = []
941 '<div class="metatag" tag="see">see =&gt; \\1 </div>', value)
968 for key, val in tags_paterns.items():
942 value = re.sub(r'\[license\ \=\>\ *([a-zA-Z0-9\/\=\?\&\ \:\/\.\-]*)\]',
969 pat, replace_html = val
943 '<div class="metatag" tag="license"><a href="http:\/\/www.opensource.org/licenses/\\1">\\1</a></div>', value)
970 tags.extend([(key, x.group()) for x in pat.finditer(value)])
944 value = re.sub(r'\[(requires|recommends|conflicts|base)\ \=\>\ *([a-zA-Z0-9\-\/]*)\]',
971 value = pat.sub('', value)
945 '<div class="metatag" tag="\\1">\\1 =&gt; <a href="/\\2">\\2</a></div>', value)
946 value = re.sub(r'\[(lang|language)\ \=\>\ *([a-zA-Z\-\/\#\+]*)\]',
947 '<div class="metatag" tag="lang">\\2</div>', value)
948 value = re.sub(r'\[([a-z]+)\]',
949 '<div class="metatag" tag="\\1">\\1</div>', value)
950
972
951 return value
973 return tags, value
952
974
953
975
954 def escaped_stylize(value):
976 def style_metatag(tag_type, value):
955 """
977 """
956 converts tags from value into html equivalent, but escaping its value first
978 converts tags from value into html equivalent
957 """
979 """
958 if not value:
980 if not value:
959 return ''
981 return ''
960
982
961 # Using default webhelper escape method, but has to force it as a
983 html_value = value
962 # plain unicode instead of a markup tag to be used in regex expressions
984 tag_data = tags_paterns.get(tag_type)
963 value = unicode(escape(safe_unicode(value)))
985 if tag_data:
986 pat, replace_html = tag_data
987 # convert to plain `unicode` instead of a markup tag to be used in
988 # regex expressions. safe_unicode doesn't work here
989 html_value = pat.sub(replace_html, unicode(value))
964
990
965 value = re.sub(r'\[see\ \=\&gt;\ *([a-zA-Z0-9\/\=\?\&amp;\ \:\/\.\-]*)\]',
991 return html_value
966 '<div class="metatag" tag="see">see =&gt; \\1 </div>', value)
967 value = re.sub(r'\[license\ \=\&gt;\ *([a-zA-Z0-9\/\=\?\&amp;\ \:\/\.\-]*)\]',
968 '<div class="metatag" tag="license"><a href="http:\/\/www.opensource.org/licenses/\\1">\\1</a></div>', value)
969 value = re.sub(r'\[(requires|recommends|conflicts|base)\ \=\&gt;\ *([a-zA-Z0-9\-\/]*)\]',
970 '<div class="metatag" tag="\\1">\\1 =&gt; <a href="/\\2">\\2</a></div>', value)
971 value = re.sub(r'\[(lang|language)\ \=\&gt;\ *([a-zA-Z\-\/\#\+]*)\]',
972 '<div class="metatag" tag="lang">\\2</div>', value)
973 value = re.sub(r'\[([a-z]+)\]',
974 '<div class="metatag" tag="\\1">\\1</div>', value)
975
976 return value
977
992
978
993
979 def bool2icon(value):
994 def bool2icon(value):
@@ -220,12 +220,7 b' class RepoModel(BaseModel):'
220 cs_cache.get('message'))
220 cs_cache.get('message'))
221
221
222 def desc(desc):
222 def desc(desc):
223 if c.visual.stylify_metatags:
223 return _render('repo_desc', desc, c.visual.stylify_metatags)
224 desc = h.urlify_text(h.escaped_stylize(desc))
225 else:
226 desc = h.urlify_text(h.html_escape(desc))
227
228 return _render('repo_desc', desc)
229
224
230 def state(repo_state):
225 def state(repo_state):
231 return _render("repo_state", repo_state)
226 return _render("repo_state", repo_state)
@@ -694,14 +694,8 b' class RepoGroupModel(BaseModel):'
694 return _render("last_change", last_change)
694 return _render("last_change", last_change)
695
695
696 def desc(desc, personal):
696 def desc(desc, personal):
697 prefix = h.escaped_stylize(u'[personal] ') if personal else ''
697 return _render(
698
698 'repo_group_desc', desc, personal, c.visual.stylify_metatags)
699 if c.visual.stylify_metatags:
700 desc = h.urlify_text(prefix + h.escaped_stylize(desc))
701 else:
702 desc = h.urlify_text(prefix + h.html_escape(desc))
703
704 return _render('repo_group_desc', desc)
705
699
706 def repo_group_actions(repo_group_id, repo_group_name, gr_count):
700 def repo_group_actions(repo_group_id, repo_group_name, gr_count):
707 return _render(
701 return _render(
@@ -71,14 +71,31 b''
71 }
71 }
72 }
72 }
73
73
74 [tag="featured"] { &:extend(.tag1); }
74 [tag="generic"] { &:extend(.tag0); }
75 [tag="stale"] { &:extend(.tag2); }
75 [tag="label"] { &:extend(.tag0); }
76 [tag="dead"] { &:extend(.tag3); }
76
77 [tag="lang"] { &:extend(.tag4); }
77 [tag="state featured"] { &:extend(.tag1); }
78 [tag="license"] { &:extend(.tag5); }
78 [tag="state dev"] { &:extend(.tag1); }
79 [tag="requires"] { &:extend(.tag6); }
79 [tag="ref base"] { &:extend(.tag1); }
80 [tag="recommends"] { &:extend(.tag7); }
80
81 [tag="state stable"] { &:extend(.tag2); }
82 [tag="state stale"] { &:extend(.tag2); }
83
84 [tag="ref requires"] { &:extend(.tag3); }
85
86 [tag="state dead"] { &:extend(.tag4); }
87
88 [tag="ref conflicts"] { &:extend(.tag4); }
89
90 [tag="license"] { &:extend(.tag6); }
91
92 [tag="lang"] { &:extend(.tag7); }
93 [tag="language"] { &:extend(.tag7); }
94 [tag="ref recommends"] { &:extend(.tag7); }
95
81 [tag="see"] { &:extend(.tag8); }
96 [tag="see"] { &:extend(.tag8); }
97 [tag="url"] { &:extend(.tag8); }
98
82
99
83 .perm_overriden {
100 .perm_overriden {
84 text-decoration: line-through;
101 text-decoration: line-through;
@@ -46,6 +46,12 b''
46 </div>
46 </div>
47 <div class="textarea editor">
47 <div class="textarea editor">
48 ${h.textarea('group_description',cols=23,rows=5,class_="medium")}
48 ${h.textarea('group_description',cols=23,rows=5,class_="medium")}
49 <% metatags_url = h.literal('''<a href="#metatagsShow" onclick="$('#meta-tags-desc').toggle();return false">meta-tags</a>''') %>
50 <span class="help-block">${_('Plain text format with support of {metatags}').format(metatags=metatags_url)|n}</span>
51 <span id="meta-tags-desc" style="display: none">
52 <%namespace name="dt" file="/data_table/_dt_elements.mako"/>
53 ${dt.metatags_help()}
54 </span>
49 </div>
55 </div>
50 </div>
56 </div>
51
57
@@ -43,6 +43,12 b''
43 </div>
43 </div>
44 <div class="textarea text-area editor">
44 <div class="textarea text-area editor">
45 ${h.textarea('group_description',cols=23,rows=5,class_="medium")}
45 ${h.textarea('group_description',cols=23,rows=5,class_="medium")}
46 <% metatags_url = h.literal('''<a href="#metatagsShow" onclick="$('#meta-tags-desc').toggle();return false">meta-tags</a>''') %>
47 <span class="help-block">${_('Plain text format with support of {metatags}').format(metatags=metatags_url)|n}</span>
48 <span id="meta-tags-desc" style="display: none">
49 <%namespace name="dt" file="/data_table/_dt_elements.mako"/>
50 ${dt.metatags_help()}
51 </span>
46 </div>
52 </div>
47 </div>
53 </div>
48
54
@@ -44,7 +44,12 b''
44 </div>
44 </div>
45 <div class="textarea editor">
45 <div class="textarea editor">
46 ${h.textarea('repo_description')}
46 ${h.textarea('repo_description')}
47 <span class="help-block">${_('Keep it short and to the point. Use a README file for longer descriptions.')}</span>
47 <% metatags_url = h.literal('''<a href="#metatagsShow" onclick="$('#meta-tags-desc').toggle();return false">meta-tags</a>''') %>
48 <span class="help-block">${_('Plain text format with support of {metatags}. Add a README file for longer descriptions').format(metatags=metatags_url)|n}</span>
49 <span id="meta-tags-desc" style="display: none">
50 <%namespace name="dt" file="/data_table/_dt_elements.mako"/>
51 ${dt.metatags_help()}
52 </span>
48 </div>
53 </div>
49 </div>
54 </div>
50 <div class="field">
55 <div class="field">
@@ -129,7 +129,13 b''
129 <div class="textarea text-area editor">
129 <div class="textarea text-area editor">
130 ${c.form['repo_description'].render(css_class='medium', oid='repo_description')|n}
130 ${c.form['repo_description'].render(css_class='medium', oid='repo_description')|n}
131 ${c.form.render_error(request, c.form['repo_description'])|n}
131 ${c.form.render_error(request, c.form['repo_description'])|n}
132 <p class="help-block">${_('Keep it short and to the point. Use a README file for longer descriptions.')}</p>
132
133 <% metatags_url = h.literal('''<a href="#metatagsShow" onclick="$('#meta-tags-desc').toggle();return false">meta-tags</a>''') %>
134 <span class="help-block">${_('Plain text format with support of {metatags}. Add a README file for longer descriptions').format(metatags=metatags_url)|n}</span>
135 <span id="meta-tags-desc" style="display: none">
136 <%namespace name="dt" file="/data_table/_dt_elements.mako"/>
137 ${dt.metatags_help()}
138 </span>
133 </div>
139 </div>
134 </div>
140 </div>
135
141
@@ -63,21 +63,10 b''
63 ${h.checkbox('rhodecode_stylify_metatags','True')}
63 ${h.checkbox('rhodecode_stylify_metatags','True')}
64 <label for="rhodecode_stylify_metatags">${_('Stylify recognised meta tags')}</label>
64 <label for="rhodecode_stylify_metatags">${_('Stylify recognised meta tags')}</label>
65 </div>
65 </div>
66 <span class="help-block">${_('Parses meta tags from repository description field and turns them into colored tags.')}</span>
66 <span class="help-block">${_('Parses meta tags from repository or repository group description fields and turns them into colored tags.')}</span>
67 <div>
67 <div>
68 <table>
68 <%namespace name="dt" file="/data_table/_dt_elements.mako"/>
69 <tr><td>[featured] </td><td><span class="metatag" tag="featured">featured</span></td></tr>
69 ${dt.metatags_help()}
70 <tr><td>[stale] </td><td><span class="metatag" tag="stale">stale</span></td></tr>
71 <tr><td>[dead] </td><td><span class="metatag" tag="dead">dead</span></td></tr>
72 <tr><td>[personal] </td><td><span class="metatag" tag="personal">personal</span></td></tr>
73
74 <tr><td>[lang =&gt; lang] </td><td><span class="metatag" tag="lang" >lang</span></td></tr>
75
76 <tr><td>[license =&gt; License] </td><td><span class="metatag" tag="license"><a href="http://www.opensource.org/licenses/License" >License</a></span></td></tr>
77 <tr><td>[requires =&gt; Repo] </td><td><span class="metatag" tag="requires" >requires =&gt; <a href="#" >Repo</a></span></td></tr>
78 <tr><td>[recommends =&gt; Repo] </td><td><span class="metatag" tag="recommends" >recommends =&gt; <a href="#" >Repo</a></span></td></tr>
79 <tr><td>[see =&gt; URI] </td><td><span class="metatag" tag="see">see =&gt; <a href="#">URI</a> </span></td></tr>
80 </table>
81 </div>
70 </div>
82 </div>
71 </div>
83 </div>
72 </div>
@@ -3,6 +3,39 b''
3 ## <%namespace name="dt" file="/data_table/_dt_elements.mako"/>
3 ## <%namespace name="dt" file="/data_table/_dt_elements.mako"/>
4 <%namespace name="base" file="/base/base.mako"/>
4 <%namespace name="base" file="/base/base.mako"/>
5
5
6 <%def name="metatags_help()">
7 <table>
8 <%
9 example_tags = [
10 ('state','[stable]'),
11 ('state','[stale]'),
12 ('state','[featured]'),
13 ('state','[dev]'),
14 ('state','[dead]'),
15
16 ('label','[personal]'),
17 ('generic','[v2.0.0]'),
18
19 ('lang','[lang =&gt; JavaScript]'),
20 ('license','[license =&gt; LicenseName]'),
21
22 ('ref','[requires =&gt; RepoName]'),
23 ('ref','[recommends =&gt; GroupName]'),
24 ('ref','[conflicts =&gt; SomeName]'),
25 ('ref','[base =&gt; SomeName]'),
26 ('url','[url =&gt; [linkName](https://rhodecode.com)]'),
27 ('see','[see =&gt; http://rhodecode.com]'),
28 ]
29 %>
30 % for tag_type, tag in example_tags:
31 <tr>
32 <td>${tag|n}</td>
33 <td>${h.style_metatag(tag_type, tag)|n}</td>
34 </tr>
35 % endfor
36 </table>
37 </%def>
38
6 ## REPOSITORY RENDERERS
39 ## REPOSITORY RENDERERS
7 <%def name="quick_menu(repo_name)">
40 <%def name="quick_menu(repo_name)">
8 <i class="icon-more"></i>
41 <i class="icon-more"></i>
@@ -74,8 +107,20 b''
74 </div>
107 </div>
75 </%def>
108 </%def>
76
109
77 <%def name="repo_desc(description)">
110 <%def name="repo_desc(description, stylify_metatags)">
78 <div class="truncate-wrap">${description}</div>
111 <%
112 tags, description = h.extract_metatags(description)
113 %>
114
115 <div class="truncate-wrap">
116 % if stylify_metatags:
117 % for tag_type, tag in tags:
118 ${h.style_metatag(tag_type, tag)|n}
119 % endfor
120 % endif
121 ${description}
122 </div>
123
79 </%def>
124 </%def>
80
125
81 <%def name="last_change(last_change)">
126 <%def name="last_change(last_change)">
@@ -168,8 +213,25 b''
168 </div>
213 </div>
169 </%def>
214 </%def>
170
215
171 <%def name="repo_group_desc(description)">
216 <%def name="repo_group_desc(description, personal, stylify_metatags)">
172 <div class="truncate-wrap">${description}</div>
217
218 <%
219 tags, description = h.extract_metatags(description)
220 %>
221
222 <div class="truncate-wrap">
223 % if personal:
224 <div class="metatag" tag="personal">${_('personal')}</div>
225 % endif
226
227 % if stylify_metatags:
228 % for tag_type, tag in tags:
229 ${h.style_metatag(tag_type, tag)|n}
230 % endfor
231 % endif
232 ${description}
233 </div>
234
173 </%def>
235 </%def>
174
236
175 <%def name="repo_group_actions(repo_group_id, repo_group_name, gr_count)">
237 <%def name="repo_group_actions(repo_group_id, repo_group_name, gr_count)">
@@ -49,7 +49,12 b''
49 </div>
49 </div>
50 <div class="textarea-repo textarea text-area editor">
50 <div class="textarea-repo textarea text-area editor">
51 ${h.textarea('description')}
51 ${h.textarea('description')}
52 <span class="help-block">${_('Keep it short and to the point. Use a README file for longer descriptions.')}</span>
52 <% metatags_url = h.literal('''<a href="#metatagsShow" onclick="$('#meta-tags-desc').toggle();return false">meta-tags</a>''') %>
53 <span class="help-block">${_('Plain text format with support of {metatags}. Add a README file for longer descriptions').format(metatags=metatags_url)|n}</span>
54 <span id="meta-tags-desc" style="display: none">
55 <%namespace name="dt" file="/data_table/_dt_elements.mako"/>
56 ${dt.metatags_help()}
57 </span>
53 </div>
58 </div>
54 </div>
59 </div>
55
60
@@ -82,11 +82,10 b''
82 ${_('Description')}:
82 ${_('Description')}:
83 </div>
83 </div>
84 <div class="right-content">
84 <div class="right-content">
85 %if c.visual.stylify_metatags:
85 <div class="input ${summary(c.show_stats)}">
86 <div class="input ${summary(c.show_stats)} desc">${h.urlify_text(h.escaped_stylize(c.rhodecode_db_repo.description))}</div>
86 <%namespace name="dt" file="/data_table/_dt_elements.mako"/>
87 %else:
87 ${dt.repo_desc(c.rhodecode_db_repo.description_safe, c.visual.stylify_metatags)}
88 <div class="input ${summary(c.show_stats)} desc">${h.urlify_text(h.html_escape(c.rhodecode_db_repo.description))}</div>
88 </div>
89 %endif
90 </div>
89 </div>
91 </div>
90 </div>
92
91
@@ -186,31 +186,115 b' def test_age_in_future(age_args, expecte'
186 assert translate(age(n + delt(**age_args), now=n, **kw)) == expected
186 assert translate(age(n + delt(**age_args), now=n, **kw)) == expected
187
187
188
188
189 def test_tag_exctrator():
189 @pytest.mark.parametrize("sample, expected_tags", [
190 sample = (
190 ((
191 "hello pta[tag] gog [[]] [[] sda ero[or]d [me =>>< sa]"
191 "hello world [stale]"
192 "[requires] [stale] [see<>=>] [see => http://url.com]"
192 ),
193 "[requires => url] [lang => python] [just a tag] <html_tag first='abc' attr=\"my.url?attr=&another=\"></html_tag>"
193 [
194 "[,d] [ => ULR ] [obsolete] [desc]]"
194 ('state', '[stale]'),
195 )
195 ]),
196 from rhodecode.lib.helpers import desc_stylize, escaped_stylize
196 # entry
197 res = desc_stylize(sample)
197 ((
198 assert '<div class="metatag" tag="tag">tag</div>' in res
198 "hello world [v2.0.0] [v1.0.0]"
199 assert '<div class="metatag" tag="obsolete">obsolete</div>' in res
199 ),
200 assert '<div class="metatag" tag="stale">stale</div>' in res
200 [
201 assert '<div class="metatag" tag="lang">python</div>' in res
201 ('generic', '[v2.0.0]'),
202 assert '<div class="metatag" tag="requires">requires =&gt; <a href="/url">url</a></div>' in res
202 ('generic', '[v1.0.0]'),
203 assert '<div class="metatag" tag="tag">tag</div>' in res
203 ]),
204 assert '<html_tag first=\'abc\' attr=\"my.url?attr=&another=\"></html_tag>' in res
204 # entry
205 ((
206 "he[ll]o wo[rl]d"
207 ),
208 [
209 ('label', '[ll]'),
210 ('label', '[rl]'),
211 ]),
212 # entry
213 ((
214 "hello world [stale]\n[featured]\n[stale] [dead] [dev]"
215 ),
216 [
217 ('state', '[stale]'),
218 ('state', '[featured]'),
219 ('state', '[stale]'),
220 ('state', '[dead]'),
221 ('state', '[dev]'),
222 ]),
223 # entry
224 ((
225 "hello world \n\n [stale] \n [url =&gt; [name](http://rc.com)]"
226 ),
227 [
228 ('state', '[stale]'),
229 ('url', '[url =&gt; [name](http://rc.com)]'),
230 ]),
231 # entry
232 ((
233 "hello pta[tag] gog [[]] [[] sda ero[or]d [me =&gt;>< sa]"
234 "[requires] [stale] [see<>=&gt;] [see =&gt; http://url.com]"
235 "[requires =&gt; url] [lang =&gt; python] [just a tag] "
236 "<html_tag first='abc' attr=\"my.url?attr=&another=\"></html_tag>"
237 "[,d] [ =&gt; ULR ] [obsolete] [desc]]"
238 ),
239 [
240 ('label', '[desc]'),
241 ('label', '[obsolete]'),
242 ('label', '[or]'),
243 ('label', '[requires]'),
244 ('label', '[tag]'),
245 ('state', '[stale]'),
246 ('lang', '[lang =&gt; python]'),
247 ('ref', '[requires =&gt; url]'),
248 ('see', '[see =&gt; http://url.com]'),
205
249
206 res_encoded = escaped_stylize(sample)
250 ]),
207 assert '<div class="metatag" tag="tag">tag</div>' in res_encoded
251
208 assert '<div class="metatag" tag="obsolete">obsolete</div>' in res_encoded
252 ], ids=no_newline_id_generator)
209 assert '<div class="metatag" tag="stale">stale</div>' in res_encoded
253 def test_metatag_extraction(sample, expected_tags):
210 assert '<div class="metatag" tag="lang">python</div>' in res_encoded
254 from rhodecode.lib.helpers import extract_metatags
211 assert '<div class="metatag" tag="requires">requires =&gt; <a href="/url">url</a></div>' in res_encoded
255 tags, value = extract_metatags(sample)
212 assert '<div class="metatag" tag="tag">tag</div>' in res_encoded
256 assert sorted(tags) == sorted(expected_tags)
213 assert '&lt;html_tag first=&#39;abc&#39; attr=&#34;my.url?attr=&amp;another=&#34;&gt;&lt;/html_tag&gt;' in res_encoded
257
258
259 @pytest.mark.parametrize("tag_data, expected_html", [
260
261 (('state', '[stable]'), '<div class="metatag" tag="state stable">stable</div>'),
262 (('state', '[stale]'), '<div class="metatag" tag="state stale">stale</div>'),
263 (('state', '[featured]'), '<div class="metatag" tag="state featured">featured</div>'),
264 (('state', '[dev]'), '<div class="metatag" tag="state dev">dev</div>'),
265 (('state', '[dead]'), '<div class="metatag" tag="state dead">dead</div>'),
266
267 (('label', '[personal]'), '<div class="metatag" tag="label">personal</div>'),
268 (('generic', '[v2.0.0]'), '<div class="metatag" tag="generic">v2.0.0</div>'),
269
270 (('lang', '[lang =&gt; JavaScript]'), '<div class="metatag" tag="lang">JavaScript</div>'),
271 (('lang', '[lang =&gt; C++]'), '<div class="metatag" tag="lang">C++</div>'),
272 (('lang', '[lang =&gt; C#]'), '<div class="metatag" tag="lang">C#</div>'),
273 (('lang', '[lang =&gt; Delphi/Object]'), '<div class="metatag" tag="lang">Delphi/Object</div>'),
274 (('lang', '[lang =&gt; Objective-C]'), '<div class="metatag" tag="lang">Objective-C</div>'),
275 (('lang', '[lang =&gt; .NET]'), '<div class="metatag" tag="lang">.NET</div>'),
276
277 (('license', '[license =&gt; BSD 3-clause]'), '<div class="metatag" tag="license"><a href="http:\/\/www.opensource.org/licenses/BSD 3-clause">BSD 3-clause</a></div>'),
278 (('license', '[license =&gt; GPLv3]'), '<div class="metatag" tag="license"><a href="http:\/\/www.opensource.org/licenses/GPLv3">GPLv3</a></div>'),
279 (('license', '[license =&gt; MIT]'), '<div class="metatag" tag="license"><a href="http:\/\/www.opensource.org/licenses/MIT">MIT</a></div>'),
280 (('license', '[license =&gt; AGPLv3]'), '<div class="metatag" tag="license"><a href="http:\/\/www.opensource.org/licenses/AGPLv3">AGPLv3</a></div>'),
281
282 (('ref', '[requires =&gt; RepoName]'), '<div class="metatag" tag="ref requires">requires =&gt; <a href="/RepoName">RepoName</a></div>'),
283 (('ref', '[recommends =&gt; GroupName]'), '<div class="metatag" tag="ref recommends">recommends =&gt; <a href="/GroupName">GroupName</a></div>'),
284 (('ref', '[conflicts =&gt; SomeName]'), '<div class="metatag" tag="ref conflicts">conflicts =&gt; <a href="/SomeName">SomeName</a></div>'),
285 (('ref', '[base =&gt; SomeName]'), '<div class="metatag" tag="ref base">base =&gt; <a href="/SomeName">SomeName</a></div>'),
286
287 (('see', '[see =&gt; http://rhodecode.com]'), '<div class="metatag" tag="see">see =&gt; http://rhodecode.com </div>'),
288
289 (('url', '[url =&gt; [linkName](https://rhodecode.com)]'), '<div class="metatag" tag="url"> <a href="https://rhodecode.com">linkName</a> </div>'),
290 (('url', '[url =&gt; [example link](https://rhodecode.com)]'), '<div class="metatag" tag="url"> <a href="https://rhodecode.com">example link</a> </div>'),
291 (('url', '[url =&gt; [v1.0.0](https://rhodecode.com)]'), '<div class="metatag" tag="url"> <a href="https://rhodecode.com">v1.0.0</a> </div>'),
292
293 ])
294 def test_metatags_stylize(tag_data, expected_html):
295 from rhodecode.lib.helpers import style_metatag
296 tag_type,value = tag_data
297 assert style_metatag(tag_type, value) == expected_html
214
298
215
299
216 @pytest.mark.parametrize("tmpl_url, email, expected", [
300 @pytest.mark.parametrize("tmpl_url, email, expected", [
General Comments 0
You need to be logged in to leave comments. Login now