Esempio n. 1
0
 def test_urlify_link(self, sample, expected):
     fake_url = FakeUrlGenerator(
         changeset_home='/%(repo_name)s/changeset/%(revision)s')
     with mock.patch('kallithea.config.routing.url', fake_url):
         from kallithea.lib.helpers import urlify_text
         assert urlify_text(sample, 'repo_name',
                            link_='#the-link') == expected
Esempio n. 2
0
    def __get_desc(self, cs):
        desc_msg = [(_('%s committed on %s') %
                     (h.person(cs.author), h.fmt_date(cs.date))) + '<br/>']
        #branches, tags, bookmarks
        if cs.branch:
            desc_msg.append('branch: %s<br/>' % cs.branch)
        if h.is_hg(c.db_repo_scm_instance):
            for book in cs.bookmarks:
                desc_msg.append('bookmark: %s<br/>' % book)
        for tag in cs.tags:
            desc_msg.append('tag: %s<br/>' % tag)
        diff_processor, changes = self.__changes(cs)
        # rev link
        _url = h.canonical_url('changeset_home',
                               repo_name=c.db_repo.repo_name,
                               revision=cs.raw_id)
        desc_msg.append('changeset: <a href="%s">%s</a>' %
                        (_url, cs.raw_id[:8]))

        desc_msg.append('<pre>')
        desc_msg.append(h.urlify_text(cs.message))
        desc_msg.append('\n')
        desc_msg.extend(changes)
        if self.include_diff:
            desc_msg.append('\n\n')
            desc_msg.append(diff_processor.as_raw())
        desc_msg.append('</pre>')
        return map(safe_unicode, desc_msg)
Esempio n. 3
0
    def __get_desc(self, cs):
        desc_msg = [(_('%s committed on %s')
                     % (h.person(cs.author), h.fmt_date(cs.date))) + '<br/>']
        #branches, tags, bookmarks
        if cs.branch:
            desc_msg.append('branch: %s<br/>' % cs.branch)
        if h.is_hg(c.db_repo_scm_instance):
            for book in cs.bookmarks:
                desc_msg.append('bookmark: %s<br/>' % book)
        for tag in cs.tags:
            desc_msg.append('tag: %s<br/>' % tag)
        diff_processor, changes = self.__changes(cs)
        # rev link
        _url = h.canonical_url('changeset_home', repo_name=c.db_repo.repo_name,
                   revision=cs.raw_id)
        desc_msg.append('changeset: <a href="%s">%s</a>' % (_url, cs.raw_id[:8]))

        desc_msg.append('<pre>')
        desc_msg.append(h.urlify_text(cs.message))
        desc_msg.append('\n')
        desc_msg.extend(changes)
        if self.include_diff:
            desc_msg.append('\n\n')
            desc_msg.append(diff_processor.as_raw())
        desc_msg.append('</pre>')
        return map(safe_unicode, desc_msg)
Esempio n. 4
0
 def test_urlify_test(self, sample, expected, url_):
     expected = self._quick_url(expected,
                                tmpl="""<a href="%s">%s</a>""", url_=url_)
     fake_url = FakeUrlGenerator(changeset_home='/%(repo_name)s/changeset/%(revision)s')
     with mock.patch('kallithea.config.routing.url', fake_url):
         from kallithea.lib.helpers import urlify_text
         assert urlify_text(sample, 'repo_name', stylize=True) == expected
Esempio n. 5
0
 def test_urlify_test(self, sample, expected, url_):
     expected = self._quick_url(expected,
                                tmpl="""<a href="%s">%s</a>""",
                                url_=url_)
     fake_url = FakeUrlGenerator(
         changeset_home='/%(repo_name)s/changeset/%(revision)s')
     with mock.patch('kallithea.config.routing.url', fake_url):
         from kallithea.lib.helpers import urlify_text
         assert urlify_text(sample, 'repo_name', stylize=True) == expected
Esempio n. 6
0
 def test_tag_extractor(self):
     sample = ("hello pta[tag] gog [[]] [[] sda ero[or]d [me =>>< sa]"
               "[requires] [stale] [see<>=>] [see => http://example.com]"
               "[requires => url] [lang => python] [just a tag]"
               "[,d] [ => ULR ] [obsolete] [desc]]")
     from kallithea.lib.helpers import urlify_text
     res = urlify_text(sample, stylize=True)
     assert '<div class="metatag" data-tag="tag">tag</div>' in res
     assert '<div class="metatag" data-tag="obsolete">obsolete</div>' in res
     assert '<div class="metatag" data-tag="stale">stale</div>' in res
     assert '<div class="metatag" data-tag="lang">python</div>' in res
     assert '<div class="metatag" data-tag="requires">requires =&gt; <a href="/url">url</a></div>' in res
     assert '<div class="metatag" data-tag="tag">tag</div>' in res
Esempio n. 7
0
 def test_tag_exctrator(self):
     sample = (
         "hello pta[tag] gog [[]] [[] sda ero[or]d [me =>>< sa]"
         "[requires] [stale] [see<>=>] [see => http://example.com]"
         "[requires => url] [lang => python] [just a tag]"
         "[,d] [ => ULR ] [obsolete] [desc]]"
     )
     from kallithea.lib.helpers import urlify_text
     res = urlify_text(sample, stylize=True)
     self.assertIn('<div class="metatag" tag="tag">tag</div>', res)
     self.assertIn('<div class="metatag" tag="obsolete">obsolete</div>', res)
     self.assertIn('<div class="metatag" tag="stale">stale</div>', res)
     self.assertIn('<div class="metatag" tag="lang">python</div>', res)
     self.assertIn('<div class="metatag" tag="requires">requires =&gt; <a href="/url">url</a></div>', res)
     self.assertIn('<div class="metatag" tag="tag">tag</div>', res)
Esempio n. 8
0
 def test_urlify_test(self, sample, expected, url_):
     from kallithea.lib.helpers import urlify_text
     expected = self._quick_url(expected,
                                tmpl="""<a href="%s">%s</a>""", url_=url_)
     self.assertEqual(urlify_text(sample), expected)
Esempio n. 9
0
 def desc(desc):
     return h.urlify_text(desc,
                          truncate=80,
                          stylize=c.visual.stylify_metatags)
Esempio n. 10
0
 def desc(desc):
     from pylons import tmpl_context as c
     if c.visual.stylify_metatags:
         return h.urlify_text(h.desc_stylize(h.truncate(desc, 60)))
     else:
         return h.urlify_text(h.truncate(desc, 60))
Esempio n. 11
0
 def desc(desc):
     if c.visual.stylify_metatags:
         return h.urlify_text(h.desc_stylize(h.truncate(desc, 60)))
     else:
         return h.urlify_text(h.truncate(desc, 60))
Esempio n. 12
0
 def desc(desc):
     return h.urlify_text(desc, truncate=60, stylize=c.visual.stylify_metatags)
Esempio n. 13
0
 def desc(desc):
     if c.visual.stylify_metatags:
         return h.urlify_text(h.desc_stylize(h.truncate(desc, 60)))
     else:
         return h.urlify_text(h.truncate(desc, 60))
Esempio n. 14
0
 def desc(desc):
     from pylons import tmpl_context as c
     return h.urlify_text(desc, truncate=60, stylize=c.visual.stylify_metatags)
Esempio n. 15
0
 def desc(desc):
     from pylons import tmpl_context as c
     if c.visual.stylify_metatags:
         return h.urlify_text(h.desc_stylize(h.truncate(desc, 60)))
     else:
         return h.urlify_text(h.truncate(desc, 60))
Esempio n. 16
0
 def test_urlify_link(self, sample, expected):
     fake_url = FakeUrlGenerator(changeset_home='/%(repo_name)s/changeset/%(revision)s')
     with mock.patch('kallithea.config.routing.url', fake_url):
         from kallithea.lib.helpers import urlify_text
         assert urlify_text(sample, 'repo_name', link_='#the-link') == expected