Skip to content

Commit

Permalink
issue #3 - add 'Moved' status
Browse files Browse the repository at this point in the history
  • Loading branch information
jantman committed May 16, 2017
1 parent a8fc775 commit 4c7de55
Show file tree
Hide file tree
Showing 28 changed files with 122 additions and 26 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
repostatus.org API/specification changelog
===========================================

1.2.0 (2017-05-15)
------------------

- Add "Moved" status.

1.1.0 (2015-11-25)
------------------

Expand Down
2 changes: 1 addition & 1 deletion badges/latest/abandoned.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion badges/latest/active.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions badges/latest/badges.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
"display_name": "Inactive",
"url": "http://www.repostatus.org/badges/latest/inactive.svg"
},
"moved": {
"description": "The project has been moved to a new location, and the version at that location should be considered authoritative.",
"display_name": "Moved",
"url": "http://www.repostatus.org/badges/latest/moved.svg"
},
"suspended": {
"description": "Initial development has started, but there has not yet been a stable, usable release; work has been stopped for the time being but the author(s) intend on resuming work.",
"display_name": "Suspended",
Expand Down
2 changes: 1 addition & 1 deletion badges/latest/concept.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion badges/latest/inactive.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions badges/latest/moved.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions badges/latest/moved_html.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<a href="http://www.repostatus.org/#moved"><img src="http://www.repostatus.org/badges/latest/moved.svg" alt="Project Status: Moved to http://example.com – The project has been moved to a new location, and the version at that location should be considered authoritative." /></a> to <a href="http://example.com">http://example.com</a>
1 change: 1 addition & 0 deletions badges/latest/moved_md.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[![Project Status: Moved to http://example.com – The project has been moved to a new location, and the version at that location should be considered authoritative.](http://www.repostatus.org/badges/latest/moved.svg)](http://www.repostatus.org/#moved) to [http://example.com](http://example.com)
5 changes: 5 additions & 0 deletions badges/latest/moved_rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
|repostatus| to `http://example.com <http://example.com>`_

.. |repostatus| image:: http://www.repostatus.org/badges/latest/moved.svg
:alt: Project Status: Moved to http://example.com – The project has been moved to a new location, and the version at that location should be considered authoritative.
:target: http://www.repostatus.org/#moved
2 changes: 1 addition & 1 deletion badges/latest/suspended.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion badges/latest/unsupported.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion badges/latest/wip.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 61 additions & 10 deletions fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@
'description': "The project has reached a stable, usable state but the author(s) have ceased all work on it. A new maintainer may be desired.",
'display_name': 'Unsupported',
},
"moved": {
'shield_url': 'http://img.shields.io/badge/repo%20status-Moved-red.svg',
'description': 'The project has been moved to a new location, and the version at that location should be considered authoritative.',
'display_name': 'Moved'
}
}

def _download_media(url, fname):
Expand All @@ -69,20 +74,66 @@ def _download_media(url, fname):

def _make_badge_markup(badge_name, display_name, description, url, savedir):
""" generate example markup for a badge, write to disk under savedir """
alt = "Project Status: {statuscap} – {desc}".format(desc=description, statuscap=display_name)
if badge_name == 'moved':
moved_to = 'http://example.com'
moved = 'to %s ' % moved_to
else:
moved_to = None
moved = ''
alt = "Project Status: {statuscap} {moved}– {desc}".format(
desc=description,
statuscap=display_name,
moved=moved
)
target = "http://www.repostatus.org/#{status}".format(status=badge_name)
with open(os.path.join(savedir, '{n}_md.txt'.format(n=badge_name)), 'w') as fh:
fh.write("[![{alt}]({url})]({target})\n".format(target=target,
url=url,
alt=alt))
fh.write(_format_md(url, target, alt, moved_to))
with open(os.path.join(savedir, '{n}_html.txt'.format(n=badge_name)), 'w') as fh:
fh.write('<a href="{target}"><img src="{url}" alt="{alt}" /></a>\n'.format(url=url,
target=target,
alt=alt))
fh.write(_format_html(url, target, alt, moved_to))
with open(os.path.join(savedir, '{n}_rst.txt'.format(n=badge_name)), 'w') as fh:
fh.write('.. image:: {url}\n :alt: {alt}\n :target: {target}\n'.format(url=url,
target=target,
alt=alt))
fh.write(_format_rst(url, target, alt, moved_to))

def _format_md(url, target, alt, moved_to=None):
if moved_to is None:
moved = ''
else:
moved = ' to [%s](%s)' % (moved_to, moved_to)
s = "[![{alt}]({url})]({target}){moved}\n".format(
target=target,
url=url,
alt=alt,
moved=moved
)
return s

def _format_rst(url, target, alt, moved_to=None):
if moved_to is None:
return '.. image:: {url}\n :alt: {alt}\n :target: {target}\n'.format(
url=url,
target=target,
alt=alt
)
s = '|repostatus| to `%s <%s>`_\n\n' % (moved_to, moved_to)
s += '.. |repostatus| image:: {url}\n :alt: {alt}\n ' \
':target: {target}\n'.format(
url=url,
target=target,
alt=alt
)
return s

def _format_html(url, target, alt, moved_to=None):
if moved_to is None:
moved = ''
else:
moved = ' to <a href="%s">%s</a>' % (moved_to, moved_to)
s = '<a href="{target}"><img src="{url}" alt="{alt}" /></a>{moved}\n'.format(
url=url,
target=target,
alt=alt,
moved=moved
)
return s

def make_badges():
""" Regenerate the badges into badges/latest """
Expand Down
2 changes: 1 addition & 1 deletion gh_pages/badges/latest/abandoned.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 4c7de55

Please sign in to comment.