diff --git a/pybadges/__init__.py b/pybadges/__init__.py index b1e6c66..c6054d2 100644 --- a/pybadges/__init__.py +++ b/pybadges/__init__.py @@ -117,7 +117,11 @@ def badge(left_text: str, right_text: str, left_link: Optional[str] = None, whole_link: Optional[str] = None, logo: Optional[str] = None, left_color: str = '#555', right_color: str = '#007ec6', measurer: Optional[text_measurer.TextMeasurer] = None, - embed_logo: bool = False) -> str: + embed_logo: bool = False, + whole_title: Optional[str] = None, + left_title: Optional[str] = None, + right_title: Optional[str] = None, + ) -> str: """Creates a github-style badge as an SVG image. >>> badge(left_text='coverage', right_text='23%', right_color='red') @@ -181,6 +185,9 @@ def badge(left_text: str, right_text: str, left_link: Optional[str] = None, logo=logo, left_color=_NAME_TO_COLOR.get(left_color, left_color), right_color=_NAME_TO_COLOR.get(right_color, right_color), + whole_title=whole_title, + left_title=left_title, + right_title=right_title, ) xml = minidom.parseString(svg) _remove_blanks(xml) diff --git a/pybadges/__main__.py b/pybadges/__main__.py index 96faaa9..d90466e 100644 --- a/pybadges/__main__.py +++ b/pybadges/__main__.py @@ -92,6 +92,20 @@ def main(): help='the path to the ttf font file containing DejaVu Sans. If not ' + 'present on your system, you can download it from ' + 'https://www.fontsquirrel.com/fonts/dejavu-sans') + parser.add_argument( + '--whole-title', + default=None, + help='the url to redirect to when the badge is clicked') + parser.add_argument( + '--left-title', + default=None, + help='the url to redirect to when the left-hand of the badge is ' + + 'clicked') + parser.add_argument( + '--right-title', + default=None, + help='the url to redirect to when the right-hand of the badge is ' + + 'clicked') args = parser.parse_args() @@ -120,7 +134,10 @@ def main(): right_color=args.right_color, logo=args.logo, measurer=measurer, - embed_logo=args.embed_logo) + embed_logo=args.embed_logo, + whole_title=args.whole_title, + left_title=args.left_title, + right_title=args.right_title) if args.browser: _, badge_path = tempfile.mkstemp(suffix='.svg') diff --git a/pybadges/badge-template-full.svg b/pybadges/badge-template-full.svg index 55bfa22..2094fee 100644 --- a/pybadges/badge-template-full.svg +++ b/pybadges/badge-template-full.svg @@ -3,6 +3,9 @@ {% set left_width = left_text_width + 10 + logo_width + logo_padding %} {% set right_width = right_text_width + 10 %} + {% if whole_title %} + {{ whole_title }} + {% endif %} @@ -13,8 +16,16 @@ - - + + {% if left_title %} + {{ left_title }} + {% endif %} + + + {% if right_title %} + {{ right_title }} + {% endif %} + diff --git a/setup.py b/setup.py index a67bc9d..c43f073 100644 --- a/setup.py +++ b/setup.py @@ -41,7 +41,7 @@ def get_long_description(): setup( name='pybadges', - version='2.0.1', + version='2.1.0', author='Brian Quinlan', author_email='brian@sweetapp.com', classifiers=[